From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932521Ab0CXRvN (ORCPT ); Wed, 24 Mar 2010 13:51:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49248 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932327Ab0CXRvK (ORCPT ); Wed, 24 Mar 2010 13:51:10 -0400 Date: Wed, 24 Mar 2010 18:49:07 +0100 From: Oleg Nesterov To: "Eric W. Biederman" Cc: Andrew Morton , Alexey Dobriyan , Roland McGrath , linux-kernel@vger.kernel.org Subject: Re: [PATCH -mm 0/3] proc: task->signal can't be NULL Message-ID: <20100324174907.GA20990@redhat.com> References: <20100322184127.GA3952@redhat.com> <20100323183116.GA22516@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/23, Eric W. Biederman wrote: > > We need a value that can be computed in constant time, and is not correct > except when the number of threads is actively changing. Sure. I was thinking of something like int get_nr_threads(struct task_struct *tsk) { int nr = atomic_read(&task->signal->live); int reasonable_min = 1; rcu_read_lock(); if (!thread_group_leader(tsk) && pid_alive(tsk) && tsk->group_leader->exit_state) reasonable_min = 2; rcu_read_unlock(); return max(nr, reasonable_min); } but as I said this doesn't look nice at all. > > OK. Let's keep this counter as "int nr_thread". > > > > Besides, when I tried to re-implement get_nr_threads() using signal->live > > I got the really ugly result ;) > > Sounds good. OK, please see the "final" patch I am going to send... Oleg.