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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 430D8C6379F for ; Sat, 18 Feb 2023 00:44:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229936AbjBRAo4 (ORCPT ); Fri, 17 Feb 2023 19:44:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229745AbjBRAow (ORCPT ); Fri, 17 Feb 2023 19:44:52 -0500 Received: from mail-pf1-x449.google.com (mail-pf1-x449.google.com [IPv6:2607:f8b0:4864:20::449]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8EE756D274 for ; Fri, 17 Feb 2023 16:44:24 -0800 (PST) Received: by mail-pf1-x449.google.com with SMTP id cm17-20020a056a00339100b005a8ee90fbc6so1417708pfb.4 for ; Fri, 17 Feb 2023 16:44:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=content-transfer-encoding:cc:to:from:subject:message-id :mime-version:date:from:to:cc:subject:date:message-id:reply-to; bh=IBSmhJ9ipoo0Oy2qay0G1ptCUfzuQODOJj/hstMVcmk=; b=imEYDxwwEn/4CYQJK/xJbuIKiY4mo1+nmV8jIzdJV4eI/764dz2m+meDh01JJx5t6S UIDNGlzyUfdjUTeiAJzDkPKXM9ee8xLByXrj//WGSQK41Cv/mEvHlEm6RlwI6jwkSLed hos8h3ENVYDv87MnLgF7CM4L7vKUHazOqBLi/CiV+d+RzuXI890doOjYQvUc62aO48q7 dm6NLSSGIcCfcUC2cr4b2EIp8NOescyaa3gXQ5KN84+KXumeahL4bqGEJcSFMld18wEW NhulrdZvIphBlSYDfp+H6ogHt67d94O36qMzB3gwpX83PL5ljNrIzL+GKkQGwlnPgWtv rrWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:from:subject:message-id :mime-version:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=IBSmhJ9ipoo0Oy2qay0G1ptCUfzuQODOJj/hstMVcmk=; b=Vh/O0Qo2xl7VQRPa2PDCvAuEQVuTn+f3Sg+6nd9JsoUrsmC3rZQ3HGKNTOLhFljrM8 fLiiRy9CO/RIUxY7Tk4lGVQWTNgVVok/jQRwbt+VR/Ehsd12exhyh24I/CP+KqUuMbfu YYcwsHrREI//Hn4M2VkgeKHpPg+YjpkTkJ7AU6fFV7bfo95l5XGIvODrn5zbtrUQQqXO lVTO5iOJd1/FiTKEmThFBNxc4Aznc29zinYh/HJ9ZCu+V+w5GEgolASdSCtnN6w4LSeL XjKUPVBfEPnjewa8+vo0XdrHpUE4OjrZJ+B4765/o09ftbXIsxT6x6SRxL5yHk6DeJZl QnPQ== X-Gm-Message-State: AO0yUKUk/oYoitiVIQFjzChLmLKY9ADdHCZqCRWZ4XIu/CabEyNtbcSL NT0g58Z8qT6wiloQ9Fug54acMRAF/QzUKavitQ== X-Google-Smtp-Source: AK7set8P2InLokX7h6SGTjLxGcvTxlMTNEl08mJjOuceq+afgJzVx8eL5P++cDQs2DMPcv+E/m77nUCKI6PeSSOwnQ== X-Received: from ackerleytng-cloudtop.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:1f5f]) (user=ackerleytng job=sendgmr) by 2002:a17:902:f782:b0:19a:b627:b260 with SMTP id q2-20020a170902f78200b0019ab627b260mr419572pln.12.1676680988770; Fri, 17 Feb 2023 16:43:08 -0800 (PST) Date: Sat, 18 Feb 2023 00:43:00 +0000 Mime-Version: 1.0 X-Mailer: git-send-email 2.39.2.637.g21b0678d19-goog Message-ID: Subject: [RFC PATCH 0/2] Add flag as THP allocation hint for memfd_restricted() syscall From: Ackerley Tng To: kvm@vger.kernel.org, linux-api@vger.kernel.org, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, qemu-devel@nongnu.org Cc: aarcange@redhat.com, ak@linux.intel.com, akpm@linux-foundation.org, arnd@arndb.de, bfields@fieldses.org, bp@alien8.de, chao.p.peng@linux.intel.com, corbet@lwn.net, dave.hansen@intel.com, david@redhat.com, ddutile@redhat.com, dhildenb@redhat.com, hpa@zytor.com, hughd@google.com, jlayton@kernel.org, jmattson@google.com, joro@8bytes.org, jun.nakajima@intel.com, kirill.shutemov@linux.intel.com, linmiaohe@huawei.com, luto@kernel.org, mail@maciej.szmigiero.name, mhocko@suse.com, michael.roth@amd.com, mingo@redhat.com, naoya.horiguchi@nec.com, pbonzini@redhat.com, qperret@google.com, rppt@kernel.org, seanjc@google.com, shuah@kernel.org, steven.price@arm.com, tabba@google.com, tglx@linutronix.de, vannapurve@google.com, vbabka@suse.cz, vkuznets@redhat.com, wanpengli@tencent.com, wei.w.wang@intel.com, x86@kernel.org, yu.c.zhang@linux.intel.com, Ackerley Tng Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, This patchset builds upon the memfd_restricted() system call that has been discussed in the =E2=80=98KVM: mm: fd-based approach for supporting KV= M=E2=80=99 patch series, at https://lore.kernel.org/lkml/20221202061347.1070246-1-chao.p.peng@linux.int= el.com/T/#m7e944d7892afdd1d62a03a287bd488c56e377b0c The tree can be found at: https://github.com/googleprodkernel/linux-cc/tree/restrictedmem-rmfd-hugepa= ge Following the RFC to provide mount for memfd_restricted() syscall at https://lore.kernel.org/lkml/cover.1676507663.git.ackerleytng@google.com/T/= #u, this patchset adds the RMFD_HUGEPAGE flag to the memfd_restricted() syscall, which will hint the kernel to use Transparent HugePages to back restrictedmem pages. This supplements the interface proposed earlier, which requires the creation of a tmpfs mount to be passed to memfd_restricted(), with a more direct per-file hint. Dependencies: + Sean=E2=80=99s iteration of the =E2=80=98KVM: mm: fd-based approach for s= upporting KVM=E2=80=99 patch series at https://github.com/sean-jc/linux/tree/x86/upm_base_support + Proposed fix for restrictedmem_getattr() as mentioned on the mailing list at https://lore.kernel.org/lkml/diqzzga0fv96.fsf@ackerleytng-cloudtop-sg.c.g= ooglers.com/ + Hugh=E2=80=99s patch: https://lore.kernel.org/lkml/c140f56a-1aa3-f7ae-b7d1-93da7d5a3572@google.= com/, which provides functionality in shmem that reads the VM_HUGEPAGE flag in key functions shmem_is_huge() and shmem_get_inode() Future work/TODOs: + man page for the memfd_restricted() syscall + Support for per file NUMA binding hints Ackerley Tng (2): mm: restrictedmem: Add flag as THP allocation hint for memfd_restricted() syscall selftests: restrictedmem: Add selftest for RMFD_HUGEPAGE include/uapi/linux/restrictedmem.h | 1 + mm/restrictedmem.c | 27 ++++++++++++------- .../restrictedmem_hugepage_test.c | 25 +++++++++++++++++ 3 files changed, 43 insertions(+), 10 deletions(-) -- 2.39.2.637.g21b0678d19-goog