From patchwork Tue Mar 5 08:59:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Kellermann X-Patchwork-Id: 13581861 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 D03BFC54E41 for ; Tue, 5 Mar 2024 09:00:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3E3F56B009A; Tue, 5 Mar 2024 03:59:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 345E66B009C; Tue, 5 Mar 2024 03:59:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1E7086B009D; Tue, 5 Mar 2024 03:59:47 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 0B7FB6B009A for ; Tue, 5 Mar 2024 03:59:47 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id D98A2C0C7E for ; Tue, 5 Mar 2024 08:59:46 +0000 (UTC) X-FDA: 81862387572.07.61DF83C Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) by imf02.hostedemail.com (Postfix) with ESMTP id 2A3E680005 for ; Tue, 5 Mar 2024 08:59:44 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=ionos.com header.s=google header.b=IC3THLdd; spf=pass (imf02.hostedemail.com: domain of max.kellermann@ionos.com designates 209.85.218.54 as permitted sender) smtp.mailfrom=max.kellermann@ionos.com; dmarc=pass (policy=quarantine) header.from=ionos.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709629185; 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=TT7smv1j1+eH6dLDpyJyxapeCn0BRAoD8ideYTGL8g4=; b=7e1aAlYhgDu1U2fvqnb+GEEITDl8K8aQjoB3USc/HKeC8hEDdrzKwai4o8V8OU8/SRrGQu 56LOvl4x4TeMLn0ep605KRQf6acDnEPLaoxtbXLbCcYFr3YHVt6OTkBSa67ECRxmMnp+4S UB8EsdA0m1b1VeHvoQXIkIGU5v3osB0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709629185; a=rsa-sha256; cv=none; b=a/TZYIn/cmmP0LUDLgO55c6/B3SAsiFgxiv0J1ui3J/iQa/4WZ3e/X5R9vl3iHju3iD/bX 8IXbI9eks4NTkUm/uNIc8e+5j/OTSkBVGcS2lK3PnlscP9MvRcI+Hn4whl8Z2edeCqsh5o cHSYxzYzNP1tumUgP17sjnmHG6BVPWE= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=ionos.com header.s=google header.b=IC3THLdd; spf=pass (imf02.hostedemail.com: domain of max.kellermann@ionos.com designates 209.85.218.54 as permitted sender) smtp.mailfrom=max.kellermann@ionos.com; dmarc=pass (policy=quarantine) header.from=ionos.com Received: by mail-ej1-f54.google.com with SMTP id a640c23a62f3a-a28a6cef709so869761766b.1 for ; Tue, 05 Mar 2024 00:59:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1709629184; x=1710233984; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TT7smv1j1+eH6dLDpyJyxapeCn0BRAoD8ideYTGL8g4=; b=IC3THLddgmFGNtxNiolirnVG0u89yBk4oIiQQwzu8ZBvMW1fuOvLr1LjuFLqK/83Do n5A1IPeJTgzQ5MpKlQa9l6nltUfYC5tVDZT7Cx3B7hiRQSPQIWBVE1Fclz7MoACTCYps YPuvkNrVjj4HZ9GnAEDojkwQLac97jEFuEmIvVn0ReaLO85UbP9IK1A2Ri2rrcTaqyWv xBe0uwETUexXhrAIUM6MXqFskIgJlBj4zWKi7+0p3gVWt7HVhgmByU0QZ2N9pZUEh4wr y9lk+MJ4na1xWb2Nu4qpnto9UxwEinxv74nL/M3oUxX/GKmSv4HnoP1bJY0TVlskU5PH uvxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709629184; x=1710233984; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TT7smv1j1+eH6dLDpyJyxapeCn0BRAoD8ideYTGL8g4=; b=phTb9Z61d4q9GTtl7utH7DG+IJuG3uYHwbepE5eSDle001zRtXna1gd1S2JnmD+3/o Jnp9jb5OstnVPnBfmVTmVwX2CUIjx1Xu+GxNX/cxcUXBdboOQ14dOj3ZUvA+DeMhMzfk /xZm6Gll6fL24Sp/WzjG6UGpskNc9PHfGBaXocTf0VazdDkDph5qReWIZl1VGcH31IzQ qvEd0fX4J0556x1QLPb4pHmFAHbCq/QZa4YB6D7QPZpjef6P5Ik5BzbfnV9Ejr+xK4mK Rz4svEuKZXpH5q8eT2ZUmlQxBlyNEdxVuyF2RVhrCSPweJ2JWsjsJuXq28hIb5byu4PG reuA== X-Forwarded-Encrypted: i=1; AJvYcCUvd0cC+x9CDs17vLMRNvxspE5EBIkqQMT15W8FNSTbjM/paL0Sdxb8iFFbG9hgBhEr/dKAM9ZdNQNGr94zd4Bnj1o= X-Gm-Message-State: AOJu0YxcPzm8zdERGQf+CKIfczhadwsy3BYct0WB8U8IRr7S/1wm6ha6 m1pAF5/pR5ayQ5+6rCMHiLe2x0iizDosX1IbWYHegm4CAfN4/wiCOgyuqzLwNUY= X-Google-Smtp-Source: AGHT+IHtBtgNb5X5tWn9KArmVzxl5Jnk/MnYuiE1JbQjADDKG/XuWp5/tNkMjxChRCvuGWsrlF/Kqg== X-Received: by 2002:a17:906:c7c3:b0:a3e:34e8:626f with SMTP id dc3-20020a170906c7c300b00a3e34e8626fmr8169467ejb.66.1709629183860; Tue, 05 Mar 2024 00:59:43 -0800 (PST) Received: from raven.blarg.de (p200300dc6f010900023064fffe740809.dip0.t-ipconnect.de. [2003:dc:6f01:900:230:64ff:fe74:809]) by smtp.gmail.com with ESMTPSA id gs4-20020a170906f18400b00a449d12cdc5sm4453005ejb.119.2024.03.05.00.59.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 00:59:42 -0800 (PST) From: Max Kellermann To: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: willy@infradead.org, sfr@canb.auug.org.au, Max Kellermann Subject: [PATCH v3 08/14] linux/mm.h: move devmap-related declarations to mm/devmap_managed.h Date: Tue, 5 Mar 2024 09:59:13 +0100 Message-Id: <20240305085919.1601395-9-max.kellermann@ionos.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240305085919.1601395-1-max.kellermann@ionos.com> References: <20240305085919.1601395-1-max.kellermann@ionos.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 2A3E680005 X-Rspam-User: X-Stat-Signature: 1m4r3drds9f4rxj85pomeui5wb6385a4 X-Rspamd-Server: rspam03 X-HE-Tag: 1709629184-929684 X-HE-Meta: U2FsdGVkX18POZ+cSZjFwCghskiGB+yRaE3Cf8kelNFRZhsjqT6ceyRoYOwk1olZ0JwmtFpdA/irfXcliTup77nNS4OtFTaNjT222JHvQgxmU+qLJsnjgz45He6B8GDEv67FEtiAoJ3ahor925xB75x/0z+tARuF+XHpGa9nnxfLDHlN3cFX+F5Y5jD9/t8Wc+lSFc2ey/BYIO978fNT3GRsR0PdXLeBUetS4gkU1iCGC1cUISVOR1gn43tgUDXEnnrtfk9uFidACEBfc9gis0BFwUgYC0E9tH4us23X9UsZALIPigIZNJd4kSUgBA3dct6nExrk/FjMDfSgPkah9NBCKU9KgpJhDvU9cLeAFZtFKjQoPyCaV9nHyA/pTdha198qxbziwPKQPcLRHsRK1HsfbRVXnRG/+xpsU1sKJEcaMc1zLck+3242DAA17KsE+Fa9jGxr7uawKtP9nkfRiGBbqMIeU8jWEmMtHh1w9M7VfyABGsI+vcGovQZ9yR2RXub7tyO+EYOTwTT2Guk2/uVfc/uFpblxmDO+AAuJtJSZCgn5LoliwFMZVFHfkIA7cKVy8wFh3GpYChEQkCXIKmXLanfz4fD3PFzt4vWYggpYXRo8fFRNZYp+hQClRYPiYRV50qYRXdimUU72BSgfKAQlOtl2ui6wPYhc/mtACaG8KXFNXm8ShHJgYNf5safTC+O68uVwn7AUebIvZgK1ClHCrI2B+8jmjqagr7imzEEy6Pv+FcJBGNkfNUK7FdgquFzS6ROE5ZLrhlfxk5RbVrPPnVP680IhMDj9kqPsp9U8yr9aQvzi18JO946U7CG/KsD/Fpwmhv/1/mFn5fe2ng2NuHl9rs2gkhLMYV/qSqCmHlxOUocj1LrxzPYilFRX/CO6M2XSKnjJ8kdFy1qPSJrf3BMaFyf8u+9SbhEIAIwpj2GrVsYhsd7ryX+kmP9U1Rd3EdPIBnZSEwwoiwf JgXInSv2 6M6yFbJ4xC3DEEs1JI2cOLXlA70JutU0/b71rh49yKfj0h70YnU9s51Lq1Lpz/5STw1X0ev7JvItKN4ttdsfodVFyy4h+rPgSSPpaySSoocGCmhIBH34BVjLw9i5xrC0aPKkgqTZTSl3V8vKKzjWe4BwF9ccHJHUs9Bo0 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: Prepare to reduce dependencies on linux/mm.h. put_devmap_managed_page() is called by put_page(). Moving it to a separate header allows us to move put_page() to a separate lean header as well. Signed-off-by: Max Kellermann --- include/linux/mm.h | 25 +-------------------- include/linux/mm/devmap_managed.h | 37 +++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 24 deletions(-) create mode 100644 include/linux/mm/devmap_managed.h diff --git a/include/linux/mm.h b/include/linux/mm.h index e6c2df977abc..61f1312a626e 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2,6 +2,7 @@ #ifndef _LINUX_MM_H #define _LINUX_MM_H +#include #include #include #include @@ -1357,30 +1358,6 @@ vm_fault_t finish_fault(struct vm_fault *vmf); * back into memory. */ -#if defined(CONFIG_ZONE_DEVICE) && defined(CONFIG_FS_DAX) -DECLARE_STATIC_KEY_FALSE(devmap_managed_key); - -bool __put_devmap_managed_page_refs(struct page *page, int refs); -static inline bool put_devmap_managed_page_refs(struct page *page, int refs) -{ - if (!static_branch_unlikely(&devmap_managed_key)) - return false; - if (!is_zone_device_page(page)) - return false; - return __put_devmap_managed_page_refs(page, refs); -} -#else /* CONFIG_ZONE_DEVICE && CONFIG_FS_DAX */ -static inline bool put_devmap_managed_page_refs(struct page *page, int refs) -{ - return false; -} -#endif /* CONFIG_ZONE_DEVICE && CONFIG_FS_DAX */ - -static inline bool put_devmap_managed_page(struct page *page) -{ - return put_devmap_managed_page_refs(page, 1); -} - /* 127: arbitrary random number, small enough to assemble well */ #define folio_ref_zero_or_close_to_overflow(folio) \ ((unsigned int) folio_ref_count(folio) + 127u <= 127u) diff --git a/include/linux/mm/devmap_managed.h b/include/linux/mm/devmap_managed.h new file mode 100644 index 000000000000..0773529d80b2 --- /dev/null +++ b/include/linux/mm/devmap_managed.h @@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_MM_DEVMAP_MANAGED_H +#define _LINUX_MM_DEVMAP_MANAGED_H + +#include // for bool + +struct page; + +#if defined(CONFIG_ZONE_DEVICE) && defined(CONFIG_FS_DAX) + +#include // for DECLARE_STATIC_KEY_FALSE(), static_branch_unlikely() +#include // is_zone_device_page() + +DECLARE_STATIC_KEY_FALSE(devmap_managed_key); + +bool __put_devmap_managed_page_refs(struct page *page, int refs); +static inline bool put_devmap_managed_page_refs(struct page *page, int refs) +{ + if (!static_branch_unlikely(&devmap_managed_key)) + return false; + if (!is_zone_device_page(page)) + return false; + return __put_devmap_managed_page_refs(page, refs); +} +#else /* CONFIG_ZONE_DEVICE && CONFIG_FS_DAX */ +static inline bool put_devmap_managed_page_refs(struct page *page, int refs) +{ + return false; +} +#endif /* CONFIG_ZONE_DEVICE && CONFIG_FS_DAX */ + +static inline bool put_devmap_managed_page(struct page *page) +{ + return put_devmap_managed_page_refs(page, 1); +} + +#endif /* _LINUX_MM_DEVMAP_MANAGED_H */