[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: init_mm linked list problem
On Tue, 2005-04-05 at 15:18 -0400, Jason J. Herne wrote:
> Can anyone tell me why the following code would STOP working if I
> upgraded from kernel version 2.6.8.1 to 2.6.11.6??
>
> I just want to be able to visit all of the mm_struct's that exist on the
> system. This code worked just fine (at least it seemed to), and then I
> upgraded my kernel version and now mcount prints to the log file with a
> value of 0. Before I was getting 60-70 depending on how many processes
> I had running.
>
> int mcount=0;
> struct mm_struct *m;
>
> spin_lock(&mmlist_lock);
> list_for_each_entry(m, &init_mm.mmlist, mmlist)
> {
> mcount++;
>
> /* Do stuff */
> }
> spin_unlock(&mmlist_lock);
>
> printk("mm_struct count: %d\n", mcount);
>
Update on this: Ok, just for fun, I tried using list_for_each instead
of list_for_each_entry and I get the same result. It seems as though
the init_mm.mmlist is EMPTY.. how can this be??
I also tried traversing the list in reverse with
list_for_each_entry_reverse. Didn't work :(
New code:
int mcount=0;
struct mm_struct* m;
spin_lock(&mmlist_lock);
struct list_head* pos;
list_for_each(pos, &init_mm.mmlist)
{
m = list_entry(pos, struct mm_struct, mmlist);
mcount++;
}
spin_unlock(&mmlist_lock);
printk("mm_struct count: %d\n", mcount);
--
Jason J. Herne <hernejj@xxxxxxxxxxxx>
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/