lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Mon, 11 Mar 2013 19:01:26 -0300
From:	Raphael S Carvalho <raphael.scarv@...il.com>
To:	Andrew Morton <akpm@...ux-foundation.org>
Cc:	"Eric W. Biederman" <ebiederm@...ssion.com>,
	"Serge E. Hallyn" <serge@...lyn.com>,
	Serge Hallyn <serge.hallyn@...onical.com>,
	"David S. Miller" <davem@...emloft.net>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/1] kernel/pid.c: Improve flow of a loop inside alloc_pidmap.

On Mon, Mar 11, 2013 at 6:57 PM, Andrew Morton
<akpm@...ux-foundation.org> wrote:
> On Mon, 11 Mar 2013 18:18:56 -0300 "Raphael S. Carvalho" <raphael.scarv@...il.com> wrote:
>
>> From: Raphael S.Carvalho <raphael.scarv@...il.com>
>>
>> Notes: find_next_offset searches for an available "cleaned bit"
>> in the respective pid bitmap (page), so returns the offset if found,
>> otherwise it returns a value equals to BITS_PER_PAGE.
>>
>> For example, suppose find_next_offset didn't find any available
>> bit, so there's no purpose to call mk_pid (Wasteful Cpu Cycles).
>>
>> Therefore, I found it could be better to call mk_pid after
>> the checking (offset < BITS_PER_PAGE) returned sucessfully!
>> Another point: If (offset < BITS_PER_PAGE) results in a "failure",
>> then mk_pid would be called again afterwards.
>>
>> ...
>>
>> --- a/kernel/pid.c
>> +++ b/kernel/pid.c
>> @@ -190,8 +190,8 @@ static int alloc_pidmap(struct pid_namespace *pid_ns)
>>                                       return pid;
>>                               }
>>                               offset = find_next_offset(map, offset);
>> -                             pid = mk_pid(pid_ns, map, offset);
>> -                     } while (offset < BITS_PER_PAGE && pid < pid_max);
>> +                     } while (offset < BITS_PER_PAGE &&
>> +                             (pid = mk_pid(pid_ns, map, offset)) < pid_max);
>>               }
>>               if (map < &pid_ns->pidmap[(pid_max-1)/BITS_PER_PAGE]) {
>>                       ++map;
>
> Looks OK.  But I think it's simpler and more straightforward to do it
> this way?

Yes, it looks much better.
>
>                         for ( ; ; ) {
>                                 if (!test_and_set_bit(offset, map->page)) {
>                                         atomic_dec(&map->nr_free);
>                                         set_last_pid(pid_ns, last, pid);
>                                         return pid;
>                                 }
>                                 offset = find_next_offset(map, offset);
>                                 if (offset >= BITS_PER_PAGE)
>                                         break;
>                                 pid = mk_pid(pid_ns, map, offset);
>                                 if (pid >= pid_max)
>                                         break;
>                         }
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ