From patchwork Thu Feb 15 14:55:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Kellermann X-Patchwork-Id: 201517 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b825:b0:106:860b:bbdd with SMTP id da37csp454366dyb; Thu, 15 Feb 2024 06:59:11 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWK4hy8PprWugWXrDf5ABHNaYhD0qXt+pTF5rhi/PEpZ3bpb3m3L/WpTxHnpurLxGDZzl+2p+Pk2lsSgJoyUUMgRD4vOw== X-Google-Smtp-Source: AGHT+IEugqmvVMK5CXjZq3iiTGB5BWbOZQFT9VHUAB72gQVLMvHfy9Qlti/93xOAFQiuLOthQq79 X-Received: by 2002:a17:906:abcd:b0:a3d:9435:5884 with SMTP id kq13-20020a170906abcd00b00a3d94355884mr1469250ejb.44.1708009151090; Thu, 15 Feb 2024 06:59:11 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708009151; cv=pass; d=google.com; s=arc-20160816; b=sDY6k7us4AQ/s9AhZykC2UyLJZzEKw+2wQT1Q9/6gfycKhAUszAFExBkWWizRFJQQi dPV3VPv+lpQp3T4ijUwg0SUCMxUmXTLpyfLEJExTXIfY5Sam/qEfk6EXSgnBXGB2cunw yhj89oYyl9Y9g4bzyFEvREIWakZE2SV8Nkfy/InL/ht5EqgNuqyfjPdDI2feIrteZ8BI VpS3HmvT+UXOyxM3ioo8eRppnhbgoXEDbzq4OQrCIFM94Lvf+oOd4fbkhlF/dqfOcTro wF2UCV8bKAa9Ih9HzmJxQSBQyUE9f9naob5IOyXNS0+Eina2GRvRxa6ZIYssVOSQfLOy hKFg== 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=eKsp875PnvJuIa0s07e10KRuMSwJl/UB/2fWYWucGxo=; fh=sFdnkpTarNmRKLwa/ffPnIaj3pfCnWmhJo/HjV6uynY=; b=TXWpvev8m6BjIxhkjj/PHYFPlk81GWTaFbmLc3inHA561zCanU0Xv/sSWeTEg7E/hp UqXqwyuQ8jkWqDbPSSm0nyxOOsDTqOKT2CjDiMbV0Vwyj1XRv1iaBw8MJeGLNTH6aWF6 ImZADRBrQnO9MWH0oQesRJ3PePqjVQTcCe6GuybtVMqM9hrhUx8PHCFuP7SEZCJO5E9a KApGXzPS1C4a+ElXM7Cf6jnMs6mYcyx+GFr2PySdZrOAnmd+hJcd8QoaYaWa2TduGX5V HGpTfWX1VE3op2sGde3iVBHUaZ1GZ62JGfjMMf0ps8ns6bbKExO8sX1Qiick8LdqB7Kn 2CHA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=fU2MgR2i; 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-67121-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67121-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 i22-20020a170906265600b00a3cf61924a1si712880ejc.542.2024.02.15.06.59.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 06:59:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67121-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=fU2MgR2i; 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-67121-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67121-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 86C7F1F21497 for ; Thu, 15 Feb 2024 14:59:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 90646134CE2; Thu, 15 Feb 2024 14:56:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b="fU2MgR2i" Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.43]) (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 D98F813341F for ; Thu, 15 Feb 2024 14:56:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708008983; cv=none; b=ngySZxBp1nkeVXJpgFl40lgOpwKHHnRAk+FEWFBp3UzVpZIJKyC0b63ZFNzbKJlA9I6wzHmEVsgScIskZlHMFHBG6XwefeYhQleSNALg8+8xEPI9N7e5GY9tCUURa25iTz9bhaXdbD3Q5FldhW8sGnKbG3jB2DaddNEunt1UY0s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708008983; c=relaxed/simple; bh=v8Wtk59h+JThQSBSnkbFVz52gm8jfgU5BR/RyxD7PT0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=YZ71V8A2OcApXLlAiX/5ZDAE/rZBJOVw0z4RqcySi8zm5/8uGUeB3S3g1lkFWVuxHFewztJW98/vwR8fCaJlhZJB/yhEGPzV1mLAYbNZAD/Zja3GwFH5tB6psIgxIrMjsMc67VBewTBAYLPyQCc8Q7+HAfjBegf9ju/tHPLkJok= 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=fU2MgR2i; arc=none smtp.client-ip=209.85.208.43 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-f43.google.com with SMTP id 4fb4d7f45d1cf-563c0f13cabso660027a12.3 for ; Thu, 15 Feb 2024 06:56:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1708008980; x=1708613780; 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=eKsp875PnvJuIa0s07e10KRuMSwJl/UB/2fWYWucGxo=; b=fU2MgR2iUTgCRKCJ5Le+EVU7pJ5UiJwyG7Fvt+S6CpKty3ReCru/Wva6FH+JCQWLng CDLeaiAL1tAiAauNRropZcrjY0+xxU9jozK9tZqQbpUfhffHvvNfgyDcenEtgE8am050 2So+XOcyQ7hkGDGkN5FDYI3xI9w1p27dmEbGYSCcJ7rrWqLy3btJNG6F9oAGBjYUYhn2 tP3SfZD8n+iTGJWLZhsx3NQatM+dZY9ts2/Oo4vfT5rkK++NxFhYTPXpMR7pQiQ1j7ek qZAnn6g3lWGnKhms7czZ05dOU5+AI3WeO6l9C0EXR0pHHL3TBA8ZzZAbp5lmMUDPxhtK LO/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708008980; x=1708613780; 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=eKsp875PnvJuIa0s07e10KRuMSwJl/UB/2fWYWucGxo=; b=aEVChNYlBNnys1RuKWpcebSHYYOIIr1cvaJRW1cTj8ddt36S83bbYIROPGKi9lZGlG uJCYGLgOuH0Vd5hTGYIYIZRQDRHCYfQOBbuMRRuPn6fUFtFOmMn9W+0JONmuXRuPgcbf thL1R6HxrsQET08Kzva/i47LmC8lYRNLVUNvS17vXIumujLoyPz2mEHbKe2SgP9soHgR ZxUfZp68hpWqNVJrpl4M5+1dSU8bPhvpPfzmTYW9jj2apOt3gnuUiNtHnxPponNXILP5 +tpXJVGYzdSJ6e4anCYBuGUhQ1i6381FfLZbAO9R3u2TPTmAm1iL0Eqqz3bm2q13E1Ex bTcA== X-Forwarded-Encrypted: i=1; AJvYcCWsdaX9mrosU3uevWJr9HK89KxhN0NF6ZH1qoPKQhiIUJ2oFIRKAGcCPjGeMuRHb2iixJUCk50l/0KuL/0HHlqA+xiwciVpHuwqPYFX X-Gm-Message-State: AOJu0Yxmr798HpfCdKNfi3PS4K4KqPKpVvpKGtNBrvSWfDQIuj0XT1MY phQYS/AmCCu2ZJ7/8ibmQEjzCmxU9hdi93PAp4EeC84+AbtI9x4viPjAbljQ1N4= X-Received: by 2002:a17:906:34cd:b0:a3d:b317:8ac9 with SMTP id h13-20020a17090634cd00b00a3db3178ac9mr499801ejb.33.1708008980212; Thu, 15 Feb 2024 06:56:20 -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.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 06:56:19 -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 10/14] linux/mm.h: move page_zone_id() and more to mm/page_zone.h Date: Thu, 15 Feb 2024 15:55:58 +0100 Message-Id: <20240215145602.1371274-11-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: 1790977403501148376 X-GMAIL-MSGID: 1790977403501148376 Prepare to reduce dependencies in linux/mm.h. Signed-off-by: Max Kellermann --- include/linux/mm.h | 30 +--------------------------- include/linux/mm/page_zone.h | 38 ++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 29 deletions(-) create mode 100644 include/linux/mm/page_zone.h diff --git a/include/linux/mm.h b/include/linux/mm.h index 26d506ed855f..aa24e6fed9b6 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -1358,35 +1359,6 @@ static inline bool is_nommu_shared_mapping(vm_flags_t flags) } #endif -/* - * The identification function is mainly used by the buddy allocator for - * determining if two pages could be buddies. We are not really identifying - * the zone since we could be using the section number id if we do not have - * node id available in page flags. - * We only guarantee that it will return the same value for two combinable - * pages in a zone. - */ -static inline int page_zone_id(struct page *page) -{ - return (page->flags >> ZONEID_PGSHIFT) & ZONEID_MASK; -} - -#ifdef NODE_NOT_IN_PAGE_FLAGS -extern int page_to_nid(const struct page *page); -#else -static inline int page_to_nid(const struct page *page) -{ - struct page *p = (struct page *)page; - - return (PF_POISONED_CHECK(p)->flags >> NODES_PGSHIFT) & NODES_MASK; -} -#endif - -static inline int folio_nid(const struct folio *folio) -{ - return page_to_nid(&folio->page); -} - #ifdef CONFIG_NUMA_BALANCING /* page access time bits needs to hold at least 4 seconds */ #define PAGE_ACCESS_TIME_MIN_BITS 12 diff --git a/include/linux/mm/page_zone.h b/include/linux/mm/page_zone.h new file mode 100644 index 000000000000..6bbd46743aeb --- /dev/null +++ b/include/linux/mm/page_zone.h @@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_MM_PAGE_ZONE_H +#define _LINUX_MM_PAGE_ZONE_H + +#include // for struct page, struct folio +#include // for ZONEID_*, NODES_* +#include // for PF_POISONED_CHECK() + +/* + * The identification function is mainly used by the buddy allocator for + * determining if two pages could be buddies. We are not really identifying + * the zone since we could be using the section number id if we do not have + * node id available in page flags. + * We only guarantee that it will return the same value for two combinable + * pages in a zone. + */ +static inline int page_zone_id(struct page *page) +{ + return (page->flags >> ZONEID_PGSHIFT) & ZONEID_MASK; +} + +#ifdef NODE_NOT_IN_PAGE_FLAGS +extern int page_to_nid(const struct page *page); +#else +static inline int page_to_nid(const struct page *page) +{ + struct page *p = (struct page *)page; + + return (PF_POISONED_CHECK(p)->flags >> NODES_PGSHIFT) & NODES_MASK; +} +#endif + +static inline int folio_nid(const struct folio *folio) +{ + return page_to_nid(&folio->page); +} + +#endif /* _LINUX_MM_PAGE_ZONE_H */