Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp2122712lqa; Tue, 30 Apr 2024 08:41:52 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUNbnrsASgj+7p7Iq067a22EPvhFaf89F5wZ21Gns972ryjl9c2omNB+BwK6fxGnm9krR8gTSZGCSDfQaeJSBinRDk8//wcGflvxcuE1A== X-Google-Smtp-Source: AGHT+IGQkAHl/278Y09yNm32MoHlBL3iJdOfksFYFzDXlwfWPFlzIXVBFDh/uhJDDKismqfXHA0g X-Received: by 2002:a50:c314:0:b0:571:bcbe:8ea8 with SMTP id a20-20020a50c314000000b00571bcbe8ea8mr2782638edb.15.1714491712699; Tue, 30 Apr 2024 08:41:52 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714491712; cv=pass; d=google.com; s=arc-20160816; b=dDoC3B5s9hERi6nVIS1Xr08VTXL5DJCAFNrk45vs1kBzpYU0j14FQPDOmr+ag/PIGS LEHBpwLN+CNjUX2S6ef1NlOR9/d9VkZxKDT9bvBzGxwq6GhUtLMCuPhiHT+Ba0QKoSqZ sS3PHqXLJoF1OYzjpBsvmkUjfnfrkh5uh5Aga6zZnYcmsS956JFdTyAq3cL6Flpyr6PU UYBWqRdJicSh/v3cFfuCEmOAlSgUYWWHis+HwZF2A4DdaEWJdfDO3fP2G5vr7BM8ovgy 0oSUboX87Qb/erUV4zV69WXtWBy8K1IrhgcPJaocBXjxfZAjWkMbqinrWcQm4mtQkoQ5 JPgQ== 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=6oorfyqrd4QwX7XzlPeMB1uMNuRLLm4J9vR9colTNE4=; fh=K7x36T69rnTjC4I3/5jE/6BkzYukzM4gEhsC2GlI4Ko=; b=dQeElznW0/DX2GSRqQQUv3jyoBEqsa0w+p6U8JR6LS4qQDYCrM8tT5bU74DE3tQrCg 46tEtx7jnJcuZS/jRuTQDITeajD6b5tJq40Wi5JYhfwzju4D7x7ES3pfvtgBQ8gA/CB8 a3HnnHuWnMsMb8q/kSn+PYkNPaLjzlvfebSmTKQLZ/AWyO2+TBa2sd7JkM0aAVossSdc xtv4mlvXgDZcudiZS8h0yaO27tWtVxpRAK63xuziqkwOBTaU+Nl9kzzluDfcR56weRzl luGl9j01h7TCQhvDmof8n7j2RIpheHYk395zVr6E3piu+yh89TSjHkcTp+qLV45hGodm 768w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b="QmDJQ0i/"; 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-164278-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-164278-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id m7-20020a509307000000b00572728383fbsi2411233eda.563.2024.04.30.08.41.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 08:41:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-164278-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b="QmDJQ0i/"; 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-164278-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-164278-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 am.mirrors.kernel.org (Postfix) with ESMTPS id A35761F24D54 for ; Tue, 30 Apr 2024 15:32:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9C34517BB11; Tue, 30 Apr 2024 15:30:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b="QmDJQ0i/" Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) (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 4153B176FDF for ; Tue, 30 Apr 2024 15:29:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714490999; cv=none; b=n2xmqJ6fy4/04J4hccbvQy9dOWzI8f379Mbe9d0U5Dy6/x/jdRSL7jQfZiN80s/QMbRiDDTOzBvOEZX/HO0sarJBqL2wiX74gWxcW0jsQmKxuhPZOPDDYpJkTlsUDub5QSksznM2wFncDvXbCXV5nHNSLAEKlDQ3kJo2hdALTaA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714490999; c=relaxed/simple; bh=elHDjSbCblCsA/mfO+fmRJExx3Cm9dPxXBtJKph6c+k=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hTll3om52bihtGhmDIw4N3UrUBr0FDTYmZsd8/a5s682+wg3ORwGcymJiTsIYXooi8Aow8suucw7YcdTCfQopD1K3R4O0Vpa96GpQPW1Li2Cl+qBcEtzusH8axspjV8lOLbUBiutIje7Wj0ADu+ceCL0ynP+xYakA0kJGWdPYP8= 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=QmDJQ0i/; arc=none smtp.client-ip=209.85.218.45 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-f45.google.com with SMTP id a640c23a62f3a-a5557e3ebcaso957606366b.1 for ; Tue, 30 Apr 2024 08:29:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1714490995; x=1715095795; 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=6oorfyqrd4QwX7XzlPeMB1uMNuRLLm4J9vR9colTNE4=; b=QmDJQ0i/JnlsdS3fwgaET2hgl9iDEqmOj/fdhIvYZOvdqUCnLnFLHIvrQ3tp0UfHHv 3+ol+T+fka38WK9fSVScOHAaCDObEkMbExrWHixKd9+mYljNY5z5B7DebmEdXEqgmpgQ G27S2wxhGdmSI21MwQ9SAZx26lixw/G7lAn83nPr+8pE20A3ZsFp/67+fWOUUhKuvS2F dwge35GlwccDmelh+zq6lkTzKZFjEyf/kG3mVgDPGTCUQr2fb8r+JA/cpJJ/GmN8c54m rhaWdd4Eca9bH62sImfa0LKcZqaqmy9WPedfwmArjmkLhCTXbgGd2V2wUgaxcw8ZrmPJ SKGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714490995; x=1715095795; 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=6oorfyqrd4QwX7XzlPeMB1uMNuRLLm4J9vR9colTNE4=; b=lfjCtNB8WGYN/JCTBClCdG2DjrfctT0aTfF2erGImOjJKsMcpUccLj8sRicgLQNjx9 +QtlGX0v5ipWZba0tCt7K++u5JWJosGmSMIMshzHx20jjK2aO+nfzgZT/tAwo2fjaYhB g99ShygPrItEjbVPrXoEFrOh9p97pPdwTBm1OUZGXzxCt5wzpGb57FKaRC97GDNOjcWm sQL9Igiihy2yR7Zma6wCbruqILQb8z5oP8NJ625BVnLWJbyMlHM6UKFEqqodvTxKEds1 qzyk1g3sEEqPoE8Bi+NF4FE23EM15HnMpVe3MqWRQEChEpS3CDXZynDYv6mkKTpQO0+F GL/g== X-Forwarded-Encrypted: i=1; AJvYcCV/L/KiK9JmrBwCUAByf1PkWvOTNFEtEtLjxoQV+LddBFQ30tcyVwSh8xvtuE9WnDxOiNyRnkvgPs6j51HbjeS1SeOAH7+1rLpmqLjQ X-Gm-Message-State: AOJu0YxPQ029JlZpvlm8D0gQVQ6uEV02qsR3POsKfwU5d73R31c9n+iu ipDL6nV8bqm9RnJQm7zNELzDzQmjsxmw5QVCN29uuYgCJLN8bCloZYOHtY8yOWs= X-Received: by 2002:a17:906:c791:b0:a58:eac2:a54f with SMTP id cw17-20020a170906c79100b00a58eac2a54fmr99681ejb.18.1714490995492; Tue, 30 Apr 2024 08:29:55 -0700 (PDT) Received: from raven.intern.cm-ag (p200300dc6f06e100023064fffe740809.dip0.t-ipconnect.de. [2003:dc:6f06:e100:230:64ff:fe74:809]) by smtp.gmail.com with ESMTPSA id a10-20020a1709066d4a00b00a52567ca1b6sm15278137ejt.94.2024.04.30.08.29.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 08:29:55 -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, david@redhat.com.au, Max Kellermann Subject: [PATCH v5 11/15] linux/mm.h: move page_zone_id() and more to mm/folio_zone.h Date: Tue, 30 Apr 2024 17:29:27 +0200 Message-Id: <20240430152931.1137975-12-max.kellermann@ionos.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240430152931.1137975-1-max.kellermann@ionos.com> References: <20240430152931.1137975-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 | 48 +----------------------------- include/linux/mm/folio_zone.h | 56 +++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 47 deletions(-) create mode 100644 include/linux/mm/folio_zone.h diff --git a/include/linux/mm.h b/include/linux/mm.h index 035e56e203df..7af85220711c 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -1377,33 +1378,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 -int page_to_nid(const struct page *page); -#else -static inline int page_to_nid(const struct page *page) -{ - return (PF_POISONED_CHECK(page)->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 @@ -1554,26 +1528,6 @@ static inline void vma_set_access_pid_bit(struct vm_area_struct *vma) } #endif /* CONFIG_NUMA_BALANCING */ -static inline struct zone *page_zone(const struct page *page) -{ - return &NODE_DATA(page_to_nid(page))->node_zones[page_zonenum(page)]; -} - -static inline pg_data_t *page_pgdat(const struct page *page) -{ - return NODE_DATA(page_to_nid(page)); -} - -static inline struct zone *folio_zone(const struct folio *folio) -{ - return page_zone(&folio->page); -} - -static inline pg_data_t *folio_pgdat(const struct folio *folio) -{ - return page_pgdat(&folio->page); -} - /** * folio_pfn - Return the Page Frame Number of a folio. * @folio: The folio. diff --git a/include/linux/mm/folio_zone.h b/include/linux/mm/folio_zone.h new file mode 100644 index 000000000000..3f3e4284b911 --- /dev/null +++ b/include/linux/mm/folio_zone.h @@ -0,0 +1,56 @@ +/* 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 +int page_to_nid(const struct page *page); +#else +static inline int page_to_nid(const struct page *page) +{ + return (PF_POISONED_CHECK(page)->flags >> NODES_PGSHIFT) & NODES_MASK; +} +#endif + +static inline int folio_nid(const struct folio *folio) +{ + return page_to_nid(&folio->page); +} + +static inline struct zone *page_zone(const struct page *page) +{ + return &NODE_DATA(page_to_nid(page))->node_zones[page_zonenum(page)]; +} + +static inline pg_data_t *page_pgdat(const struct page *page) +{ + return NODE_DATA(page_to_nid(page)); +} + +static inline struct zone *folio_zone(const struct folio *folio) +{ + return page_zone(&folio->page); +} + +static inline pg_data_t *folio_pgdat(const struct folio *folio) +{ + return page_pgdat(&folio->page); +} + +#endif /* _LINUX_MM_FOLIO_ZONE_H */ -- 2.39.2