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: 201519 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b825:b0:106:860b:bbdd with SMTP id da37csp454613dyb; Thu, 15 Feb 2024 06:59:39 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUpT9fZUGZWpA4DWIux3btBzzqYfz/CCStDjFJWywwzMyuU7wAX8a6PKSBP93Dw4WzRT+IyORiuJNpq46v+nqVnRq8m8A== X-Google-Smtp-Source: AGHT+IEWdfhbkaiTCC0lSEAaex2slIgv7gbom7cp/sY0R3w0UOzVQ835bc+K1RWy+5DGAzMFDuGO X-Received: by 2002:a17:907:1c21:b0:a38:4dc0:22f9 with SMTP id nc33-20020a1709071c2100b00a384dc022f9mr5636965ejc.4.1708009178854; Thu, 15 Feb 2024 06:59:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708009178; cv=pass; d=google.com; s=arc-20160816; b=f+nAc824+UH/LB9J8kn7uC27a75Wm/Eoez3V7Jxhu1Gk9AKOL7seUYMv4iNiR54geE 7G4CzYXOEvo1k5IHYzhavDxDKEkU9dunLq507kHpsc/rUakC1WTLsaaaF3WUiPf5Xeao BFXv/9pvvlNg8YupXebuKfg+e4bd3RsJK5StIwWxhDouQMoAglGr95X0b6ckfcaZ6B3C Vk0NjzXmI5ngg6wyuoUcsKii5cFTISFhvh2rSdWO0bqRhW+fDm/Tjm+ojInH13i4K3Q4 FBK3Gm7Pnaj2xizVGTElPgaTk7EzHT6sPWwrV/mpfDE77oJjQ5qFxX3yOHpwceRxUihQ yYhA== 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=Ui87eR1N8KdYrsRAWgwlBy5zGHV5S5KAP6ANHsd3+6c=; fh=tQLeZLykEiUpoEIiqtVPTkNozwozr9lLIThkvYKTfeg=; b=cvZl+VmuOaQEueoWF7rj6dUrCZu80ICDzvAb7iF40/xXyyjGEmCxIZejTJEovcoJuO 6MPWsZqEAjiFfDeYFJ4FbEA8cLp0bLAdgKsZPKY7jNO5Hn8A2/1p+VN7Bv416+T4zMDf oE1XbppB1E7GRe0p+EIBULEkNEHJqpvPtLNmVZr1W8sSmRJIYbJ+fW+6qQhjrz0gqJXW qNpykfBh6de7Wq8iF/CAlabsC+q4zrwyPuhN5+xE1amdUSEY2tGq5uiJ6kgP5b3kI4td 0QUMJfxbm14GYlbR2kW2y8so70Vai5LlV3R7l3utfrPs49MU8d48hIwhfCaXfPcnll3o 3J3A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=WSDNOxLA; 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-67122-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67122-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id v19-20020a170906565300b00a3d38952605si720077ejr.746.2024.02.15.06.59.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 06:59:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67122-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=WSDNOxLA; 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-67122-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67122-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 4972A1F219D3 for ; Thu, 15 Feb 2024 14:59:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 69FEF1350D7; Thu, 15 Feb 2024 14:56:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b="WSDNOxLA" Received: from mail-ed1-f46.google.com (mail-ed1-f46.google.com [209.85.208.46]) (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 B8718132C02 for ; Thu, 15 Feb 2024 14:56:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708008986; cv=none; b=NmIds+IlJcYx6Viipk3Jiw2pv+/qyn/U69jY0oQCtfmJ9Fh//T05jb4T7e472WxI/D51C7+gYZ7HnKjsrx+30+J9mSa6MFyTIcXsIlRo65vbbgz91HlYgN1zLHVp+JOXo3k390WGSv1LjIb3GB3+er7sFCOrmbkjk0dTSNw7pfI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708008986; c=relaxed/simple; bh=pxtwIOSGybK0E8+t3Yis8zIqDX8fSripsw1A41Tnjfc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=KxOvNvh40MXN+C+K3oP6SGqIFxx3DoGuf1R1oBnAltzWyXE4JHC9Z/Vut6TbiFksOrGNZshk8SiAbb+bDLrFDnROf/+zPQLNWzc3WAI5lFXOkw8QHiRqsfGinvoezPygBGsqWBdBI3oH1oERq7oOrI/f5Fc1UeIXp+SWxwLWAi0= 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=WSDNOxLA; arc=none smtp.client-ip=209.85.208.46 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-ed1-f46.google.com with SMTP id 4fb4d7f45d1cf-563cf32e130so346378a12.0 for ; Thu, 15 Feb 2024 06:56:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1708008982; x=1708613782; 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=Ui87eR1N8KdYrsRAWgwlBy5zGHV5S5KAP6ANHsd3+6c=; b=WSDNOxLACrxXb9cY+bzWtYovcQSkpndkcyQ8ekdgm6s/SIfTelLjM7F+mA/1Tyfc+7 UBu1KNYuj4wijkv6YWlOkh+r1eKjXlf6naUCOqL1eLqnKKsHyBCOB9oEkyS2XuHYWmDJ XMFia/h9VVJoGB2mGVuVXyqv7WZHrnB6NRjt5wKQ52xRZEdtDym8fcfY8p2BysuTNez/ eitHa0tlW5Oxw1AvwQZjz3CYsz2uH3qj6+2Ukg54CEqMbO6gZ8I68zg9XyyVaZ+NMirZ Yhyq6OMw6OWJgp6ooFzYzkwy+g6A5fljFL1LE0ImRSkigtfIKwS3PQlOL7WSbK8BCyra UoUA== 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=YvB/qA/XrqGgZMJxnrHRcD6d4e1wsOVgIBUAalFVaLkExOB+OkOUuVoSamQl+Sz++D GAtnotQq70xvJ8ll9Mug+HoMmnEW2bZcjwXHJg1YhViNyTLgtf4Vdc+3bEj8IL88iAxX +w8dsYoaauPx0i0Iu2OEz5N72XSFkN1Gn3NoMPipos6l/TP1VJv2SYsRkjSbx6ichc60 7s1umSkyUfD739/bxh06xxt6s4I/YQlgDLp5ijD++rWfVrF4caAa3DStsE2wQCvRwdrD N1pKMCgKnzfUVj+OgCIpdv64GJ6u1O8JEmMzuu2UD3gmpkRqp6TE/Xe5d7tSe6kZRXor /JMQ== X-Forwarded-Encrypted: i=1; AJvYcCUk8BGr1KVlSABs9/rfgvQjFJV7n+hpkusu6awUOToEbxJe3COQxoVwofonhv0y1XhyGCVzGcg6xb24iEutsdRwA5MFZT5diGJTMN1F X-Gm-Message-State: AOJu0Yx0SAAcoxxkxyZbbCP/WgxPb/5PMdED1rVLaH09DprpEwIrIuZe GfYkVM8OzuK5cj17yVKxtA7fWTtO7bOHuxJoHupoxs1/drp5cpC17/0us3sXzTU= 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> 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: 1790977432865857199 X-GMAIL-MSGID: 1790977432865857199 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 */