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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4F906C433F5 for ; Wed, 9 Mar 2022 20:50:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234321AbiCIUvz (ORCPT ); Wed, 9 Mar 2022 15:51:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238214AbiCIUvt (ORCPT ); Wed, 9 Mar 2022 15:51:49 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04F0065499 for ; Wed, 9 Mar 2022 12:50:49 -0800 (PST) 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 ams.source.kernel.org (Postfix) with ESMTPS id 8407DB823CF for ; Wed, 9 Mar 2022 20:50:48 +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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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)) _