From patchwork Thu Feb 15 14:55:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Kellermann X-Patchwork-Id: 13558592 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 AA622C4829E for ; Thu, 15 Feb 2024 14:56:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E0D926B0082; Thu, 15 Feb 2024 09:56:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D961F6B0098; Thu, 15 Feb 2024 09:56:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9EB486B0082; Thu, 15 Feb 2024 09:56:26 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 7ACB56B0082 for ; Thu, 15 Feb 2024 09:56:26 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 461311402BF for ; Thu, 15 Feb 2024 14:56:26 +0000 (UTC) X-FDA: 81794339172.20.28646C1 Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) by imf10.hostedemail.com (Postfix) with ESMTP id 4FD97C0021 for ; Thu, 15 Feb 2024 14:56:23 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=ionos.com header.s=google header.b=f7E3Q8mF; spf=pass (imf10.hostedemail.com: domain of max.kellermann@ionos.com designates 209.85.218.50 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=1708008983; 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=Ui87eR1N8KdYrsRAWgwlBy5zGHV5S5KAP6ANHsd3+6c=; b=erudhZjsyCeGek7rcySP79/dK6FOW6RjZhBZpdRFA/IJMwNVeIst6Wg9YbisfjUe8spCmr jCgy3Y5G/lJsjXdpiOAozCrdIZpM0ShFiJxDVPO6cf3m/XvDaqn6TC7q5CDt/N8KoVSFZf aa3TR1ERCCJM8UOS+Uy042teZUVKlGs= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=ionos.com header.s=google header.b=f7E3Q8mF; spf=pass (imf10.hostedemail.com: domain of max.kellermann@ionos.com designates 209.85.218.50 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=1708008983; a=rsa-sha256; cv=none; b=ZP1yCHg+JGABKAmo0xxn8Q4EYlyfaaotg695mZV7pYvlH/T7HoFZILudRxvGiosyr/1ILd A3flJODBPS9i8rp/fAMKUEnIjXcNW6kg6FPpQPhEdSreCWozu9EJ+bD/bM8hkUpHBieTNw S6U6fMlCq+f6/SFElNa99XOFP1RNVbE= Received: by mail-ej1-f50.google.com with SMTP id a640c23a62f3a-a3d5e77cfbeso177505966b.0 for ; Thu, 15 Feb 2024 06:56:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1708008982; x=1708613782; 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=Ui87eR1N8KdYrsRAWgwlBy5zGHV5S5KAP6ANHsd3+6c=; b=f7E3Q8mFDswnDfM7jY1aFgn3rzGcm0cvlDX4MYRyeK/1lR2ikpFIItp7i00GahyeLN 1HFklD5Jh1TKLv2pQNNOVBtyHq+7FLwZudwAXtWETpQoCKkiQ+rp6YY/fmfArSahUk/j 5dvFlc0/AFvTuyM3rnVscIayfKxdZUgQo86Q7TEtw1faUFLKy4SpH2jiRFOfd8QXGso+ VEsYjeoMBC1h0c5KZryf/fssXoYWLEjFJOf3bLTnWShcO5CK27LkuMCtQCsNu3T3YBSI L91bG3/fETPGLrFSn3GHlnYQdYC+kGg1CWs1ubWCa1fX9IPPKUm9bGEEZLZ7OZzAw9qv KnpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708008982; x=1708613782; 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=Ui87eR1N8KdYrsRAWgwlBy5zGHV5S5KAP6ANHsd3+6c=; b=OFR1TN5d12p6gA05l0ujPLR7i2JQbHvWUWGWPUj9Afq1PSyadI+qlcWLyrh4qkJFE8 a69WmuqbnO8txNNsdM/4FLZw0zK0beCHgt3r8Bh9NMMeQcJiSIyhvsPGGS9//FdHwU6K Sc56LpAX38j/ruDl7ZO/oP3rPKkgGebMn6d1RHq/gIqm0Cs2xI5W0pHurZKGRty3ciiD o18s9lu/d7jco154vB7dsHMbuhOzINafXolGbf/AQI3znYHiGs5ih6eYyIC/eu/Y6Y/x 5z40yoJ1OVWba/M2r9rosiz3/0vQtJ2jbl0fKA3YZAGtUgyMnhuqm6k1NBGXJRHUT5+d qFRw== X-Forwarded-Encrypted: i=1; AJvYcCVkM0ETSEWS9rBR3wBIhgYj2uiHrEiCLXSy2Tm8osjKIHq/s948uI8jDHUEjOg/hLVUAXaj1mQIDGDgE3693gnRDYI= X-Gm-Message-State: AOJu0Yyvt+NOkbMVWkNUr9PVTSOkIWRGZqC22XbivMBum4T//tb3ZHKm nWerQGOVrv5QX9NNNEfroNvQdaGetRqGnOzF6xjZLyXAaSvv/JMN3UMKDVZx5TLwTRh8qr6q43i h X-Google-Smtp-Source: AGHT+IHJPjSHl7B3baS+ulCtYjH6fSBlPEEmxM5P3E0Kdh/Ma+gFX7l5Bh2omHP9cArRkMUptWYd9w== X-Received: by 2002:a17:907:b0a:b0:a3c:ce90:bf4 with SMTP id h10-20020a1709070b0a00b00a3cce900bf4mr4128460ejl.14.1708008981990; Thu, 15 Feb 2024 06:56:21 -0800 (PST) Received: from raven.intern.cm-ag (p200300dc6f267100023064fffe740809.dip0.t-ipconnect.de. [2003:dc:6f26:7100:230:64ff:fe74:809]) by smtp.gmail.com with ESMTPSA id s18-20020a170906169200b00a3d1897ab68sm631175ejd.113.2024.02.15.06.56.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 06:56:20 -0800 (PST) From: Max Kellermann To: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Max Kellermann Subject: [PATCH v1 11/14] linux/mm.h: move pfmemalloc-related functions to pfmemalloc.h Date: Thu, 15 Feb 2024 15:55:59 +0100 Message-Id: <20240215145602.1371274-12-max.kellermann@ionos.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240215145602.1371274-1-max.kellermann@ionos.com> References: <20240215145602.1371274-1-max.kellermann@ionos.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 4FD97C0021 X-Rspam-User: X-Stat-Signature: f66mwf4ea5h93din5nmfcuoqbknzmsjm X-Rspamd-Server: rspam01 X-HE-Tag: 1708008983-6707 X-HE-Meta: U2FsdGVkX1/jK6XPJG0jaCQAk+aLVk26jq7AQpvmFOeEWBvjJWoNUGT2ihDqfr+W2e5QFJEJZHCPrLNtn0JtA4PA7I40zImW2tMSsEkkx4LTRf5XLAq3TxgeOrx0EONre56Qwc+bKQOeZsXRIIP3vuxTC2xvBdZcIaIQEjr8LLpQqimJ0daLH8OFrSuIqoVgVQv/GSKWUPwkUSz24NBvVzS1KYpJUQm3MF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cqiR8qYvttcBGnbWwqqh9thY98j19Scw3gjKPeJmKchBgsnzrNsTt2IUAJAXEl4+BgP5Wq55XVdG4wQK35fPa5ws4kq1cjTTbDr7tv7k X-Bogosity: Ham, tests=bogofilter, spamicity=0.000563, 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 in 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 aa24e6fed9b6..c7e53cd0cdd0 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -1744,50 +1745,6 @@ static inline pgoff_t page_index(struct page *page) return page->index; } -/* - * 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 */