2004-04-19 10:10:28

by Amol

[permalink] [raw]
Subject: alloc_pidmap() query

Hi,
It seems in the alloc_pidmap() code (2.6), that for the first time when
the PIDs are allocated, the alternate entries in pidmap array is used.

Lets take an example,
offset = pid & BITS_PER_PAGE_MASK;
map = pidmap_array + pid / BITS_PER_PAGE;

if pid == BITS_PER_PAGE, then we have
offset = 0;
map = pidmap_array[1];

as this is the first time allocation, so map->page == NULL,

Following code with get executed,

if (!offset || !atomic_read(&map->nr_free)) {
next_map:
map = next_free_map(map, &max_steps);
if (!map)
goto failure;
offset = 0;
}

This code will select pidmap_array[2] for pid selection even though no
pids are yet allocated from pidmap_array[1].

is this ok ?

please cc me
Amol




--
Linus's Law - Given enough eyeballs, all bugs are shallow.