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 A9389C433EF for ; Thu, 28 Apr 2022 16:52:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0C6A18D000D; Thu, 28 Apr 2022 12:52:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 077358D0005; Thu, 28 Apr 2022 12:52:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E58A38D000D; Thu, 28 Apr 2022 12:52:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.27]) by kanga.kvack.org (Postfix) with ESMTP id D40F78D0005 for ; Thu, 28 Apr 2022 12:52:13 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 9C1E8225CF for ; Thu, 28 Apr 2022 16:52:13 +0000 (UTC) X-FDA: 79406880546.16.4DFF3D0 Received: from mail-qk1-f176.google.com (mail-qk1-f176.google.com [209.85.222.176]) by imf25.hostedemail.com (Postfix) with ESMTP id 84C6CA0067 for ; Thu, 28 Apr 2022 16:52:04 +0000 (UTC) Received: by mail-qk1-f176.google.com with SMTP id a22so973261qkl.5 for ; Thu, 28 Apr 2022 09:52:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:in-reply-to:message-id:references :mime-version; bh=ge3ZPWN0M9amQ6mKSg0omt63Nk/S+2cZMmx9LZwp68s=; b=ljDUmMK6e/vLTCndgDDSANmK5RkqAFHOzkTv1LANQNLVtJx7jHydDO96kr/QUFkFL5 8Mp9tmkS7I1gQxYtkwfpUlDsPs8GRBsJ0ykxxNJDKBb6pwlPNlweAukPs5GHsryNdD1b UzIVHdKWP0fKg7XjBrKILhxYCgKFsUk1K9I12+QrUiMWpL+PVE6a2tekJuW80qnjvAQ8 3sdRbOUDWLoFE4GvDuaA6i9KYvoWLSxCsqbWD6osE3xFU4yOTQ3urv59AFsppRrpdZJn lImagqiFa9fVCtEPY+qnzhumXUrNulpfVQK2fGBCxYK+/uPY0EFdjxXwfNDtcJfC2hEo RCSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:mime-version; bh=ge3ZPWN0M9amQ6mKSg0omt63Nk/S+2cZMmx9LZwp68s=; b=vAS68cYFgsMw5RPTJRM/l4BVRTJA3PoiTWv4OET9H7C8aGjdLAsn9HmdWGMacysbbn HSc+DRjy8IAKcarrCU9caSlRWQn6K03PIU8id0hg8TjcKGIwG3xctIUxDksCvvxj6Y3a 2yJ2aBkCZERuskWJR/R6e6FymWudlovgyGHpM0B6NLHbaxfKouKA0RFZZwemQnGFeI1k 3FTmQ9z6uZAVPL4nlKv1/TOsEO9R95EDidOfSMKNQUwDpnlvrox9/VBYZRurujpzh7Ss BYFxv1MefJu3+/BuACVCffoC5LYrdO8ihgyI1TyDwifNi3gAPn+8WlV/KMphpThE6TQd oqQg== X-Gm-Message-State: AOAM532JxJINuaTQjzDRgKwm5WizYHKWZOyYhpBSerKfmae0w5wMEHQv rsL8n7TdYSSAl35AZ3K5HMfB6A== X-Google-Smtp-Source: ABdhPJwzfes0ShPwouYNOLRg6xLyz9XwoSBWEQsuuqe3bVE9E4WYyzToSnX9IlhVbJ944pqcLt97bg== X-Received: by 2002:a05:620a:28cb:b0:69e:befa:a4c5 with SMTP id l11-20020a05620a28cb00b0069ebefaa4c5mr20228939qkp.477.1651164732094; Thu, 28 Apr 2022 09:52:12 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id q27-20020a05620a039b00b0069c8307d9c4sm205919qkm.18.2022.04.28.09.52.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Apr 2022 09:52:11 -0700 (PDT) Date: Thu, 28 Apr 2022 09:51:58 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.anvils To: Greg Kroah-Hartman cc: stable@vger.kernel.org, linux-kernel@vger.kernel.org, Hugh Dickins , Yang Shi , "Kirill A. Shutemov" , Andrew Morton , Linus Torvalds , linux-mm@kvack.org Subject: Re: [PATCH AUTOSEL 13/14] mm/thp: ClearPageDoubleMap in first page_add_file_rmap() In-Reply-To: <20220428154222.1230793-13-gregkh@linuxfoundation.org> Message-ID: References: <20220428154222.1230793-1-gregkh@linuxfoundation.org> <20220428154222.1230793-13-gregkh@linuxfoundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 84C6CA0067 X-Stat-Signature: 6edamdd3shyuxtqmwt9ycszkxcoqwa7p Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=ljDUmMK6; spf=pass (imf25.hostedemail.com: domain of hughd@google.com designates 209.85.222.176 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com X-HE-Tag: 1651164724-722233 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 Thu, 28 Apr 2022, Greg Kroah-Hartman wrote: > From: Hugh Dickins > > commit bd55b0c2d64e84a75575f548a33a3dfecc135b65 upstream. > > PageDoubleMap is maintained differently for anon and for shmem+file: the > shmem+file one was never cleared, because a safe place to do so could > not be found; so it would blight future use of the cached hugepage until > evicted. > > See https://lore.kernel.org/lkml/1571938066-29031-1-git-send-email-yang.shi@linux.alibaba.com/ > > But page_add_file_rmap() does provide a safe place to do so (though later > than one might wish): allowing testing to return to an initial state > without a damaging drop_caches. > > Link: https://lkml.kernel.org/r/61c5cf99-a962-9a25-597a-53ab1bd8fbc0@google.com > Fixes: 9a73f61bdb8a ("thp, mlock: do not mlock PTE-mapped file huge pages") > Signed-off-by: Hugh Dickins > Reviewed-by: Yang Shi > Cc: "Kirill A. Shutemov" > Signed-off-by: Andrew Morton > Signed-off-by: Linus Torvalds > Signed-off-by: Greg Kroah-Hartman NAK. I thought we had a long-standing agreement that AUTOSEL does not try to add patches from akpm's tree which had not been marked for stable. (Whereas, if a developer asks for such a patch to be added to stable later, and verifies the result, that's of course a different matter.) I've chosen to answer to this patch of my 3 in your 14 AUTOSELs, because this one is just an improvement, not at all a bugfix needed for stable (maybe AUTOSEL noticed "racy" or "safely" in the comments, and misunderstood). The "Fixes" was intended to help any humans who wanted to backport into their trees. I do recall that this 13/14, and 14/14, are mods to mm/rmap.c which followed other (mm/munlock) mods to mm/rmap.c in 5.18-rc1, which affected the out path of the function involved, and somehow made 14/14 a little cleaner. I'm sorry, but I just don't rate it worth my time at the moment, to verify whether 14/14 happens to have ended up as a correct patch or not. And nobody can verify them without these AUTOSELs saying to which tree they are targeted - 5.17 I suppose. Hugh > --- > mm/rmap.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/mm/rmap.c b/mm/rmap.c > index 9e27f9f038d3..444d0d958aff 100644 > --- a/mm/rmap.c > +++ b/mm/rmap.c > @@ -1252,6 +1252,17 @@ void page_add_file_rmap(struct page *page, bool compound) > } > if (!atomic_inc_and_test(compound_mapcount_ptr(page))) > goto out; > + > + /* > + * It is racy to ClearPageDoubleMap in page_remove_file_rmap(); > + * but page lock is held by all page_add_file_rmap() compound > + * callers, and SetPageDoubleMap below warns if !PageLocked: > + * so here is a place that DoubleMap can be safely cleared. > + */ > + VM_WARN_ON_ONCE(!PageLocked(page)); > + if (nr == nr_pages && PageDoubleMap(page)) > + ClearPageDoubleMap(page); > + > if (PageSwapBacked(page)) > __mod_lruvec_page_state(page, NR_SHMEM_PMDMAPPED, > nr_pages); > -- > 2.36.0