From patchwork Fri Aug 9 16:08:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13758917 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 AFFA2C52D7C for ; Fri, 9 Aug 2024 16:09:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 40EBF6B009A; Fri, 9 Aug 2024 12:09:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3C0556B009E; Fri, 9 Aug 2024 12:09:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 212A26B009F; Fri, 9 Aug 2024 12:09:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id EC5486B009A for ; Fri, 9 Aug 2024 12:09:22 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 8DE48412C2 for ; Fri, 9 Aug 2024 16:09:22 +0000 (UTC) X-FDA: 82433191764.08.B3EEB76 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf26.hostedemail.com (Postfix) with ESMTP id 6B174140014 for ; Fri, 9 Aug 2024 16:09:19 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=WQmcrt4G; spf=pass (imf26.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=1723219693; 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=fKim6v00HbGyszP90Y55Ixe8BGOuNlK0Kt5OSqhmIXk=; b=TtOGcpKGE9HB8sUpuFs+ANKtrTDYtvl5TapTVuNBFUCHTesdGsqVVxtXilo0/mI39BfyRI 7Rn7MaWolg/kAwcXKF1QN5eOCN4hbNS23N9yK+beTnJaIXopiXMVtGgY1FhVgTg1HF5f5k XWmd1YIoQLD7mM2RbmtTHGGPRSIBQSo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723219693; a=rsa-sha256; cv=none; b=tNS7AOTJnD+OEzziMGuADxeXV5iGCq26dfQRyrqWGrzW4zn6c0sq84OkkzegJFPuzrsrk2 HQAhYw2YegEvTiSi6o4jGYf3T5RbtBCd7L+lzlT6FFY2xgUgwqXqnFXx2RSy2NmCcI/t9f TIWdQqqSGVJ7mVBGa5MryEqK1iyYRKc= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=WQmcrt4G; spf=pass (imf26.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=1723219758; 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=fKim6v00HbGyszP90Y55Ixe8BGOuNlK0Kt5OSqhmIXk=; b=WQmcrt4GzDvpomcCmmo5ToSnVO+INctBuXCOUQ3auzuvhxMYhACHwmP6D2GBDboupjq6HE YuMgs/UHQaUL4xWQ7A+X9qwagzP3gN93+XlfwJxYc29WzvqODbkXjw5/QmLXAhM1NSAqds lu+LyExRnkakYClNc5vUpHYUh4HJCb8= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-617-Qmd3C24qOpiinUJEEOUMOw-1; Fri, 09 Aug 2024 12:09:17 -0400 X-MC-Unique: Qmd3C24qOpiinUJEEOUMOw-1 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-7a1d3c02fcfso7764685a.0 for ; Fri, 09 Aug 2024 09:09:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723219757; x=1723824557; 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=fKim6v00HbGyszP90Y55Ixe8BGOuNlK0Kt5OSqhmIXk=; b=SkcrRan5dDVYKCHi8QyKdkYx3o1uVbEFEfWZfuL1nvKbZ1M51RNL/WvUG9xTQ1ecQr OEUH3LKGQO/7u23QOWDvGXwh4lHcM4Pa6/dHLFFokax4hG7pf7dsfckQDKswp2DUpDOQ RXiz3umSwmhemYqg8qmMw8vQNGPx+pLLqfOjUOxX5adNMBXvwsgDkxqz1+d85RKSCHvY pKdOrbipHC0ctxUwgAZ0vEHFBfRVTj69REpLKOFOOysE4ouc4DaCvKqb5DHldInfozF2 j1npLyDb7S44D0CdmZK4BJ4zO2Ksa9oXGfKM8aZFazHuAnoJWIHUXyuq9OPXUZmDInY0 Miwg== X-Gm-Message-State: AOJu0Yy/4z10/JN5xaU1/o2D2Zhoqq+bF3L1tjmBJceVtHoXykpmi8uy lrJKG04wmn7q+iWA81QpAyr8uzepySTfTR0mCoYdxpBy0i9z1mBl0uAN67An9iCa9KE4LXYqG0c 0/yCKh0ecnfxs6+UxCE8Id9XILPbxqmbYYbyzs+mxzIFlIyd2eSDI1oG9ShMXzzvd4RFxVfyWli hZaMm+PWou+NU8AkcUw2LjosLmcUhof8R+ X-Received: by 2002:ac8:58c4:0:b0:450:1e5e:3f3f with SMTP id d75a77b69052e-4531255bb38mr13611261cf.5.1723219756764; Fri, 09 Aug 2024 09:09:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEAN0G3ozf6o5j8NgDrSR8g+6fB/Zkz8yhBLk8I4VWUl++aRhUduuiwR699bOA3QLxmHpo6kg== X-Received: by 2002:ac8:58c4:0:b0:450:1e5e:3f3f with SMTP id d75a77b69052e-4531255bb38mr13610781cf.5.1723219756198; Fri, 09 Aug 2024 09:09:16 -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 d75a77b69052e-451c870016csm22526741cf.19.2024.08.09.09.09.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Aug 2024 09:09:15 -0700 (PDT) From: Peter Xu To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Sean Christopherson , Oscar Salvador , Jason Gunthorpe , Axel Rasmussen , linux-arm-kernel@lists.infradead.org, x86@kernel.org, peterx@redhat.com, Will Deacon , Gavin Shan , Paolo Bonzini , Zi Yan , Andrew Morton , Catalin Marinas , Ingo Molnar , Alistair Popple , Borislav Petkov , David Hildenbrand , Thomas Gleixner , kvm@vger.kernel.org, Dave Hansen , Alex Williamson , Yan Zhao Subject: [PATCH 01/19] mm: Introduce ARCH_SUPPORTS_HUGE_PFNMAP and special bits to pmd/pud Date: Fri, 9 Aug 2024 12:08:51 -0400 Message-ID: <20240809160909.1023470-2-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240809160909.1023470-1-peterx@redhat.com> References: <20240809160909.1023470-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 6B174140014 X-Stat-Signature: ren19cqf9h4min68wno6ggt31expgwse X-HE-Tag: 1723219759-765670 X-HE-Meta: U2FsdGVkX1/k+smkUzu/B4ot38UMYG5bXYF7s1VI0ZwjIyeMa19MONwhwCRLPCfqT63AQXsxyQp2TPuqDz8IDIRrLia6F6ASW3QfrgkR3e4rgxoTOyBWRAF1NPRxU33HRhBunGiu0wjprc2bJY+X3YcIPGvHekzKSGrh2q0Rcq4c/j31MrG50kcJ2ur8tTeTjk39NxBbJpuIijZHNMGz9dkVBw36vIupHxiHkRZHhCVMzNkrTuX1oisvx4SSDqR1co8sCijp2PnA8a1MWNtJXiS585PQ8cpuMiLmoM0bwHmVKshz+uyAcTSWosIK+2cEk6o4N+zLzUbfQoFCf4KZXPY5LC0pJQmezn/WP+InStHWSPyaCYbODW4BWzw8PMuXvoeC3eB+wt0Jx/UEfhc3bjTOFGWmigYL4f/JUFrx3FPJwL0hk7SLqWQ010uj7Vcn91ylzT36DZKgFbvUo0Pqk7PpBFJ+Yn/Z0/RT2FSuTJKYisqhjRebgMEg9Gsgf9ZS/Dv3gzkdIkvo9f7cxG0Ld94E0NebemwEUIK21suZP7/npvpF41uBJAewayWLbTumHUtq1B01mcUxFpeDnZxZSGVPS7OvGvRapkCzkGSJKNpEhkpbttW5BCcpfQhCx2mltNoiXlCJxv7fV3nr25B1lsH20bl0Ojz4yqITfAUI7qdeG0GhG+1YgZYyJIKt75w02tpd3b8ami5QwoxDdf4YodebelZMciTI2H3Cc4bNjPJCm6wJ43fi2w+6Voj2dcP6hv8dT2DmC6b93M4+VBDF8FWW9HgOTQwQvQn6pXJfkZU8E5snRxXngU0Y+jpws+Zw8X3IJr5Uktu6Vx7VO9RVEBeAUD3MRnYXI65dOxlNE7HboeUlGxUkbqanirrQOXfidHinJJxIXHdhAJOP4WP8CId8pFuri/ZNbUbnXW5YNs2BlFzcF9SqMS6eO8hHq+2KrNqDHDELI8MOXD5ckLt We98TiWS C6g/i8EnbFhJC593TzPxd+FUdphkc7woYFnf42nqqz6effrW2b3tyhXZLixDiJ/ZPysr/2PvTYamnNo8kq3vt4nBc9Ah9eUsSGu2K8IGETfN7K/L3l+AUGQCnZ1oofP7NiHXQCA4Urk69ece2sGwbqF1SfbqmngWUqLWr3+Vd331vuaVs+UFYmaXlk6u/vaKTHmFc+wgH8Lb1OiBFxfY1I6sdEJ2GDDtKJzZK/BOjASxJ4Q+KSrC/yY2j0WAoKgoMja8v9idrnrlOetnzms86X6zCC4I7/zfot8TyPTs+JsFVx4Wz7ndus0jdb+wzvb+pdPbhAH8MA0LS1J22z+C45HqG5oMSbswgG8ZSuaOFp1xqK+oY9wNMkk1nGhJpywH/mGi8p1RrJtt2y09JksQQuDPyY9Q3OBSuZwx7RZkEcNUmkQWmmss/b7OP92wM2z8oxGtEJSHDdQWbGM0LNXbNMaxwoarJo4TScX9Vo73K8EmPmAmgP6saJkvT8r/agOY80VVI 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 43b40334e9b2..90ca84200800 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2644,6 +2644,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 3936fe4d26d9..3db0eebb53e2 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -881,6 +881,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 #