Trouble with for_each_process(p) funciton

From: Joseph D. Wagner
Date: Tue Jan 27 2004 - 19:43:48 EST


I'm doing some analysis of various memory management tequiniques and
allocation algorithims. I'm trying to edit the sys_brk function in mmap.c.
I added the following function to mmap.c and the appropriate function call
in the sys_brk function immediately after set_brk:.

static inline void decrement_prealloc_pages(void)
{
struct task_struct *p;

for_each_process(p)
{
p->mm->prealloc_pages = 0;
}
}

Everything works OK without the line:

p->mm->prealloc_pages = 0;

which doesn't make any sense to me because it's only an assignment.

A similar line directly in the sys_brk function:

mm->prealloc_pages |= 0x80;

works just fine, but I'm not trying to use that assignment on every process,
just the current one.

I tried all sorts of hacks to get it to work including checking for NULL,
&init_task, and a counter to prevent an infinite loop. Nothing helps. The
kernel always stops just before INIT when the last line is "Freed xKB of
kernel memory" (or something like that). If someone could help me figure
out what I'm doing wrong I'd appreciate it greatly.

FYI: prealloc_pages is an unsigned char that I added to the struct
mm_struct.

TIA.

Joseph D. Wagner

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/