Re: quadratic behaviour

From: Manfred Spraul (
Date: Sat Sep 21 2002 - 09:15:10 EST

> Let me repeat this, and call it an observation instead of a question,
> so that you do not think I am in doubt.
> If you have 20000 processes, and do ps, then get_pid_list() will be
> called 1000 times, and the for_each_process() loop will examine
> 10000000 processes.
> Unlike the get_pid() situation, which was actually amortized linear with a very
> small coefficient, here we have a bad quadratic behaviour, still in 2.5.37.
One solution would be to replace the idtag hash with an idtag tree.

Then get_pid_list() could return an array of sorted pids, and finding
the next pid after unlocking the task_lock would be just a tree lookup
(find first pid larger than x).

And a sorted tree would make it possible find the next safe range for
get_pid() with O(N) instead of O(N^2).


- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to More majordomo info at Please read the FAQ at

This archive was generated by hypermail 2b29 : Mon Sep 23 2002 - 22:00:33 EST