Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp943126lql; Tue, 12 Mar 2024 02:45:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWU8/LnCf1ei3I8jpf9gzy6/KjT4PX7Jary+trnYBRuDiTkAZIr9yhIfzK84TNgDICYH6n0/Pf6uwn3G11jKe+S/0AqhLsTpDyHLAbjOg== X-Google-Smtp-Source: AGHT+IHSKzDt14ebjcHDfqyPjB21h6yKl9YipVlv2KsF1x8iRUZG01Pzg377+lgUWucBvcMd2i8+ X-Received: by 2002:a05:622a:1a13:b0:42f:3083:b464 with SMTP id f19-20020a05622a1a1300b0042f3083b464mr1384933qtb.14.1710236737487; Tue, 12 Mar 2024 02:45:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710236737; cv=pass; d=google.com; s=arc-20160816; b=C4x+pL6Ha3KIpWxy8p0nFQmlGyTGPYZt7vVfIMtSAP+jjZYVmJE05c3hSGZ5gYJN3i XrtagED7ajv5siuOlODmNCo+tlcaDcCcCiZrPFM8z8uuMOYu+EnFN1itRHkTPG733hP/ O66CuN7j7uwa6xmCcPrNh/wQIz88PR5T8y26czjSHMPVCS4QaQJ8qUazSpR45ip6SRKR 9I3EHkcu7KWnN0Lx/GPXHtJ7HJqePAXD60H/qM2T5o7jxGPnX9+wQviUEvhcva1/49e4 0T9BVHz0pnGGzggqeFcOxObe+d3PyAgFDhpVM9jeXOvaQVaxsNo7Th1FjcKzEt+ekzBs u7+g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=i50xlwbZc74AakEZHNdRuLF9vXbOX6ErFGehWmkuapg=; fh=TKG+8y2cqQsfEVeA69P/0wN59b2AVOh+YsQrsrcLZMw=; b=tBHO3Sd9YcdA0ZpXI7gTcvv9W4wWqAasGu4Tcbb0V0qRZf2vIyOL0SFJ02W/7WKDbI 2wwdtg7VVvmBbEP6qC/zjPjxYFLrscBzyyY9pKJuQaoTMUtUMCzGu9q+XdrLLO7RW4J8 l4FSA5TlKc6fVSfgR8NtGu2QuAM9PyNVhoyUD7blawYsAA1nmwMTyqImV7Mo3jtyVpDi u5ZDFHMPXonB7T0Ck8ipGMnF/Z9OyzYtoDkg7Q5nj8QEb4CE32vwlH1drUdGF0AHjuIm Xy19c+Ot9wfouSS+UT7gu7X8zH2EhHbEm1kJN0NownRNdjmsHjJqfiWLvxxeU9AQtaOt wt1Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=a6A1MDjS; arc=pass (i=1 spf=pass spfdomain=ionos.com dkim=pass dkdomain=ionos.com dmarc=pass fromdomain=ionos.com); spf=pass (google.com: domain of linux-kernel+bounces-100051-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-100051-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id l18-20020a05622a051200b0042efaefcff1si7052185qtx.589.2024.03.12.02.45.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 02:45:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-100051-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=a6A1MDjS; arc=pass (i=1 spf=pass spfdomain=ionos.com dkim=pass dkdomain=ionos.com dmarc=pass fromdomain=ionos.com); spf=pass (google.com: domain of linux-kernel+bounces-100051-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-100051-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 2D62C1C20D35 for ; Tue, 12 Mar 2024 09:45:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CAC527C6D6; Tue, 12 Mar 2024 09:42:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b="a6A1MDjS" Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BF22B7B3E6 for ; Tue, 12 Mar 2024 09:42:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710236524; cv=none; b=tSj/HSP4ugRUvultd8hO7MtJ0EtQGArGqd84y0RFy4Mtg/BF5qUNX/9piOHkXZoahHBbTAWyYTtvRUJlEwASVaw8+KO2bp2YH9q94T60eBzGWVByYzF4gzdHRd4PauOLCUmqSXLv4fNyoSe/nc3QIYFx1CQjBr9royGRCEwCDqI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710236524; c=relaxed/simple; bh=gvv5QAtWzHwpsz/x1Apq4Lva4NNrjhRHP3W2M/SGVoQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jrDIPTARTtkA+f81jQv5z6EfhRTBTntj56Ki9y8E3crfs+EfQCo+4LIOUjsAwnXcing+xJKB3Exlz3BIwCS3TPDGgEKwKPOBXn7CFDEt/j3UstvC2uG5kCWOsxiO+OObjFT6weAhrKfC221dmtU3vqyrIyaqDvps4vfQsn1ty6w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ionos.com; spf=pass smtp.mailfrom=ionos.com; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b=a6A1MDjS; arc=none smtp.client-ip=209.85.218.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ionos.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ionos.com Received: by mail-ej1-f50.google.com with SMTP id a640c23a62f3a-a4467d570cdso452711266b.3 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=vger.kernel.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=a6A1MDjSnHX30cuq3bLIPtgO3DM+C7o/Np68DxDFPC7/u1fGpLRnviMRg5DNW7NmG/ 5vDp80t4n69zZvjfyQH1swFa9JPh65BmcpwSOYxCO13HX4YP8bFKyyQdduOTxZv0/IBo VajA8rgkLp60/Q4vAWa86dwzFAvl+h0DmHFEdKpXr4jxbUP6MJyicgz+g1o1gLaZHJEP XfUd0UjYIS3J4Phjpr3eUToOapiron/SSD6qcB9rLsfUd8PRxq9APpwdPzq1AHMW8JFg S5gph1wc2Rzm8NaPXrCVKkYT3DglJHNxhLTH/OEMHUgN9jVDaie2BSN1j2AQlWZmUhBd Yduw== 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=KTXZf/ibD0jur/9GMIPXdFG/x2JzCkwJcS4KAgtr9L9+sDniu9HBnskHIlCqjR6DHE ni+/qh6llne2XAPQO4FAynzfjUMAiJ+kpTHaVz8q0QzXVeAzY8kkCwwuSV36VO4yNah9 iMLkTHIlbjWfjwHvZ/4ENJb7HVC6guvmazpysyWTxtz+Jrbm0M2MjlIa+V32hPzDI+XS CD5cWTpLmKLmbArHmOQCr52USZf4Ef5sUApGTh+no2wxTxXehN11LUiwja9v++SRcDA5 1k3AAmxgVSOtfY0uE1kqRFApeHjGkYG4NrKgjdOL58HqzI7ukIsTU0fP/7Nks0cYQTWp wdgg== X-Forwarded-Encrypted: i=1; AJvYcCXblIB6dmzYgNZcaKR2dltNePo16f294+wtHAkt0ecuzQO2gu+kY36k/ZPCs5imM18WeDl12gBumd+yx8PA8bnFJj5UeQ/fnuo4mmWz X-Gm-Message-State: AOJu0Yzu/LyPv6czEqG+Qt9w2XXWPaiP9DvrIELoG2sjwOx995LMNy0P vz4SJrYSk4+3iCwrZOCuf7mZrMlZ2myowwOTxrY1OrEcGacYf6HeSAk5r8Ko4fg= 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 */ -- 2.39.2