From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933589Ab2AIX4x (ORCPT ); Mon, 9 Jan 2012 18:56:53 -0500 Received: from mail-gy0-f174.google.com ([209.85.160.174]:41585 "EHLO mail-gy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932158Ab2AIX4w (ORCPT ); Mon, 9 Jan 2012 18:56:52 -0500 Date: Mon, 9 Jan 2012 15:56:36 -0800 (PST) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: KOSAKI Motohiro cc: Andrew Morton , Minchan Kim , Rik van Riel , Shaohua Li , Eric Dumazet , Johannes Weiner , Michel Lespinasse , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH 2/2] SHM_UNLOCK: fix Unevictable pages stranded after swap In-Reply-To: <4F0B73AC.7000504@gmail.com> Message-ID: References: <4F0B5146.6090200@gmail.com> <4F0B73AC.7000504@gmail.com> User-Agent: Alpine 2.00 (LSU 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 9 Jan 2012, KOSAKI Motohiro wrote: > (1/9/12 5:25 PM), Hugh Dickins wrote: > > On Mon, 9 Jan 2012, KOSAKI Motohiro wrote: > > > > > PG_mlocked operation is not protected by LRU lock. So, I think we > > > > Right. But I don't see that I've made a significant change there. > > > > I may be being lazy, and rushing back to answer you, without giving > > constructive thought to what the precise race is that you see, and > > how we might fix it. If the case you have in mind is easy for you > > to describe in detail, please do so; but don't hesitate to tell me > > to my own work for myself! > > Bah! I was moron. I now think your code is right. > > spin_lock(lru_lock) > if (page_evictable(page)) > blah blah blah > spin_unlock(lru_lock) > > is always safe. Counter part should have following code and > waiting spin_lock(lru_lock) in isolate_lru_page(). > > if (!isolate_lru_page(page)) > putback_lru_page(page); > > then, even if check_move_unevictable_pages() observed wrong page status, > putback_lru_page() should put back the page into right lru. > > I'm very sorry for annoying you. Far from it, thank you again for giving it serious thought. I am not going to pretend to have thought down these paths myself, not recently - I was just relying on not changing the behaviour. But I am reassured to know that you have worked through it again and are now satisfied. > > Reviewed-by: KOSAKI Motohiro Thank you. > > Probably, page_evictable() might be needed some additional comments. But > I have no idea what comment clearly explain this complex rule..... I don't know any language that can make it clear: when forced to, one just has to think through it back and forth by oneself; and even then, it's so quickly forgotten. Hugh