From patchwork Mon Aug 26 20:43:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13778394 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C87C4C5472C for ; Mon, 26 Aug 2024 20:44:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1C6026B0082; Mon, 26 Aug 2024 16:44:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 12E716B0088; Mon, 26 Aug 2024 16:44:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D865E6B0083; Mon, 26 Aug 2024 16:44:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id B342F6B0082 for ; Mon, 26 Aug 2024 16:44:03 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 24DEA813F8 for ; Mon, 26 Aug 2024 20:44:03 +0000 (UTC) X-FDA: 82495573566.17.D8FDDB1 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf22.hostedemail.com (Postfix) with ESMTP id F39BBC0016 for ; Mon, 26 Aug 2024 20:44:00 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=CA7zNfCF; spf=pass (imf22.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724704954; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=2iIRbDNVyj1lHjlop0tZMw2JlHFFftRtxMxE0Q8z7r8=; b=OCTniikZddJpJLc8fJliw5ZJ7tpEkcKJchEWaN/kIUfGSMR093EawSfVDNKqBisaS5D0wq ImcItjFveDGY0ZNo+QLnlw1FZanPIaGDjdBB+t67RiF10R3lYCPOb/bbCUXGeROCKgRw3+ zT+jjdkalfIBDiynidKgDj+gWiopf08= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724704954; a=rsa-sha256; cv=none; b=QjNQFK4FgClozr/jY/NYNnhqZR+9b5wiyOuC9baI0GK6c0yGXcjfppjp2m/BqEobZuJXP7 Kd1JZ2CozeJVNUc14FzbReAQL2As0rGTAsmF3+RNRQTzJ4ScwbYjElYXonYig2GbnWDy9f cSnPcaQEoKq6thEZYGRd89ZwahFlv6Q= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=CA7zNfCF; spf=pass (imf22.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724705040; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2iIRbDNVyj1lHjlop0tZMw2JlHFFftRtxMxE0Q8z7r8=; b=CA7zNfCF0xUY8jKJ9JgY/kSX2J8YK01F40vOchM0sYYa4NDNpDHxg9BeNO4hagmivubtyG YlZAgkrrQI78kEmy0yTimIsepL55GhwXOU5gUt2wPO9I3SedP/HrTTKKZ9SceYnSXIA30L e1107/ltOvoiEiQ0f5QPulh9HawiSEQ= Received: from mail-oo1-f70.google.com (mail-oo1-f70.google.com [209.85.161.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-355-y9rnmEz8NU2Ygaoy134OUA-1; Mon, 26 Aug 2024 16:43:59 -0400 X-MC-Unique: y9rnmEz8NU2Ygaoy134OUA-1 Received: by mail-oo1-f70.google.com with SMTP id 006d021491bc7-5d5ba96af29so6521244eaf.0 for ; Mon, 26 Aug 2024 13:43:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724705038; x=1725309838; 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=2iIRbDNVyj1lHjlop0tZMw2JlHFFftRtxMxE0Q8z7r8=; b=kk0PHQ/vwRxKjwp3fmjHqjWFlfkB6wTBXpwRnPqEYhRCQKSMkqRdWN+RPbdC2qoPgE 2tnC3QaQJb6BONsOwxKbHyL9865ykNapW6MryEuBjeO62VWp4uPthThMOPJwtrri50D9 q3Rkz4wtvnwSE0A4YNopV5Fk/HhiDHvUEifRYVpepY0hDwWIH3oYuvuPVmXb1oy0y8Hz Z9dMYQHkPuJyA4fQ/l8b4K6MLlMy6j8JGVvIIVJ4Yn6UAHONS5PQfgJ8M8AXKc/vKqPR 0UJMKFRLmBurVikbrOrtiCG/ZdsfsTBUC9g4A6Or531BumZoE9PlHZyWaz2UcilIVdMI 39zQ== X-Forwarded-Encrypted: i=1; AJvYcCXOG9MCHglDOy+PQ3skybupEUc3CX+ovkw7ecpuozoOwsfpBhyh0YMhXvtSMjncMD7JCB+KPfB5yA==@kvack.org X-Gm-Message-State: AOJu0YzDKmjgnu8LPxB6Sr5eo/DfKez8lSzqro53gYPOdNRpJdTMPO+q T4+OENnNiYmHgqQlISsuRTBr3JSJ+kbVm7BQdz7WbFDnHk13jDyGfGuDgropuEYe0cbRLcpRbAB wBSqSGcX0LXmFUE2C4xK/qo2/CREJ6CmhignNTcV4y7e511M/ X-Received: by 2002:a05:6358:52ca:b0:1b5:a032:9994 with SMTP id e5c5f4694b2df-1b5ebe5b1b3mr113536255d.0.1724705038386; Mon, 26 Aug 2024 13:43:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHkrFRhmUpfOOmJ2YwtqClR5K8A29/GQ8sXabHeZ52sv0b77XENUJCQ9LJLwxTjS7HZUYg0sQ== X-Received: by 2002:a05:6358:52ca:b0:1b5:a032:9994 with SMTP id e5c5f4694b2df-1b5ebe5b1b3mr113532855d.0.1724705038035; Mon, 26 Aug 2024 13:43:58 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a67f3fd6c1sm491055185a.121.2024.08.26.13.43.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2024 13:43:57 -0700 (PDT) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Gavin Shan , Catalin Marinas , x86@kernel.org, Ingo Molnar , Andrew Morton , Paolo Bonzini , Dave Hansen , Thomas Gleixner , Alistair Popple , kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Sean Christopherson , peterx@redhat.com, Oscar Salvador , Jason Gunthorpe , Borislav Petkov , Zi Yan , Axel Rasmussen , David Hildenbrand , Yan Zhao , Will Deacon , Kefeng Wang , Alex Williamson Subject: [PATCH v2 01/19] mm: Introduce ARCH_SUPPORTS_HUGE_PFNMAP and special bits to pmd/pud Date: Mon, 26 Aug 2024 16:43:35 -0400 Message-ID: <20240826204353.2228736-2-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240826204353.2228736-1-peterx@redhat.com> References: <20240826204353.2228736-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Stat-Signature: km6uekbzhx64ckxmoygj6wxnyen9xu11 X-Rspamd-Queue-Id: F39BBC0016 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1724705040-672687 X-HE-Meta: U2FsdGVkX18hXbVwUgKuzTt1Wzwt2EynbH7Rs3DWrCiUa17s+FJzpLdZwD/3nMHc3FhWXXj3oG3lyh60Zv5PHzmIgzeSkPlFTEvg5yh1DLrHHcD3d3IjqjDJLoWnojHP3qHnmN2t5JfckLxgFWaMGq11mqTTAtYmmjk5nduRZ+XSSKEa3CUQxc0z6AqrKhLzx0yL72svAbi0tRKOnPfFvZpYV+MCmdBaEaTAxhoJOXCewQd7CBIgpScPgHk/x/ho4s5LUthCaS0gtp/FPFleeF+NI0YE9+HXFQPb2SXeLtcyaKSGjlnifPPKRguTkxORTPis4f+pyzypMbTOXbHrZOI7ps70aOifVlD4sDiOxUmvCSCEOB7ndv7NCYXyfbQCr1vddPnqcNae1YoAhyWBs7j1QCka2/4+LpCOhT6nw20cxeawpwaB+rZDG3Y2aQYPnxZmZxWR4c86g6+CjTeAqLMFTIRWy5zHptisi1fVZeMJbWJKWVrIPF1EyUeR7FzwAAiZsccwRQNg5zNNQq4snlfAyvHeoZO3O7DjVAsRt5jiPG/AzePjHD8SEAJxiCViw3ijem1MUBtE5ov6Pg2jBuKbaEkNwOBmsI3ZFu3dQ7Wigw4/BmSWk58m7+mjJuJS8v0zh6F4yYC/BxehLl4WL5H6DtakiocADErSK6VGQbaMQxMRGOlYrhByboFqdTfwanrI0K+oT/AbY1VQS4btLLpKiui9YYvO4C3dFLip6olnXPGIDCSjbpqEFuUR+PfV30/2pyzs9gckZPbajUQCVe4hyfF4C+A6WfpIIVLVBEGKYyX5vDhAO8Z1iZgcL591gTHWiUhfmU5vAeUQ+kk4YeS3b76HsRtz/0no6osLhb3orWDt/TCcOXs97h7F6oCDSlGiU1KjFYHmYC2VfVx/+vGGH/0tVQTkhk7fq3gz/NGiOodQMK8q+X4jdMP0Uf6xY5+fIV2k7mtT37z4yXu ZUtP4TpU vR3WiN7cYH5+uNPip+LXUlQb9nFhcD9vPHnX/jv7zRss+iEXGE2F9zEmRnReA1l5w8QVxdDGFmyDJNsaGFpQ5f5ezRMs1iNkSu1lMfMHIpVkdh1gAc/1RIv9w4SqhMG2hQ16J3U71YfgjwuOxxsjN7Pp8FMlSwrX4yvAR16H2M24wOIil27QSv/GC/d3GM5ZvlOo8KX9a/xWxImGmC/SLg0QBt9ENkYkhJmz8q+xc8I/n/5M1RqEuf/Ukucw3Y3QxIUjxvFiIf97PE8PHjbhUAd3OJQoAO7K4fUBUmRQ3BPxhrpqJM8QrPQN2c2xm/J5T+bDErtQN9wzezCilSU5DhfiuP0wOscvN5mEABzblEsb5eY3ma/4PXU0Xtp10O1eMvhP5 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: This patch introduces the option to introduce special pte bit into pmd/puds. Archs can start to define pmd_special / pud_special when supported by selecting the new option. Per-arch support will be added later. Before that, create fallbacks for these helpers so that they are always available. Signed-off-by: Peter Xu --- include/linux/mm.h | 24 ++++++++++++++++++++++++ mm/Kconfig | 13 +++++++++++++ 2 files changed, 37 insertions(+) diff --git a/include/linux/mm.h b/include/linux/mm.h index b0ff06d18c71..d900f15b7650 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2643,6 +2643,30 @@ static inline pte_t pte_mkspecial(pte_t pte) } #endif +#ifndef CONFIG_ARCH_SUPPORTS_PMD_PFNMAP +static inline bool pmd_special(pmd_t pmd) +{ + return false; +} + +static inline pmd_t pmd_mkspecial(pmd_t pmd) +{ + return pmd; +} +#endif /* CONFIG_ARCH_SUPPORTS_PMD_PFNMAP */ + +#ifndef CONFIG_ARCH_SUPPORTS_PUD_PFNMAP +static inline bool pud_special(pud_t pud) +{ + return false; +} + +static inline pud_t pud_mkspecial(pud_t pud) +{ + return pud; +} +#endif /* CONFIG_ARCH_SUPPORTS_PUD_PFNMAP */ + #ifndef CONFIG_ARCH_HAS_PTE_DEVMAP static inline int pte_devmap(pte_t pte) { diff --git a/mm/Kconfig b/mm/Kconfig index 8078a4b3c509..b23913d4e47e 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -875,6 +875,19 @@ endif # TRANSPARENT_HUGEPAGE config PGTABLE_HAS_HUGE_LEAVES def_bool TRANSPARENT_HUGEPAGE || HUGETLB_PAGE +# TODO: Allow to be enabled without THP +config ARCH_SUPPORTS_HUGE_PFNMAP + def_bool n + depends on TRANSPARENT_HUGEPAGE + +config ARCH_SUPPORTS_PMD_PFNMAP + def_bool y + depends on ARCH_SUPPORTS_HUGE_PFNMAP && HAVE_ARCH_TRANSPARENT_HUGEPAGE + +config ARCH_SUPPORTS_PUD_PFNMAP + def_bool y + depends on ARCH_SUPPORTS_HUGE_PFNMAP && HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD + # # UP and nommu archs use km based percpu allocator #