From patchwork Thu Feb 22 11:50:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Kellermann X-Patchwork-Id: 204717 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:aa16:b0:108:e6aa:91d0 with SMTP id by22csp197135dyb; Thu, 22 Feb 2024 03:52:31 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVcVHej/z8O2XHNyI4dkJ0Nv/tWaLVjMz1L7I79DNJCNmNMLOpHLRCte5XwPMFwSjuSp2vWOHQOsEgCORmVUV+16sSBJQ== X-Google-Smtp-Source: AGHT+IENsPiAUQQw2x/kg+i5MiFcSUPglQSBBxHjWGYwaF2GAvXL8TNaKdqGWCykm68KsD+TRayh X-Received: by 2002:a05:6358:b3cd:b0:17b:5b30:3389 with SMTP id pb13-20020a056358b3cd00b0017b5b303389mr5058641rwc.14.1708602751278; Thu, 22 Feb 2024 03:52:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708602751; cv=pass; d=google.com; s=arc-20160816; b=BKF80datWtrhdY/6iWioCLw7LnlPw2v9qCTecivqFEunTAAd79Im7BSQm/mO58a1np BPP63i3ya2eDaLjrK3Cj63Q0v0HgB7Auye4pB4jmQEySRE7Fm8eSEPs1/V1bqyLumC01 Ix9vA8yqwc9dAgvvSu9VMgEP4baiWrEuFW/oIzN/waQtWktUKDqr0iWmGFcxmNvcI3A0 ZS/D4p31WPbLr+A9/Gjuyh534IwxeGV7RHNi7IFYtyxZ9h9qDKkybsgCpn8febpnnamI 84SleZrMm+J19rvILf5OEixOHRn0Zl8uvlSEBWaSbC4zVzzIgm0kUOS90Jzien2hY+u2 vjbw== 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=jDtDdAHhdomsee3Ex/DKrZGnvTgKe9aa55S2NGfs23I=; fh=E/nEvhVPF8V3Af6lGSdvRuiCyxsbzKxVFEuUctK9vlI=; b=okBOilBhIoLED1A2UImPA4Ed2+wau4IIMpgqkrEZ4c1pVgtyX36V5N+8jfh4IHZnyg WnY5Q58fvu3dTAH3UZsTtKsKH0GW10+ZWOhC+z8m4e2zdxNgHrn0jQprlQC+mTMuO/KZ 3nCHvVYOyhPAVOhebCYIt4VCvNwrVIL16mZBSDKTT22eFqYvtOLLoiz6IlZyy38g9XcP azjs1lkiyfjNPXbm6DRtTZVnkRn3aKljSdSKFiItqAbeBe08zVilbKb6xE2anBmSJo5m diNaKFip4YLLKj0GF1qyivB7jj5EhPYuIXeFX96jeWN7ZP3mmCO9moACNd81PgcM/lbu wwOQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b="LRK/ub8n"; 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-76449-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76449-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id n29-20020a63721d000000b005dcbbacc92esi10063961pgc.872.2024.02.22.03.52.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 03:52:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76449-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b="LRK/ub8n"; 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-76449-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76449-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id C3D45282A1F for ; Thu, 22 Feb 2024 11:52:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C05B14D13B; Thu, 22 Feb 2024 11:51:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b="LRK/ub8n" Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) (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 CCFD938FB2 for ; Thu, 22 Feb 2024 11:51:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708602667; cv=none; b=GkbTdpAVz/JG5cJ77EnEeXHGy5P+ruiAITIjGijMymXRjD0irHXhTF5v2dD5d0G7AmxsWH8pIYUTTIdbhjYMx/wJp/LTK0B4/nRTT2VajEqbvXlSrfR6naZA3w3pxFuMjTCbe4zb21+VpgGDvOJ7DJpswt3LY60GIlqgTmNcleQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708602667; c=relaxed/simple; bh=Ap8Xe20ngfUIVvUMGOsadC9GpgU9Wf4no7RRx7xF/vQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Pt8SXU/ET6yPSsOheQph2m/7GEgczTU1QSgJPEHCKMyiecDs9zkx9xFj45CWzlLXpYii3bYGlv5ld/+B5dr/A3kgG+nCLUXzO3Yi+lpJeQXERKYww2tV3K2CHKGe/tmXBgy+GkdG31MXnTVpwNnARlRyoUf9bTVCiPIZnWyL5Kk= 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=LRK/ub8n; arc=none smtp.client-ip=209.85.221.51 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-wr1-f51.google.com with SMTP id ffacd0b85a97d-33d18931a94so1383092f8f.1 for ; Thu, 22 Feb 2024 03:51:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1708602663; x=1709207463; 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=jDtDdAHhdomsee3Ex/DKrZGnvTgKe9aa55S2NGfs23I=; b=LRK/ub8ngZ8g/37EQpdkfz1Wv8fQ87zls5DWsN1vTcaYdzdFbPfcvxRbdyIn63XiEi lYXZEgX0E26YgYKI0fn2hKJPjkvZYMCzLyAKrSHwmRJm4Z8rakCHlAK73WgP8RByoq9R Jch3xX8CbyunAfmMFDzZDAPWKZa422Rqotms7gKYLElLLcXTlgA0/M9K11kqgX1eRR1t kJY4xPVcDhM1EsUn7hACYvo9ft9pueDruTTC8QUZ92HUr3tx1zQzLQaNYOqgAENyeRqR ClzEa11qfcZgIUfvB26vHs6DM0p6ep1QsGJw6UWPegYi9WRK2+ZXoyKszKyJ/iaK/fad md4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708602663; x=1709207463; 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=jDtDdAHhdomsee3Ex/DKrZGnvTgKe9aa55S2NGfs23I=; b=XFiBxzIbLLDFyKbVP7eTf9/gJ5WDvfJZuYKjOMnE18BsxDveGpXjq6pYuJPmYqpRKq 0ycHUg9EScgc9ko7GK8WQfaTQeQuzfQ89LDPAnssyXdCtzUSvIaK09V84llwh2P9b8Wb rs/Q5mEmdsCnQ4bh2aSdVpg3hMOkseDxbefEPzb5PY9jx81uymYCohx1pSbK5go+Jlkv I47SmPXh7cCnTQwKRtst3AYC5fsfFDbiMjFIwdFko70vnUedMmt9nb4XMOL6cB0rIRnF r8d0HE1wFi33Cp5bcUZHtk0NtfmzppRVFGJMMm0a8TN1vX9tv0l8fVBblc8kyE8qDSXk JOpQ== X-Forwarded-Encrypted: i=1; AJvYcCV+ui978v53rbdHzMlz9sLrxe6msmy5JYqh+F8MKDho+0ub730MgcL4GYkQLjolOR0mTAeW5ooB4XLpgl+5U3bp0fEnZcBgcR1+a4m1 X-Gm-Message-State: AOJu0YyldmZ2rdB5t4YpMk7QvXhoqQzZYPVgMDeD7ovAyT9LhbvJnBRh fURktQVJbq3aObEj0Oa4zCM9zBzIiew6EGX/f9Yqxjfl+gxftj09sc16sf68e6RAVcmyDnVp/m0 f X-Received: by 2002:a05:6000:38d:b0:33d:8cb5:1429 with SMTP id u13-20020a056000038d00b0033d8cb51429mr2153581wrf.27.1708602663111; Thu, 22 Feb 2024 03:51:03 -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.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 03:51:02 -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 01/14] drivers: add missing includes on linux/mm.h (and others) Date: Thu, 22 Feb 2024 12:50:42 +0100 Message-Id: <20240222115055.1172877-2-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: 1791599838379871552 X-GMAIL-MSGID: 1791599838379871552 After developing the other patches in this series, I had lots of build failures because "#include " was missing. This patch fixes those build failures by adding the missing "#include" lines. To allow bisects, it is ordered before the others. Signed-off-by: Max Kellermann --- arch/arm/mm/iomap.c | 3 +++ drivers/comedi/comedi_buf.c | 1 + drivers/crypto/intel/qat/qat_common/adf_gen4_pm_debugfs.c | 1 + drivers/dma/dma-axi-dmac.c | 1 + drivers/dma/sh/rcar-dmac.c | 1 + drivers/firmware/qcom/qcom_scm-legacy.c | 1 + drivers/firmware/qcom/qcom_scm-smc.c | 1 + drivers/firmware/raspberrypi.c | 1 + drivers/iio/buffer/industrialio-buffer-dma.c | 1 + drivers/iommu/iommufd/ioas.c | 2 ++ drivers/iommu/iommufd/selftest.c | 1 + drivers/media/platform/mediatek/vpu/mtk_vpu.c | 1 + drivers/media/platform/ti/omap/omap_voutlib.c | 1 + drivers/misc/bcm-vk/bcm_vk_dev.c | 1 + drivers/misc/fastrpc.c | 1 + drivers/misc/genwqe/card_dev.c | 1 + drivers/misc/uacce/uacce.c | 1 + drivers/mtd/spi-nor/core.h | 2 ++ drivers/pci/p2pdma.c | 1 + drivers/pci/pci.c | 1 + drivers/remoteproc/remoteproc_core.c | 1 + drivers/soc/qcom/rmtfs_mem.c | 1 + drivers/spi/spi-aspeed-smc.c | 1 + drivers/spi/spi-bcm2835.c | 2 ++ drivers/spi/spi-intel.c | 1 + drivers/virtio/virtio_ring.c | 1 + include/linux/huge_mm.h | 2 ++ include/linux/iommu.h | 1 + include/linux/nvme-keyring.h | 2 ++ include/linux/scatterlist.h | 6 ++++++ kernel/dma/ops_helpers.c | 1 + kernel/dma/remap.c | 1 + mm/dmapool.c | 1 + 33 files changed, 45 insertions(+) diff --git a/arch/arm/mm/iomap.c b/arch/arm/mm/iomap.c index 415d0a454237..9873d8156908 100644 --- a/arch/arm/mm/iomap.c +++ b/arch/arm/mm/iomap.c @@ -29,6 +29,9 @@ EXPORT_SYMBOL(ioport_unmap); #endif #ifdef CONFIG_PCI + +#include // for VMALLOC_* + unsigned long pcibios_min_io = 0x1000; EXPORT_SYMBOL(pcibios_min_io); diff --git a/drivers/comedi/comedi_buf.c b/drivers/comedi/comedi_buf.c index 393966c09740..23b07ebc97ca 100644 --- a/drivers/comedi/comedi_buf.c +++ b/drivers/comedi/comedi_buf.c @@ -10,6 +10,7 @@ #include #include #include +#include // for PAGE_KERNEL* #include "comedi_internal.h" #ifdef PAGE_KERNEL_NOCACHE diff --git a/drivers/crypto/intel/qat/qat_common/adf_gen4_pm_debugfs.c b/drivers/crypto/intel/qat/qat_common/adf_gen4_pm_debugfs.c index ee0b5079de3e..c9b2787baac7 100644 --- a/drivers/crypto/intel/qat/qat_common/adf_gen4_pm_debugfs.c +++ b/drivers/crypto/intel/qat/qat_common/adf_gen4_pm_debugfs.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* Copyright(c) 2023 Intel Corporation */ #include +#include // for simple_read_from_buffer() #include #include #include diff --git a/drivers/dma/dma-axi-dmac.c b/drivers/dma/dma-axi-dmac.c index 4e339c04fc1e..0c98bf0e4b5d 100644 --- a/drivers/dma/dma-axi-dmac.c +++ b/drivers/dma/dma-axi-dmac.c @@ -15,6 +15,7 @@ #include #include #include +#include // for PAGE_ALIGN() #include #include #include diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c index 40482cb73d79..784da367665c 100644 --- a/drivers/dma/sh/rcar-dmac.c +++ b/drivers/dma/sh/rcar-dmac.c @@ -12,6 +12,7 @@ #include #include #include +#include // for PAGE_ALIGN() #include #include #include diff --git a/drivers/firmware/qcom/qcom_scm-legacy.c b/drivers/firmware/qcom/qcom_scm-legacy.c index 029e6d117cb8..01e082c7163c 100644 --- a/drivers/firmware/qcom/qcom_scm-legacy.c +++ b/drivers/firmware/qcom/qcom_scm-legacy.c @@ -5,6 +5,7 @@ #include #include +#include // for PAGE_ALIGN() #include #include #include diff --git a/drivers/firmware/qcom/qcom_scm-smc.c b/drivers/firmware/qcom/qcom_scm-smc.c index 16cf88acfa8e..a5c74d8996fe 100644 --- a/drivers/firmware/qcom/qcom_scm-smc.c +++ b/drivers/firmware/qcom/qcom_scm-smc.c @@ -5,6 +5,7 @@ #include #include #include +#include // for PAGE_ALIGN() #include #include #include diff --git a/drivers/firmware/raspberrypi.c b/drivers/firmware/raspberrypi.c index 322aada20f74..beef5c4afef2 100644 --- a/drivers/firmware/raspberrypi.c +++ b/drivers/firmware/raspberrypi.c @@ -9,6 +9,7 @@ #include #include #include +#include // for PAGE_ALIGN() #include #include #include diff --git a/drivers/iio/buffer/industrialio-buffer-dma.c b/drivers/iio/buffer/industrialio-buffer-dma.c index 5610ba67925e..b3ce8c4b101a 100644 --- a/drivers/iio/buffer/industrialio-buffer-dma.c +++ b/drivers/iio/buffer/industrialio-buffer-dma.c @@ -6,6 +6,7 @@ #include #include +#include // for PAGE_ALIGN() #include #include #include diff --git a/drivers/iommu/iommufd/ioas.c b/drivers/iommu/iommufd/ioas.c index 742248276548..40c4942406cd 100644 --- a/drivers/iommu/iommufd/ioas.c +++ b/drivers/iommu/iommufd/ioas.c @@ -5,6 +5,8 @@ #include #include #include +#include +#include #include #include "io_pagetable.h" diff --git a/drivers/iommu/iommufd/selftest.c b/drivers/iommu/iommufd/selftest.c index 8abf9747773e..710789a2add9 100644 --- a/drivers/iommu/iommufd/selftest.c +++ b/drivers/iommu/iommufd/selftest.c @@ -5,6 +5,7 @@ */ #include #include +#include // for GUP_PIN_COUNTING_BIAS #include #include #include diff --git a/drivers/media/platform/mediatek/vpu/mtk_vpu.c b/drivers/media/platform/mediatek/vpu/mtk_vpu.c index 7243604a82a5..885b873982e4 100644 --- a/drivers/media/platform/mediatek/vpu/mtk_vpu.c +++ b/drivers/media/platform/mediatek/vpu/mtk_vpu.c @@ -8,6 +8,7 @@ #include #include #include +#include // for totalram_pages() #include #include #include diff --git a/drivers/media/platform/ti/omap/omap_voutlib.c b/drivers/media/platform/ti/omap/omap_voutlib.c index 0ac46458e41c..3b653b49cc48 100644 --- a/drivers/media/platform/ti/omap/omap_voutlib.c +++ b/drivers/media/platform/ti/omap/omap_voutlib.c @@ -18,6 +18,7 @@ * */ +#include // for PAGE_ALIGN() #include #include #include diff --git a/drivers/misc/bcm-vk/bcm_vk_dev.c b/drivers/misc/bcm-vk/bcm_vk_dev.c index d4a96137728d..c5a39a8189bf 100644 --- a/drivers/misc/bcm-vk/bcm_vk_dev.c +++ b/drivers/misc/bcm-vk/bcm_vk_dev.c @@ -11,6 +11,7 @@ #include #include #include +#include // for io_remap_pfn_range() #include #include #include diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index dbd26c3b245b..35701e9ec28e 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -10,6 +10,7 @@ #include #include #include +#include // for find_vma() #include #include #include diff --git a/drivers/misc/genwqe/card_dev.c b/drivers/misc/genwqe/card_dev.c index 4441aca2280a..ce3acb938ca6 100644 --- a/drivers/misc/genwqe/card_dev.c +++ b/drivers/misc/genwqe/card_dev.c @@ -17,6 +17,7 @@ #include #include +#include // for struct vm_operations_struct #include #include #include diff --git a/drivers/misc/uacce/uacce.c b/drivers/misc/uacce/uacce.c index bdc2e6fda782..af815b8a718e 100644 --- a/drivers/misc/uacce/uacce.c +++ b/drivers/misc/uacce/uacce.c @@ -2,6 +2,7 @@ #include #include #include +#include // for struct vm_operations_struct #include #include #include diff --git a/drivers/mtd/spi-nor/core.h b/drivers/mtd/spi-nor/core.h index d36c0e072954..0d11ff848a7f 100644 --- a/drivers/mtd/spi-nor/core.h +++ b/drivers/mtd/spi-nor/core.h @@ -9,6 +9,8 @@ #include "sfdp.h" +#include // for SZ_* + #define SPI_NOR_MAX_ID_LEN 6 /* * 256 bytes is a sane default for most older flashes. Newer flashes will diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c index 4f47a13cb500..ef37ea6c09fc 100644 --- a/drivers/pci/p2pdma.c +++ b/drivers/pci/p2pdma.c @@ -16,6 +16,7 @@ #include #include #include +#include // for VM_MAYSHARE #include #include #include diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index cfc5b84dc9c9..e2afd992caa7 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -25,6 +25,7 @@ #include #include #include +#include // for pgprot_device() #include #include #include diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index f276956f2c5c..938220fe29f5 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -18,6 +18,7 @@ #include #include +#include // for PAGE_ALIGN() #include #include #include diff --git a/drivers/soc/qcom/rmtfs_mem.c b/drivers/soc/qcom/rmtfs_mem.c index df850d073102..15c2f6e5eaff 100644 --- a/drivers/soc/qcom/rmtfs_mem.c +++ b/drivers/soc/qcom/rmtfs_mem.c @@ -6,6 +6,7 @@ #include #include #include +#include // for remap_pfn_range() #include #include #include diff --git a/drivers/spi/spi-aspeed-smc.c b/drivers/spi/spi-aspeed-smc.c index bbd417c55e7f..e45f64761e5e 100644 --- a/drivers/spi/spi-aspeed-smc.c +++ b/drivers/spi/spi-aspeed-smc.c @@ -11,6 +11,7 @@ #include #include #include +#include // for SZ_* #include #include diff --git a/drivers/spi/spi-bcm2835.c b/drivers/spi/spi-bcm2835.c index e1b9b1235787..d8ed5575a9c6 100644 --- a/drivers/spi/spi-bcm2835.c +++ b/drivers/spi/spi-bcm2835.c @@ -33,6 +33,8 @@ #include #include +#include // for ZERO_PAGE() + /* SPI register offsets */ #define BCM2835_SPI_CS 0x00 #define BCM2835_SPI_FIFO 0x04 diff --git a/drivers/spi/spi-intel.c b/drivers/spi/spi-intel.c index 3e5dcf2b3c8a..cf8e4f1c4d93 100644 --- a/drivers/spi/spi-intel.c +++ b/drivers/spi/spi-intel.c @@ -8,6 +8,7 @@ #include #include +#include // for SZ_* #include #include diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index 49299b1f9ec7..5c3ca44aef42 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c @@ -12,6 +12,7 @@ #include #include #include +#include // for PAGE_ALIGN() #include #include diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h index 5adb86af35fc..e3395a9bea81 100644 --- a/include/linux/huge_mm.h +++ b/include/linux/huge_mm.h @@ -7,6 +7,8 @@ #include /* only for vma_is_dax() */ +#include // for pmd_t + vm_fault_t do_huge_pmd_anonymous_page(struct vm_fault *vmf); int copy_huge_pmd(struct mm_struct *dst_mm, struct mm_struct *src_mm, pmd_t *dst_pmd, pmd_t *src_pmd, unsigned long addr, diff --git a/include/linux/iommu.h b/include/linux/iommu.h index de839fd01bb8..c49cd93b9c85 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -14,6 +14,7 @@ #include #include #include +#include // for copy_struct_from_user() #define IOMMU_READ (1 << 0) #define IOMMU_WRITE (1 << 1) diff --git a/include/linux/nvme-keyring.h b/include/linux/nvme-keyring.h index e10333d78dbb..9e033850b967 100644 --- a/include/linux/nvme-keyring.h +++ b/include/linux/nvme-keyring.h @@ -6,6 +6,8 @@ #ifndef _NVME_KEYRING_H #define _NVME_KEYRING_H +#include + #if IS_ENABLED(CONFIG_NVME_KEYRING) key_serial_t nvme_tls_psk_default(struct key *keyring, diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h index 77df3d7b18a6..0516e64dc03e 100644 --- a/include/linux/scatterlist.h +++ b/include/linux/scatterlist.h @@ -8,6 +8,12 @@ #include #include +#ifdef CONFIG_UML +#include // for virt_to_page(), page_to_phys() +#else +#include // for virt_to_page(), page_to_phys() +#endif + struct scatterlist { unsigned long page_link; unsigned int offset; diff --git a/kernel/dma/ops_helpers.c b/kernel/dma/ops_helpers.c index af4a6ef48ce0..641363b13bb9 100644 --- a/kernel/dma/ops_helpers.c +++ b/kernel/dma/ops_helpers.c @@ -4,6 +4,7 @@ * the allocated memory contains normal pages in the direct kernel mapping. */ #include +#include // for PAGE_ALIGN() static struct page *dma_common_vaddr_to_page(void *cpu_addr) { diff --git a/kernel/dma/remap.c b/kernel/dma/remap.c index 27596f3b4aef..87b3c874d370 100644 --- a/kernel/dma/remap.c +++ b/kernel/dma/remap.c @@ -3,6 +3,7 @@ * Copyright (c) 2014 The Linux Foundation */ #include +#include // for vmap(), PAGE_ALIGN() #include #include diff --git a/mm/dmapool.c b/mm/dmapool.c index f0bfc6c490f4..b8e23fdc81d7 100644 --- a/mm/dmapool.c +++ b/mm/dmapool.c @@ -25,6 +25,7 @@ #include #include #include +#include // for want_init_on_alloc() #include #include #include From patchwork Thu Feb 22 11:50:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Max Kellermann X-Patchwork-Id: 204719 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:aa16:b0:108:e6aa:91d0 with SMTP id by22csp197557dyb; Thu, 22 Feb 2024 03:53:25 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUWJP8+jYGv0qp55Hk0YRPjT1AQyCO6K20Dx7FAAfCaze/uOqyzj0ajl6LBGTixqR4wkLHNp9ztnLnnGlnTYUvS6sIong== X-Google-Smtp-Source: AGHT+IHv8LKeQImOIipiWYdwOmqM+oFeyN5z4M6l+Dk26Tbqoyd6HgqofL/H91DHmN8BNvYG6v83 X-Received: by 2002:a17:90a:5785:b0:299:11d0:4b0d with SMTP id g5-20020a17090a578500b0029911d04b0dmr17813178pji.27.1708602805564; Thu, 22 Feb 2024 03:53:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708602805; cv=pass; d=google.com; s=arc-20160816; b=AQ7kSAA//XPwUuZunP6clVCIsxNtX3/yKVUwVkB/gjLMOYz4LqTtdPpUQua6qFdHiU AV95aVCPN/PFy8e+P1narLpW4SDmZEz1S8drTmptBqL8BJx8LahX0/Sd76a31NPgy3xg 08IVN3FcWUMESFEBUgAwUFBofdBasfTuoiDiEweh9N54+S+pnb1q7MhICOusFCGLglbB MdEo6292XwttTz9m8csJeRjBkJcYS2X33D2BEiqDJRWBlrtvz7rZx5l7r2vSx+57BjEf 2b/l41nPDyCOggZgbdhYXoWoQKXm64QdOuzGhBhDlS34rGjZaxGo+XOAxgwV/50a2rdF 6XTg== 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=BL1pmIo7s1MX4N9LU8kIbt0i/wU5mZK2rTJkOzRk4Zc=; fh=HnlHeP2HmRknYWzaLJ+ypncu+79KwybUIXojTfubGKY=; b=AkPFIbL0rvhivwozh6bWFIxC3LcUNU9vdg1dGeewX71jZHEoVrCkU2CX396IuSJKZ6 90P4MqXNRQHINoNwFnDeSemVKL6a1Y5okpdiJ21PF98XeyM4dp7APa45TabFBUdHfRZS 1c8CyIDwZk+KH22uhF9RfBI07rvWeqTMgkQNDlTCno/WXGF4APK1TS9jZse9rVJs+Ypm mQLQdY9TOzk01cFGQ3nrGwj4BXLXVo1bG0v/jdmn8yq2FgxVX6Gg2gwCpr7ltOSS3oRI TUPZsnh5Ts7AuIg/pdB5eIZTLeRuU2IQE53jyV9NG2g7jhktuGGuufid0oEDBPC65Htf LuSA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=Rt81lnVz; 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-76450-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76450-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id u15-20020a170903124f00b001db5df6dfb7si10163291plh.421.2024.02.22.03.53.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 03:53:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76450-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=Rt81lnVz; 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-76450-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76450-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 4BB43B26139 for ; Thu, 22 Feb 2024 11:51:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 00A304A9BF; Thu, 22 Feb 2024 11:51:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b="Rt81lnVz" Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) (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 E7A0741C64 for ; Thu, 22 Feb 2024 11:51:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708602668; cv=none; b=PXVEyjXnqhzWLCMwRUpWXI5fri+LDrynNhnljxS1Sye/o93LZcYyIJDfkU0N3TJqJwUb46N98POSwlUnTpQp0JNdLVGmsuZKAWfy9ECI8YRDcTOCETmBxB0fpQGpPJXLtQt2tk7LolEVBxvNogSFqhPBzc9AzVad9vsY8Rt4as4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708602668; c=relaxed/simple; bh=7E++P3NE3gX/uG8sJhez163L//hFb7dWE0h0h4Q6OTA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=tcY4/5dCUpTKnMCXWokVxct5vgjYYEh6iu55Q+75pt51QRWnA6ty7dADHc1mdtF+XsaXfKXN3WAGHqlzbrU0CiE2k33NbMeBTRJSLWjFzYej2HAatxk7QSlVaYA1G8FjMdfRx64o21IbHHQyPJ5G7Hny624qTQEVKmNkUObITNE= 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=Rt81lnVz; arc=none smtp.client-ip=209.85.221.42 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-wr1-f42.google.com with SMTP id ffacd0b85a97d-3394b892691so434512f8f.1 for ; Thu, 22 Feb 2024 03:51:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1708602664; x=1709207464; 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=BL1pmIo7s1MX4N9LU8kIbt0i/wU5mZK2rTJkOzRk4Zc=; b=Rt81lnVzkwe7EDCA6zC/ONS8lDJJpxCT2WZq0l30xixTiOsGtYJttDV0TJCnG9pS6u WPq6YFR6VYGRlR5zao+ZT+CU3xwUFuWufowP23EYujpRN1el2fvdK2cL4iVUAlGG8I4i vxjyWWAk6KvbbD82fd06O5Sc3mdsJEG58XA5zEVoWecW4CEPhdTifBxt9SGuH9+xgiJz naYE0zyXtfBGb4cQLNkU3zjSiuFrYioY1iIYDLDyBvy6pH0AiNiBZnxo3JWI9iUFobhZ 4WHZIMyp3jUMQldOHyNeTfT9GVbuiiPh/RMT86CIEgpXMIwrxmKb4VCk862d0p58IAeA swGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708602664; x=1709207464; 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=BL1pmIo7s1MX4N9LU8kIbt0i/wU5mZK2rTJkOzRk4Zc=; b=ZhaHro8n4JUeQcyzFdIgaJ5yyodmnPGUd7wdleucNZQhw49B1FHxFBRpk4hNE0vDUL BkhLQFvqeayGYepXXrx62PFR+Fo0j41AltK9PaAscmnekPLgLmjFQBuE9T+IutVI0em+ CS7nEVsB0Z1XIuom6CBm6w1kJ3Umi0R4TqUvvLuL78tH+QSkMGDaZl7ucxrNXyG/z9Tb 1/8onZLoYXgygXrTgzHtJCQQaOgOi9JxAijiNlEkg0VzCuvFZZMFH+lNx1/ywLO979Uj 6l4nMFSRkK6iJsDps/YtqxJ3LUIxVSudbE4zsoOkaUNLFzOaCvTuPpLHZpTQn4C3h1D+ TBQw== X-Forwarded-Encrypted: i=1; AJvYcCWfDrWVQjZlS6+k7MXt+JzckrLou2BqshpTxOB+9f8d5KUyGJm9tNkD8XMq5ZekNEfttDlcfb1UMXiDjeRRxa0TG6dmyHEAQXRNs/JC X-Gm-Message-State: AOJu0Yxu9O1BrzszElQhxqSITMib5qzFBRW/dUb3BsVynOqI0/sStUz8 O1e6/uLwoYGxBPhmDMZJBopbq3dzGsfPG3sBnhel9VA7yiGCpsgbgo+H0z5KCsmvt1zloM2eDYt P X-Received: by 2002:a5d:404c:0:b0:33d:64a3:9bc6 with SMTP id w12-20020a5d404c000000b0033d64a39bc6mr2229571wrp.4.1708602664281; Thu, 22 Feb 2024 03:51:04 -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.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 03:51:03 -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 02/14] include/drm/drm_gem.h: add poll_table_struct forward declaration Date: Thu, 22 Feb 2024 12:50:43 +0100 Message-Id: <20240222115055.1172877-3-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: 1791599895473666107 X-GMAIL-MSGID: 1791599895473666107 After eliminating includes of linux/mm.h, the following build failure occurred: ./include/drm/drm_file.h:443:45: warning: ‘struct poll_table_struct’ declared inside parameter list will not be visible outside of this definition or declaration 443 | __poll_t drm_poll(struct file *filp, struct poll_table_struct *wait); | ^~~~~~~~~~~~~~~~~ In file included from drivers/gpu/drm/imagination/pvr_gem.h:12, from drivers/gpu/drm/imagination/pvr_fw.h:9: ./include/drm/drm_gem.h:447:27: error: initialization of ‘__poll_t (*)(struct file *, struct poll_table_struct *)’ {aka ‘unsigned int (*)(struct file *, struct poll_table_struct *)’} from incompatible pointer type ‘__poll_t (*)(struct file *, struct poll_table_struct *)’ {aka ‘unsigned int (*)(struct file *, struct poll_table_struct *)’} [-Werror=incompatible-pointer-types] 447 | .poll = drm_poll,\ | ^~~~~~~~ The compiler is confused, and that can be fixed easily by forward-declaring the struct expicitly. Signed-off-by: Max Kellermann --- include/drm/drm_file.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/drm/drm_file.h b/include/drm/drm_file.h index ab230d3af138..f24ade9f766f 100644 --- a/include/drm/drm_file.h +++ b/include/drm/drm_file.h @@ -44,6 +44,7 @@ struct drm_device; struct drm_printer; struct device; struct file; +struct poll_table_struct; /* * FIXME: Not sure we want to have drm_minor here in the end, but to avoid From patchwork Thu Feb 22 11:50:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Kellermann X-Patchwork-Id: 204715 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:aa16:b0:108:e6aa:91d0 with SMTP id by22csp197039dyb; Thu, 22 Feb 2024 03:52:19 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUZfz1qm9wT8yDrRdc6i4wTAtDPVRbFd7rfh/sqoZoO0juqkKMlwd8hQ2U0YAV2Bhor03uN6DMOjfyRVWRabfTiwNyQaQ== X-Google-Smtp-Source: AGHT+IHbm7QYwypVv+qBXhEFMPhA4zhyvy22UtCSYgrvpSujzJFWCupjigMoOdA5UMhLOP6CkRa9 X-Received: by 2002:a05:6402:448d:b0:561:3b53:d0af with SMTP id er13-20020a056402448d00b005613b53d0afmr1920825edb.12.1708602738908; Thu, 22 Feb 2024 03:52:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708602738; cv=pass; d=google.com; s=arc-20160816; b=L8EWJMnMsfGqIAoLrGH6PRF7kKW4qy3c6R+z2aehGyZqux2zmtuRPlBHEjcyWKp6iR vSGoZnlhSOxI0VF3itVJA3Q0fvwI28cRkt3j/N6LH16BSoXrsdMy/neEb64M0PjUkXyD vfm1NE7pAFqlKQwnugMmgblPKWEwfWCP2qWOLFfkXv9NAvqe0uNm7WSjmdEBceiO6UjK jX5d9oMJdRunsX/o6RMK9wqMgxTHooP8t39muPZ1KCCIHB0FFExaPcY9P3JZ5GXMkSa1 clypbG4LgaR2PjqXT4cNsr1Atxwz4YK+2ufnFPBrRnoEGyX5KbNqQorIcwKqohFjXaFe Xc2g== 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=7b5/uhjfqeIuQAGiFdEn3Xr4J+TBvtutx0p1n4ubkzU=; fh=cS/LX3DreNzScQzHN83yX0N3RzS1Z/fnqdGIpQ2YLuU=; b=swPfdpPJAB2owhiyx5k1aKSDZS2d3itJntVgX755iefrJM0WatW39/EaXCZguJ3hTJ eM1oV3PwfpROZbRY3/ajPvCttGowyK/uUWs06t/NBl9DOTCcgFxrC0GYgoUYufcwrqnw cjwGHTI429PXXbZHVLmMK+ymDQ0Et+eWzyEv6Boq386/O9mz16PDkzaXzR8r6OfDXhIn YdSdlyBHrEOlKqnoZPRRwbGAHcvHL8sS+CcKdKvyzNa/yuHlteumIcBNUELfTjVh6BQ/ thvomKcDEx2j/lw2IwxpoxyB8cbk/EU7qcGwe7BP/yJu1d1imbub5PGXOMlaNi3hTtEM VeNw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=hcUbHLOJ; 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-76451-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76451-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. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id de26-20020a056402309a00b00565103756bcsi1016376edb.182.2024.02.22.03.52.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 03:52:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76451-ouuuleilei=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=hcUbHLOJ; 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-76451-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76451-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 5BC971F21B9B for ; Thu, 22 Feb 2024 11:52:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A9E424CB57; Thu, 22 Feb 2024 11:51:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b="hcUbHLOJ" Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) (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 A096B446DE for ; Thu, 22 Feb 2024 11:51:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708602668; cv=none; b=Y48DhbnO5tlQMi5xR/yxTkJ6HkjyyH9UCvrGOF6FmmQis6I9eOGFv7jYCJn5hx32cVl22OfHCRnyISNTAyUBD26jlzWWTg/rgnW1vEe0/U5Ehm+mAlsYuz5cowVK8jPOx07WHmSd7jtV8lPWCvIeUjTknhVsEg5TJkKKiLY4fT8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708602668; c=relaxed/simple; bh=aG/T2NPOQsNeyDUNTYV6KWwxd7/uxtPCMFLlShvPJLE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Gf6NvYT28uKgUFLvCsOzgw8lOExJHciCqHeS8UVFqultk4LB9qJlFwK3ZC22dGHZ+Xn8HrKlZJBcJMbFBIxP634RH3rW4KEJxD/hcSAj4Vek3+tM4NA6ODlhuLw/dMaGapHab4sltYRMJ4kw+4WFWQl2kE8Yev+xK9TM3/mUcPI= 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=hcUbHLOJ; arc=none smtp.client-ip=209.85.221.51 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-wr1-f51.google.com with SMTP id ffacd0b85a97d-3394b892691so434522f8f.1 for ; Thu, 22 Feb 2024 03:51:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1708602665; x=1709207465; 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=7b5/uhjfqeIuQAGiFdEn3Xr4J+TBvtutx0p1n4ubkzU=; b=hcUbHLOJh3hHHm7E08Oi5NVR/r8Y1WgJKtqrUYpAJLqZaeR+iGf13V7vtsJ5tYPisi QQt1YcuavbYtOjGa2CDCSseGtQBt2ibz9ieB99+XLPLdu26/rYf+sBKlX9TYF0c4KGl3 oKm/nwBwygAtkm6pRmAsFp78HLnfM7KjktsO5/fVwCTPfe3ct2hsB9bbTSfSsPqD0QdS rt0t0T24c4zPVz+wDoS4ZrI2DK05fa2d72Z6teB5q6DQLFSdTfWKHRlN9q7MGb2CHEgu 1fpbU8BbOepWnyfRKRu4Q6Cz+Vc7eqEpAPEq/9++/FoH4PZozvITcV5bOYpZUw2XPGTW I59A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708602665; x=1709207465; 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=7b5/uhjfqeIuQAGiFdEn3Xr4J+TBvtutx0p1n4ubkzU=; b=X0onyKuGdQIw/c4mdxEv+XvoaVmqCVlzmTl7Jhy+KJNh0HEPBg/zmy0wmc1MKkGmfx UVGOSMWxHFBLiu+teZLcHGbPMkduJRLeSwxbafacnWi4kMWXH72RBA37aBkkQaebHC5M XGhYc8Iloyi///AdY2JtRYxBW2imOgTIPK6jnLoXubld0+BtagdOn7PnGivIIvt1HDbg 0q114Ii7SWXgNEhR6KGo6L4Jr3BMGG9SMRQ93jN8tuQ7BSbGPceuR2bK1Ep+fqtPxmfC 5/vIJSNHWWDaZ+wt85Yt0zTpuo7K4K3JhDJMcjELYfPDthJfZL4KVFC/YsPNyBIh1G4G iSLw== X-Forwarded-Encrypted: i=1; AJvYcCWMJPpLGl/8bSHKkc6+bui4msEtZJ/gwTQDJCO0lMX/Ax7uqyyuwDLmoogq9YjjJvPiZvNN+kzqBs1kgffrR88Xk667G+gwNuGPiJYv X-Gm-Message-State: AOJu0YxVobEeVehwoK4Nt6SFijarWPDe2cOmwnckZIENvVG64zqTjJu2 8WgQtOhAi9A1FIzcSaXT3DLiGyhYEcq9FqvWWBMAWEII51J20+6FLpVz5dYxSEQ= X-Received: by 2002:a5d:4ac4:0:b0:33d:3ff3:f888 with SMTP id y4-20020a5d4ac4000000b0033d3ff3f888mr2385231wrs.0.1708602664992; Thu, 22 Feb 2024 03:51:04 -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.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 03:51:04 -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 03/14] linux/mm.h: move page_kasan_tag() to mm/page_kasan_tag.h Date: Thu, 22 Feb 2024 12:50:44 +0100 Message-Id: <20240222115055.1172877-4-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: 1791599825760545949 X-GMAIL-MSGID: 1791599825760545949 Prepare to reduce dependencies on linux/mm.h. page_kasan_tag() is used by the page_to_virt() macro in ARM64 (but asm/memory.h does not include linux/mm.h). Thus, in order to be able to use anything that calls page_to_virt(), linux/mm.h needs to be included. This would prevent us from moving page_address() to a separate header, because it calls lowmem_page_address() which in turn calls page_to_virt(). To prepare for this move, we move page_kasan_tag() out of linux/mm.h into a separate lean header. A side effect of this patch is that the include line is moved inside the "#ifdef CONFIG_KASAN..." block, i.e. it is not included at all if KASAN is disabled. Signed-off-by: Max Kellermann --- MAINTAINERS | 1 + include/linux/mm.h | 56 +------------------------- include/linux/mm/page_kasan_tag.h | 66 +++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+), 55 deletions(-) create mode 100644 include/linux/mm/page_kasan_tag.h diff --git a/MAINTAINERS b/MAINTAINERS index c042ca394893..ad208d8aea4b 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14187,6 +14187,7 @@ F: include/linux/mempolicy.h F: include/linux/mempool.h F: include/linux/memremap.h F: include/linux/mm.h +F: include/linux/mm/*.h F: include/linux/mm_*.h F: include/linux/mmzone.h F: include/linux/mmu_notifier.h diff --git a/include/linux/mm.h b/include/linux/mm.h index 1743bdeab506..c8d909cc1353 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2,6 +2,7 @@ #ifndef _LINUX_MM_H #define _LINUX_MM_H +#include #include #include #include @@ -27,7 +28,6 @@ #include #include #include -#include #include #include @@ -1810,60 +1810,6 @@ static inline void vma_set_access_pid_bit(struct vm_area_struct *vma) } #endif /* CONFIG_NUMA_BALANCING */ -#if defined(CONFIG_KASAN_SW_TAGS) || defined(CONFIG_KASAN_HW_TAGS) - -/* - * KASAN per-page tags are stored xor'ed with 0xff. This allows to avoid - * setting tags for all pages to native kernel tag value 0xff, as the default - * value 0x00 maps to 0xff. - */ - -static inline u8 page_kasan_tag(const struct page *page) -{ - u8 tag = KASAN_TAG_KERNEL; - - if (kasan_enabled()) { - tag = (page->flags >> KASAN_TAG_PGSHIFT) & KASAN_TAG_MASK; - tag ^= 0xff; - } - - return tag; -} - -static inline void page_kasan_tag_set(struct page *page, u8 tag) -{ - unsigned long old_flags, flags; - - if (!kasan_enabled()) - return; - - tag ^= 0xff; - old_flags = READ_ONCE(page->flags); - do { - flags = old_flags; - flags &= ~(KASAN_TAG_MASK << KASAN_TAG_PGSHIFT); - flags |= (tag & KASAN_TAG_MASK) << KASAN_TAG_PGSHIFT; - } while (unlikely(!try_cmpxchg(&page->flags, &old_flags, flags))); -} - -static inline void page_kasan_tag_reset(struct page *page) -{ - if (kasan_enabled()) - page_kasan_tag_set(page, KASAN_TAG_KERNEL); -} - -#else /* CONFIG_KASAN_SW_TAGS || CONFIG_KASAN_HW_TAGS */ - -static inline u8 page_kasan_tag(const struct page *page) -{ - return 0xff; -} - -static inline void page_kasan_tag_set(struct page *page, u8 tag) { } -static inline void page_kasan_tag_reset(struct page *page) { } - -#endif /* CONFIG_KASAN_SW_TAGS || CONFIG_KASAN_HW_TAGS */ - static inline struct zone *page_zone(const struct page *page) { return &NODE_DATA(page_to_nid(page))->node_zones[page_zonenum(page)]; diff --git a/include/linux/mm/page_kasan_tag.h b/include/linux/mm/page_kasan_tag.h new file mode 100644 index 000000000000..1210c62170a3 --- /dev/null +++ b/include/linux/mm/page_kasan_tag.h @@ -0,0 +1,66 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_MM_PAGE_KASAN_TAG_H +#define _LINUX_MM_PAGE_KASAN_TAG_H + +#include + +struct page; + +#if defined(CONFIG_KASAN_SW_TAGS) || defined(CONFIG_KASAN_HW_TAGS) + +#include +#include // for struct page + +/* + * KASAN per-page tags are stored xor'ed with 0xff. This allows to avoid + * setting tags for all pages to native kernel tag value 0xff, as the default + * value 0x00 maps to 0xff. + */ + +static inline u8 page_kasan_tag(const struct page *page) +{ + u8 tag = KASAN_TAG_KERNEL; + + if (kasan_enabled()) { + tag = (page->flags >> KASAN_TAG_PGSHIFT) & KASAN_TAG_MASK; + tag ^= 0xff; + } + + return tag; +} + +static inline void page_kasan_tag_set(struct page *page, u8 tag) +{ + unsigned long old_flags, flags; + + if (!kasan_enabled()) + return; + + tag ^= 0xff; + old_flags = READ_ONCE(page->flags); + do { + flags = old_flags; + flags &= ~(KASAN_TAG_MASK << KASAN_TAG_PGSHIFT); + flags |= (tag & KASAN_TAG_MASK) << KASAN_TAG_PGSHIFT; + } while (unlikely(!try_cmpxchg(&page->flags, &old_flags, flags))); +} + +static inline void page_kasan_tag_reset(struct page *page) +{ + if (kasan_enabled()) + page_kasan_tag_set(page, KASAN_TAG_KERNEL); +} + +#else /* CONFIG_KASAN_SW_TAGS || CONFIG_KASAN_HW_TAGS */ + +static inline u8 page_kasan_tag(const struct page *page) +{ + return 0xff; +} + +static inline void page_kasan_tag_set(struct page *page, u8 tag) { } +static inline void page_kasan_tag_reset(struct page *page) { } + +#endif /* CONFIG_KASAN_SW_TAGS || CONFIG_KASAN_HW_TAGS */ + +#endif /* _LINUX_MM_PAGE_KASAN_TAG_H */ From patchwork Thu Feb 22 11:50:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Kellermann X-Patchwork-Id: 204716 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:aa16:b0:108:e6aa:91d0 with SMTP id by22csp197053dyb; Thu, 22 Feb 2024 03:52:20 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXoCofxc3JnyqJVqsbRkUZZnaM9RGV64G6hf+lVK24nHidU/Zhzived2KEAQpcVC5k4JZUi4GlBWpU8gove+x5T0imPfA== X-Google-Smtp-Source: AGHT+IEXYS1GT0L61zVXWIcmQ+MTC4m+OpBnyLHqYUYvWKCkljDYx6JBOp1d1ymVqCm6d8wClJM7 X-Received: by 2002:a0c:cb94:0:b0:68f:b9c0:9bcf with SMTP id p20-20020a0ccb94000000b0068fb9c09bcfmr1562776qvk.50.1708602740410; Thu, 22 Feb 2024 03:52:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708602740; cv=pass; d=google.com; s=arc-20160816; b=COYYJ3u8128Sst1VVdM2L127YCmJcLpNvS+1OwYp3WhatqQatgOrzq1FLKQ8aJO/1p +lY722S+TmUiZpgtL7RSZ2hh3tsvNuI6WDPnZ0VDA3nElOgIoKpH3Iu62vaUl4JRvRNq GPhul2SNlIwE7GkmTMly6VQLhb8016LE/vCVr9KbM55Opyf2x3JGcxmUBw1B6LicfRT7 94j/9VOLQy7cEfCUw0uFRnssQi98AriTFckE34JoqWpI7WqeNxbeMl2ccN48UoE5xfZs 5hGOTYXXmIaU3qm8nRDHZ7Be+a++M2ns2zOO3TGRdXDCgdzZgDKqStakmo/S5l0WqDSP XAlQ== 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=bU66tnpYofC3HczPR5LqCx53IAlSBOajb8Iggei03v8=; fh=UwaqDO0SlgQyZAonbJesEuSHdKaQuUu6LizBx+Ix9kY=; b=EgrrqsVzX4kDzjGy0L98TgGcusnpW5C0Go8fUkoUPcLW+SO1Mz0kAl4c7UzDmDNRs8 tPK8aC4TtR7kRgaxdi2ufELNUxeAapNewjHEYLjo/LxrXrdfRIND5j6yjhvdpDAEpV3Q FDpVrsDd96lrN2doTnIc5cKpvYYihszfCa+lcQyHwHXtyAfe/YBr1H3e/TqclvRswOVt qGX1pm8MxjIegXIcp0Yl5a8DTOSEW0x+0BE9rsnT/1BAV6+ejN8peWBEPra3s9F4yaIF UCweerNvFgfbYibB5YtBy+Zfy7mF/jCq6aZb50rja3A2u/Gy78E/h8pEiAapmGkpuad7 0mYw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=QfFKhXnj; 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-76452-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76452-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 jk7-20020ad45d47000000b0068fb4967643si1989816qvb.237.2024.02.22.03.52.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 03:52:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76452-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=QfFKhXnj; 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-76452-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76452-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 281181C20C67 for ; Thu, 22 Feb 2024 11:52:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E818E4CDE0; Thu, 22 Feb 2024 11:51:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b="QfFKhXnj" Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.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 897B846521 for ; Thu, 22 Feb 2024 11:51:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708602669; cv=none; b=khz4quS/B3zH6a39If/Duka06KLW5p/+Ah4+FvogKU0K2JtYfgTwBI4oh+RkoL7oaax6SPiS7hu+nPNcIR5MHAifMjN/cscnnqrCitTO5Eiv2+AmVidCN5akq6XMHnSNRG0O8TNOro4sKAXeRtfBxMZvDeoGyKmmQ0QN+Dj+u1I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708602669; c=relaxed/simple; bh=LuiNKwot/c2cGXu1azbocNtVe8hBsdaf1P55KumReSA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=l9r2+qe5ge69XV8GeMNOnh7Q5mT8qVagwCBBPfSUunQvPybnCRQzn7V0Aj2tA7Iq5UmVPh4CocRFcARPAE3kp10xYn2ziQgDF9XbxpnoLcEH9cx2C/iUaweVQTh1wYx1VCq1UVWP0e3EiZ4JG14fTZK9XK0DeWvcz7ufDbP6K0s= 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=QfFKhXnj; arc=none smtp.client-ip=209.85.221.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-wr1-f53.google.com with SMTP id ffacd0b85a97d-33d9c3f36c2so128418f8f.2 for ; Thu, 22 Feb 2024 03:51:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1708602666; x=1709207466; 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=bU66tnpYofC3HczPR5LqCx53IAlSBOajb8Iggei03v8=; b=QfFKhXnjAq30/tZfPhsxMENYDZlQaRwHWLbQv5/IfE/Rgos158IFhti1m5CcTxGBio o/v0JUAHvRhA7FKPHcTkZ2iD4NiGmfmGCOoOcbvA1ZTEEvMGt3QvT/1X/uf5Ml0vdMkT 7q+T2vdgQ4xA5JlUaWHukRe/hn/P45qy+C/F/nzO1LTY3RbdHgU+Kk3Hlzi79d7jC8st TeLCRKkfgTfz9pblVE2XqxXPfQkwMxYA9utemdHLniTGvr7+lIci7bmklxu5SKdqGlfS BhcbCEzsOMQ6IuNLIlcGmG5hGQExEV+ANqKr6og3TXnSsPXS/o5cpZ2K0w+w9dmNjbE5 gDmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708602666; x=1709207466; 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=bU66tnpYofC3HczPR5LqCx53IAlSBOajb8Iggei03v8=; b=JrY4XR33aKzOjhl0erEtpy2mZBefsn7oBhylAF5f5SbGGkzPYh81AumUtfTbIDAUZi RgJw0NW1wuTnood/SI8A74ZHQxLaU3Aeiav/5NUTIy5KNuxiimsUd6tICyDDT5SPYHPu Eqnm/ejQm81yiutY8o4NyvMKGSNKRKnwxbo3j2p297uB/hZ7N3FEcuR1LFJM0gvfamea E/nB3zz6Fw2C8iBmBtv16A8JiaBGMZbargdgGyk2S4FXbbo8ubjyd0BEBuvEw6fzdJEe RTH4hHtDlkMNs52htAgq2F3nH1U/UE7hpDFRb8NIFVu9BqE2TbjUQKV2M4QELbku9Y3R rpbQ== X-Forwarded-Encrypted: i=1; AJvYcCUuxfy0gYSsSTSM4PEArvy0jcSHtidFF12pUcmw/0UTdamHjuZPiSEEg9XKOb8avnNqGhwfC9GrxU23BKrcE1tzghNWGs2Cv7Q4hcfU X-Gm-Message-State: AOJu0YxJ+qQO8kKZRLQGGGkFTBop/uw3u3CaNh+AjG+qN6iFObdPIAmH UY3SjZmEN/HPPHMiLiHl2fuB4AvB9qTbW/i0YDVBef6bLyKzTaUm0YgcTChLqfY= X-Received: by 2002:a05:6000:12c5:b0:33d:40f0:b0de with SMTP id l5-20020a05600012c500b0033d40f0b0demr7809643wrx.6.1708602665810; Thu, 22 Feb 2024 03:51:05 -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.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 03:51:05 -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 04/14] linux/mm.h: move section functions to mm/page_section.h Date: Thu, 22 Feb 2024 12:50:45 +0100 Message-Id: <20240222115055.1172877-5-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: 1791599827336859282 X-GMAIL-MSGID: 1791599827336859282 Prepare to reduce dependencies on linux/mm.h. page_to_section() is used by __page_to_pfn() (but asm-generic/memory_model.h does not include linux/mm.h). Thus, in order to be able to use anything that calls page_to_pfn(), linux/mm.h needs to be included. This would prevent us from moving page_address() to a separate header, because it calls lowmem_page_address() which in turn calls page_to_virt() and then page_to_pfn(). To prepare for this move, we move page_to_section() out of linux/mm.h into a separate lean header. Signed-off-by: Max Kellermann --- include/linux/mm.h | 18 +----------------- include/linux/mm/page_section.h | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 17 deletions(-) create mode 100644 include/linux/mm/page_section.h diff --git a/include/linux/mm.h b/include/linux/mm.h index c8d909cc1353..7c3d2bd69818 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3,6 +3,7 @@ #define _LINUX_MM_H #include +#include #include #include #include @@ -1627,10 +1628,6 @@ static inline bool is_nommu_shared_mapping(vm_flags_t flags) } #endif -#if defined(CONFIG_SPARSEMEM) && !defined(CONFIG_SPARSEMEM_VMEMMAP) -#define SECTION_IN_PAGE_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 @@ -1830,19 +1827,6 @@ static inline pg_data_t *folio_pgdat(const struct folio *folio) return page_pgdat(&folio->page); } -#ifdef SECTION_IN_PAGE_FLAGS -static inline void set_page_section(struct page *page, unsigned long section) -{ - page->flags &= ~(SECTIONS_MASK << SECTIONS_PGSHIFT); - page->flags |= (section & SECTIONS_MASK) << SECTIONS_PGSHIFT; -} - -static inline unsigned long page_to_section(const struct page *page) -{ - return (page->flags >> SECTIONS_PGSHIFT) & SECTIONS_MASK; -} -#endif - /** * folio_pfn - Return the Page Frame Number of a folio. * @folio: The folio. diff --git a/include/linux/mm/page_section.h b/include/linux/mm/page_section.h new file mode 100644 index 000000000000..e4558c2691b8 --- /dev/null +++ b/include/linux/mm/page_section.h @@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_MM_PAGE_SECTION_H +#define _LINUX_MM_PAGE_SECTION_H + +#include // for struct page +#include // for SECTIONS_* + +#if defined(CONFIG_SPARSEMEM) && !defined(CONFIG_SPARSEMEM_VMEMMAP) +#define SECTION_IN_PAGE_FLAGS + +static inline void set_page_section(struct page *page, unsigned long section) +{ + page->flags &= ~(SECTIONS_MASK << SECTIONS_PGSHIFT); + page->flags |= (section & SECTIONS_MASK) << SECTIONS_PGSHIFT; +} + +static inline unsigned long page_to_section(const struct page *page) +{ + return (page->flags >> SECTIONS_PGSHIFT) & SECTIONS_MASK; +} +#endif + +#endif /* _LINUX_MM_PAGE_SECTION_H */ From patchwork Thu Feb 22 11:50:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Kellermann X-Patchwork-Id: 204723 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:aa16:b0:108:e6aa:91d0 with SMTP id by22csp198103dyb; Thu, 22 Feb 2024 03:54:44 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXw/dAsQkF4WstSbJ5tdYA01HX7j+JRRCW6+o7DHQUmMB5A76LPEBzxfefMy+JBiu9Rep9Tu/VGOZ0LqYZcu67hl2pe5Q== X-Google-Smtp-Source: AGHT+IHZq6jgL8dxHwVouPkMSQCIQheNFmmA/2fe6qXV45u7Vek8UOMaEmfH1dsxXFNibbIHbRvy X-Received: by 2002:a05:6a20:d04f:b0:19c:a2ef:c45e with SMTP id hv15-20020a056a20d04f00b0019ca2efc45emr21675579pzb.37.1708602884194; Thu, 22 Feb 2024 03:54:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708602884; cv=pass; d=google.com; s=arc-20160816; b=PLF1NewagG0KIrs3vV/PscK719EQbvdkiVR0uWDALTjORzlGfoLi2MSjW3hs0v/j14 Al+sGcv0/O2xZ/jIVMkxmogrNpa/L8aOvQ2Y0XJlBAR6Z6wLm4hUotSKImwlS95lk765 EqmJamwEq0e+zvz/LiVCcx2p84j4qjIg2Dhwd9VH8HVzSYNHEyTzMVFTICFvgpRysQb6 LDwOi+evjH8YNc/erk6bru7ByvvCn1rw24HrlkKeJU/xB6ttcGgpOKOYK63ZWqwCKKVG E2BnLMWQh2wL56xAD/lEqpjV0p9dZMRK36c+4B//rxqpr8Hygz6ZZg7Sy20V6a/aHs/Q RRiw== 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=TYSYlSdUn/dXTjpoW2eB+NQW7lqG+bTDZOpmc2h8jwc=; fh=qJ/p4J+HsKIoErDVqhEILECNHE0//9BYOVtHOJtR4CI=; b=Xq1M4l75OTNqAyPPECg+E0JFF0nOPTe+yPmxEGQLXpO59i4JjnwxdimBBbc07kzpXV OOk12YDpFFEM5CseyIpC0uz7JOj2ErdfzFFwVAvWDUi5qjasQNeyqi3QuOCo2JjEGDzY 2oIODALaRPKKqbhHDygTgTheXvnO7RmEDaT7LwxdJQxIni0L/de1bHAAc3/8TDreARFh AYrohUOQ9rxFLohZLYfltstPac8K0+f8OylcM4sJZHHIUaEAgWStdVPGBqeNdP848Y0d vWKhqW1StbuIpBQdj08zrUPPhY6v1N0csqPQIFbVymhqd6XgyC3R5fo2w+d1mcFklxoO mHJQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=g0eIL8rQ; 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-76453-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76453-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id k5-20020a632405000000b005d8e352afefsi10154032pgk.695.2024.02.22.03.54.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 03:54:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76453-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=g0eIL8rQ; 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-76453-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76453-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 820E1B23C62 for ; Thu, 22 Feb 2024 11:53:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 77DF94655D; Thu, 22 Feb 2024 11:51:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b="g0eIL8rQ" Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (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 5C29D47774 for ; Thu, 22 Feb 2024 11:51:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708602670; cv=none; b=meVl2YocZ+AGnHhg2VzJ5dwmrGvKWg/fXvxmpSV+088Kx2Hi+q/8FVRv9738AF9IuIoW5DmU2c0I2i5dR8XZEsqBSDlTTgmwZ3cWBizEWOESnPfEs37e1aOdBFkIz1R14oO4DvJtTkktz3ufCGPTez54Iu4OD3bdaaUdcdUkswQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708602670; c=relaxed/simple; bh=q8kKn6ZoIx/6RjLM+3qIn9pYs3Fc/OtpL0DtI2Q7y9Y=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kh44g4dpeC6ny2khfvW3p9g54DJW/NuCpcaeeC4t2iG7wcGv3T4UHNflcNkdjCi5acqxEtpd8x8oWCncXnASr4eyc94YWh8lVxwWv2uN+pSXA4zQY/JBw9JLWaB/cxqQIEjASJFpqH4FGv3hQmssoEvgu1Txh+rrK67etpkA4ZY= 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=g0eIL8rQ; arc=none smtp.client-ip=209.85.128.50 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-f50.google.com with SMTP id 5b1f17b1804b1-4128d15a4e4so1586095e9.3 for ; Thu, 22 Feb 2024 03:51:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1708602667; x=1709207467; 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=TYSYlSdUn/dXTjpoW2eB+NQW7lqG+bTDZOpmc2h8jwc=; b=g0eIL8rQ2fH0h/GmuUP3dWN5UpXI1266O9mRsn0dXTc6dELpx0UcW5e2PrJ6t2aUKL muVEnyfQpnbF+/9whRcVjKbqO8kQebv7o1tS1YTYa8L8MqPb9tS8Snw5/bFgQ8dIHmjI U4KfdJsn3S+/nyYcrl0MF7sZykYllQrIBlLrRop2BIEvw7iBiMnSh9JrFyynvTe5nFgk RCTWSCEMcvXUXDutjMoaoQL5J/Ai0OUCCGjiyEyq1ywaShnOnPamyi02tM7ltpHyRUMG JJHQid6Sj/4Uzrg4Q6NWZCsXTLQmap0gOs3fiP6ncOqg95hjFmp0KXqg+qrJ2qylAF54 yBSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708602667; x=1709207467; 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=TYSYlSdUn/dXTjpoW2eB+NQW7lqG+bTDZOpmc2h8jwc=; b=Opf25ie2KRFVnvi/tZBocsmW1zRPr43QzzLaSGG1m9FhBlbQIiznMhXJNkIwU6ftSs 49x1ZftDH1l7zm5bbgXzkQy6L2EM3aiW7Rk8PanxrKF1HMAN2fBoIBDt5klhRPQLQedS eu2bnNK/AX1aRIjwdigslsyfLUOIV//UD+liqn8ASgw7dHVZUsSp/zR4u3X3aS7qY5UA l08f6+yH9aLUU7xd3EJv8m7ihtzCeXWNMMya9wvPdN3s3QG6QbNFAdRg9MNjmBSnEu+L nN8wmFZrXnNKUIvGrnun/dZn6bthJxa5hqjZuXW1htNzU/IYYwswSJEom3JdqWidQRgK mMxw== X-Forwarded-Encrypted: i=1; AJvYcCV6b3dbTCxqcW4G5I3GgLhlhleRWtnsxQxJM+zsoZdP3u20R9KDB2qzTWOC3gDNn1KFkFfUjKfDfkrJlWLYqV1ahfX91o21yEPOX4Jq X-Gm-Message-State: AOJu0Yxg4IrwBVRNkvqKvE7XDAzqeJiyRnV0c+B8/AZLcrKKupX0WiTC dt4hMVQraJzDYxIyuHhzhRjP9n929iVkeBm8UkadM6AU0NHuV9oDjGQWPCKipBM= X-Received: by 2002:a05:600c:3c8a:b0:411:9508:e237 with SMTP id bg10-20020a05600c3c8a00b004119508e237mr17669840wmb.19.1708602666816; Thu, 22 Feb 2024 03:51:06 -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.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 03:51:06 -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 05/14] linux/mm.h: move page_address() and others to mm/page_address.h Date: Thu, 22 Feb 2024 12:50:46 +0100 Message-Id: <20240222115055.1172877-6-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: 1791599978324640086 X-GMAIL-MSGID: 1791599978324640086 Prepare to reduce dependencies on linux/mm.h. page_address() is used by the following popular headers: - linux/bio.h - linux/bvec.h - linux/highmem.h - linux/scatterlist.h - linux/skbuff.h Moving it to a separate lean header will allow us to avoid the dependency on linux/mm.h. Signed-off-by: Max Kellermann --- include/linux/mm.h | 56 +------------------------- include/linux/mm/page_address.h | 71 +++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 55 deletions(-) create mode 100644 include/linux/mm/page_address.h diff --git a/include/linux/mm.h b/include/linux/mm.h index 7c3d2bd69818..57c091e7579e 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2,7 +2,7 @@ #ifndef _LINUX_MM_H #define _LINUX_MM_H -#include +#include #include #include #include @@ -103,10 +103,6 @@ extern int mmap_rnd_compat_bits __read_mostly; #define __pa_symbol(x) __pa(RELOC_HIDE((unsigned long)(x), 0)) #endif -#ifndef page_to_virt -#define page_to_virt(x) __va(PFN_PHYS(page_to_pfn(x))) -#endif - #ifndef lm_alias #define lm_alias(x) __va(__pa_symbol(x)) #endif @@ -210,14 +206,6 @@ int overcommit_kbytes_handler(struct ctl_table *, int, void *, size_t *, int overcommit_policy_handler(struct ctl_table *, int, void *, size_t *, loff_t *); -#if defined(CONFIG_SPARSEMEM) && !defined(CONFIG_SPARSEMEM_VMEMMAP) -#define nth_page(page,n) pfn_to_page(page_to_pfn((page)) + (n)) -#define folio_page_idx(folio, p) (page_to_pfn(p) - folio_pfn(folio)) -#else -#define nth_page(page,n) ((page) + (n)) -#define folio_page_idx(folio, p) ((p) - &(folio)->page) -#endif - /* to align the pointer to the (next) page boundary */ #define PAGE_ALIGN(addr) ALIGN(addr, PAGE_SIZE) @@ -2122,44 +2110,6 @@ static inline int arch_make_folio_accessible(struct folio *folio) */ #include -static __always_inline void *lowmem_page_address(const struct page *page) -{ - return page_to_virt(page); -} - -#if defined(CONFIG_HIGHMEM) && !defined(WANT_PAGE_VIRTUAL) -#define HASHED_PAGE_VIRTUAL -#endif - -#if defined(WANT_PAGE_VIRTUAL) -static inline void *page_address(const struct page *page) -{ - return page->virtual; -} -static inline void set_page_address(struct page *page, void *address) -{ - page->virtual = address; -} -#define page_address_init() do { } while(0) -#endif - -#if defined(HASHED_PAGE_VIRTUAL) -void *page_address(const struct page *page); -void set_page_address(struct page *page, void *virtual); -void page_address_init(void); -#endif - -#if !defined(HASHED_PAGE_VIRTUAL) && !defined(WANT_PAGE_VIRTUAL) -#define page_address(page) lowmem_page_address(page) -#define set_page_address(page, address) do { } while(0) -#define page_address_init() do { } while(0) -#endif - -static inline void *folio_address(const struct folio *folio) -{ - return page_address(&folio->page); -} - extern pgoff_t __page_file_index(struct page *page); /* @@ -2222,10 +2172,6 @@ static inline void clear_page_pfmemalloc(struct page *page) */ extern void pagefault_out_of_memory(void); -#define offset_in_page(p) ((unsigned long)(p) & ~PAGE_MASK) -#define offset_in_thp(page, p) ((unsigned long)(p) & (thp_size(page) - 1)) -#define offset_in_folio(folio, p) ((unsigned long)(p) & (folio_size(folio) - 1)) - /* * Parameter block passed down to zap_pte_range in exceptional cases. */ diff --git a/include/linux/mm/page_address.h b/include/linux/mm/page_address.h new file mode 100644 index 000000000000..e1aaacc5003f --- /dev/null +++ b/include/linux/mm/page_address.h @@ -0,0 +1,71 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_MM_PAGE_ADDRESS_H +#define _LINUX_MM_PAGE_ADDRESS_H + +#include // for struct page +#include // needed by the page_to_virt() macro on some architectures (e.g. arm64) +#include // for PAGE_MASK, page_to_virt() + +#if defined(CONFIG_FLATMEM) +#include // for memmap (used by __pfn_to_page()) +#elif defined(CONFIG_SPARSEMEM_VMEMMAP) +#include // for vmemmap (used by __pfn_to_page()) +#elif defined(CONFIG_SPARSEMEM) +#include // for page_to_section() (used by __page_to_pfn()) +#endif + +#ifndef page_to_virt +#define page_to_virt(x) __va(PFN_PHYS(page_to_pfn(x))) +#endif + +#if defined(CONFIG_SPARSEMEM) && !defined(CONFIG_SPARSEMEM_VMEMMAP) +#define nth_page(page,n) pfn_to_page(page_to_pfn((page)) + (n)) +#define folio_page_idx(folio, p) (page_to_pfn(p) - folio_pfn(folio)) +#else +#define nth_page(page,n) ((page) + (n)) +#define folio_page_idx(folio, p) ((p) - &(folio)->page) +#endif + +static __always_inline void *lowmem_page_address(const struct page *page) +{ + return page_to_virt(page); +} + +#if defined(CONFIG_HIGHMEM) && !defined(WANT_PAGE_VIRTUAL) +#define HASHED_PAGE_VIRTUAL +#endif + +#if defined(WANT_PAGE_VIRTUAL) +static inline void *page_address(const struct page *page) +{ + return page->virtual; +} +static inline void set_page_address(struct page *page, void *address) +{ + page->virtual = address; +} +#define page_address_init() do { } while(0) +#endif + +#if defined(HASHED_PAGE_VIRTUAL) +void *page_address(const struct page *page); +void set_page_address(struct page *page, void *virtual); +void page_address_init(void); +#endif + +#if !defined(HASHED_PAGE_VIRTUAL) && !defined(WANT_PAGE_VIRTUAL) +#define page_address(page) lowmem_page_address(page) +#define set_page_address(page, address) do { } while(0) +#define page_address_init() do { } while(0) +#endif + +static inline void *folio_address(const struct folio *folio) +{ + return page_address(&folio->page); +} + +#define offset_in_page(p) ((unsigned long)(p) & ~PAGE_MASK) +#define offset_in_thp(page, p) ((unsigned long)(p) & (thp_size(page) - 1)) +#define offset_in_folio(folio, p) ((unsigned long)(p) & (folio_size(folio) - 1)) + +#endif /* _LINUX_MM_PAGE_ADDRESS_H */ From patchwork Thu Feb 22 11:50:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Kellermann X-Patchwork-Id: 204724 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:aa16:b0:108:e6aa:91d0 with SMTP id by22csp198196dyb; Thu, 22 Feb 2024 03:55:00 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWalPSM4NB68gtHlZMzjXFJuhYLoVXu0a90vqgeL02vOIxRMy5fRskr2icvOoJxk0RAB3ytq6jOjJoTXpTpaipzNWCV/A== X-Google-Smtp-Source: AGHT+IGLCgFlHhKdi5OMeICov/qVSp2oAuXYfFmk4Df4bDF6VAlgsC7HVS+vtmdSLJC8PWHy52Se X-Received: by 2002:a17:90a:c394:b0:299:2cba:7588 with SMTP id h20-20020a17090ac39400b002992cba7588mr16654031pjt.1.1708602900565; Thu, 22 Feb 2024 03:55:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708602900; cv=pass; d=google.com; s=arc-20160816; b=ZPMlwIPyGQuaF1OU3zRCih3Nk0/rEU15wRdxSz/A3XNPca+WSqz97TwUIPJwicojp5 6RbuDpVlkS/cgd2ZqBkq5VYSDYHrIXN8aGNFDzIwg3Lfb/oDLlykd9ONCDFV4yqSbA/k +Y2FYZh0c0tGH0a8YSsuDCWEw63a+qVgSjpMOK1X4XdiS5hR4LsZGuxy5nMWp4urSP+q EzWfAERT43l1WdCeHP0r9/gQd3AVDs244UQgWTENbtYLuMxsv0QprIg0w7f/KpDSpdLB UXsdv3ILrz1Xjx3TB8B74UACrELelBOuU+Q5L7e0KmwteyLu+WvuXjJcTuCp1wnK7GBx lmMw== 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=zrzkS3Jr9rDGJgnZMZCc9dS49bV9O/AFecbIWIE3ZsM=; fh=WBKBGWCB3kCqaAe1zAIy+nT4wB4XIWnyYOBSH9VtMuI=; b=QO+c7bBOzB7O+dns+F41e38I0no4oek+WrWW/+dVkiNy9tP/q69MMIHU+/1y2+O3l0 gwfzTAg5S7pu/lspdZkvVweQVtVR/xiHisJ3HGFBD9NsOhVmtBOWT+i9/QWktiAIbQAp bMSwqRJnjmWVa9C3jLKXrrr/aBNDQ7wjKNudlKxtwHDJ5Pn+3cUTkiu0VSCYI26ZOmLt Lpm9W1PG4yMB7Vgpojrwv7CzNYpviXmlMe2LjGaCDPwgIJvE38PefOshuWtmv3CxQ/ou V3JOUhHpaBPP7iUFLJX7rvwylSMtJ4YW7ypM8wij2aIRp+ow2ouSJSRiZg1dpFzjK+zA q81Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=OpSb1LuY; 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-76454-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76454-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id n18-20020a17090ade9200b002997a9e041esi3384921pjv.184.2024.02.22.03.55.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 03:55:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76454-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=OpSb1LuY; 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-76454-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76454-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 311A5B24ACA for ; Thu, 22 Feb 2024 11:53:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2133B4DA1A; Thu, 22 Feb 2024 11:51:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b="OpSb1LuY" Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.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 A58B347F6C for ; Thu, 22 Feb 2024 11:51:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708602672; cv=none; b=F+wq7+Mi7glQkMDOsTyHq5dhn6tiw7ov86dbrU+eyJH7npsNe7AacSIVxjQyG/HEAZElUjWmHETnUvAUglycxCRwZg/uFxtsPTvBpDmhcoasVcI2DndyVu6FxHoPm0Eodkl/bYJ8fSlvkN9cOsgTK5dFakYtBvJCUcJFpNI7p5k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708602672; c=relaxed/simple; bh=N8Ly4oEy5piq03Mm8FrpU9io5s7b24dCbY2FPMutdCg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DNqDOuQYwieu8B1tcu8WoVOuf4HoDqPb+n2g5q/d02LrdiBfYSjfO3EvpHzcB6H8IIwMD5U5nJd/0hM47uU8WNDjCpDjMeLt6jdT9GTKO5rAgpDKkTOKkDS+G+fim18pLMQOVFYdHoj0up7d3su7TFT4JmaK1cKQ5XkNixfbLVo= 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=OpSb1LuY; arc=none smtp.client-ip=209.85.221.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-wr1-f43.google.com with SMTP id ffacd0b85a97d-33d36736d4eso3480074f8f.1 for ; Thu, 22 Feb 2024 03:51:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1708602668; x=1709207468; 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=zrzkS3Jr9rDGJgnZMZCc9dS49bV9O/AFecbIWIE3ZsM=; b=OpSb1LuYX/E2V3o/GDNfqnmgD6DcYEEF4WcPmPmDmGPUKqdrlmTQ87YBx05oal1q6K 7V7ExPJNWRFXT6L/k1rZ0if09Df3VNHHgoTde3GFWYijRoSEVGK9jMfU6GzrB222O1wZ +Lax6oZ5khapzeaQA7dKmTOdAJHNS4y/l/0Met+JW/eRAA2DLPon2OBJodg8RYb52Fwd N5eh1VHgSFJHb6CJ2PSJKnOw2AXlfgMpAMa9Gk/xDv6CpYoHD5U7HvGNkpvhIS2qFfp9 0Hhp0OsL8xeznoa/CvpqO/WJUuhe8OnavVzzTskmh1zDoVnAWy/9bwm7EXB4BmPf6qJk OWLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708602668; x=1709207468; 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=zrzkS3Jr9rDGJgnZMZCc9dS49bV9O/AFecbIWIE3ZsM=; b=PTXDiuhqoe5nns21h2Vcc7yZHZuljsQVAsub8sLnWRirhQOii0Ejq2peeHljFGuC+S dRALDIuNaw1YaM3+IefNRkn37OOYDlDipL+3DT4Rn5CdQ6FwNmuD7XaqG+UikH1AehEL psxI9rb6oUKrM8BissnqI3tbapPL/P8racy86WXIR1/uW99eFmh5fIFaTK24uY6bwM/Z nkB7irggCgNhJol6gxEANyWdEyGIHxbZEECjkbEgFCcEScxPXI6qPx0OWq/p2UC7RrIc jPsrUFW9iA5a7hjj8+8xYuL6lhU6YUQNnbiL8rU00ugqMmyu3o5wuIWcJQiBVskhVq2W VRng== X-Forwarded-Encrypted: i=1; AJvYcCUkCfT3rTyPo7Ol8Fd9bfCbJb+0LE86ubN6DQ9iXWnk5WeqEE4rxlM+Bsqsl6O4soG+DP1pPpDnj5TrTWGEEGONq0EjxNXhUKQLIQol X-Gm-Message-State: AOJu0YyFX/nu2PEnNetStCMkt34azAwqJ1wpwqvI6788DUG8gGwEeJz/ 8hyexBgzqqtU0XpIak2IoAIHuQMoTx0CLtjuV7I8oVHmqFKaR7SsatjmnZwxoCg= X-Received: by 2002:a5d:54c4:0:b0:33d:887c:fe04 with SMTP id x4-20020a5d54c4000000b0033d887cfe04mr1569315wrv.19.1708602667899; Thu, 22 Feb 2024 03:51:07 -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.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 03:51:07 -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 06/14] linux/mm.h: move folio_size(), ... to mm/folio_size.h Date: Thu, 22 Feb 2024 12:50:47 +0100 Message-Id: <20240222115055.1172877-7-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: 1791599994983831061 X-GMAIL-MSGID: 1791599994983831061 Prepare to reduce dependencies on linux/mm.h. folio_size()/page_size() are used by the following popular headers: - linux/highmem.h - linux/iov_iter.h - linux/pagemap.h Moving them to a separate lean header will allow us to avoid the dependency on linux/mm.h. Additionally, it allows us to move folio_next() to a separate header, because it needs folio_nr_pages() which is also moved to folio_size.h. Signed-off-by: Max Kellermann --- include/linux/mm.h | 140 +------------------------------ include/linux/mm/folio_size.h | 150 ++++++++++++++++++++++++++++++++++ 2 files changed, 151 insertions(+), 139 deletions(-) create mode 100644 include/linux/mm/folio_size.h diff --git a/include/linux/mm.h b/include/linux/mm.h index 57c091e7579e..9dea6477b4ac 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2,6 +2,7 @@ #ifndef _LINUX_MM_H #define _LINUX_MM_H +#include #include #include #include @@ -1054,38 +1055,6 @@ int vma_is_stack_for_current(struct vm_area_struct *vma); struct mmu_gather; struct inode; -/* - * compound_order() can be called without holding a reference, which means - * that niceties like page_folio() don't work. These callers should be - * prepared to handle wild return values. For example, PG_head may be - * set before the order is initialised, or this may be a tail page. - * See compaction.c for some good examples. - */ -static inline unsigned int compound_order(struct page *page) -{ - struct folio *folio = (struct folio *)page; - - if (!test_bit(PG_head, &folio->flags)) - return 0; - return folio->_flags_1 & 0xff; -} - -/** - * folio_order - The allocation order of a folio. - * @folio: The folio. - * - * A folio is composed of 2^order pages. See get_order() for the definition - * of order. - * - * Return: The order of the folio. - */ -static inline unsigned int folio_order(struct folio *folio) -{ - if (!folio_test_large(folio)) - return 0; - return folio->_flags_1 & 0xff; -} - #include /* @@ -1299,39 +1268,6 @@ unsigned long nr_free_buffer_pages(void); void destroy_large_folio(struct folio *folio); -/* Returns the number of bytes in this potentially compound page. */ -static inline unsigned long page_size(struct page *page) -{ - return PAGE_SIZE << compound_order(page); -} - -/* Returns the number of bits needed for the number of bytes in a page */ -static inline unsigned int page_shift(struct page *page) -{ - return PAGE_SHIFT + compound_order(page); -} - -/** - * thp_order - Order of a transparent huge page. - * @page: Head page of a transparent huge page. - */ -static inline unsigned int thp_order(struct page *page) -{ - VM_BUG_ON_PGFLAGS(PageTail(page), page); - return compound_order(page); -} - -/** - * thp_size - Size of a transparent huge page. - * @page: Head page of a transparent huge page. - * - * Return: Number of bytes in this page. - */ -static inline unsigned long thp_size(struct page *page) -{ - return PAGE_SIZE << thp_order(page); -} - #ifdef CONFIG_MMU /* * Do pte_mkwrite, but only if the vma says VM_WRITE. We do this when @@ -1971,50 +1907,6 @@ static inline void set_page_links(struct page *page, enum zone_type zone, #endif } -/** - * folio_nr_pages - The number of pages in the folio. - * @folio: The folio. - * - * Return: A positive power of two. - */ -static inline long folio_nr_pages(struct folio *folio) -{ - if (!folio_test_large(folio)) - return 1; -#ifdef CONFIG_64BIT - return folio->_folio_nr_pages; -#else - return 1L << (folio->_flags_1 & 0xff); -#endif -} - -/* - * compound_nr() returns the number of pages in this potentially compound - * page. compound_nr() can be called on a tail page, and is defined to - * return 1 in that case. - */ -static inline unsigned long compound_nr(struct page *page) -{ - struct folio *folio = (struct folio *)page; - - if (!test_bit(PG_head, &folio->flags)) - return 1; -#ifdef CONFIG_64BIT - return folio->_folio_nr_pages; -#else - return 1L << (folio->_flags_1 & 0xff); -#endif -} - -/** - * thp_nr_pages - The number of regular pages in this huge page. - * @page: The head page of a huge page. - */ -static inline int thp_nr_pages(struct page *page) -{ - return folio_nr_pages((struct folio *)page); -} - /** * folio_next - Move to the next physical folio. * @folio: The folio we're currently operating on. @@ -2034,36 +1926,6 @@ static inline struct folio *folio_next(struct folio *folio) return (struct folio *)folio_page(folio, folio_nr_pages(folio)); } -/** - * folio_shift - The size of the memory described by this folio. - * @folio: The folio. - * - * A folio represents a number of bytes which is a power-of-two in size. - * This function tells you which power-of-two the folio is. See also - * folio_size() and folio_order(). - * - * Context: The caller should have a reference on the folio to prevent - * it from being split. It is not necessary for the folio to be locked. - * Return: The base-2 logarithm of the size of this folio. - */ -static inline unsigned int folio_shift(struct folio *folio) -{ - return PAGE_SHIFT + folio_order(folio); -} - -/** - * folio_size - The number of bytes in a folio. - * @folio: The folio. - * - * Context: The caller should have a reference on the folio to prevent - * it from being split. It is not necessary for the folio to be locked. - * Return: The number of bytes in this folio. - */ -static inline size_t folio_size(struct folio *folio) -{ - return PAGE_SIZE << folio_order(folio); -} - /** * folio_estimated_sharers - Estimate the number of sharers of a folio. * @folio: The folio. diff --git a/include/linux/mm/folio_size.h b/include/linux/mm/folio_size.h new file mode 100644 index 000000000000..dd8af39ef572 --- /dev/null +++ b/include/linux/mm/folio_size.h @@ -0,0 +1,150 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_MM_FOLIO_SIZE_H +#define _LINUX_MM_FOLIO_SIZE_H + +#include // for test_bit() +#include // for VM_BUG_ON_PGFLAGS() +#include // for struct page +#include // for folio_test_large() +#include // for PAGE_SIZE, PAGE_SHIFT + +/* + * compound_order() can be called without holding a reference, which means + * that niceties like page_folio() don't work. These callers should be + * prepared to handle wild return values. For example, PG_head may be + * set before the order is initialised, or this may be a tail page. + * See compaction.c for some good examples. + */ +static inline unsigned int compound_order(struct page *page) +{ + struct folio *folio = (struct folio *)page; + + if (!test_bit(PG_head, &folio->flags)) + return 0; + return folio->_flags_1 & 0xff; +} + +/** + * folio_order - The allocation order of a folio. + * @folio: The folio. + * + * A folio is composed of 2^order pages. See get_order() for the definition + * of order. + * + * Return: The order of the folio. + */ +static inline unsigned int folio_order(struct folio *folio) +{ + if (!folio_test_large(folio)) + return 0; + return folio->_flags_1 & 0xff; +} + +/* Returns the number of bytes in this potentially compound page. */ +static inline unsigned long page_size(struct page *page) +{ + return PAGE_SIZE << compound_order(page); +} + +/* Returns the number of bits needed for the number of bytes in a page */ +static inline unsigned int page_shift(struct page *page) +{ + return PAGE_SHIFT + compound_order(page); +} + +/** + * thp_order - Order of a transparent huge page. + * @page: Head page of a transparent huge page. + */ +static inline unsigned int thp_order(struct page *page) +{ + VM_BUG_ON_PGFLAGS(PageTail(page), page); + return compound_order(page); +} + +/** + * thp_size - Size of a transparent huge page. + * @page: Head page of a transparent huge page. + * + * Return: Number of bytes in this page. + */ +static inline unsigned long thp_size(struct page *page) +{ + return PAGE_SIZE << thp_order(page); +} + +/** + * folio_nr_pages - The number of pages in the folio. + * @folio: The folio. + * + * Return: A positive power of two. + */ +static inline long folio_nr_pages(struct folio *folio) +{ + if (!folio_test_large(folio)) + return 1; +#ifdef CONFIG_64BIT + return folio->_folio_nr_pages; +#else + return 1L << (folio->_flags_1 & 0xff); +#endif +} + +/* + * compound_nr() returns the number of pages in this potentially compound + * page. compound_nr() can be called on a tail page, and is defined to + * return 1 in that case. + */ +static inline unsigned long compound_nr(struct page *page) +{ + struct folio *folio = (struct folio *)page; + + if (!test_bit(PG_head, &folio->flags)) + return 1; +#ifdef CONFIG_64BIT + return folio->_folio_nr_pages; +#else + return 1L << (folio->_flags_1 & 0xff); +#endif +} + +/** + * thp_nr_pages - The number of regular pages in this huge page. + * @page: The head page of a huge page. + */ +static inline int thp_nr_pages(struct page *page) +{ + return folio_nr_pages((struct folio *)page); +} + +/** + * folio_shift - The size of the memory described by this folio. + * @folio: The folio. + * + * A folio represents a number of bytes which is a power-of-two in size. + * This function tells you which power-of-two the folio is. See also + * folio_size() and folio_order(). + * + * Context: The caller should have a reference on the folio to prevent + * it from being split. It is not necessary for the folio to be locked. + * Return: The base-2 logarithm of the size of this folio. + */ +static inline unsigned int folio_shift(struct folio *folio) +{ + return PAGE_SHIFT + folio_order(folio); +} + +/** + * folio_size - The number of bytes in a folio. + * @folio: The folio. + * + * Context: The caller should have a reference on the folio to prevent + * it from being split. It is not necessary for the folio to be locked. + * Return: The number of bytes in this folio. + */ +static inline size_t folio_size(struct folio *folio) +{ + return PAGE_SIZE << folio_order(folio); +} + +#endif /* _LINUX_MM_FOLIO_SIZE_H_H */ From patchwork Thu Feb 22 11:50:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Kellermann X-Patchwork-Id: 204720 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:aa16:b0:108:e6aa:91d0 with SMTP id by22csp197580dyb; Thu, 22 Feb 2024 03:53:28 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUx+i2yGAGjBvmm0472ghrP2Cxclnd0m6R9WqFmtvf2CdsGhhF60lywMTxF+QEEUFSqCu3OrHzUtL4q3WU35YLAVJE2Mw== X-Google-Smtp-Source: AGHT+IGRVq+8grxYH7OGWcEJUriCbk2l24q2cbfxtdWLz49afETaHZrT7LmaE3O16K6cNfZB9j8O X-Received: by 2002:a17:902:b414:b0:1d9:586d:5d81 with SMTP id x20-20020a170902b41400b001d9586d5d81mr17222567plr.47.1708602808270; Thu, 22 Feb 2024 03:53:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708602808; cv=pass; d=google.com; s=arc-20160816; b=hDo5HWFglkXaEEUkY5JeazUR1cRslp1bWpc1NUC+wEVHsrMmcJ+ACPxBnvd1unVq57 Vip9b4DiVguCALBVRHhiVf1xmN9cE1mUMRECvUqmVQBk7lHFWoWPnCWyB7w5/4Xa1Ouk kOj0aFJ/m0gCvMGgmAU7RNgKSVrN3dyBDYC6TPE3ZuaT3F6EayiDZa346Rk3hesyWUS7 MCjG6gi7SUnPmL2lMx3U7bWd6nNz4UoRzkbdeuOMSaTqqySzYYU4dfykRYo5Vuf9tBRx gdl4x2QWyH/xWiYpjWhlN7QCVhJpfeOXw+hy23ZJTrOTYn+cB8c/t9ZJq9V0Zi9kbWwy b92g== 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=B9RcqoFubCuQScg9fnwnkgqqvXJKp60zqkqXexg+avE=; fh=W14nudP5/fnfW71KEgToqMX2BhOBLSk+LbULH3sCY2U=; b=mf0NN7eS7/9Xbmqi3dUYYQ6yqYO5o2QNqdhhiRBQgpWejBquYLarlpNdcJSqp1gHiL W4COx+IhhEULhBi4svRIV/ugGjgnvpbgwP/zKoGP4J+6gPDzDtMvajcFjAnDBvq6k/tY xVWxU6GnwKuaxFz1HwDvgogMJCAA4R0sFjln828/24B/ryxbVOxERHhbHkZQfB9DSMGP Ds5y3LHu8cDV4Cl/ZdPSjOy7NmV7+DLnNboB4ZsqwQYzaWwBc2XgVGXIWVuxs+GjG6dn Kmb6HwTRO1Ey8x9dmFS/FuERwj9T6hhx81q8Jmo+k0KCbFtA3pI2HR7zvJTfrMlH47iO v70g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b="Wq/gEQTZ"; 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-76456-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76456-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id o9-20020a170902d4c900b001d944e92be8si10091786plg.146.2024.02.22.03.53.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 03:53:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76456-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b="Wq/gEQTZ"; 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-76456-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76456-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 12175282E0C for ; Thu, 22 Feb 2024 11:53:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0B5354EB22; Thu, 22 Feb 2024 11:51:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b="Wq/gEQTZ" Received: from mail-lj1-f171.google.com (mail-lj1-f171.google.com [209.85.208.171]) (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 BB463487B3 for ; Thu, 22 Feb 2024 11:51:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708602674; cv=none; b=e4NfRsMD6UcYxLJDVbHDuNhnD17nhQSbOZYGewstt3Y4RJgjCln4O4wCO44hxmI0VbRDvIL9AjlwQFd2Ng2uGKUYqztP9kvlLrDIsCf/P3oPdDtuWy0J/yf3WQcGPcDK+Kc5ehXdCvy5ZHEeDoIJHkCVI6wTztPoGs3p2BEKu6Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708602674; c=relaxed/simple; bh=nGXby0NmJJV7zXYu/W6/SBzCu1Ho1ka1ItR5hSRX0fs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=iy7UYMSLZdnIhpuWui46zWi8GLBeAkQhDf86n7dfa+HyglxuNCu2yxfRCKsq88kbDqdu409ZhMwsmYVMbxGTT4wGM0LUP5LJ+cGyf7iQi7NoWFOUJrQS6luXeMxaWr1FhTkDgq2BUpvAr7nSMg3LjF7SJ60uzcNhvsNDy1Q8lq0= 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=Wq/gEQTZ; arc=none smtp.client-ip=209.85.208.171 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-lj1-f171.google.com with SMTP id 38308e7fff4ca-2d1094b5568so99787731fa.1 for ; Thu, 22 Feb 2024 03:51:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1708602669; x=1709207469; 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=B9RcqoFubCuQScg9fnwnkgqqvXJKp60zqkqXexg+avE=; b=Wq/gEQTZ7rrxE2gu4QiZ/mirmJUeINetqgd+mt3Scw4DVXbGKSPbb7w7DmDxZj1UEA Or/FdYtqLPtg/zuyZLkSojYnnHie4qHAnqs3AcB3cQGaFVKc+HubIavh/yAm5heOCG2o Rj+MQk5Xlt8Phu4a9UVCMPcW5ndh9AYDMSV7P+HR8HSL0SWZQofGks9jIThYGpBAbnaY bAI2/xxsoE8vGZ8lKzYcs0hbQ2CWu8RpwfHimpGbvHJJZ98h1Wx5SeDcKSHsvEWwTAs5 a3q4IexBAjb4ylDofOhI23c57nuJTzZOcg8yOkwPTtLi8bSs1JPihZHpPOnfAyB+EihZ BAnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708602669; x=1709207469; 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=B9RcqoFubCuQScg9fnwnkgqqvXJKp60zqkqXexg+avE=; b=ih2Xx5GaUpz6XZqyXHSiZZvykPFnCnboXU1xsw+WkazB9y7FGaV4KD29Oj+hF/qyGe RWhikjjMaY5mtvgjSjSsakqi7eiH81FbyY43BRJHCrf+AqPrKzSdQiod/j/9EivMyoLc 63CnzIr/0dHa2SwHvTMIvfCx7yx+V5VgFIXoa1b/KngrQZDbN+EXfBkHYdg4f8QoebeX zEjyEjP4E1LcEh77SPHAEP9GgcZBK6tBwFi3lCigBRYvVdvbDybzypRtCdl+PdV9bjMf pCd0JpqjVhEJcDFNTjXdF01GNKr9+aITYpypxpOgYbtFD/rCTncybSr0pXsODABWCiQG RWRg== X-Forwarded-Encrypted: i=1; AJvYcCUv8z+uW1JEYirkwuj67n7mu0Y87zbe9uewGw/8EXOIrfotYamAmW4gr/e24vmFLzXIxvS5eM+zXXMGOgX3BDv9ksIKDH/vDZhd53mX X-Gm-Message-State: AOJu0YyqebvZX7OfaRjztPp6h2u9+k/fnBOoujsyCof4lqw3v9qQhGZx 7+mSP9KCsLV1KYYbwfKUXT7rESsehsVJ7+lwXdo2a/hfCeXdY6ZTCZ4yLagMvgQ= X-Received: by 2002:a2e:968e:0:b0:2d2:43fd:391b with SMTP id q14-20020a2e968e000000b002d243fd391bmr6042449lji.26.1708602668784; Thu, 22 Feb 2024 03:51:08 -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.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 03:51:08 -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 07/14] linux/mm.h: move folio_next() to mm/folio_next.h Date: Thu, 22 Feb 2024 12:50:48 +0100 Message-Id: <20240222115055.1172877-8-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: 1791599897991676359 X-GMAIL-MSGID: 1791599897991676359 Prepare to reduce dependencies on linux/mm.h. folio_next() is used by linux/bio.h. Moving it to a separate lean header will allow us to avoid the dependency on linux/mm.h. Signed-off-by: Max Kellermann --- include/linux/mm.h | 20 +------------------- include/linux/mm/folio_next.h | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 19 deletions(-) create mode 100644 include/linux/mm/folio_next.h diff --git a/include/linux/mm.h b/include/linux/mm.h index 9dea6477b4ac..7d83d6d64f30 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2,6 +2,7 @@ #ifndef _LINUX_MM_H #define _LINUX_MM_H +#include #include #include #include @@ -1907,25 +1908,6 @@ static inline void set_page_links(struct page *page, enum zone_type zone, #endif } -/** - * folio_next - Move to the next physical folio. - * @folio: The folio we're currently operating on. - * - * If you have physically contiguous memory which may span more than - * one folio (eg a &struct bio_vec), use this function to move from one - * folio to the next. Do not use it if the memory is only virtually - * contiguous as the folios are almost certainly not adjacent to each - * other. This is the folio equivalent to writing ``page++``. - * - * Context: We assume that the folios are refcounted and/or locked at a - * higher level and do not adjust the reference counts. - * Return: The next struct folio. - */ -static inline struct folio *folio_next(struct folio *folio) -{ - return (struct folio *)folio_page(folio, folio_nr_pages(folio)); -} - /** * folio_estimated_sharers - Estimate the number of sharers of a folio. * @folio: The folio. diff --git a/include/linux/mm/folio_next.h b/include/linux/mm/folio_next.h new file mode 100644 index 000000000000..7016e303439c --- /dev/null +++ b/include/linux/mm/folio_next.h @@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_MM_FOLIO_NEXT_H +#define _LINUX_MM_FOLIO_NEXT_H + +#include // for folio_nr_pages() +#include // for nth_page(), needed by folio_page() + +/** + * folio_next - Move to the next physical folio. + * @folio: The folio we're currently operating on. + * + * If you have physically contiguous memory which may span more than + * one folio (eg a &struct bio_vec), use this function to move from one + * folio to the next. Do not use it if the memory is only virtually + * contiguous as the folios are almost certainly not adjacent to each + * other. This is the folio equivalent to writing ``page++``. + * + * Context: We assume that the folios are refcounted and/or locked at a + * higher level and do not adjust the reference counts. + * Return: The next struct folio. + */ +static inline struct folio *folio_next(struct folio *folio) +{ + return (struct folio *)folio_page(folio, folio_nr_pages(folio)); +} + +#endif /* _LINUX_MM_FOLIO_NEXT_H */ From patchwork Thu Feb 22 11:50:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Kellermann X-Patchwork-Id: 204718 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:aa16:b0:108:e6aa:91d0 with SMTP id by22csp197490dyb; Thu, 22 Feb 2024 03:53:18 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV0LKztItobyU7J+dOG0J+kZbHfaibMMfDsactUdzXQ4FMRQzKNx/MwX6nxHpxFQQ6044vQNUccGeTHYINv9lvSwq/nwg== X-Google-Smtp-Source: AGHT+IFtqYZi6rfiJSLEpXWKHrPbiRQ/LUUGvieIBauhU2ePLabW3s9tftnoX7dCFTf3OKJm7YCf X-Received: by 2002:a17:902:c94e:b0:1db:def5:17e4 with SMTP id i14-20020a170902c94e00b001dbdef517e4mr16959300pla.7.1708602797861; Thu, 22 Feb 2024 03:53:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708602797; cv=pass; d=google.com; s=arc-20160816; b=EcSKilQLmyT11szh/6zCoXKCLnaOL9lHwRDpP30yHk6nwZCx1mUTJd2rnmpQ+8FNVR OrVg0dRNjnMqI3Onaut/iRcI4qksyza4NMOlzSUDLQVlbyqBSZwkFx+xa6iLgoVMLkj2 2mEdOOqXuINnz9p6nYGrJMZdkiwrCEhU4bxZqIrrn+N7UWaTE1WGSNUU6vXy89uRZpUn LoYVCN+6c2XgC8tApazCsZI2TXw1e17Jdc1d+11+7tY535jroFhEqCF1mRixWDkGTGbu DfFdlGCZGFA4x0owWyAN/16EW5159N54p4qnFAcHUE2GOUI8461ofUaNSTrOoVv+GWnD GC8Q== 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=kxFeZ/0ASaJvoJHkw5FuQa0hU1Ih3iAyraY4h2cFePg=; fh=AFd4HwAe6u8h7a++skJcOLP4JeKks0aoeSlj4tAZX+I=; b=gFCOkrKsFIXde88siENsD/Ss/FNc9YWG/bNQer7A960W4R5yLeRl8xVfYzNK/wUcqP fjECFnjP4fnXnnG8InnEjNtcjfYEW1z91peqYBq+Rdr692pbBA+LKEK35UDhzh6JVAyq lMf67vpmBDlE3EH8K5K6EwzdYii6yErNQPp+KfOdodncftjcD/grPbbBaAlNwNQrynhv qOMV7Pkl+nwkawQgLMPvfbK7wlTgpCCygCKs1Y2O9NNEUraNbe4vaYA9WMKvTu0b6rpP LmD3/RfYuFbnyyd9Z1sINpMddX4tMHTLhqpc2HaYGBMTxEBWsEKnq1wNj6hbL3XsGuOV 53MQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=M4tb2t7I; 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-76455-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76455-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id x2-20020a170902fe8200b001db57f32f38si9742799plm.463.2024.02.22.03.53.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 03:53:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76455-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=M4tb2t7I; 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-76455-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76455-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id A341A283416 for ; Thu, 22 Feb 2024 11:53:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7B4DE4E1BD; Thu, 22 Feb 2024 11:51:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b="M4tb2t7I" Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (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 603D94C60B for ; Thu, 22 Feb 2024 11:51:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708602673; cv=none; b=NFccgsGyvyIp1FAJPJE3QZXWCshRpr1gMz3drSNEh3pyHYvy8AyjctYTra0NO/v2O6ynedpxvwbQ6jGHf/byqUEZN9OjlFtPahvZ+xrpwezMil2ugUSljQAZIkTpBJCyQ+ZnfNGOQT3WjmsTE32X1GRW7I2bZV0sEKADQTQVY5c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708602673; c=relaxed/simple; bh=YID5EHIsC8yhor+I6AoFup3aQLQc9ccnLMMd80bhUqs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RgxVXHeo18KPryRbJ9SsQAMRDIECZdbPDkEOUxzLuOUSNW/PuKjhM7VXY9Luhr7azzaB5ASMFhKFgbbvYaaCAmuCPT2Z05Nd6GJhOh4jEr3+IUduCoQctEaiuVuOjMFwDRFu+nrfrbs3eNt8qCyut/zK/dMYaUopEgF5scvApDc= 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=M4tb2t7I; arc=none smtp.client-ip=209.85.221.52 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-wr1-f52.google.com with SMTP id ffacd0b85a97d-33d9c3f36c2so128455f8f.2 for ; Thu, 22 Feb 2024 03:51:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1708602669; x=1709207469; 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=kxFeZ/0ASaJvoJHkw5FuQa0hU1Ih3iAyraY4h2cFePg=; b=M4tb2t7Icr6vscFWaupRbi4WvvLYyiNzureWIuzKd/QSU2HbWoGg+GXDZ0B4MrCTdx cjTM18zeNRFnzaEy93H9l6hCZrTBk13ULnI/KEba/wOWU/sGXTVlsmqSO4qJh29rRxbL aLPyYRHzHSdqQPD7amHpniUA2M/W8xdDEX6bwCc+2xMXMNPkjlQ5KiNNO8YLGivw5Vju /xcQx1HefC/uqqIjGtuiaazSPcfvJqABsyYU90/4jtihza33fba5Y0IrANwAJWqlNpOB ZGtblZ7gllObeWfXh62v/ZCihiyzWNhd9QYkttOmG4f3/GdKirEiFf1NZuJH5sukC/NZ 97ZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708602669; x=1709207469; 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=kxFeZ/0ASaJvoJHkw5FuQa0hU1Ih3iAyraY4h2cFePg=; b=F+2Ovq31Pe8UJ0TQzXRJf31jkJ8xw5NLHu24bNB/fz3wzloiBXayaD5zkuhqEuVghy epIG6OdgSbcfT+bESBSFtnO22OYj6xQvL/Q8pJdxU6Url0gHjV80lcZA8w3GmupF+7er 3y4NMGX1zC8tSlONqlfHxhe/RSfBIqign/10JHOswfOAOCYOGJnZ8stIq3t+AlBnNfM7 CZTHWMiHcUxGXP8+mXQb1hnhv+XgcVAuNSqiShxCSjaooTKd0X/pH15Q37bui9/qX95t KRBIGDicTUaa+be4c9nVG3PRIZtHHrO9LOCti1Q71ifDVeAIQsx/KVbzFQcrIQmOoq1e lUeQ== X-Forwarded-Encrypted: i=1; AJvYcCWmPv0+dD7T2takYokrYVdEpv23Dcm9HAQWdFUxA139RvNBr7xAKCMBoN6o59U18z/LKmAY0GcwSikc8rY6Jf+ItLxvTewcfg/L+e9y X-Gm-Message-State: AOJu0YygCJjOzkduGrk5yyB3E5SLH89EQJDe/Ayj+EGdtivJmWHXbN0F 5dYDiBoR5jeuZo8mhZuRY8M0vUvzxLGAgYhC188yiLWD+Fio+2YEN5qCTQyXwrcq11I2Le4eKuC w X-Received: by 2002:a05:6000:1787:b0:33d:56a0:88e3 with SMTP id e7-20020a056000178700b0033d56a088e3mr8736928wrg.65.1708602669683; Thu, 22 Feb 2024 03:51:09 -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.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 03:51:09 -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 08/14] linux/mm.h: move devmap-related declarations to mm/devmap_managed.h Date: Thu, 22 Feb 2024 12:50:49 +0100 Message-Id: <20240222115055.1172877-9-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: 1791599887412632289 X-GMAIL-MSGID: 1791599887412632289 Prepare to reduce dependencies on linux/mm.h. put_devmap_managed_page() is called by put_page(). Moving it to a separate header allows us to move put_page() to a separate lean header as well. Signed-off-by: Max Kellermann --- include/linux/mm.h | 24 -------------------- include/linux/mm/devmap_managed.h | 37 +++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 24 deletions(-) create mode 100644 include/linux/mm/devmap_managed.h diff --git a/include/linux/mm.h b/include/linux/mm.h index 7d83d6d64f30..7a302da7de24 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1350,30 +1350,6 @@ vm_fault_t finish_fault(struct vm_fault *vmf); * back into memory. */ -#if defined(CONFIG_ZONE_DEVICE) && defined(CONFIG_FS_DAX) -DECLARE_STATIC_KEY_FALSE(devmap_managed_key); - -bool __put_devmap_managed_page_refs(struct page *page, int refs); -static inline bool put_devmap_managed_page_refs(struct page *page, int refs) -{ - if (!static_branch_unlikely(&devmap_managed_key)) - return false; - if (!is_zone_device_page(page)) - return false; - return __put_devmap_managed_page_refs(page, refs); -} -#else /* CONFIG_ZONE_DEVICE && CONFIG_FS_DAX */ -static inline bool put_devmap_managed_page_refs(struct page *page, int refs) -{ - return false; -} -#endif /* CONFIG_ZONE_DEVICE && CONFIG_FS_DAX */ - -static inline bool put_devmap_managed_page(struct page *page) -{ - return put_devmap_managed_page_refs(page, 1); -} - /* 127: arbitrary random number, small enough to assemble well */ #define folio_ref_zero_or_close_to_overflow(folio) \ ((unsigned int) folio_ref_count(folio) + 127u <= 127u) diff --git a/include/linux/mm/devmap_managed.h b/include/linux/mm/devmap_managed.h new file mode 100644 index 000000000000..0773529d80b2 --- /dev/null +++ b/include/linux/mm/devmap_managed.h @@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_MM_DEVMAP_MANAGED_H +#define _LINUX_MM_DEVMAP_MANAGED_H + +#include // for bool + +struct page; + +#if defined(CONFIG_ZONE_DEVICE) && defined(CONFIG_FS_DAX) + +#include // for DECLARE_STATIC_KEY_FALSE(), static_branch_unlikely() +#include // is_zone_device_page() + +DECLARE_STATIC_KEY_FALSE(devmap_managed_key); + +bool __put_devmap_managed_page_refs(struct page *page, int refs); +static inline bool put_devmap_managed_page_refs(struct page *page, int refs) +{ + if (!static_branch_unlikely(&devmap_managed_key)) + return false; + if (!is_zone_device_page(page)) + return false; + return __put_devmap_managed_page_refs(page, refs); +} +#else /* CONFIG_ZONE_DEVICE && CONFIG_FS_DAX */ +static inline bool put_devmap_managed_page_refs(struct page *page, int refs) +{ + return false; +} +#endif /* CONFIG_ZONE_DEVICE && CONFIG_FS_DAX */ + +static inline bool put_devmap_managed_page(struct page *page) +{ + return put_devmap_managed_page_refs(page, 1); +} + +#endif /* _LINUX_MM_DEVMAP_MANAGED_H */ From patchwork Thu Feb 22 11:50:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Kellermann X-Patchwork-Id: 204722 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:aa16:b0:108:e6aa:91d0 with SMTP id by22csp197927dyb; Thu, 22 Feb 2024 03:54:17 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXz3/SZ4J5DT0v7+SFp9S0j+ye9L5W0Gjf6WkmeWg8a3CAG9KZB6qTJvUdLDpFMiVCiuB4sCuzVp3GBEONy4kNUxYH/yw== X-Google-Smtp-Source: AGHT+IGhBSm8rEAcHNXQdxEgMcE8SXJvoBjvjuYt73tsMjtD+Pi8yS9B2dTjkNQpIq3cUoYJPWtY X-Received: by 2002:a05:6a00:2e8b:b0:6e1:3dd3:3c89 with SMTP id fd11-20020a056a002e8b00b006e13dd33c89mr19117445pfb.11.1708602857756; Thu, 22 Feb 2024 03:54:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708602857; cv=pass; d=google.com; s=arc-20160816; b=cnlJIFtvlTB1U7q7qJIZq6Qq1FXOFAHpKl8f+u/vzmUBcI2c/RFjFjc9GDzba5sym4 1bCsNDUaHwT73+XXivWmjvl1fYsIqZEciP3dmTHDYlKMLaD92IhBpSqq942Two9dI0fx dTzEYyHXjnhWhOwJgN8Fv8s9x7y4fb42KInvbUX8grzg1zEmTQMfTcevKLoF3nI1KfVE b+ZBN9Q1WbHut3Fse/2YGxVUWsCZMVe7W1STt6byRbueZ6auCMA5E8kgTrwGMqgqfp5T lc2Vt6vnNFzPrNqUUsDtD1sCigEXUjmIE6p5iPwtoRJwEp7fZ6eeH4Qs1IQVqoBxbMiP RV+w== 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=1kLoKUxPzCv4au/TRObsd9V3UzJrpdaiZFCw0biA2LU=; fh=iqufaGIEgqMk/IkouQoWSX4cGUWB34FY0R6naGbhbfM=; b=DO+Ec9hW1ja07XBMDX0MajT5z/GKN/QOCnp+XmqLMJowK/6PXgaU1y96bADpU7qgMQ TJaIWxC8VVyeyZxLYKF+EnDOJnJ4/9n0dLfUEKEQSJ1cxutVUwE1uoSeP1b/tB2H8MJ/ Gma4WkMXbUcxQO6hV9043eIAS59t794Dl3zxutiBJOEsntC+dK/sD1xigFdRcfrT4Ylj R/giluDb+vjMUDOChXarfFgSliDoMyHIH0ejS5j95xgbCcAlUK+u0InkKrjcrF2MwYtE ZJtLbR3lqEOJMrc2aQr5roHeh3KqDYDNR2F6cRa0hoQI8SKGAOh1tZ+mcDxxb472h/l5 DuCg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=KjzHQ1Ba; 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-76457-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76457-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id s15-20020a63af4f000000b005dc6d16aba7si10053708pgo.344.2024.02.22.03.54.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 03:54:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76457-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=KjzHQ1Ba; 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-76457-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76457-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 8AB7E284286 for ; Thu, 22 Feb 2024 11:54:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DB37C5102A; 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="KjzHQ1Ba" Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) (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 682834CB35 for ; Thu, 22 Feb 2024 11:51:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708602675; cv=none; b=CW4hMFr3NN3/9ThApmlFEbYRBhyvLbZwQT0j5ZlZ9KNnpmKyElF3i1TvI65bcq83uDKJZ9dz800GfVLi4HXrreZUFw9zU0IOv/B9V1P8zyutgDRzYE6JYomRt6wcxumdbbaeT7YAVQ2nOHP6Q3VQs1dD21GxPDhL5wNYZegNndI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708602675; c=relaxed/simple; bh=H98XR5ehGdkw5G5ubT2gWgECqnXtNMZuxsZ6WMDIYgI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZzWUiyY/4zFoShL2F/hwqpr/fBDVhj874PX0RGLNEdo4Knhf0B7YKFH+8rM1i0ozyWVLvR4mfjGAclfvAyA28wjSqi8bNIfkrC8Rbrq51owUXudUF1MLWI7RXdF+P6l2XeQPkpN0J9MA+zcO3rS0onbCkvoDh67BoswhlxKt6tQ= 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=KjzHQ1Ba; arc=none smtp.client-ip=209.85.167.44 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-lf1-f44.google.com with SMTP id 2adb3069b0e04-512be6fda52so4879887e87.0 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=1708602670; x=1709207470; 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=1kLoKUxPzCv4au/TRObsd9V3UzJrpdaiZFCw0biA2LU=; b=KjzHQ1BaUI8bHKThNpR+jBdPqYbXUvuLP98kFxxC2JaCn3+Vgnx4z1PH/kT+YaLMVS sZceJdGG/7IBoMkXmrf72oHpZCPJYOFRlhUgIAX5WEbEAZB8JsTs5giBL3dSzGsHV/8J /ddg/dsrAKMZE0+6aIYNW+aMSDhbSp4yvI7EjLBmnEWMthSBFKGrfpbakShMCOoIiW5u mJcSdANPA2i1Vm7Gzl19BZu2bSpfgxKkYFrWXpLgoMzW3wWVPjbBP4vRUO1y2bOUIrsN kdYO3pJa/5xnuzRaRvs7ROZ2OvQW0v1CvAzJ8foKv5ITM2B5L6CSL/0ZCfbTTLylPf9V WupA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708602670; x=1709207470; 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=1kLoKUxPzCv4au/TRObsd9V3UzJrpdaiZFCw0biA2LU=; b=B0hcjDsynp2ZT7dRjVFQudsWhknmVLUyCiK7vWXwEypyvFJ4IwKYbi15+/m1FxG5Wx FfOk/W/+o4n+wvh7+4aBVWf5gt720OnoYIA9QLI1HAzotD9CIwjO2QTKIlGsW6mlPRmb egQ21dXZUVdggRzEXMNz3sUdiAJV4QKZo8ng+W6It+H4bHcDjTbzQWZs85uPVQ7iAl7j /KaYKn4YWcZIVV+W0k64PkJ4VWIpYE+iYmtxwU5MhfheCg3fDl7KZ6aYn/LGDRt1Rtgm dwfIL7ODoTEPvI4Ny0arO/QYpwZGQAS/VXHAODS5k/yPcvyC7/C4ON5UScjFS+d2Dv0p fXgw== X-Forwarded-Encrypted: i=1; AJvYcCWgPiiEfH/e2kB424ey6YwimVcYnYEY2JjbENuJCP6xADIowSlW8cXLGCdP5rY/U/KuBspjXlQsXd5c4Bm8OGKQk3TiJ7JkdObJhIYO X-Gm-Message-State: AOJu0YxOJ7uuBAbx+p6wfku+6kz0NJKFlDJ/yjGrxOilEtVgZbMAjjDH tA+vY4CLrF/ruszsC6vjJSQEepuR3n/U0DlMwjOvVEtHQeH5bOhfEt01UK3Ua1U= X-Received: by 2002:a19:ac03:0:b0:512:beb3:7070 with SMTP id g3-20020a19ac03000000b00512beb37070mr5896813lfc.59.1708602670390; 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.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 03:51:09 -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 09/14] linux/mm.h: move usage count functions to mm/folio_usage.h Date: Thu, 22 Feb 2024 12:50:50 +0100 Message-Id: <20240222115055.1172877-10-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: 1791599949910308855 X-GMAIL-MSGID: 1791599949910308855 Prepare to reduce dependencies on linux/mm.h. This new header contains wrappers for the low-level functions from page_ref.h. By having those higher-level functions in a separate header, we can avoid their additional dependencies in the page_ref.h. Having these in a separate header will allow eliminating the dependency on linux/mm.h from these headers: - linux/skbuff.h - linux/swap.h Signed-off-by: Max Kellermann --- include/linux/mm.h | 168 +------------------------------ include/linux/mm/folio_usage.h | 177 +++++++++++++++++++++++++++++++++ 2 files changed, 178 insertions(+), 167 deletions(-) create mode 100644 include/linux/mm/folio_usage.h diff --git a/include/linux/mm.h b/include/linux/mm.h index 7a302da7de24..0dc38017e134 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -1058,51 +1059,6 @@ struct inode; #include -/* - * Methods to modify the page usage count. - * - * What counts for a page usage: - * - cache mapping (page->mapping) - * - private data (page->private) - * - page mapped in a task's page tables, each mapping - * is counted separately - * - * Also, many kernel routines increase the page count before a critical - * routine so they can be sure the page doesn't go away from under them. - */ - -/* - * Drop a ref, return true if the refcount fell to zero (the page has no users) - */ -static inline int put_page_testzero(struct page *page) -{ - VM_BUG_ON_PAGE(page_ref_count(page) == 0, page); - return page_ref_dec_and_test(page); -} - -static inline int folio_put_testzero(struct folio *folio) -{ - return put_page_testzero(&folio->page); -} - -/* - * Try to grab a ref unless the page has a refcount of zero, return false if - * that is the case. - * This can be called when MMU is off so it must not access - * any of the virtual mappings. - */ -static inline bool get_page_unless_zero(struct page *page) -{ - return page_ref_add_unless(page, 1, 0); -} - -static inline struct folio *folio_get_nontail_page(struct page *page) -{ - if (unlikely(!get_page_unless_zero(page))) - return NULL; - return (struct folio *)page; -} - extern int page_is_ram(unsigned long pfn); enum { @@ -1258,8 +1214,6 @@ static inline struct folio *virt_to_folio(const void *x) return page_folio(page); } -void __folio_put(struct folio *folio); - void put_pages_list(struct list_head *pages); void split_page(struct page *page, unsigned int order); @@ -1350,126 +1304,6 @@ vm_fault_t finish_fault(struct vm_fault *vmf); * back into memory. */ -/* 127: arbitrary random number, small enough to assemble well */ -#define folio_ref_zero_or_close_to_overflow(folio) \ - ((unsigned int) folio_ref_count(folio) + 127u <= 127u) - -/** - * folio_get - Increment the reference count on a folio. - * @folio: The folio. - * - * Context: May be called in any context, as long as you know that - * you have a refcount on the folio. If you do not already have one, - * folio_try_get() may be the right interface for you to use. - */ -static inline void folio_get(struct folio *folio) -{ - VM_BUG_ON_FOLIO(folio_ref_zero_or_close_to_overflow(folio), folio); - folio_ref_inc(folio); -} - -static inline void get_page(struct page *page) -{ - folio_get(page_folio(page)); -} - -static inline __must_check bool try_get_page(struct page *page) -{ - page = compound_head(page); - if (WARN_ON_ONCE(page_ref_count(page) <= 0)) - return false; - page_ref_inc(page); - return true; -} - -/** - * folio_put - Decrement the reference count on a folio. - * @folio: The folio. - * - * If the folio's reference count reaches zero, the memory will be - * released back to the page allocator and may be used by another - * allocation immediately. Do not access the memory or the struct folio - * after calling folio_put() unless you can be sure that it wasn't the - * last reference. - * - * Context: May be called in process or interrupt context, but not in NMI - * context. May be called while holding a spinlock. - */ -static inline void folio_put(struct folio *folio) -{ - if (folio_put_testzero(folio)) - __folio_put(folio); -} - -/** - * folio_put_refs - Reduce the reference count on a folio. - * @folio: The folio. - * @refs: The amount to subtract from the folio's reference count. - * - * If the folio's reference count reaches zero, the memory will be - * released back to the page allocator and may be used by another - * allocation immediately. Do not access the memory or the struct folio - * after calling folio_put_refs() unless you can be sure that these weren't - * the last references. - * - * Context: May be called in process or interrupt context, but not in NMI - * context. May be called while holding a spinlock. - */ -static inline void folio_put_refs(struct folio *folio, int refs) -{ - if (folio_ref_sub_and_test(folio, refs)) - __folio_put(folio); -} - -/* - * union release_pages_arg - an array of pages or folios - * - * release_pages() releases a simple array of multiple pages, and - * accepts various different forms of said page array: either - * a regular old boring array of pages, an array of folios, or - * an array of encoded page pointers. - * - * The transparent union syntax for this kind of "any of these - * argument types" is all kinds of ugly, so look away. - */ -typedef union { - struct page **pages; - struct folio **folios; - struct encoded_page **encoded_pages; -} release_pages_arg __attribute__ ((__transparent_union__)); - -void release_pages(release_pages_arg, int nr); - -/** - * folios_put - Decrement the reference count on an array of folios. - * @folios: The folios. - * @nr: How many folios there are. - * - * Like folio_put(), but for an array of folios. This is more efficient - * than writing the loop yourself as it will optimise the locks which - * need to be taken if the folios are freed. - * - * Context: May be called in process or interrupt context, but not in NMI - * context. May be called while holding a spinlock. - */ -static inline void folios_put(struct folio **folios, unsigned int nr) -{ - release_pages(folios, nr); -} - -static inline void put_page(struct page *page) -{ - struct folio *folio = page_folio(page); - - /* - * For some devmap managed pages we need to catch refcount transition - * from 2 to 1: - */ - if (put_devmap_managed_page(&folio->page)) - return; - folio_put(folio); -} - /* * GUP_PIN_COUNTING_BIAS, and the associated functions that use it, overload * the page's refcount so that two separate items are tracked: the original page diff --git a/include/linux/mm/folio_usage.h b/include/linux/mm/folio_usage.h new file mode 100644 index 000000000000..2700e2ec4d78 --- /dev/null +++ b/include/linux/mm/folio_usage.h @@ -0,0 +1,177 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_MM_FOLIO_USAGE_H +#define _LINUX_MM_FOLIO_USAGE_H + +#include // for put_devmap_managed_page() +#include // for VM_BUG_ON_PAGE() +#include // for struct folio +#include + +/* + * Methods to modify the page usage count. + * + * What counts for a page usage: + * - cache mapping (page->mapping) + * - private data (page->private) + * - page mapped in a task's page tables, each mapping + * is counted separately + * + * Also, many kernel routines increase the page count before a critical + * routine so they can be sure the page doesn't go away from under them. + */ + +/* + * Drop a ref, return true if the refcount fell to zero (the page has no users) + */ +static inline int put_page_testzero(struct page *page) +{ + VM_BUG_ON_PAGE(page_ref_count(page) == 0, page); + return page_ref_dec_and_test(page); +} + +static inline int folio_put_testzero(struct folio *folio) +{ + return put_page_testzero(&folio->page); +} + +/* + * Try to grab a ref unless the page has a refcount of zero, return false if + * that is the case. + * This can be called when MMU is off so it must not access + * any of the virtual mappings. + */ +static inline bool get_page_unless_zero(struct page *page) +{ + return page_ref_add_unless(page, 1, 0); +} + +static inline struct folio *folio_get_nontail_page(struct page *page) +{ + if (unlikely(!get_page_unless_zero(page))) + return NULL; + return (struct folio *)page; +} + +void __folio_put(struct folio *folio); + +/* 127: arbitrary random number, small enough to assemble well */ +#define folio_ref_zero_or_close_to_overflow(folio) \ + ((unsigned int) folio_ref_count(folio) + 127u <= 127u) + +/** + * folio_get - Increment the reference count on a folio. + * @folio: The folio. + * + * Context: May be called in any context, as long as you know that + * you have a refcount on the folio. If you do not already have one, + * folio_try_get() may be the right interface for you to use. + */ +static inline void folio_get(struct folio *folio) +{ + VM_BUG_ON_FOLIO(folio_ref_zero_or_close_to_overflow(folio), folio); + folio_ref_inc(folio); +} + +static inline void get_page(struct page *page) +{ + folio_get(page_folio(page)); +} + +static inline __must_check bool try_get_page(struct page *page) +{ + page = compound_head(page); + if (WARN_ON_ONCE(page_ref_count(page) <= 0)) + return false; + page_ref_inc(page); + return true; +} + +/** + * folio_put - Decrement the reference count on a folio. + * @folio: The folio. + * + * If the folio's reference count reaches zero, the memory will be + * released back to the page allocator and may be used by another + * allocation immediately. Do not access the memory or the struct folio + * after calling folio_put() unless you can be sure that it wasn't the + * last reference. + * + * Context: May be called in process or interrupt context, but not in NMI + * context. May be called while holding a spinlock. + */ +static inline void folio_put(struct folio *folio) +{ + if (folio_put_testzero(folio)) + __folio_put(folio); +} + +/** + * folio_put_refs - Reduce the reference count on a folio. + * @folio: The folio. + * @refs: The amount to subtract from the folio's reference count. + * + * If the folio's reference count reaches zero, the memory will be + * released back to the page allocator and may be used by another + * allocation immediately. Do not access the memory or the struct folio + * after calling folio_put_refs() unless you can be sure that these weren't + * the last references. + * + * Context: May be called in process or interrupt context, but not in NMI + * context. May be called while holding a spinlock. + */ +static inline void folio_put_refs(struct folio *folio, int refs) +{ + if (folio_ref_sub_and_test(folio, refs)) + __folio_put(folio); +} + +/* + * union release_pages_arg - an array of pages or folios + * + * release_pages() releases a simple array of multiple pages, and + * accepts various different forms of said page array: either + * a regular old boring array of pages, an array of folios, or + * an array of encoded page pointers. + * + * The transparent union syntax for this kind of "any of these + * argument types" is all kinds of ugly, so look away. + */ +typedef union { + struct page **pages; + struct folio **folios; + struct encoded_page **encoded_pages; +} release_pages_arg __attribute__ ((__transparent_union__)); + +void release_pages(release_pages_arg, int nr); + +/** + * folios_put - Decrement the reference count on an array of folios. + * @folios: The folios. + * @nr: How many folios there are. + * + * Like folio_put(), but for an array of folios. This is more efficient + * than writing the loop yourself as it will optimise the locks which + * need to be taken if the folios are freed. + * + * Context: May be called in process or interrupt context, but not in NMI + * context. May be called while holding a spinlock. + */ +static inline void folios_put(struct folio **folios, unsigned int nr) +{ + release_pages(folios, nr); +} + +static inline void put_page(struct page *page) +{ + struct folio *folio = page_folio(page); + + /* + * For some devmap managed pages we need to catch refcount transition + * from 2 to 1: + */ + if (put_devmap_managed_page(&folio->page)) + return; + folio_put(folio); +} + +#endif /* _LINUX_MM_FOLIO_USAGE_H */ 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: 204726 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:aa16:b0:108:e6aa:91d0 with SMTP id by22csp198673dyb; Thu, 22 Feb 2024 03:56:07 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVA5l1mf+D2Iy1MaVVUuQl/H+a4mn/MFXjhOu7Bd699bYu+SF3jOyna5CaBXlD7mD9KOerAv3iS6RF5aHTG7yipkbecEQ== X-Google-Smtp-Source: AGHT+IFI/c8XEbJoVSYJtkoMZ/SuTtWNfsGXEwDnmqlxJZrPCskH8zw2DThfiK6moaJ1TRJz8fXB X-Received: by 2002:a05:6a00:f85:b0:6e4:8b55:68a8 with SMTP id ct5-20020a056a000f8500b006e48b5568a8mr6610510pfb.6.1708602966918; Thu, 22 Feb 2024 03:56:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708602966; cv=pass; d=google.com; s=arc-20160816; b=PnatMsueXtcp8xCAH1k20yCNegJFGfh12widQzNMaWGPMoE6HsYTgGNsfwj2iSz6nX +TEsebLgRg5DCN1e8aASeRIBVd6cDdFraaB63izfsFZIsHSJ2hV2zLvnYku9KCRfQria AS3q7BiRo2ZVMQij6R84I0BaT7ngMo4ft7jksl7lmS4VDv5kLJFB72rpZOWCvKEloHqd hwQ12EV6Z+VYI6dedJN90llbP3bK74EjdmDVQjxECVU5SSNdaDCv232FZ8D+rFBlfXfe moCWnHmYae67pUnppxtFA2z3scQKX5qtx+6ulskNqDtsDgecjpk/Cxzc9jtnChtpF2dP nNyw== 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=MFa9Dx9xV4GQAl7iRO46X+jLcP69enhwI/ycHUy9Pls=; fh=pm2pOVcPQm5c/+DzBxic/Nv+PxpxyfvFT50bvSao0lk=; b=RXP7VkIjQBNc7C4MW1mywRViwT83Pi6Wbb7Bt4XoFKTa2oxGBBxbRpTGaY6QNGA0IJ oH4EXFrHXYc47IhofKHvKG14eB73rK0wmPGRleAxdpfpZ8S+GthPCsV7BMacIG16XfUo HME+AoyNlzBilYnifrL9EENMqtLDBkgjI6pn7xHW3niFv+N/sbfZN6eR0FvDcXv5Cf53 II2AO1FWa7covRVaQaBSWPZPf+pm04jN+1A5ntkktGedzcSo/ozKDWSgHZ2j5hpucqKE OH4L2mxW6ei9rEvQaO4WmRqQBIdmH0D35WEQiXNaJPD+vH9HLu+4z3WQwG2P65RrIg2z Kbyw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=L2LLVJXP; 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-76458-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76458-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id j65-20020a638b44000000b005be09b723b7si9906441pge.636.2024.02.22.03.56.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 03:56:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76458-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=L2LLVJXP; 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-76458-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76458-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id AF49DB266E9 for ; Thu, 22 Feb 2024 11:54:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CD0A84F88E; Thu, 22 Feb 2024 11:51:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b="L2LLVJXP" Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.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 045014CDE5 for ; Thu, 22 Feb 2024 11:51:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708602676; cv=none; b=qGdNNSXWA5mVzXpb9kPyz9eZTQ29pO/XXqV5THKba6H7nZC09x392E5SJQ9R78Qj8zJUyVKya32f4H9gJTXfQbhfEmHgZfe0DBElEvf4hjSpffsXxdUc1V6Q5kZOE5+Dqgn9tBundnEgvuBmdwkhUjHcw+8eKx80ul8Z2peSjkI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708602676; c=relaxed/simple; bh=MZvE3LEuDYWnJOlrzdBWCDdF99dM1xYbBHWyWAdVIM4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kYLjzDRAFo53D5UpDUp7UXHDJ1hSDdTAvtAtSsxkmFQi2ETNqvvYZV4RMqWCtzFTPWdyP8okzlfuYheHTO46lzb7FNV3qtUdrT3u5CjyQbxqqVcyoTLerWap+773iGh/URr3WRivGOSt7T8ZmYG9Bl8c+MqI433is00XHlfzV7g= 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=L2LLVJXP; arc=none smtp.client-ip=209.85.167.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-lf1-f43.google.com with SMTP id 2adb3069b0e04-51197ca63f5so9045008e87.1 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=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=MFa9Dx9xV4GQAl7iRO46X+jLcP69enhwI/ycHUy9Pls=; b=L2LLVJXPdq3wDlYsmcsWTrfWJw5+HdXSLNNpfQg+gPbWW6UqBT0Tkc0YDIS4Q8T+T8 /FMc4j5oNTKDDYQwdvdPNPmBXgNsHg34stD+gsM+2vQ+TVuW5rqPXMWejTU/6vnC7Z6F 0Scd1wFPWu88gLkKmBZe3dnvhmH1OM4qIHU4YhAm8BRyiaCb3I+IgydsQNPCpBFyAsIS wiOykrhmk1pF2dQ6S/opdPeSK+7YUC7SsjqbFW5LJfnnPoshYmgFDEYJ3+k3bugBwpRo 0oB9tzB2qYRjtpxe9uyNsjZYjVtb7sXRDWFxpzMXrPBclf8iLaeJ5Vwx3TB5yk4Kuc9R IgWA== 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=CsPbDjeMXcBUY3sOaJ6maVmWCPwNXrwgwI8A8STgEisOiJ1If800q59dEEhmDwVMJK YZMoMm2mqql5/NpmTE9I/SxyIom2k+1/mfErvJDCn3J8huBChmXY7mfH2OXLXgi1uWhP Fx4bTtfz6PSYEtMOQKZ8j9Jw4MHh3Ih6zbFt/K0f81qdZoJlAruueA3TMFDMXu6Rk8GP bj0ro96EzfjU0FBh821BaWFOE7F7AHWtmdcu2r9h1XkE4GUu+u1KpyXp56j5uG5bPXjB QHKEzc59P5SkyzAcRsRRcIg2jlSmAOLmyiUGCgPhFrwUe4UnqsvQWLnmfEn+KNe+LaXH PbWQ== X-Forwarded-Encrypted: i=1; AJvYcCVHE6wbfQo8A5RdYv9gHs+0PrLkM3IJ4Bqkvhdf3gNqzoHGh5MhARaEyOjPY0BcODZ+i9NRtW4mzzWuqq46gOx5qHJGO1Omb1GiQtid X-Gm-Message-State: AOJu0Yyv+XNoe+YgUwIJgTq1fc38HZIIPp3q/i/TuQ2du9y4pUgo7ODk ecSF7tcbmVAi9YQaio13/hAufxTufOW4MODz0+IIRazIsQDdR0YvbpKUzbIQGHE= 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> 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: 1791600064534637300 X-GMAIL-MSGID: 1791600064534637300 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 */ 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 */ From patchwork Thu Feb 22 11:50:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Kellermann X-Patchwork-Id: 204727 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:aa16:b0:108:e6aa:91d0 with SMTP id by22csp198789dyb; Thu, 22 Feb 2024 03:56:27 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUVJgTapS2+7yjdKllK6ZQvt2opEALRticRtmfch72FbCYwXzhGzWtMDGmT6asN0IDAiylQxYLOfjvvnZVSsO1lyahabg== X-Google-Smtp-Source: AGHT+IGN09oNeat5x/842+M5OK0iqWyYrtDducP+UuFZsojyQemgbtE23MzaZ9ccOB9NHZ0nlwkd X-Received: by 2002:a05:6a20:9d90:b0:19e:9c5e:9d97 with SMTP id mu16-20020a056a209d9000b0019e9c5e9d97mr23473324pzb.62.1708602987545; Thu, 22 Feb 2024 03:56:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708602987; cv=pass; d=google.com; s=arc-20160816; b=t1isswbQGe89HnW/jCXphv067HjvuyoRw2CHKz5kmVGCCX6tAmmu10u4Tu6CerFHVq p+7ogS8jOzg9vHcpqpjDtdi9IIXhnxBADOA0fpPMU29WHsaX4Pm90ovkY24mBtQbVa8U ePYPGRMms7LFqwOeIWNmyQgY5wcOekTrIjLd+46d8JjrD+c3AsMBgQhFpJvoVxgMrrPm NZxBgH2KJN7KYAgRCRmuL2gj16lE1w/N/FBA1aJU5nNQOB6t/HpcKTmYuikBCdHnuMa0 f/ayL1Cm3HQwMwsmgqzfXV6tYN0Rq6DvomxyGau1e1O/lhkDDY8YqVhUa+AFUaSM/dOX rUBA== 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=+Ry2UB7dcYeDT9zlEEyR0ChQEn3iuoF+FIIQJnSpSl4=; fh=meY/okdGOyo1nr17yQRInZLTAWZEJC1U19pBTD6oN2s=; b=rlsqoIIkOUjJAL8YoCXujYOCiMIsa9hDcnE32p/LSB/Q50k9V7k5MT+KLgLyojsaph Q+0m7Wlq1JsDJM0dk0SBoOC+Pe0SByLG+p4LFQPKB7SXflgcyOVV2UXEA5x4jdh17KNK C4gU8L15+GJn5XIRJ9P1W1vR/0G+trAuk0ftcC//wYl+36uo/H6/tOU7tNixQz/2KZTN GL7VQR9j35wzPPz4bHsatEOAI6d/fTfLrQ72HSQ/+FUK21Cv/xVgsoGzFL16bltgC3/y 92JxVFczkhJgc4LNmInhWHaZ4Ejpcxz2DCrJCjTuRXuGeq+78Xfa7+9fXp4x5ScKUpXc 0VcQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=FK8LKP6C; 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-76460-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76460-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id u15-20020a170903124f00b001db5df6dfb7si10163291plh.421.2024.02.22.03.56.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 03:56:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76460-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=FK8LKP6C; 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-76460-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76460-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 87B6BB2280C for ; Thu, 22 Feb 2024 11:54:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9D09E50A77; 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="FK8LKP6C" Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (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 0C8F54D9F5 for ; Thu, 22 Feb 2024 11:51:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708602677; cv=none; b=GGzClH3S6d9Pjc0F1y4v3FcJW/3K3zwAtWh7sFDKjCS9QphXZCd9l69SI5opDBHijPACC0ewDep6sgwUvegLMVfnywJO7aVyG/EVAYT/tUBQS0jhTLOJ7ZUTxYSByrYAlul0r0lIS6IdfxEvxoKVtDMLfgTdHbUiceNUunMt/WM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708602677; c=relaxed/simple; bh=AI6dnZoshIANIqbcoSAEYz35mK5JXJZ7+iH1ThOklac=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=f+btNbI5+m8UJK1sZFFrxGYd/d+/xmrp/54OPDHjWqI7mVVHKqdr+FTqjAkEjsL6nMwTqO6JaV8oaGX0pNGAjHAXcxPqlt6xkAdM5dbFK0SNwXVFZ9zJEz/KmyK38Qz29YyHDsQQnDnR2X3N9xOT9czyHKlmDi+7KXopwi8RKqI= 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=FK8LKP6C; arc=none smtp.client-ip=209.85.128.52 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-f52.google.com with SMTP id 5b1f17b1804b1-41282be73e7so4459335e9.3 for ; Thu, 22 Feb 2024 03:51:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1708602673; x=1709207473; 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=+Ry2UB7dcYeDT9zlEEyR0ChQEn3iuoF+FIIQJnSpSl4=; b=FK8LKP6CQKfWwwAg/llcM0rN9Ju0Pg0GbsuGNflU/ml9LolP+l8KAPxhS7pKgsjItZ D+DAICVVVpD8IAH2DdJ+Z9X2/dgXSr59qj712fFMuBUwCnkE4cDlYnq14see7lLw/0q8 uqR7DszC6UXMIdQengJ/tevD6SMzUD2qQYuGTouwnGycjlRa0ipey+ypDlCbmUHMOGo5 +qG3hWzvq/VaDVfsAEAzhIpzK7MHiQGkBhxE+qBRyawd8G471Pr2vAWeDkScf5mEXWy4 uxsXyrbIy2dedTRwF+eleWI+5HmOhlUSP8jLfTZYznrC2cCkT3ijUbv2O0cvZ8aFFTdZ hsrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708602673; x=1709207473; 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=+Ry2UB7dcYeDT9zlEEyR0ChQEn3iuoF+FIIQJnSpSl4=; b=w4Ga1PnHmOEnxfxHSmWBYrOgAIV1dnJWhfuRRCNkwMg0RTlBVl8g4ysJpy6decnr5Z 5L1ei/xB2aBBLVOSuE5jSQqcT0Go209QHum8QUAqMfwmbyx1P9TP6f9+SMiLRVnmK6gA vBmad+Dj6ktybP/Tg0/ad4Ywbpqd0fylojgF32+Kty8smfpAr/vHIg1O1YRGr8J/Wrpk TxE/PAtbQnV3n1AWvClbIiUOB2ltrOs62MSSSQ2ukbrZn6vmV2n7XxU640MUypmMC7nK LG+HgIuwzJj9ibccfu/tSVRy/m1xUARhL8fXDu2l0JwmmNAKygQtm/Y8NIDxVMYN2Fgc dDIA== X-Forwarded-Encrypted: i=1; AJvYcCU4GkV/AsPmkDPUTUcpC8Ajc3p+RE6mU/MZunezBMGPsI5daOfTwM7CRpVoXBLtP1V0nn54q9wErGMowK3LcaSS/ZIsdQW3T7sZrjvR X-Gm-Message-State: AOJu0Yy+BVQuMtLS0LcNVa3Ws5VX0zLlI/Ak/OpUtYjnLetpUqEVvmEu Yz7xjkHYSn20hVZcmh0hKg+Y1e5XCVyBgbwQdnyb9oXvq+UrF/r5fkVJYG6pBOo= X-Received: by 2002:a5d:5962:0:b0:33d:3a0e:9168 with SMTP id e34-20020a5d5962000000b0033d3a0e9168mr9439866wri.3.1708602673418; Thu, 22 Feb 2024 03:51:13 -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.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 03:51:12 -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 12/14] linux/mm.h: move is_vmalloc_addr() to mm/vmalloc_addr.h Date: Thu, 22 Feb 2024 12:50:53 +0100 Message-Id: <20240222115055.1172877-13-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: 1791600086509234297 X-GMAIL-MSGID: 1791600086509234297 This is needed to eliminate linux/dma-mapping.h's dependency on linux/mm.h. Signed-off-by: Max Kellermann --- include/linux/mm.h | 25 +------------------------ include/linux/mm/vmalloc_addr.h | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 24 deletions(-) create mode 100644 include/linux/mm/vmalloc_addr.h diff --git a/include/linux/mm.h b/include/linux/mm.h index 68228f43e7ca..ad5971219ef6 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -1072,30 +1073,6 @@ enum { int region_intersects(resource_size_t offset, size_t size, unsigned long flags, unsigned long desc); -/* Support for virtually mapped pages */ -struct page *vmalloc_to_page(const void *addr); -unsigned long vmalloc_to_pfn(const void *addr); - -/* - * Determine if an address is within the vmalloc range - * - * On nommu, vmalloc/vfree wrap through kmalloc/kfree directly, so there - * is no special casing required. - */ -#ifdef CONFIG_MMU -extern bool is_vmalloc_addr(const void *x); -extern int is_vmalloc_or_module_addr(const void *x); -#else -static inline bool is_vmalloc_addr(const void *x) -{ - return false; -} -static inline int is_vmalloc_or_module_addr(const void *x) -{ - return 0; -} -#endif - /* * How many times the entire folio is mapped as a single unit (eg by a * PMD or PUD entry). This is probably not what you want, except for diff --git a/include/linux/mm/vmalloc_addr.h b/include/linux/mm/vmalloc_addr.h new file mode 100644 index 000000000000..86ad2dc94960 --- /dev/null +++ b/include/linux/mm/vmalloc_addr.h @@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_MM_VMALLOC_ADDR_H +#define _LINUX_MM_VMALLOC_ADDR_H + +#include // for bool + +struct page; + +/* Support for virtually mapped pages */ +struct page *vmalloc_to_page(const void *addr); +unsigned long vmalloc_to_pfn(const void *addr); + +/* + * Determine if an address is within the vmalloc range + * + * On nommu, vmalloc/vfree wrap through kmalloc/kfree directly, so there + * is no special casing required. + */ +#ifdef CONFIG_MMU +extern bool is_vmalloc_addr(const void *x); +extern int is_vmalloc_or_module_addr(const void *x); +#else +static inline bool is_vmalloc_addr(const void *x) +{ + return false; +} +static inline int is_vmalloc_or_module_addr(const void *x) +{ + return 0; +} +#endif + +#endif /* _LINUX_MM_VMALLOC_ADDR_H */ From patchwork Thu Feb 22 11:50:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Kellermann X-Patchwork-Id: 204729 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:aa16:b0:108:e6aa:91d0 with SMTP id by22csp200130dyb; Thu, 22 Feb 2024 04:00:09 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV/vhXRXVQMsnUMSwq72Siq6rJjo6vukkZUzg2ETNFAKM6uMPyYaIXG3+IGpGrBn63OVME5fWH1nRT1W35TrajJx+gK2w== X-Google-Smtp-Source: AGHT+IHB2lYoh5PH5JH/57AA8LAA/qH3bVGxh+G+vHji4QxfH822g1avZFNDvRnn07FipvC1NCt6 X-Received: by 2002:a05:6a21:1583:b0:19e:cae4:7c07 with SMTP id nr3-20020a056a21158300b0019ecae47c07mr20067263pzb.45.1708603209323; Thu, 22 Feb 2024 04:00:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708603209; cv=pass; d=google.com; s=arc-20160816; b=k01diXV0pSna5MU29IckkLprs9d2PxTaFJIgvMqbP44yhS63vVG7RUoUj48ElUJeLw aXlh+F7J2EP4UxNqnZ00vpCMPdxc8O4wo8OmbLx6J+7USp7sqnhTyCvXm7jedga2i9De tWQKVaB5Ps/oL/fU4QAfu9oGsN0M+UT+j1uBgCnK/3xYKo4IX0m1Gk/Sv1U64yIPRWYX bLQXbBIVq/9mwfxUHKjzsQjYM3i0RnmribKmAYkOhVD67/fo+nto4UHihwgnbPB+MAMn FWQ/Ts+rAdxDjHwZ2Icmm5ZdoHGF1a6uKKGPYpUck9uUKRZip7OAsPMp64b36zi7Eb5F Rqwg== 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=rnyD5PxkKV5o19zNsO0L5tf/fTdRWviw2NTc0WpmPto=; fh=8IRiN35HfrJ5VnEzzJDxq94yq2BPgrE6fDd5PLxvq5U=; b=BRnPxTlIcfL3feGoFNT8bc/TVXwAkleOpOH7ylP6e4T29LL9n+VsLxM65CIfKyueb6 b0twotMwZ3lQNy6cim23ylbgE7pnUunWY4speTmGEOow9j+k9L5+eED8nWsXwuXFmCrV gGr1GJY3rZO/AUU9rH4deGaao3Bsio4p0HGEaX43+NcBPKr3+D1Zb5PcYCzFzDn2lWDX UokP2ULJTMO8VORQObkJ82JNjiPqDAA4F/Mc119fq0YTcL7AZ5nB6UtpZG5AcYFRjX8Q x4FDV6Aba8UNllKsanDJxS+eyxkas7SAHi2HrdMYATQ4DoeQ8H49o1yFf/U6LgvVghn+ E6gw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b="IANuR/ae"; 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-76461-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76461-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id a28-20020a056a001d1c00b006e464e0bcf2si7085081pfx.34.2024.02.22.04.00.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 04:00:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76461-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b="IANuR/ae"; 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-76461-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76461-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 328EFB2192F for ; Thu, 22 Feb 2024 11:54:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 486B2524BE; Thu, 22 Feb 2024 11:51:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b="IANuR/ae" Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (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 AEE3B40BEE for ; Thu, 22 Feb 2024 11:51:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708602678; cv=none; b=mLIKyKoEsLFsUUDE2LK+ihRB+6vwSqJx6axkALsFL5vw5fmZeBY7fV+FRDdg1X0HN+ellfqMiq6MuuOaVQOfmjtD9Yi55wKEMmhSOY68h+Scoo2B+b5Ym7XI63z4iGTyvM/8xbej7h+5on9RuNWmFhhqRcneRl+NNclzjU4DO3M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708602678; c=relaxed/simple; bh=daz2rq6rFV2eHut/CqMGAgO7JV6tA0j6PgEXIH1uJ3w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=V15Rc4C5llrlYgvbLhfIceypUkCb6YizYTGc04w8DofNTnHqeigcjVcxGp+xyBvD1N2SCVWanHG3WiPxXp8laG+VDOGrVnSljwpF7LQTXOKcbYjIt4pwV/I7NrNxqwq3EVXmWZbX5mBDQWsCoRQnEEPIh89daGQnkMM1/uwVLg4= 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=IANuR/ae; arc=none smtp.client-ip=209.85.128.47 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-f47.google.com with SMTP id 5b1f17b1804b1-4128cfb6c1aso1724245e9.0 for ; Thu, 22 Feb 2024 03:51:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1708602674; x=1709207474; 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=rnyD5PxkKV5o19zNsO0L5tf/fTdRWviw2NTc0WpmPto=; b=IANuR/aehwOTPGBYD5nwExGsqLGHpEIuy8W0edvY50gfmS+4q2wDuvj6CnW80IlW1n VLiaJCUqD1DR47sHqDjCmss+/xfbdgPmUnmjACIa9kybjvYSVKe7Ftv4CjYXaVH5KjSg bz8O+mbykdeZDfE+urerkO2v5yBOZaiG/Bx+R9PQcj989RnL/nFHEerZS/LLGZBKmewH ey0n+Zvsydq7RASkqmzardIi4KgfyXTxFfSZbs7DrT4taAFdJnYaKSrDrnPKMLwkS7LA FEVREuOH34xSf4mzp2h7HvUxQrZdiy70+Eha49dV1sOIUBhj7WsSmKrPVAgwGrDS8sQb re7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708602674; x=1709207474; 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=rnyD5PxkKV5o19zNsO0L5tf/fTdRWviw2NTc0WpmPto=; b=D1PE2BHbgiKcu3M/GunzYBm09IZ/P+Jb6bYtEiL8dzZ+7Uw6EucyTn1Ey8VcJu6Mkb Km2G7RQaQUaLn/9Sqqv+A8wcyQ59PDWAA5Lnh2Tzd/Cly+z86B4vWDECzS6Fguvh/2i7 Um9Fz/qf+IRdy6EjzLMkBhzEwQfXI/+PfRdqtdeXQdxbpXjCVR6jiEWNQ6lnxe4eKara JhQtppYY+QBdg5drDvbGbrx7Sl18M5J06+rR0nxIcdZZxAlcaY7BRTK4RLr9Qh+I/89B 1AqASsDjytN+OvUE+0g26xhis6Q/ed6PsxvuE0udJW2uN4uQTjlxnecn9HJhMUXfa0jH uh0g== X-Forwarded-Encrypted: i=1; AJvYcCVastPb5EFGbFqvwaqdtdV8OTq8DIktheWeKD/f2kpUKLS2dQsT8AGWeoAZU2vfb4He6pNZOCIRJK52v4Y61Ilo+Vl70QDoDX+45Y64 X-Gm-Message-State: AOJu0YztuUr98ItC31w6KdjpdaEpIlNg5wy9rE7M5UXf8WDmlC9Ylzw8 /KdtE9rJ97QwTV5DiBbIUYQa5RJSvp6NTURPezUgwTdEKlv3DuN+qPZjyh/i1yFYUTZptH6ka+M 1 X-Received: by 2002:a05:600c:444a:b0:411:c8a7:7b09 with SMTP id v10-20020a05600c444a00b00411c8a77b09mr1966316wmn.10.1708602674092; Thu, 22 Feb 2024 03:51:14 -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.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 03:51:13 -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 13/14] linux/mm.h: move high_memory to mm/high_memory.h Date: Thu, 22 Feb 2024 12:50:54 +0100 Message-Id: <20240222115055.1172877-14-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: 1791600319101713351 X-GMAIL-MSGID: 1791600319101713351 This variable is used by lots of arch/*/include/asm/ headers, but these do not (and should not) include the huge linux/mm.h header. Let's move this "extern" variable to a separate header and include this one in arch/. Signed-off-by: Max Kellermann --- arch/arm/include/asm/memory.h | 4 ++++ arch/arm/include/asm/pgtable.h | 2 ++ arch/csky/include/asm/page.h | 1 + arch/hexagon/include/asm/mem-layout.h | 4 ++++ arch/m68k/include/asm/page_mm.h | 1 + arch/m68k/include/asm/pgtable_mm.h | 1 + arch/parisc/include/asm/floppy.h | 1 + arch/powerpc/include/asm/book3s/32/pgtable.h | 4 ++++ arch/powerpc/include/asm/nohash/32/pgtable.h | 1 + arch/powerpc/include/asm/page.h | 1 + arch/x86/include/asm/floppy.h | 1 + arch/x86/include/asm/pgtable_32_areas.h | 4 ++++ drivers/mtd/nand/onenand/onenand_samsung.c | 1 + include/linux/mm.h | 2 +- include/linux/mm/high_memory.h | 7 +++++++ 15 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 include/linux/mm/high_memory.h diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h index ef2aa79ece5a..a67afb213e2e 100644 --- a/arch/arm/include/asm/memory.h +++ b/arch/arm/include/asm/memory.h @@ -387,6 +387,10 @@ static inline unsigned long __virt_to_idmap(unsigned long x) */ #define ARCH_PFN_OFFSET PHYS_PFN_OFFSET +#ifndef __ASSEMBLY__ +#include +#endif + #define virt_to_page(kaddr) pfn_to_page(virt_to_pfn(kaddr)) #define virt_addr_valid(kaddr) (((unsigned long)(kaddr) >= PAGE_OFFSET && (unsigned long)(kaddr) < (unsigned long)high_memory) \ && pfn_valid(virt_to_pfn(kaddr))) diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h index be91e376df79..eb80f6a65619 100644 --- a/arch/arm/include/asm/pgtable.h +++ b/arch/arm/include/asm/pgtable.h @@ -11,6 +11,8 @@ #include #ifndef __ASSEMBLY__ +#include + /* * ZERO_PAGE is a global shared page that is always zero: used * for zero-mapped memory areas etc.. diff --git a/arch/csky/include/asm/page.h b/arch/csky/include/asm/page.h index 4a0502e324a6..016f722fbe43 100644 --- a/arch/csky/include/asm/page.h +++ b/arch/csky/include/asm/page.h @@ -32,6 +32,7 @@ #ifndef __ASSEMBLY__ +#include #include #define virt_addr_valid(kaddr) ((void *)(kaddr) >= (void *)PAGE_OFFSET && \ diff --git a/arch/hexagon/include/asm/mem-layout.h b/arch/hexagon/include/asm/mem-layout.h index e2f99413fe56..a09116c50043 100644 --- a/arch/hexagon/include/asm/mem-layout.h +++ b/arch/hexagon/include/asm/mem-layout.h @@ -10,6 +10,10 @@ #include +#ifndef __ASSEMBLY__ +#include +#endif + /* * Have to do this for ginormous numbers, else they get printed as * negative numbers, which the linker no likey when you try to diff --git a/arch/m68k/include/asm/page_mm.h b/arch/m68k/include/asm/page_mm.h index e0ae4d5fc985..f958655d1931 100644 --- a/arch/m68k/include/asm/page_mm.h +++ b/arch/m68k/include/asm/page_mm.h @@ -5,6 +5,7 @@ #ifndef __ASSEMBLY__ #include +#include #include /* diff --git a/arch/m68k/include/asm/pgtable_mm.h b/arch/m68k/include/asm/pgtable_mm.h index dbdf1c2b2f66..ec593656bdc5 100644 --- a/arch/m68k/include/asm/pgtable_mm.h +++ b/arch/m68k/include/asm/pgtable_mm.h @@ -13,6 +13,7 @@ #ifndef __ASSEMBLY__ #include +#include #include #include diff --git a/arch/parisc/include/asm/floppy.h b/arch/parisc/include/asm/floppy.h index b318a7df52f6..98ed37c5dc59 100644 --- a/arch/parisc/include/asm/floppy.h +++ b/arch/parisc/include/asm/floppy.h @@ -8,6 +8,7 @@ #ifndef __ASM_PARISC_FLOPPY_H #define __ASM_PARISC_FLOPPY_H +#include #include diff --git a/arch/powerpc/include/asm/book3s/32/pgtable.h b/arch/powerpc/include/asm/book3s/32/pgtable.h index 52971ee30717..03e0a32e1c2c 100644 --- a/arch/powerpc/include/asm/book3s/32/pgtable.h +++ b/arch/powerpc/include/asm/book3s/32/pgtable.h @@ -4,6 +4,10 @@ #include +#ifndef __ASSEMBLY__ +#include +#endif + /* * The "classic" 32-bit implementation of the PowerPC MMU uses a hash * table containing PTEs, together with a set of 16 segment registers, diff --git a/arch/powerpc/include/asm/nohash/32/pgtable.h b/arch/powerpc/include/asm/nohash/32/pgtable.h index 9164a9e41b02..8a9f5b546e4a 100644 --- a/arch/powerpc/include/asm/nohash/32/pgtable.h +++ b/arch/powerpc/include/asm/nohash/32/pgtable.h @@ -5,6 +5,7 @@ #include #ifndef __ASSEMBLY__ +#include #include #include #include /* For sub-arch specific PPC_PIN_SIZE */ diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h index e5fcc79b5bfb..c541e71d3d5c 100644 --- a/arch/powerpc/include/asm/page.h +++ b/arch/powerpc/include/asm/page.h @@ -7,6 +7,7 @@ */ #ifndef __ASSEMBLY__ +#include #include #include #include diff --git a/arch/x86/include/asm/floppy.h b/arch/x86/include/asm/floppy.h index 6ec3fc969ad5..7756e984f146 100644 --- a/arch/x86/include/asm/floppy.h +++ b/arch/x86/include/asm/floppy.h @@ -10,6 +10,7 @@ #ifndef _ASM_X86_FLOPPY_H #define _ASM_X86_FLOPPY_H +#include #include /* diff --git a/arch/x86/include/asm/pgtable_32_areas.h b/arch/x86/include/asm/pgtable_32_areas.h index b6355416a15a..b339137b4f4e 100644 --- a/arch/x86/include/asm/pgtable_32_areas.h +++ b/arch/x86/include/asm/pgtable_32_areas.h @@ -3,6 +3,10 @@ #include +#ifndef __ASSEMBLY__ +#include +#endif + /* * Just any arbitrary offset to the start of the vmalloc VM area: the * current 8MB value just means that there will be a 8MB "hole" after the diff --git a/drivers/mtd/nand/onenand/onenand_samsung.c b/drivers/mtd/nand/onenand/onenand_samsung.c index fd6890a03d55..7c3cc270386d 100644 --- a/drivers/mtd/nand/onenand/onenand_samsung.c +++ b/drivers/mtd/nand/onenand/onenand_samsung.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include diff --git a/include/linux/mm.h b/include/linux/mm.h index ad5971219ef6..b5cfe35ee7f2 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -81,7 +82,6 @@ static inline void totalram_pages_add(long count) atomic_long_add(count, &_totalram_pages); } -extern void * high_memory; extern int page_cluster; extern const int page_cluster_max; diff --git a/include/linux/mm/high_memory.h b/include/linux/mm/high_memory.h new file mode 100644 index 000000000000..e504aafd0d48 --- /dev/null +++ b/include/linux/mm/high_memory.h @@ -0,0 +1,7 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_MM_HIGH_MEMORY_H +#define _LINUX_MM_HIGH_MEMORY_H + +extern void * high_memory; + +#endif /* _LINUX_MM_HIGH_MEMORY_H */ From patchwork Thu Feb 22 11:50:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Kellermann X-Patchwork-Id: 204728 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:aa16:b0:108:e6aa:91d0 with SMTP id by22csp200117dyb; Thu, 22 Feb 2024 04:00:08 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU5EfPlx40tIL+MwHd/pV0al187cPnwxqNe9PD+SdAHDKl52C9N8x7jDAKNmjbOFBsu+vkNMk1YVerfVMXvw91tvp07hw== X-Google-Smtp-Source: AGHT+IFFCHrx3W2r8Lgn4ck6CTy2d8Mm/PSuWY85PUfjRD4aJt+I9ui2QIXIg5PmP6HMiMbFFdeP X-Received: by 2002:a05:6830:204a:b0:6e2:deab:fe54 with SMTP id f10-20020a056830204a00b006e2deabfe54mr18014361otp.30.1708603208295; Thu, 22 Feb 2024 04:00:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708603208; cv=pass; d=google.com; s=arc-20160816; b=bbujtEeg4uaXsPKTjNpRcHxcW6KkP+XE6w8maTS/G0tT4VA8srFig984pnoxlwy9nD edvOHYNK1z7kFJoHZciH90Ux09wx6340GdA2qPk3aS7CMxX5KbKzAgSzgEXNtjiSSrjv iYVlGmxrUvaqSx6PWlSfvsS1HhIWe3vs5eQ6/KhZ9zZLCF/5FBqANZKZi5/W37JDSjzV WCfy7Oi/VU1sAWc8PZLW77QYVOVdhc+qnN7NktIG0OcGYeGMoizwqVYbVbzEOUn4WQVm GvSya2syDhygK6VpThK+OjjwBn1ZFQvhorU30J97f9ndZ7WVzL31Zkppqf2cknfzZqqL +iRA== 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=FORSCnEJSDoW1xOoni46e3+631c/MspUPxiW79pGM2g=; fh=6m69o1A7FQIkAR8abCrFYMoupLrqTbEthlWgRrvzOcM=; b=l8a7qPNNdM5WZahYkV/Nd2kcTe272GQwEQcSexSruA/zQySWQmgX1izxUv2jDAP3zA Nhq8h31QruvN1sJ+TKdqR0XeHi4u7inTi8GyQbze3CtFfGuy1/zRW1QRJrTiW34jvpIa 8V2o0P5iWBkwlOzipsaGNQ16JN54jW7pFftn1ezqwwugfnoJ0NIXtf3TV3AFyleT8Lsf kZHXU2XKPYMkZwLzzHtKx5+UnLvZUItcHvfVm4GeBlFQIEpSEamx465uGIUeHALy577A AOApOlASSDoQOb3seD9xne6BWMq7qO2LziBsKVr8DH62d6tOiuVGNXZNjOHgOn0tbpyL 2LhQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=WvabO7Hp; 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-76462-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76462-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id l25-20020a637019000000b005dc8650cc61si10051526pgc.847.2024.02.22.04.00.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 04:00:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76462-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=WvabO7Hp; 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-76462-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76462-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 37C78B217FB for ; Thu, 22 Feb 2024 11:54:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1FE39524BB; Thu, 22 Feb 2024 11:51:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b="WvabO7Hp" Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.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 812B4481B9 for ; Thu, 22 Feb 2024 11:51:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708602678; cv=none; b=GiXlA7V619V2HSQymY151Arj53wTHOkng8a0WLifWS2LfRnXredzA8qTHmXJgD+cnNqTO+baAOyg7VeXO5VRcpm6atfQn0F0GYpiNVgNCDX7dYP6e04svUlyjQS8RtCscPVNtayTl9nuLXwZCjV2aAjOwf4wUUZEy/DuROu4NdQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708602678; c=relaxed/simple; bh=6lHFOBxOmXiBL1X6gyWvD/30KjkqW7REHaVOVl6TAHs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=EIHeS8LdhIdAihduJ5ZVZX6CipxneVwpJSTyedLABBhAzB//JgNX0fKnlH2bkUBXNUUDkJ8gOmUeQAjb2kNOlKhRawH+VgJ0vx4sIYjBTp1h5lASQfz4GXssE2yzbpk+HlyrxV5tcHSKb/7QI5Ioc33UQULjlhC6mDty+3MJb0o= 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=WvabO7Hp; arc=none smtp.client-ip=209.85.128.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-wm1-f46.google.com with SMTP id 5b1f17b1804b1-41278553016so12338565e9.2 for ; Thu, 22 Feb 2024 03:51:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1708602675; x=1709207475; 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=FORSCnEJSDoW1xOoni46e3+631c/MspUPxiW79pGM2g=; b=WvabO7HpLa0OO8HsDYl6mhxMQLBuOjCz+c3ZIviTiMbZd/rNgrnL4N9iJfKooPcaoI tdWTyw5vq0mIXv0GrEwSGUKCmoY9oqhgqZBWkI40PYN1VBAIfHly/o+o+fKNKKcZsMPK ukHldpcWsUB0p7WWIZ+Qkz80FdHJzrcjShF6A8Wncy/2F4E73FSCVPghq/wcPVbdE6F7 YQuI1bEuSSlrh4xxJkmWNxpykfBvjL4EiyOqZSJzl0x+G5e8Of/1Ov5RMDqkA9TfmbrM /P+SrUDBM05Mv1dx3LEoo7edzgMhnwWD3/FbZ4aZ/Ymy8SKybc49YkKq4FRcJSAuRyCR KloA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708602675; x=1709207475; 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=FORSCnEJSDoW1xOoni46e3+631c/MspUPxiW79pGM2g=; b=er2u+QDJmPVWAv4ci56EqbWey3MVbs0DGOw3HHKiw/CQGGtOQOOmwbUuHx92i1kS/u 18kiWNRx5nAQaR7/RX9YLEmgx2MjHJJHhebYOVIcamexsZhaGSf5qdF2ocwb7lOyZH+d zdAidkZxnexyBox6mllZO5jULCXkni3flg+HAtyVG8iMya+/paX+rYBSx+q6q4Uh0buY ACuRhUEe66HJfybhkp2L/elXbWTk0cXytOA3VUBt/hLlDjV8qQJPPhJU0yU4SQnLTuHR ujQyFTnWuUPPidp38KXlTqbPhnGiQ89g+yEtSLN/JXWlD/MzEJpS78LQjItIebsgY9ZD xvqg== X-Forwarded-Encrypted: i=1; AJvYcCV/aeP2dW8kCzPoHm2HE771eXwwXzbCkXlnf1FdBLPhFbUJlq3G3qhsQMjajWAyVY5UXqgKteO2nUKy6EhYqX7LicQXpbhSvXKaQjKK X-Gm-Message-State: AOJu0Yxaf9w84aU0+18Lt/lKus1yFqYYkDwp6S0ZOVRlDW2yk07VI84Z 74+oHacjNOD2oKxaUTemvarRbAvBpOTOtJ0tE84QHeHzwC0O1x47Wyhd3tLV7sE= X-Received: by 2002:a5d:64a7:0:b0:33d:ed4:5c86 with SMTP id m7-20020a5d64a7000000b0033d0ed45c86mr19274430wrp.63.1708602674795; Thu, 22 Feb 2024 03:51:14 -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.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 03:51:14 -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 14/14] include: reduce dependencies on linux/mm.h Date: Thu, 22 Feb 2024 12:50:55 +0100 Message-Id: <20240222115055.1172877-15-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: 1791600317916896498 X-GMAIL-MSGID: 1791600317916896498 Replace with the smaller pieces that were just splitted out. This affects a few headers that are included by many, e.g. bio.h and highmem.h, which now no longer depend on the fat header. For this, several missing includes need to be added because they are no longer indirectly included, e.g. . Signed-off-by: Max Kellermann --- include/linux/bio.h | 2 ++ include/linux/dma-mapping.h | 1 + include/linux/highmem-internal.h | 2 ++ include/linux/highmem.h | 4 +++- include/linux/scatterlist.h | 2 +- include/linux/skbuff.h | 4 ++++ lib/scatterlist.c | 1 + 7 files changed, 14 insertions(+), 2 deletions(-) diff --git a/include/linux/bio.h b/include/linux/bio.h index 875d792bffff..e2f24d7235d3 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -5,7 +5,9 @@ #ifndef __LINUX_BIO_H #define __LINUX_BIO_H +#include // for struct kiocb, IOCB_NOWAIT #include +#include /* struct bio, bio_vec and BIO_* flags are defined in blk_types.h */ #include #include diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h index 4a658de44ee9..37d5591039c7 100644 --- a/include/linux/dma-mapping.h +++ b/include/linux/dma-mapping.h @@ -11,6 +11,7 @@ #include #include #include +#include /** * List of possible attributes associated with a DMA mapping. The semantics diff --git a/include/linux/highmem-internal.h b/include/linux/highmem-internal.h index a3028e400a9c..a479e6b7c54c 100644 --- a/include/linux/highmem-internal.h +++ b/include/linux/highmem-internal.h @@ -2,6 +2,8 @@ #ifndef _LINUX_HIGHMEM_INTERNAL_H #define _LINUX_HIGHMEM_INTERNAL_H +#include + /* * Outside of CONFIG_HIGHMEM to support X86 32bit iomap_atomic() cruft. */ diff --git a/include/linux/highmem.h b/include/linux/highmem.h index 00341b56d291..10a165a913ad 100644 --- a/include/linux/highmem.h +++ b/include/linux/highmem.h @@ -7,7 +7,9 @@ #include #include #include -#include +#include // for page_size() +#include // for folio_put() +#include #include #include diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h index 0516e64dc03e..9221bba82b23 100644 --- a/include/linux/scatterlist.h +++ b/include/linux/scatterlist.h @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #ifdef CONFIG_UML diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 28c7cb7ce251..06fedc08b998 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -16,6 +16,10 @@ #include #include #include +#include // for alloc_pages_node() +#include // for get_page(), put_page() +#include // for page_to_nid() +#include // for page_is_pfmemalloc() #include #include #include diff --git a/lib/scatterlist.c b/lib/scatterlist.c index 68b45c82c37a..03599396f15d 100644 --- a/lib/scatterlist.c +++ b/lib/scatterlist.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include