From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753548Ab0KJHvO (ORCPT ); Wed, 10 Nov 2010 02:51:14 -0500 Received: from smtp-out.google.com ([74.125.121.35]:1100 "EHLO smtp-out.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753196Ab0KJHvM (ORCPT ); Wed, 10 Nov 2010 02:51:12 -0500 DomainKey-Signature: a=rsa-sha1; c=nofws; d=google.com; s=beta; h=date:from:x-x-sender:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version:content-type; b=EueJgahA4wUzMNdpRLJkfRQeHhaCux/9UvcjEByJnLvoGrDpkhioABfeF67sRQzwGM PIQKoGDtk7zvNK1ByUbA== Date: Tue, 9 Nov 2010 23:49:30 -0800 (PST) From: Hugh Dickins X-X-Sender: hugh@sister.anvils To: Andrea Arcangeli cc: KOSAKI Motohiro , linux-mm@kvack.org, Linus Torvalds , Andrew Morton , linux-kernel@vger.kernel.org, Marcelo Tosatti , Adam Litke , Avi Kivity , Rik van Riel , Mel Gorman , Dave Hansen , Benjamin Herrenschmidt , Ingo Molnar , Mike Travis , KAMEZAWA Hiroyuki , Christoph Lameter , Chris Wright , bpicco@redhat.com, Balbir Singh , "Michael S. Tsirkin" , Peter Zijlstra , Johannes Weiner , Daisuke Nishimura , Chris Mason , Borislav Petkov Subject: Re: [PATCH 43 of 66] don't leave orhpaned swap cache after ksm merging In-Reply-To: <20101109214036.GE6809@random.random> Message-ID: References: <20101109120747.BC4B.A69D9226@jp.fujitsu.com> <20101109214036.GE6809@random.random> User-Agent: Alpine 2.00 (LSU 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-System-Of-Record: true Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 9 Nov 2010, Andrea Arcangeli wrote: > On Tue, Nov 09, 2010 at 12:08:25PM +0900, KOSAKI Motohiro wrote: > > > From: Andrea Arcangeli > > > > > > When swapcache is replaced by a ksm page don't leave orhpaned swap cache. > > > > > > Signed-off-by: Andrea Arcangeli > > > Reviewed-by: Rik van Riel > > > > This explanation seems to tell this is bugfix. If so, please separate > > this one from THP and will send mainline and -stable soon. > > Right. I'm uncertain if this is so bad to require -stable I think, if > it was more urgent I would have submitted already separately but it's > true it's not THP specific. Yes, we discussed this a few months ago: it's a welcome catch, but not very serious, since it's normal for some pages to evade swap freeing, then eventually memory pressure sorts it all out in __remove_mapping(). We did ask you back then to send in a fix separate from THP, but both sides then forgot about it until recently. We didn't agree on what the fix should look like. You're keen to change the page locking there, I didn't make a persuasive case for keeping it as is, yet I can see no point whatever in changing it for this swap fix. Could I persuade you to approve this simpler alternative? [PATCH] ksm: free swap when swapcache page is replaced When a swapcache page is replaced by a ksm page, it's best to free that swap immediately. Reported-by: Andrea Arcangeli Signed-off-by: Hugh Dickins --- mm/ksm.c | 2 ++ 1 file changed, 2 insertions(+) --- 2.6.37-rc1/mm/ksm.c 2010-10-20 13:30:22.000000000 -0700 +++ linux/mm/ksm.c 2010-11-09 23:01:24.000000000 -0800 @@ -800,6 +800,8 @@ static int replace_page(struct vm_area_s set_pte_at_notify(mm, addr, ptep, mk_pte(kpage, vma->vm_page_prot)); page_remove_rmap(page); + if (!page_mapped(page)) + try_to_free_swap(page); put_page(page); pte_unmap_unlock(ptep, ptl); From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail144.messagelabs.com (mail144.messagelabs.com [216.82.254.51]) by kanga.kvack.org (Postfix) with ESMTP id D454C6B004A for ; Wed, 10 Nov 2010 02:51:15 -0500 (EST) Received: from kpbe13.cbf.corp.google.com (kpbe13.cbf.corp.google.com [172.25.105.77]) by smtp-out.google.com with ESMTP id oAA7njBv029331 for ; Tue, 9 Nov 2010 23:49:45 -0800 Received: from gxk21 (gxk21.prod.google.com [10.202.11.21]) by kpbe13.cbf.corp.google.com with ESMTP id oAA7nfAW029561 for ; Tue, 9 Nov 2010 23:49:43 -0800 Received: by gxk21 with SMTP id 21so179157gxk.29 for ; Tue, 09 Nov 2010 23:49:41 -0800 (PST) Date: Tue, 9 Nov 2010 23:49:30 -0800 (PST) From: Hugh Dickins Subject: Re: [PATCH 43 of 66] don't leave orhpaned swap cache after ksm merging In-Reply-To: <20101109214036.GE6809@random.random> Message-ID: References: <20101109120747.BC4B.A69D9226@jp.fujitsu.com> <20101109214036.GE6809@random.random> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-linux-mm@kvack.org To: Andrea Arcangeli Cc: KOSAKI Motohiro , linux-mm@kvack.org, Linus Torvalds , Andrew Morton , linux-kernel@vger.kernel.org, Marcelo Tosatti , Adam Litke , Avi Kivity , Rik van Riel , Mel Gorman , Dave Hansen , Benjamin Herrenschmidt , Ingo Molnar , Mike Travis , KAMEZAWA Hiroyuki , Christoph Lameter , Chris Wright , bpicco@redhat.com, Balbir Singh , "Michael S. Tsirkin" , Peter Zijlstra , Johannes Weiner , Daisuke Nishimura , Chris Mason , Borislav Petkov List-ID: On Tue, 9 Nov 2010, Andrea Arcangeli wrote: > On Tue, Nov 09, 2010 at 12:08:25PM +0900, KOSAKI Motohiro wrote: > > > From: Andrea Arcangeli > > > > > > When swapcache is replaced by a ksm page don't leave orhpaned swap cache. > > > > > > Signed-off-by: Andrea Arcangeli > > > Reviewed-by: Rik van Riel > > > > This explanation seems to tell this is bugfix. If so, please separate > > this one from THP and will send mainline and -stable soon. > > Right. I'm uncertain if this is so bad to require -stable I think, if > it was more urgent I would have submitted already separately but it's > true it's not THP specific. Yes, we discussed this a few months ago: it's a welcome catch, but not very serious, since it's normal for some pages to evade swap freeing, then eventually memory pressure sorts it all out in __remove_mapping(). We did ask you back then to send in a fix separate from THP, but both sides then forgot about it until recently. We didn't agree on what the fix should look like. You're keen to change the page locking there, I didn't make a persuasive case for keeping it as is, yet I can see no point whatever in changing it for this swap fix. Could I persuade you to approve this simpler alternative? [PATCH] ksm: free swap when swapcache page is replaced When a swapcache page is replaced by a ksm page, it's best to free that swap immediately. Reported-by: Andrea Arcangeli Signed-off-by: Hugh Dickins --- mm/ksm.c | 2 ++ 1 file changed, 2 insertions(+) --- 2.6.37-rc1/mm/ksm.c 2010-10-20 13:30:22.000000000 -0700 +++ linux/mm/ksm.c 2010-11-09 23:01:24.000000000 -0800 @@ -800,6 +800,8 @@ static int replace_page(struct vm_area_s set_pte_at_notify(mm, addr, ptep, mk_pte(kpage, vma->vm_page_prot)); page_remove_rmap(page); + if (!page_mapped(page)) + try_to_free_swap(page); put_page(page); pte_unmap_unlock(ptep, ptl); -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/ Don't email: email@kvack.org