title: Why doesn't for_each_process show every task?
body: <p>I am trying to loop through every process in a <em><code>/proc</code></em> utility I'm writing (a kernel module in <em><code>/fs/proc</code></em>). The problem is, I am only seeing processes in the root namespace. I'm trying to use the macro <code>for_each_process()</code> from <code>sched.h</code>.</p>
  
  <p>I can type <code>ps</code> in a shell and see plenty of processes, but my <code>for_each_process()</code> loop doesn't see them. What gives?</p>
  
  <p><strong>Note:</strong> I am wondering if it has something to do with <code>rcu_read_lock()</code>? I'm afraid to put an <code>rcu_read_lock()</code> and I don't know where it should go. The trouble is, the <a href="http://lxr.free-electrons.com/source/include/linux/rcupdate.h?a=arm#L594" rel="nofollow noreferrer">documentation</a> I read seems to say that in a preemptive kernel (mine is), it is illegal to sleep inside of <code>rcu_read_lock()</code>. I need to call <code>down_read(mmap_sem)</code> which I am afraid will sleep. So that means I can't use <code>rcu_read_lock()</code>?</p>