From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id EE170C433F5 for ; Wed, 9 Mar 2022 20:50:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8D1A78D0003; Wed, 9 Mar 2022 15:50:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8825A8D0001; Wed, 9 Mar 2022 15:50:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 770BD8D0003; Wed, 9 Mar 2022 15:50:49 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.28]) by kanga.kvack.org (Postfix) with ESMTP id 6A2E48D0001 for ; Wed, 9 Mar 2022 15:50:49 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id 1B22A60C41 for ; Wed, 9 Mar 2022 20:50:49 +0000 (UTC) X-FDA: 79226041818.06.E89EA9E Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf17.hostedemail.com (Postfix) with ESMTP id 9298D4001A for ; Wed, 9 Mar 2022 20:50:48 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7772861A47; Wed, 9 Mar 2022 20:50:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 45758C340F3; Wed, 9 Mar 2022 20:50:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1646859047; bh=OgKg/0vp35QJf41JfruLbYi6bvW8ZM/QnzZq2U4YFCY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=QRaMnKngT/vueTUdBgVKEAtGsWlVUdZXX+uG41GutJ9FLINk1O67xy3/cWX3W7oPn jircwk4P6VKvPxc64gnZagjIAZ1t6ChGboVcx9qnAkdD3LwH/eZksTQh2mD/9pzlLJ jxBmjx/d1KMvw6qMDBV9EEaWDJAUejijZv8WaFK8= Date: Wed, 9 Mar 2022 12:50:45 -0800 From: Andrew Morton To: David Hildenbrand Cc: Yang Shi , Linux Kernel Mailing List , Hugh Dickins , Linus Torvalds , David Rientjes , Shakeel Butt , John Hubbard , Jason Gunthorpe , Mike Kravetz , Mike Rapoport , "Kirill A . Shutemov" , Matthew Wilcox , Vlastimil Babka , Jann Horn , Michal Hocko , Nadav Amit , Rik van Riel , Roman Gushchin , Andrea Arcangeli , Peter Xu , Donald Dutile , Christoph Hellwig , Oleg Nesterov , Jan Kara , Liang Zhang , Linux MM Subject: Re: [PATCH v3 3/9] mm: slightly clarify KSM logic in do_swap_page() Message-Id: <20220309125045.b04d20235a7260afceaf04d6@linux-foundation.org> In-Reply-To: References: <20220131162940.210846-1-david@redhat.com> <20220131162940.210846-4-david@redhat.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 9298D4001A X-Rspam-User: Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=QRaMnKng; dmarc=none; spf=pass (imf17.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org X-Stat-Signature: kn7hky1ngnb6dipeqrk4mzs1y3mdwes5 X-HE-Tag: 1646859048-774410 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, 9 Mar 2022 20:15:54 +0100 David Hildenbrand wrote: > On 09.03.22 19:48, Yang Shi wrote: > > On Mon, Jan 31, 2022 at 8:33 AM David Hildenbrand wrote: > >> > >> Let's make it clearer that KSM might only have to copy a page > >> in case we have a page in the swapcache, not if we allocated a fresh > >> page and bypassed the swapcache. While at it, add a comment why this is > >> usually necessary and merge the two swapcache conditions. > >> > >> Signed-off-by: David Hildenbrand > >> --- > >> mm/memory.c | 38 +++++++++++++++++++++++--------------- > >> 1 file changed, 23 insertions(+), 15 deletions(-) > >> > >> diff --git a/mm/memory.c b/mm/memory.c > >> index 923165b4c27e..3c91294cca98 100644 > >> --- a/mm/memory.c > >> +++ b/mm/memory.c > >> @@ -3615,21 +3615,29 @@ vm_fault_t do_swap_page(struct vm_fault *vmf) > >> goto out_release; > >> } > >> > >> - /* > >> - * Make sure try_to_free_swap or reuse_swap_page or swapoff did not > > > > We could remove the reference to "reuse_swap_page", right? > > > Yes, I noticed this a couple of days ago as well and already have a > patch prepared for that ("mm: adjust stale comment in do_swap_page() > mentioning reuse_swap_page()" at > https://github.com/davidhildenbrand/linux/commits/cow_fixes_part_3) > > If Andrew wants, we can fix that up directly before sending upstream or > I'll simply include that patch when sending out part2 v2. > > (I want to avoid sending another series just for this) Thanks, I did this. The same change plus gratuitous comment reflowing. --- a/mm/memory.c~mm-slightly-clarify-ksm-logic-in-do_swap_page-fix +++ a/mm/memory.c @@ -3609,11 +3609,11 @@ vm_fault_t do_swap_page(struct vm_fault if (swapcache) { /* - * Make sure try_to_free_swap or reuse_swap_page or swapoff did - * not release the swapcache from under us. The page pin, and - * pte_same test below, are not enough to exclude that. Even if - * it is still swapcache, we need to check that the page's swap - * has not changed. + * Make sure try_to_free_swap or swapoff did not release the + * swapcache from under us. The page pin, and pte_same test + * below, are not enough to exclude that. Even if it is still + * swapcache, we need to check that the page's swap has not + * changed. */ if (unlikely(!PageSwapCache(page) || page_private(page) != entry.val)) _