mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: ebiederm@xmission.com (Eric W. Biederman)
To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: linux-kernel@vger.kernel.org, akpm@osdl.org,
	saito.tadashi@soft.fujitsu.com, ak@suse.de, oleg@tv-sign.ru,
	jdelvare@suse.de
Subject: Re: [PATCH] proc: readdir race fix.
Date: Mon, 04 Sep 2006 20:30:55 -0600	[thread overview]
Message-ID: <m1lkoz3uzk.fsf@ebiederm.dsl.xmission.com> (raw)
In-Reply-To: <20060905103010.5f744bee.kamezawa.hiroyu@jp.fujitsu.com> (KAMEZAWA Hiroyuki's message of "Tue, 5 Sep 2006 10:30:10 +0900")

KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> writes:

> Hi,
>
> On Mon, 04 Sep 2006 17:13:10 -0600
> ebiederm@xmission.com (Eric W. Biederman) wrote:
>> These better semantics are implemented by scanning through the
>> pids in numerical order and by making the file offset a pid
>> plus a fixed offset.
> I think this is very sane/solid approach.
> Maybe this is the way to go. I'll test and ack later, thank you.
>
>> The pid scan happens on the pid bitmap, which when you look at it is
>> remarkably efficient for a brute force algorithm.  Given that a typical
>> cache line is 64 bytes and thus covers space for 64*8 == 200 pids.  There
>> are only 40 cache lines for the entire 32K pid space.  A typical system
>> will have 100 pids or more so this is actually fewer cache lines we have
>> to look at to scan a linked list, and the worst case of having to scan
>> the entire pid bitmap is pretty reasonable.
>
> I agree with you but..
> Becasue this approach has to access *all* task structs in a system,
> and have to scan pidhash many times. I'm not sure that this scan & lookup
> is good for future implementation. But this patch is obviously better than
> current implementation.

Quite possibly.  But where this approach falls down in not in the basics
but in the data structures.  And it isn't that hard to fix the data
structures.  Just something I don't want to do the first pass.

>>  /*
>> + * Used by proc to find the pid with the first
>> + * pid that is greater than or equal to number.
>> + *
>> + * If there is a pid at nr this function is exactly the same as find_pid.
>> + */
>> +struct pid *find_next_pid(int nr)
>> +{
>
> How about find_first_used_pid(int nr) ?

Maybe.  The best name I can think of is:
find_greater_or_equal_pid(int nr) and that is a little 
clumsy.   On the other hand it isn't confusing what the function
does.

Any other suggestions?

Eric

  reply	other threads:[~2006-09-05  2:32 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-25  9:29 [RFC][PATCH] ps command race fix take 4 [4/4] proc root open/release/llseek KAMEZAWA Hiroyuki
2006-09-04 23:13 ` [PATCH] proc: readdir race fix Eric W. Biederman
2006-09-05  1:30   ` KAMEZAWA Hiroyuki
2006-09-05  2:30     ` Eric W. Biederman [this message]
2006-09-05  2:41     ` KAMEZAWA Hiroyuki
2006-09-05  2:26   ` KAMEZAWA Hiroyuki
2006-09-05  2:54     ` Eric W. Biederman
2006-09-05  3:07     ` Eric W. Biederman
2006-09-05  5:39       ` KAMEZAWA Hiroyuki
2006-09-05 10:10       ` Oleg Nesterov
2006-09-05 11:36         ` Eric W. Biederman
2006-09-05 14:52         ` [PATCH] proc: readdir race fix (take 3) Eric W. Biederman
2006-09-06  9:01           ` Jean Delvare
2006-09-06 21:12             ` Jean Delvare
2006-09-06 22:25               ` Oleg Nesterov
2006-09-06 22:38                 ` [PATCH] proc-readdir-race-fix-take-3-fix-3 Oleg Nesterov
2006-09-06 22:59                   ` Eric W. Biederman
2006-09-08  6:38                   ` Eric W. Biederman
2006-09-06 22:43               ` [PATCH] proc: readdir race fix (take 3) Eric W. Biederman
2006-09-07  8:31                 ` Jean Delvare
2006-09-07 13:57                   ` Eric W. Biederman
2006-09-07 18:07                     ` Jean Delvare
2006-09-07 18:40                       ` Eric W. Biederman
2006-09-05  5:26   ` [PATCH] proc: readdir race fix KAMEZAWA Hiroyuki
2006-09-05  5:41     ` KAMEZAWA Hiroyuki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m1lkoz3uzk.fsf@ebiederm.dsl.xmission.com \
    --to=ebiederm@xmission.com \
    --cc=ak@suse.de \
    --cc=akpm@osdl.org \
    --cc=jdelvare@suse.de \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oleg@tv-sign.ru \
    --cc=saito.tadashi@soft.fujitsu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®