From patchwork Thu Feb 22 11:50:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Kellermann X-Patchwork-Id: 13567171 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 6D816C48BEB for ; Thu, 22 Feb 2024 11:51:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0E8EE6B0085; Thu, 22 Feb 2024 06:51:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 020266B0089; Thu, 22 Feb 2024 06:51:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DB6E26B0085; Thu, 22 Feb 2024 06:51:14 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id A85026B0087 for ; Thu, 22 Feb 2024 06:51:14 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 7804040DB3 for ; Thu, 22 Feb 2024 11:51:14 +0000 (UTC) X-FDA: 81819274068.05.B904E67 Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com [209.85.167.48]) by imf30.hostedemail.com (Postfix) with ESMTP id 83AD880008 for ; Thu, 22 Feb 2024 11:51:12 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=ionos.com header.s=google header.b=LM+uBq8O; spf=pass (imf30.hostedemail.com: domain of max.kellermann@ionos.com designates 209.85.167.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=1708602672; 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=MFa9Dx9xV4GQAl7iRO46X+jLcP69enhwI/ycHUy9Pls=; b=25CxUA4Fe/tKnKYeRDiMwXp0k8ThtxEh11Mejid012R29NraJ0ks2Goy32AgnYFZ52jisH fA6tela5uiaRvDlqtwyIoW8zSVUHPyBYKCHT2lJiMTNfH1TKmQfcYHeH4wPOsgghBwy7sW YE8kYDDhi8t+cIoB8OFU+jRwtLQLUiY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708602672; a=rsa-sha256; cv=none; b=FF57SRGVNQS4gU+R4OYR/VolQRPDFtvewQbuyQEE9myZVkgh8a80s5wJcLBE+rAM+ke1Od S2oS4uPyU3uTTmePpClK90NvhCgy/3b5aQhXY1MLIJRCPQX9bl7XVhGSyEH9WvfYz/KR79 Y/D2virTkARwUXe82WpEmsiJJnOWVjQ= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=ionos.com header.s=google header.b=LM+uBq8O; spf=pass (imf30.hostedemail.com: domain of max.kellermann@ionos.com designates 209.85.167.48 as permitted sender) smtp.mailfrom=max.kellermann@ionos.com; dmarc=pass (policy=quarantine) header.from=ionos.com Received: by mail-lf1-f48.google.com with SMTP id 2adb3069b0e04-5129e5b8cecso7137430e87.3 for ; Thu, 22 Feb 2024 03:51:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1708602671; x=1709207471; 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=MFa9Dx9xV4GQAl7iRO46X+jLcP69enhwI/ycHUy9Pls=; b=LM+uBq8O36JEmcGuRCIo2r7NS4R7i6maJY5CJgsXjhdSF7a0TFoEG3iYYeUX6Xi+Qf 9w/abNV1lK9jnHMKI3FHOuYMr9koDSfg3EBnUsf133VZNyaHHvWfhstwQmV9YrOz3bv9 1B+NVed5WOhWOMFu8C11GfIuvCuIQ+KD60C3xU2UEP+SsVwdFLmPOCBR+GYa8kpUnD62 3TV29OnsAXwZaaJMWb2MsT3w+pS51Vaw2vbVEySSUgM7GATmL5YQaBjviEL81ekdoOgQ iqgZpeSelEPwJB5ikOIY19NIMJTmsakXbLyqqUanm9Bkz1cSLh1hbhPV5HYnUHhqww01 bujg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708602671; x=1709207471; 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=MFa9Dx9xV4GQAl7iRO46X+jLcP69enhwI/ycHUy9Pls=; b=I/c2XytomQqcEVEmXbvKmmf0SXOETm5AjotTyEqy5A3kr3/V0ZO5hlQdCjmfkO29Mx vXYgPhTgBKvY+zmMoSDIDsOI7yUy32aYHDR53B1IHz/mkC/1VVNI9WtYZz7MLc/jhsOa TmIP9oqxnMX981B7CR3dDiCiicGhgLFp8q5jcKq/pQ+qkWX56pvPMmGLjGLBteNRF5Jz wJfSASRkT6RgrzWObZC/TEnxXGv14q4jC2LO0md+E7UndLhO9T/IGupKbv2WBRI+y5fK 5Y7/Pf3YMLRfyPXbihSi1vf49Jf306J0NyVDQy/nwsE5j3qVyXkffMvjQ+I67VxOnXEe j5lQ== X-Forwarded-Encrypted: i=1; AJvYcCUABoPbFyaZpvNkbLWN/WG1f/Ml06Vau1AL7t/lkqTojnRPM0VSLG1L4YK6XyjHXlyADynlTUZpz9LVvKoGsXJWIpg= X-Gm-Message-State: AOJu0YzzStHWC5PFoP2xmMqVz7JRc78d4KjJx7aT/HAZuzj0ZXTOXbXM YDUao9Q5Qd7X37MUr/gb7nyEV3ijjw6ZYW53m/VKeNSQKMBjf3cJFEE8au7YbwNkuFm12nIjNBE 5 X-Google-Smtp-Source: AGHT+IGIO6dtLuYV1/1VqNo1n3zSBkE3XkdIVv4w1GdYfmtSErj42ytjrkrSj0uYvF/i1uTgxDlvlA== X-Received: by 2002:ac2:4a68:0:b0:512:a37a:bde2 with SMTP id q8-20020ac24a68000000b00512a37abde2mr9448627lfp.67.1708602670967; Thu, 22 Feb 2024 03:51:10 -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.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 03:51:10 -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 10/14] linux/mm.h: move page_zone_id() and more to mm/folio_zone.h Date: Thu, 22 Feb 2024 12:50:51 +0100 Message-Id: <20240222115055.1172877-11-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> MIME-Version: 1.0 X-Stat-Signature: fe6ray3d3iyqqf75cgn1x3fx1gctegr5 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 83AD880008 X-Rspam-User: X-HE-Tag: 1708602672-761823 X-HE-Meta: U2FsdGVkX1+4Zi2jfg9eRnjUgge/U+bUHzat0k/90byASe08P5P+vgotOW0Q8vauy9dC9rZpxyQ8m02RKINYZ757PVv3Nu6LgQnf/gxFO6eSoRAzNP9QPj+j1DzMnQCsTpsr1mR3/R6sn56TCCZFRLDgq/QiwJXrFnau7NwANADOQJMFpQrFM+jASmd9LcZIP8EpFsaym5NHzVhYMEwAe/n2Wy0RVV6PQDq/lBp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DaT409NH+S7CiIXn2xmDwiU1LTsvIv7e/ogLsPVGw60pwHgyoSTaLIzmoMnGqj8dI5oxThuxLng6Se8kjHeNODGDKsMyN+bhbn2g4TBi4= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000191, 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 | 30 +-------------------------- include/linux/mm/folio_zone.h | 38 +++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 29 deletions(-) create mode 100644 include/linux/mm/folio_zone.h diff --git a/include/linux/mm.h b/include/linux/mm.h index 0dc38017e134..1297ae7b2541 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -1363,35 +1364,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/folio_zone.h b/include/linux/mm/folio_zone.h new file mode 100644 index 000000000000..8ebcdb57ee2d --- /dev/null +++ b/include/linux/mm/folio_zone.h @@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_MM_FOLIO_ZONE_H +#define _LINUX_MM_FOLIO_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_FOLIO_ZONE_H */