Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964864AbWCTTfl (ORCPT ); Mon, 20 Mar 2006 14:35:41 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S964868AbWCTTfl (ORCPT ); Mon, 20 Mar 2006 14:35:41 -0500 Received: from mail.tv-sign.ru ([213.234.233.51]:10954 "EHLO several.ru") by vger.kernel.org with ESMTP id S964864AbWCTTfi (ORCPT ); Mon, 20 Mar 2006 14:35:38 -0500 Message-ID: <441F0352.758F0321@tv-sign.ru> Date: Mon, 20 Mar 2006 22:32:34 +0300 From: Oleg Nesterov X-Mailer: Mozilla 4.76 [en] (X11; U; Linux 2.2.20 i686) X-Accept-Language: en MIME-Version: 1.0 To: "Eric W. Biederman" Cc: Andrew Morton , linux-kernel@vger.kernel.org Subject: Re: [PATCH] simplify/fix first_tid() References: <441DB045.87C4134C@tv-sign.ru> <441EF4D7.AEC1AE8C@tv-sign.ru> Content-Type: text/plain; charset=koi8-r Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1261 Lines: 42 "Eric W. Biederman" wrote: > > Oleg Nesterov writes: > > >> So we really still need the nr_threads test in there so we don't > >> traverse the list twice everytime through readdir. > > > > How so? We don't do it twice? > > In general user space does. Because a read of 0 bytes signifies > the end of a directory. > > So we have 2 trips through proc_task_readdir initiated by user > space. Oh, thanks, you are right. [PATCH] simplify-fix-first_tid-fix Restore a stupidly deleted optimization. Signed-off-by: Oleg Nesterov --- MM/fs/proc/base.c~ 2006-03-21 01:08:10.000000000 +0300 +++ MM/fs/proc/base.c 2006-03-21 01:14:36.000000000 +0300 @@ -2190,6 +2190,11 @@ static struct task_struct *first_tid(str goto found; } + /* If nr exceeds the number of threads there is nothing todo */ + pos = NULL; + if (nr && nr >= get_nr_threads(leader)) + goto out; + /* If we haven't found our starting place yet start * with the leader and walk nr threads forward. */ - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/