Re: [MM] Make mm counters per cpu instead of atomic

Zhang, Yanmin
2009-11-23T08:48:41Z

On Tue, 2009-11-17 at 12:25 -0500, Christoph Lameter wrote:
> On Tue, 17 Nov 2009, Zhang, Yanmin wrote:
>
> > The right change above should be:
> > struct mm_counter *m = per_cpu_ptr(mm->rss, cpu);
>
> Right.
>
> > With the change, command 'make oldconfig' and a boot command still
> > hangs.
>
> Not sure if its worth spending more time on this but if you want I will
> consolidate the fixes so far and put out another patchset.
>
> Where does it hang during boot?
Definitely faint.

1) In function exec_mmap: in the 2nd 'if (old_mm) {', mm_reader_unlock
should be used. Your patch uses mm_reader_lock. I found it when reviewing your
patch, but forgot to fix it when testing.
2) In function madvise: the last unlock should be mm_reader_unlock. Your
patch uses mm_writer_unlock.

It's easy to hit the issues with normal testing. I'm surprised you didn't
hit them.

Another theoretic issue is below scenario:
Process A get the read lock on cpu 0 and is scheduled to cpu 2 to unlock. Then
it's scheduled back to cpu 0 to repeat the step. eventually, the reader counter
will overflow. Considering multiple thread cases, it might be faster to
overflow than what we imagine. When it overflows, processes will hang there.