From patchwork Thu Feb 22 11:50:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Kellermann X-Patchwork-Id: 204721 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:aa16:b0:108:e6aa:91d0 with SMTP id by22csp197831dyb; Thu, 22 Feb 2024 03:54:04 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWvK7qQOPHC7WlbrA0b0kQHLKaWBg4jaABHUestIzuehhhBtV5nB/CBo8b19s3RJATMw4j8RaXi1YRqFsTaboOb8wORuA== X-Google-Smtp-Source: AGHT+IHkhMA6iOmmMXf3AwwuXszAu+13dR5kNoNH8IMrOetL8aBBbBc/Rt7eUhHK0FIN9C7B+N8X X-Received: by 2002:a05:6214:da6:b0:68f:5c34:5346 with SMTP id h6-20020a0562140da600b0068f5c345346mr17915427qvh.44.1708602844077; Thu, 22 Feb 2024 03:54:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708602844; cv=pass; d=google.com; s=arc-20160816; b=q/Wcn3+oqd6Rlf5DWqNzxo0SNyKBN1cUyejSfnHilLhU6TCZaBuUzAzjdtIxVta1QC QbYbToErANgcR/Sng1ih9+Uhg7lHAGT8eimyAL7CXLW1LQhvd+v5+ceRSI9Vtmo8/HKB wsYlPUhqIwiuoCOpPOMHSJsn5a2r9Hn94mxwpVUr5pHk2AUtSmV2PuK4c7ZRRS+8kFKU CrawuVFtjdycsgc9SmHBlS5vAu8IgQT3oco8HzFhmD0DQ/2VIVaJ/b1ryLgepqlI1lOh bXyTGQVX3kBOdi/g+SFHG8n1W/SlDsJSgWFMEnLsGWx3IW9QbpYbPqDWkMWXENoVibcZ rlGw== 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=QIuZ9zlRlzs4cjZtyrA8C8bTBDZzt0jvXmpPfaEdUlE=; fh=eXN6tW06cj/b2Kv8/mW8eVA4gquChTGuRqAk/yEAklw=; b=Jk5gihJJTGTHUF/gEqEj5bFeSyxfv0m9V577O4SuTgbC46ufQ8z1t0410gZsfFC2Yb auHgQA4pI4WJ0GbJZ46xaf9RFZfu660yrd5HDaPXMO2cLCHWRCVP/bQVEmCewrR0SoP/ AHlMnUYcI5b55GoArVmx43JyUsCJjhgGSrDkfegf4KE4am8FKdB8MFBQP3EPrc2ugawI zo5aieHPI0aJB0qEe5jMERv/bHhNrXW1+MQvDMQW/gkIBAgWP/edKMZtZJ3EnSSgpQGo kljOWdu9PFkf42oCtpcjyE8sUAgPE+ySP5Rd6cVyHKeJxW9dUyvLI5DPjw9BdXbOmZ0y bPjQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=iLEp2xy3; 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-76459-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76459-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id q9-20020ad45749000000b0068fa7211a3dsi3029586qvx.313.2024.02.22.03.54.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 03:54:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76459-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=iLEp2xy3; 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-76459-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76459-ouuuleilei=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 C98191C2084E for ; Thu, 22 Feb 2024 11:54:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 11F544F8A2; Thu, 22 Feb 2024 11:51:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b="iLEp2xy3" Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (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 C925D4D595 for ; Thu, 22 Feb 2024 11:51:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708602676; cv=none; b=L6kmh6pBm+/ngfcqd9t6o9Yg7Wei+jh3wyKnO9C6t9eu584rcZ9ZG3kB1YOmgITtopf8vgDqB4h31K9/lywKRgJbV8D0J+0EZ8WuBkdr1aP1M4qpw45x/M20ZApRZHs9NJMYZgVFCQWEm41gxi0xAQ9aeWlSp1XaVJqXPMOweeM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708602676; c=relaxed/simple; bh=YgLBTN5D5Do778oi/eRa8MuhD8uhB7i6cOaSs76xSFg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=fWTYQ9y3xLL1SmezRN1NAqxpIEhkJN96lBMRzE7KvWdaERww7upJGeqpWixmZzmNqFggCInziO1+M72hvs0ePFDryVqhXQQsyQtzEMjH8dmmplhl7QCkypqk8mtz400e6kEUeFizdBNrLJDIAVLLynbzs6XNN5CK1We49SUsmdk= 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=iLEp2xy3; arc=none smtp.client-ip=209.85.128.53 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-wm1-f53.google.com with SMTP id 5b1f17b1804b1-40fd72f7125so12500185e9.1 for ; Thu, 22 Feb 2024 03:51:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1708602672; x=1709207472; 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=QIuZ9zlRlzs4cjZtyrA8C8bTBDZzt0jvXmpPfaEdUlE=; b=iLEp2xy3lgE3c5NLP5o2VV5AvN9CRHm6ppuS3EAwBSuuBJPxq2cmLIpYDBIPjLk3op yLDvABdIiRvDy6z3qj7QURydQTkBRK8b4fQu9Suyx+PHp3i4DB4B6no+JHZpMPSXo/Ng q5rAxSZvB7kMVtRC06nbAWFa09SRDdfbc2POXNoNxN4fMNWeDUdHvgV0xh/Q19Kq8ZJc MyMDNUU6V3+vcURJW2HoW+pXxzY9Sg8W+5Lw+jVGZzUIlsF26iww6YEDFhPqAiEm+xXX 0Xh/rxiVGPnEYYJaSgPLB78oBAb3Faej8OVdaybjVr2rHClOr/hW05CxPBJuuGdBgki7 Q9EA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708602672; x=1709207472; 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=QIuZ9zlRlzs4cjZtyrA8C8bTBDZzt0jvXmpPfaEdUlE=; b=UI8rVDOTYI9V2hvtV2idJVIwCXGaEcwTtvFWkpLnI23ujg5cpM8uuJ0vb1Qsash9Ye AvaBqmFNDnogYH5ILvCcas0hZEZEn2RNCvtZ7WtNQbtyg9/iYE+GM8O2IXjSc++cE9eC lRR0k0VPwCb98i48xOMhi+EqZ0O/cPjaKOE37pGkXUBkRiTQmvyHvJviVkNzRuiaACB8 CVIAmdvbrEm3JBoAvuMTmnbdeR0MxSJSag8PgIeJ8SmgaXFswzr+C4zj3YKsZbw87R/D wPHn/+9MBxuBfm+6xYeUlEp4UQ/PymV7+1y1ip9mkVPXKVTe0jy5T7GwGc9RKaiq325v 6ttA== X-Forwarded-Encrypted: i=1; AJvYcCW4O20XeQ5apEOu9KGYuI//hOsCoevmff1Ec6JP/C7k+ZGsC4sCTc0+oLo0Ux8GpuhUoObFYSGE1ryV3C5iWjaGuDVgs4rtn2JkUi21 X-Gm-Message-State: AOJu0YzxZF9CIq4L/E9ujfTeQHXxYqy2wOdWRJRpR/scUfurm9DSFysh 3Ufc5sVNqHBBwKXGJWG+MHKVEB/BFPr3ccfSzqTKkJ5E87l8UpE5PzBLdGFmJqI= X-Received: by 2002:a5d:47a9:0:b0:33d:3a06:acbc with SMTP id 9-20020a5d47a9000000b0033d3a06acbcmr10659700wrb.70.1708602672077; Thu, 22 Feb 2024 03:51:12 -0800 (PST) Received: from raven.intern.cm-ag (p200300dc6f010900023064fffe740809.dip0.t-ipconnect.de. [2003:dc:6f01:900:230:64ff:fe74:809]) by smtp.gmail.com with ESMTPSA id co18-20020a0560000a1200b0033d4c3b0beesm15044920wrb.19.2024.02.22.03.51.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 03:51:11 -0800 (PST) From: Max Kellermann To: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: willy@infradead.org, Max Kellermann Subject: [PATCH v2 11/14] linux/mm.h: move pfmemalloc-related functions to pfmemalloc.h Date: Thu, 22 Feb 2024 12:50:52 +0100 Message-Id: <20240222115055.1172877-12-max.kellermann@ionos.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240222115055.1172877-1-max.kellermann@ionos.com> References: <20240222115055.1172877-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791599935694358745 X-GMAIL-MSGID: 1791599935694358745 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 1297ae7b2541..68228f43e7ca 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -1749,50 +1750,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 */