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: 13778434 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5E779C5472C for ; Mon, 26 Aug 2024 20:45:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=2iIRbDNVyj1lHjlop0tZMw2JlHFFftRtxMxE0Q8z7r8=; b=pzmI0vjfTUjygiDyM8oQVWczsE 4wV5xGmETpwPuZfc0g/W8J01K40LBedtMKlDHDaMj8g2DzVx1lIByGoq/UzDUiRtoqc1HOtmJIrnu BeZQDS2bFaANUMpFThdbtVxYKFgROuy6eVWH7m3bcNRp2OAJnDj4LpOqIpmNeB7agm4D60T1LL0OA vfQ+xNGfbaX/X1BdXmD9xD5VzLBfwFj1aSB42wsAbCN1qEvuTfhCUGnybotl/ZgPIvXL2WCtNS5hO 0C1mnuGZYqrrT04smiMu6bevTBAbq0gHvZRXonFK6BxOdg6P2I+F4llTIQ6swK+kdAT+Kr7rZ8Hxt XiU+h4KQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1siga9-00000008epa-2XbI; Mon, 26 Aug 2024 20:44:57 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sigZG-00000008eKW-2yWI for linux-arm-kernel@lists.infradead.org; Mon, 26 Aug 2024 20:44:04 +0000 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-347-T7iKttrrONKZ__wYvhEJTQ-1; Mon, 26 Aug 2024 16:43:59 -0400 X-MC-Unique: T7iKttrrONKZ__wYvhEJTQ-1 Received: by mail-oo1-f70.google.com with SMTP id 006d021491bc7-5de842f4435so3259461eaf.1 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=b7wgZo1cZBG8c9A0Vg04rV3oSwCZsYCS+eoVzT4/m0CVw068k9d/oFyZHh/8s2bpX1 1LzNOtNdo97+UhMwqIv5DnJriXgBelv/EFOWEVP2Osmrb1wSIo6Y+5Dj+v71zPeuEhPH f1Ttg+u8/v+rmVjK6C6GgpEHsjBi/SwvwRmkS+pEzUmq7NHErQUdR8SPURY5wfsgMXfl INY+AzbLsqku0Obtz2+6AEWlblB+RQZS+GvLjMjry1YM6rl0mvCBMuTOBI4slxjZjpmE V3KQFFkHFdwxUyRKdcL1bBsizLSVKBIw9JJwwfDf32Hw6maqnLYhsxAtnfg3JHGhdXuX qQrg== X-Forwarded-Encrypted: i=1; AJvYcCWD4a5qWzOq0P9z3eAO9FjeB2sdl+tVNCy6Vl57mN7j9eN5nG0AiJXbKxKnMZPFTpyWHBd0G9zjWHOXBswghZXT@lists.infradead.org X-Gm-Message-State: AOJu0Yw5jtKeA9KOXC6SVL/p4Hp9FXLzfk2/1Gfaa81To/eaFj0wEIM0 qx3hjCg9oZ2AY9BI8nEGfEwZK4seVHRpBUfySpzwtjXmhL+nhhXZQSKHJJLwLPzcCD088tpLNw+ 3VLDeO29jgylBPQlekQVDKCACFSM3gTyAF/y7/mPkD0NQIXBPAZECp09cnV2/+AHZl9dvFF8E X-Received: by 2002:a05:6358:52ca:b0:1b5:a032:9994 with SMTP id e5c5f4694b2df-1b5ebe5b1b3mr113534655d.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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240826_134402_842947_714D659B X-CRM114-Status: GOOD ( 12.69 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 #