From patchwork Tue Jun 4 09:08:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Kellermann X-Patchwork-Id: 13684925 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 BD4DAC25B78 for ; Tue, 4 Jun 2024 09:09:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 368606B00A5; Tue, 4 Jun 2024 05:09:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3176D6B00A8; Tue, 4 Jun 2024 05:09:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F27446B00A5; Tue, 4 Jun 2024 05:09:25 -0400 (EDT) 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 C73146B00A7 for ; Tue, 4 Jun 2024 05:09:25 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 870FE1407C8 for ; Tue, 4 Jun 2024 09:09:25 +0000 (UTC) X-FDA: 82192632690.03.EB8DA47 Received: from mail-ed1-f41.google.com (mail-ed1-f41.google.com [209.85.208.41]) by imf21.hostedemail.com (Postfix) with ESMTP id AEFA51C001E for ; Tue, 4 Jun 2024 09:09:22 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=ionos.com header.s=google header.b=Pv61nEPa; spf=pass (imf21.hostedemail.com: domain of max.kellermann@ionos.com designates 209.85.208.41 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=1717492162; 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=66hU7JCzDxZkm1iV/ENOXsQE3QPWNxsFJw0nhpOp8E8=; b=PhjrhZyqPzru/RufcCBIXSSLSuMyvAX8DmFNM8iAu+3oAPkjUXeQao3TRsheZkYAP2M/Cm ybfjeEl4/tE+R+rmLW1kVoQdiv8JAJ3bySG2gdx3I25glc2z0omAFyc+iBJ+u9KtyAMnso 5fB+oTn3n2wPwsUVQzqeubqg7cAzvIA= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=ionos.com header.s=google header.b=Pv61nEPa; spf=pass (imf21.hostedemail.com: domain of max.kellermann@ionos.com designates 209.85.208.41 as permitted sender) smtp.mailfrom=max.kellermann@ionos.com; dmarc=pass (policy=quarantine) header.from=ionos.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1717492162; a=rsa-sha256; cv=none; b=gE6Ib/262zmU70nJla8ZasS4gi12kL30uu4d+JUb893MAjSqrT1XET2qsVQ80VoqyZ2hke 2R8qlYum8MCG+r5kQVsUpukkE9bfbYFD5oGzFZridDD1wKTywtMPaSr2NhwUBk7IW0QMDA KWU+jZ/KFomfqh/Ly/X/+RH5mUY1Tac= Received: by mail-ed1-f41.google.com with SMTP id 4fb4d7f45d1cf-57a1fe6392eso6069896a12.0 for ; Tue, 04 Jun 2024 02:09:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1717492161; x=1718096961; 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=66hU7JCzDxZkm1iV/ENOXsQE3QPWNxsFJw0nhpOp8E8=; b=Pv61nEPa7kifAFK9jxv0Fpl8MLXito5dbm4OzoN3x59n3eu2mV6m+DAvI9uoNc1hAz JK1sb/bjZpnlJx7UQ6PjQ0b18iHG/WCvh1PRY84r+M4rrx8598i60y0VEtJy00GHMPow 9L3eOdv7qg0gour7gaAoSvO+e1rf7VPOFbeo//fZ8vVybuxvsyXmRT/uhJMy3fYh0xaP WCpsXzc+ApMMZJgr8c7Qgw7yWSdHngZtvAsJ1Z/Ehcl2wrX/GOCDqeCsRA6qzWFqq7r9 CQoeCOS9wtHsL7Kj7Y6kNwVCUgdmk0XfN+ONjYwoyw09KkGeWURUVYVTOtKLzoIobVjI fp4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717492161; x=1718096961; 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=66hU7JCzDxZkm1iV/ENOXsQE3QPWNxsFJw0nhpOp8E8=; b=rfDsKElVz/YnpcFN4jNqGCTu3wI89Mi2W8qQEd6HCAnkRDfyVFOvMaE5Z8a51PA4X2 moXSwnPx7iwTLWHaGvEtkN90+Y8pxKIsa1EEd3lrLbhIBXgeeUtuMV9MNF5edfXFBqHC p1C2X5jBncAE/QNzLGiZr7iyleJee0HVIoUYozzeQ2XHA591szPCck0kEdXDFqI3o4RF xofmv6cGkGb5KAIKouh2qZ/vFR5fjW47nSJ+HPZo6hpD6vNPerYEF5GLy4Ezv8gcMjc7 TaUw+60ER0eak3J9r/DahaginaIGwqa7pL2mjdnWlNDcfo/iuJ+jfuLY/ghCcYWPQHiu 5Lkg== X-Forwarded-Encrypted: i=1; AJvYcCWYmwCvGY9Q0XfUJsQ7o4SXIoPLERJNg1uL0O1ZKSbtebpvMVL6Jm30CjfTGsAQN4qCIrs3nhoDelVGK0g+1216Ezo= X-Gm-Message-State: AOJu0YwicrykUfstVe+HM0mHuZjd1vIiJeECcX7+Rt/oYjB0GqbL3LYz j9SX6QpmQJVElRVq9z4lsiwrX3Mjns3KQiwuOjKlOiUJqtRKQ7Hp7XDFTEHsmE8= X-Google-Smtp-Source: AGHT+IFjlRq5i4sRiIz9ii8DICuiWwLZihtIRXZ77Dt4nvy+Gy+GZJvOZGsJ7ckHFkBdl+70Wt0aaw== X-Received: by 2002:a17:906:f585:b0:a68:f0ce:9f2e with SMTP id a640c23a62f3a-a68f0cea079mr465457066b.44.1717492161256; Tue, 04 Jun 2024 02:09:21 -0700 (PDT) Received: from raven.blarg.de (p200300dc6f4f9200023064fffe740809.dip0.t-ipconnect.de. [2003:dc:6f4f:9200:230:64ff:fe74:809]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a68fa49e66fsm328376766b.129.2024.06.04.02.09.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 02:09:20 -0700 (PDT) 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, david@redhat.com, Max Kellermann Subject: [PATCH v6 12/15] linux/mm.h: move pfmemalloc-related functions to pfmemalloc.h Date: Tue, 4 Jun 2024 11:08:42 +0200 Message-Id: <20240604090845.2182265-13-max.kellermann@ionos.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240604090845.2182265-1-max.kellermann@ionos.com> References: <20240604090845.2182265-1-max.kellermann@ionos.com> MIME-Version: 1.0 X-Stat-Signature: 4t5hueizj1fcmq7seimnbb4rgr3sk6pp X-Rspamd-Queue-Id: AEFA51C001E X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1717492162-864119 X-HE-Meta: U2FsdGVkX1/TpmEPMGLosBwmdoM83M1R2NiuxXBdrYKZLEAhtz1UHnRx6+r/bAfejd816wq0eql93LbF8R2qMYc5CrrxJBy+5j1nKVhj/RhvP4qAwq9ehcD/pw/4A8RpyV5rPm2gAmJkzr3YOXIk/MiQd7AON6Hovm4l1nmHgJlez4+XzPtbhN6QaPjjW4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MRelTc6UL5nMGC4a1Cp7+in7rGN6jofAJse6mge5t2sjxxHI8VR/NIgjww6IeqOMh1ePb0PnqjLKguO0+RpuvAo1wrs2Y3tLTVyuBcFfGt4O1wdReylUnXwjmjqCTDr6KP1iCNPmWP0pa5 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000328, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: This is needed to eliminate linux/skbuff.h's dependency on linux/mm.h. Signed-off-by: Max Kellermann --- include/linux/mm.h | 45 +----------------------------- include/linux/mm/pfmemalloc.h | 52 +++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 44 deletions(-) create mode 100644 include/linux/mm/pfmemalloc.h diff --git a/include/linux/mm.h b/include/linux/mm.h index c026e58e3725..e178bda2525d 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -1772,50 +1773,6 @@ static inline int arch_make_folio_accessible(struct folio *folio) */ #include -/* - * Return true only if the page has been allocated with - * ALLOC_NO_WATERMARKS and the low watermark was not - * met implying that the system is under some pressure. - */ -static inline bool page_is_pfmemalloc(const struct page *page) -{ - /* - * lru.next has bit 1 set if the page is allocated from the - * pfmemalloc reserves. Callers may simply overwrite it if - * they do not need to preserve that information. - */ - return (uintptr_t)page->lru.next & BIT(1); -} - -/* - * Return true only if the folio has been allocated with - * ALLOC_NO_WATERMARKS and the low watermark was not - * met implying that the system is under some pressure. - */ -static inline bool folio_is_pfmemalloc(const struct folio *folio) -{ - /* - * lru.next has bit 1 set if the page is allocated from the - * pfmemalloc reserves. Callers may simply overwrite it if - * they do not need to preserve that information. - */ - return (uintptr_t)folio->lru.next & BIT(1); -} - -/* - * Only to be called by the page allocator on a freshly allocated - * page. - */ -static inline void set_page_pfmemalloc(struct page *page) -{ - page->lru.next = (void *)BIT(1); -} - -static inline void clear_page_pfmemalloc(struct page *page) -{ - page->lru.next = NULL; -} - /* * Can be called by the pagefault handler when it gets a VM_FAULT_OOM. */ diff --git a/include/linux/mm/pfmemalloc.h b/include/linux/mm/pfmemalloc.h new file mode 100644 index 000000000000..345b215a3566 --- /dev/null +++ b/include/linux/mm/pfmemalloc.h @@ -0,0 +1,52 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_MM_PFMEMALLOC_H +#define _LINUX_MM_PFMEMALLOC_H + +#include // for BIT() +#include // for struct page + +/* + * Return true only if the page has been allocated with + * ALLOC_NO_WATERMARKS and the low watermark was not + * met implying that the system is under some pressure. + */ +static inline bool page_is_pfmemalloc(const struct page *page) +{ + /* + * lru.next has bit 1 set if the page is allocated from the + * pfmemalloc reserves. Callers may simply overwrite it if + * they do not need to preserve that information. + */ + return (uintptr_t)page->lru.next & BIT(1); +} + +/* + * Return true only if the folio has been allocated with + * ALLOC_NO_WATERMARKS and the low watermark was not + * met implying that the system is under some pressure. + */ +static inline bool folio_is_pfmemalloc(const struct folio *folio) +{ + /* + * lru.next has bit 1 set if the page is allocated from the + * pfmemalloc reserves. Callers may simply overwrite it if + * they do not need to preserve that information. + */ + return (uintptr_t)folio->lru.next & BIT(1); +} + +/* + * Only to be called by the page allocator on a freshly allocated + * page. + */ +static inline void set_page_pfmemalloc(struct page *page) +{ + page->lru.next = (void *)BIT(1); +} + +static inline void clear_page_pfmemalloc(struct page *page) +{ + page->lru.next = NULL; +} + +#endif /* _LINUX_MM_PFMEMALLOC_H */