From patchwork Wed Oct 2 15:25:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13819963 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 CC986CF6D38 for ; Wed, 2 Oct 2024 15:25:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BD42A4401B6; Wed, 2 Oct 2024 11:25:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B5E944401B5; Wed, 2 Oct 2024 11:25:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9B2BE4401B6; Wed, 2 Oct 2024 11:25:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 71FDA4401B5 for ; Wed, 2 Oct 2024 11:25:48 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 27E57C09D0 for ; Wed, 2 Oct 2024 15:25:48 +0000 (UTC) X-FDA: 82629037176.13.A81E782 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf27.hostedemail.com (Postfix) with ESMTP id 8792840021 for ; Wed, 2 Oct 2024 15:25:46 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=puqg8JRR; dmarc=none; spf=none (imf27.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1727882605; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=otjZaZiWSr5Zsq16KlIVTi2JYEjXY2WlATJleYRPFIs=; b=tQkqqtNmkcZaaNJMjuWL1Swa5pcNmyfhCFKr5+xVwpvd20cYUmZwm+D0phNsc6y2gARzSv Mk3dVYsX8tPLI51vOuKnnZ5RY12boyJfA3Rx9iNgs/iTIkfFe12UehcEDMbC0T5Eu/KKhO +zdopC9a8VBdj2bgDnKy08XMUcSisIY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727882605; a=rsa-sha256; cv=none; b=bkEJ2xZo+ROR2/JV/K4fQX+A0ciidEg9xRSnovghkT/SUpnsVW2dsxdhvfQTiGs1tT7xfS 0NjgNaODN0tuRoK1fVbo/M7y8dRY19cWowgO+EFk8wMyzNzdIog4mxkbq9LLfZVzf8qEL3 lRXLZ3hP/RiIuK9XgQA/zZdy/6YKE+c= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=puqg8JRR; dmarc=none; spf=none (imf27.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=otjZaZiWSr5Zsq16KlIVTi2JYEjXY2WlATJleYRPFIs=; b=puqg8JRRX4a96pzmS8Qwiul2u7 +6rwYUzWKJ4vuP2H+/an28MQ/Z3kZ2GDNbgy80hU4Du7Y4Q7xD1zaiYq+32zahCIJQwHf0BZyuOdc jSszvkfH9r4o/nb4izqEwf9Uc0R3Maq2rLETqMUXisznp3lmGM3PR0UW6DJQqDwutlmCX2g5nS4I4 HHUia17ovCMUMrZ/mTB8x3YlND3IyIX2SASU5peq9s+2+3WoSV3QQ+y0eCFDlxLBVVBqfrBjRszM8 kpgCuZwRJpxIui9qCliq1lTkaggl55p7Ji7s+HADmZLsFGeeo10cpxOS3KhQ5YwrUZ0Ud23RZVfRv D4Wc4Xig==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1sw1EN-00000005fMs-1qIB; Wed, 02 Oct 2024 15:25:35 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, Alex Shi Subject: [PATCH 4/5] mm: Add PageAnonNotKsm() Date: Wed, 2 Oct 2024 16:25:30 +0100 Message-ID: <20241002152533.1350629-5-willy@infradead.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241002152533.1350629-1-willy@infradead.org> References: <20241002152533.1350629-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 8792840021 X-Stat-Signature: dpdp3ycdps5e5dk8b1qny3kuemn95tcq X-Rspam-User: X-HE-Tag: 1727882746-762674 X-HE-Meta: U2FsdGVkX1/0iQiz+V8WyCUpz24D3qAUxc/IQAzDSJYhHrxPT07E8sxXTLWj+VEP+X3+fofVT/NPeE5ehsa9f4bdN/Ls8920OOmRUGejlCDaoZ8RI6E0KN5R9yPek3+p+86Kls/d3OATOOL0wSMCKMuMfNPTSYN2HECwNhcjSwhoScybAyLwB8jt59UqO2Vz7oQOB3LyytfZCN9anphE8nT3DCBLVw+yxk+g6DGI5m1zCzv3CYmmatP0S5emQvexp+FmFjj2Qwy56nngRIQPAGParWBh+nIX5BW7kfD1v1X/+FOB4KL5Sh+RlEbLpEw1OBQ09Nddfqd4mcKAdX/T0kx9AqUM11dNe6vygYpT937JFmLLIfX6n+DQHIjuaeSNcQyVVoDCb4yTpNFebJWflplIbnci3aIqn7QZx8w3/J1pASbVpoG9PgYTLbX1pWsDRIjIapTeOEDVlGE5OWFgTz4GpjIKlU7Cj82SefYh11AGy8++gpE7JGtt/zBB3HQfKQClxTkdOByF8B02/PpQszovv14wfwRzBAWvLazlyoqh71yEwRhoE504VC6hOmGzJmSG3w1XQ2zOTBCOxXXbbR2kt3PnphQJY7RIQiJygxwXq4XAROhZZxiMyPkACW5YXjnhsE5o5++834gbb3s96y4vU9u2DWIihrCvCmKPDAmD/sVK15DzKKivKQMicLOg84DINO1nFdH0MW86sJopV+GZMoGhCqPb0T+c2IsMh3FC3VbEx/UEARRTEo7zHHrzkSE7jnrPi9G1lXA7uUzc1zY9rtL4JMot2SmrhrttYZB2U2mJLhpYMkQQuOHST1Lr/My7nuTWLTKGyXaKg6sQ2VAuNrXxrUs0sOyz1yeZEQ4yFTfQdpfybaKx3IZvZ/87tDT+9xI1/YHiFfKen7tEkwn4UVeVwi0XYBmYX0ylbaPJAxCTrSwM+vtoQpDviJQceiONr1SrihTsPzU95PU sxpQ2kbu S6qugBSq7bUHuNwsW/oCzrmixjgWTQlWFCWk/yZ0fvw+CmCZGH9/3WkvJIqLlPjct/qDzvg7n3INV/b7B+/lkAYCchtiU4fwa1a/VXDxrFhFRpNDeEOoP0g++YAxCHJWb3UpgDpA55UnhpgNQxqKAGAH95itA4B0FzSa92ueKARvFbQ6M6f69j/RECLeMxqTVqtQr9BxP7wQfWysPkh8bqW2+ZUInHhULIA70Yzm0dWDfU2w= 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: List-Subscribe: List-Unsubscribe: Check that this anonymous page is really anonymous, not anonymous-or-KSM. This optimises the debug check, but its real purpose is to remove the last two users of PageKsm(). Signed-off-by: Matthew Wilcox (Oracle) Acked-by: David Hildenbrand --- include/linux/page-flags.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index 4c2dfe289046..157c4ffc2fdc 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -689,6 +689,13 @@ static __always_inline bool folio_test_anon(const struct folio *folio) return ((unsigned long)folio->mapping & PAGE_MAPPING_ANON) != 0; } +static __always_inline bool PageAnonNotKsm(const struct page *page) +{ + unsigned long flags = (unsigned long)page_folio(page)->mapping; + + return (flags & PAGE_MAPPING_FLAGS) == PAGE_MAPPING_ANON; +} + static __always_inline bool PageAnon(const struct page *page) { return folio_test_anon(page_folio(page)); @@ -1129,14 +1136,14 @@ static __always_inline int PageAnonExclusive(const struct page *page) static __always_inline void SetPageAnonExclusive(struct page *page) { - VM_BUG_ON_PGFLAGS(!PageAnon(page) || PageKsm(page), page); + VM_BUG_ON_PGFLAGS(PageAnonNotKsm(page), page); VM_BUG_ON_PGFLAGS(PageHuge(page) && !PageHead(page), page); set_bit(PG_anon_exclusive, &PF_ANY(page, 1)->flags); } static __always_inline void ClearPageAnonExclusive(struct page *page) { - VM_BUG_ON_PGFLAGS(!PageAnon(page) || PageKsm(page), page); + VM_BUG_ON_PGFLAGS(PageAnonNotKsm(page), page); VM_BUG_ON_PGFLAGS(PageHuge(page) && !PageHead(page), page); clear_bit(PG_anon_exclusive, &PF_ANY(page, 1)->flags); }