From patchwork Tue Mar 12 09:41:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Kellermann X-Patchwork-Id: 13589725 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 2598FC54E66 for ; Tue, 12 Mar 2024 09:42:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 46CAF8D0032; Tue, 12 Mar 2024 05:42:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3C8418D0030; Tue, 12 Mar 2024 05:42:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F3CC98D0032; Tue, 12 Mar 2024 05:42:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id D926A8D0030 for ; Tue, 12 Mar 2024 05:42:04 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id B3F891C08D2 for ; Tue, 12 Mar 2024 09:42:04 +0000 (UTC) X-FDA: 81887895768.26.3318207 Received: from mail-ed1-f48.google.com (mail-ed1-f48.google.com [209.85.208.48]) by imf17.hostedemail.com (Postfix) with ESMTP id BD5FA40007 for ; Tue, 12 Mar 2024 09:42:02 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=ionos.com header.s=google header.b=AXbw08Ib; spf=pass (imf17.hostedemail.com: domain of max.kellermann@ionos.com designates 209.85.208.48 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=1710236522; 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=i50xlwbZc74AakEZHNdRuLF9vXbOX6ErFGehWmkuapg=; b=xq5AqxXwOOED1a7pcPf4Rc/AwgnrlOGZxM2eU0I31qFOrBxSU5wF81JzVbFy6akgzsZ/Dh IyZJLWcaivII2hgY2BaOdcDC3WBHT5Y1uZIXRwQQLd4nRZJot9bW0woqlag980CjbxzQQs yIQJ+nMDaFmnV4bUPqTbqWPsGGZLxUc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1710236522; a=rsa-sha256; cv=none; b=D9ZjhS+P4v0Ynwlu2S3BTT5tOILL0D2Ln2H87unF8qz6opJ/gUvnEk0D9XKJ4vpCdAwKtL Is9G8XrdKL4ILCc/7oJlgaYt3PuEue7SnOKLExxWvoRBF6cFBHPV9trxO+uig8DoP9x74Y MSayfpukLClezLF5wiQ4zg/ObKVVWJs= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=ionos.com header.s=google header.b=AXbw08Ib; spf=pass (imf17.hostedemail.com: domain of max.kellermann@ionos.com designates 209.85.208.48 as permitted sender) smtp.mailfrom=max.kellermann@ionos.com; dmarc=pass (policy=quarantine) header.from=ionos.com Received: by mail-ed1-f48.google.com with SMTP id 4fb4d7f45d1cf-5684ea117a3so4036089a12.0 for ; Tue, 12 Mar 2024 02:42:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1710236521; x=1710841321; 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=i50xlwbZc74AakEZHNdRuLF9vXbOX6ErFGehWmkuapg=; b=AXbw08IbVbl2Q7rDjvxHlGd/Q4i2X7oYaOychnl33sgVDSRYgbcQ2w3yNbhXUfvqyr bWWZcr9mfjPgJBQzV7ORhIRbe+30Muk2J78IHBeOKUbk4BNQsYdc8d0v3hUEJaW73TSQ p4jeXI5jt2m0xf6AawY2dHLcDzGcVeV/i4EWDSwLxid5/skitBMu4F4PSiXTxIj53EHy qp3IOaIkZG7NEzHXqJMGL6rmT/MUmFbRjOlLzPinKw0VehMJPjRB1xX4m6nmFLE0hrKM TW9gaiTfK65CPR4S58pnLPYUTYDOhZI4Fr6rmX19Ogr8IHvUGJPz8TYAyYVHB53UJi9K kd1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710236521; x=1710841321; 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=i50xlwbZc74AakEZHNdRuLF9vXbOX6ErFGehWmkuapg=; b=qSsB6mbzwg9kBvhh78mOpE+9C5DAvvV+JZjrHAUAvA7ZseTACJSNWaMRgfRKGUKGM6 r7gMSgH1AA1f2Tj9R0ADSs06WYWe36zxYbH27MldQBJy41cIFP3Zcjyv3PNme/SbFAOm 6Q1DQqsltPF7A3mdIHqhJ45iu0UYHhgxAuECCKnQP2lVf7djiJylPcOqhmUIcJxs0Fco bpDwOZLmjgjNw6P7zrHlXaRm9F3+Ocz9QyB90k3miXhpy3t7dMY4GDR7XrjsQB5fetN9 8Si72QpLPzqXyrTybW2KWMwmsYiP7poF4uMrgUFIV54FXPrkygwlS8M9E064o5PveRU2 +KBw== X-Forwarded-Encrypted: i=1; AJvYcCWxJ09gY6YsfyDIrpXT/n45zjve2ZUNBV9d8/H3zs086stvzzd+GYo+anoAG3eydWtBSWcVlcq/CeQf+3gQSzsBbns= X-Gm-Message-State: AOJu0YxNgq4KxajA67GbLEkpMsXOloLyRkTeVEEl84hLzmA5AuiAQUz2 1f7mQ8v3CJA1IUgwDQdlbD7ESaUzcQXMJZRK71raoc3hu+n1gz73A0HGqM2X/d4= X-Google-Smtp-Source: AGHT+IHE1rmIWCBb38RKNMnxPLtWxqbctrPPIxbV0WrCoKWmsRzG7Lzagrq8yH3gH7FOwHCKd2fZew== X-Received: by 2002:a17:907:7714:b0:a45:a98f:2cf7 with SMTP id kw20-20020a170907771400b00a45a98f2cf7mr5679209ejc.57.1710236521219; Tue, 12 Mar 2024 02:42:01 -0700 (PDT) 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 jw22-20020a170906e95600b00a4623030893sm2091961ejb.126.2024.03.12.02.42.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 02:42:00 -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, Max Kellermann Subject: [PATCH v4 12/15] linux/mm.h: move pfmemalloc-related functions to pfmemalloc.h Date: Tue, 12 Mar 2024 10:41:30 +0100 Message-Id: <20240312094133.2084996-13-max.kellermann@ionos.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240312094133.2084996-1-max.kellermann@ionos.com> References: <20240312094133.2084996-1-max.kellermann@ionos.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: BD5FA40007 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: xq4npshyahigr1hzcbycp9yd5k18r6td X-HE-Tag: 1710236522-925372 X-HE-Meta: U2FsdGVkX19Keep/L4YQWkJNiP8EaFJqT9Jc/u7wsxVhdxXVBS2HjV408PnABvnJQLOFyJfkHMMBPetOJh75xRnLF0J4l6s2iY85uAfw/Ahr95X9S64M1SEapJt6ZYnBL6R/e5ZnsR9iwJitPgV6sWXN0m+m/l903Wy9MuVtNu9A3+n30tX97zCAOuufli75H2dZxeVrdKxD/A19dVEsiPLAHwOkAWhCQYyGWKB8n3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6vbGKCjtPb5KbXBpGU+qceZ+M000yqN9nYY/hdoetOEvgI+K4P7hSiTjySJtfwVgHxuQB20+TeZnsvCn7MXkfuND X-Bogosity: Ham, tests=bogofilter, spamicity=0.000089, 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 b3f83fb26aca..07262ae43c5d 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -1763,50 +1764,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 */