On Tue, Apr 12, 2011 at 8:48 AM, Robert Święcki wrote: >> >> Hmm. Sounds like an endless loop in kernel mode. >> >> Use "perf record -ag" as root, it should show up very clearly in the report. > > I've put some data here - > http://groups.google.com/group/fa.linux.kernel/browse_thread/thread/4345dcc4f7750ce2 > - I think it's somewhat connected (sys_mlock appears on both cases). Ok, so it's definitely sys_mlock. And I suspect it's due to commit 53a7706d5ed8 somehow looping forever. One possible cause would be how that commit made things care deeply about the return value of __get_user_pages(), and in particular what happens when that return value is zero. It ends up looping forever in do_mlock_pages() for that case, because it does nend = nstart + ret * PAGE_SIZE; so now the next round we'll set "nstart = nend" and start all over. I see at least one way __get_user_pages() will return zero, and it's if it is passed a npages of 0 to begin with. Which can easily happen if you try to mlock() the first page of a stack segment: the code will jump over that stack segment page, and then have nothing to do, and return zero. So then do_mlock_pages() will just keep on trying again. THIS IS A HACKY AND UNTESTED PATCH! It's ugly as hell, because the real problem is do_mlock_pages() caring too damn much about the return value, and us hiding the whole stack page thing in that function. I wouldn't want to commit it as-is, but if you can easily reproduce the problem, it's a good patch to test out the theory. Assuming I didn't screw something up. Again, TOTALLY UNTESTED! Linus