From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2069 invoked by alias); 16 Feb 2011 21:04:12 -0000 Mailing-List: contact archer-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: List-Id: Received: (qmail 2053 invoked by uid 22791); 16 Feb 2011 21:04:11 -0000 X-SWARE-Spam-Status: No, hits=-6.4 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Date: Wed, 16 Feb 2011 21:04:00 -0000 From: Oleg Nesterov To: Roland McGrath Cc: Jan Kratochvil , Project Archer Subject: Re: ptrace improvement: PTRACE_O_INHERIT Message-ID: <20110216205558.GA19564@redhat.com> References: <20110214193052.3EC8D1814BA@magilla.sf.frob.com> <20110214193812.GA20765@redhat.com> <20110215003551.BC1EA1802A2@magilla.sf.frob.com> <20110215130805.GA30742@redhat.com> <20110215214333.GA18086@host1.dyn.jankratochvil.net> <20110215220153.470031806E0@magilla.sf.frob.com> <20110216194010.GC15576@redhat.com> <20110216200201.7895218020E@magilla.sf.frob.com> <20110216200654.GB17601@redhat.com> <20110216203057.D15E618020E@magilla.sf.frob.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20110216203057.D15E618020E@magilla.sf.frob.com> User-Agent: Mutt/1.5.18 (2008-05-17) X-SW-Source: 2011-q1/txt/msg00077.txt.bz2 On 02/16, Roland McGrath wrote: > > > Or, attach can use a mutex in engine->data and synchronize with its > > own report_clone/report_death callbacks. This makes attach O(n). > > ugdb does this. > > Sure, you'd do that too. But for attaching to live threads, you still have > to chase the new clones just done by the unattached threads before you > attached them. Actually no, or I misunderstood. To simplify, lets ignore the problems with the dead group_leader. Now suppose (again, to simplify) that report_clone/report_death take global_mutex before anything else, and attach-to-all takes this mutex too. This means we can always use next_thread(last_attached_thread). The next attach can fail if it races with exit, in this case we should just re-read next_thread() and retry. We should see all sub-threads, copy_process() does list_add_tail(). Once next_thread() returns the group leader, everything is done. Oleg.