From patchwork Sat Feb 18 00:43:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ackerley Tng X-Patchwork-Id: 13145418 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 7CDD0C05027 for ; Sat, 18 Feb 2023 00:43:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 22C906B0099; Fri, 17 Feb 2023 19:43:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1DC6A6B009A; Fri, 17 Feb 2023 19:43:12 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0A5596B009B; Fri, 17 Feb 2023 19:43:12 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id ECC8D6B0099 for ; Fri, 17 Feb 2023 19:43:11 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id BFC3280556 for ; Sat, 18 Feb 2023 00:43:11 +0000 (UTC) X-FDA: 80478563382.17.17E3D38 Received: from mail-pf1-f202.google.com (mail-pf1-f202.google.com [209.85.210.202]) by imf02.hostedemail.com (Postfix) with ESMTP id 0309B8000E for ; Sat, 18 Feb 2023 00:43:09 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=imEYDxww; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf02.hostedemail.com: domain of 3HB_wYwsKCEEdfnhuoh1wqjjrrjoh.frpolqx0-ppnydfn.ruj@flex--ackerleytng.bounces.google.com designates 209.85.210.202 as permitted sender) smtp.mailfrom=3HB_wYwsKCEEdfnhuoh1wqjjrrjoh.frpolqx0-ppnydfn.ruj@flex--ackerleytng.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1676680990; 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: references:dkim-signature; bh=IBSmhJ9ipoo0Oy2qay0G1ptCUfzuQODOJj/hstMVcmk=; b=FPpft9kpcwSl2VYIMJzOoiNwhHiKFz9ySJPldoWJm0eE8faKZHS5DLWstKZ8JZ4VBo4spQ nAbSnCx6e939HRv+DdWjpbp0jT0cyUiUMpyYsFhk31tNhSpYXHRJC/SrqwYLG8QgnkCK72 +SMwyGX3s5Hc4H7nThTha4AzysPPAbE= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=imEYDxww; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf02.hostedemail.com: domain of 3HB_wYwsKCEEdfnhuoh1wqjjrrjoh.frpolqx0-ppnydfn.ruj@flex--ackerleytng.bounces.google.com designates 209.85.210.202 as permitted sender) smtp.mailfrom=3HB_wYwsKCEEdfnhuoh1wqjjrrjoh.frpolqx0-ppnydfn.ruj@flex--ackerleytng.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1676680990; a=rsa-sha256; cv=none; b=0KFTDWedgfmdSOmHAYf7xafb3QfyEVpgvMlCFUGJUmN1C1MuE7sS79csYfXKu8LwX1Cffi 7HBvB8JirXawxraVaLEfaRAT4sVAdlhLgkTGsOq7cOxPCFTTjSWMxLwfTB+5dhRc4/R59Y P8IBoLr3nGpC5mmsZUysdYGL9qByyro= Received: by mail-pf1-f202.google.com with SMTP id h25-20020a62b419000000b005a8da78efedso1221718pfn.2 for ; Fri, 17 Feb 2023 16:43:09 -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=pZm0iSTy4NEreSYtnDDCJPpMB342vJ++BxBncMCy/me4HxdlaEwE567+8tRMgUBgrF 6Yrt6BbQLoXocwnAMzVsEcBKAYx2bcGsRXNbacjVxhavil2tj+foHYmb+1VrOH8TbHxM 7Gik6wQtlddHl/n2djJyZW9ZPVWUcAF60skN46vp9s2Jnf2+6Q5jcQLpe7BAA3H5435L h0S3KiNg31DTYO3GcNz04RGB+u6s6SctMt+fUyWxpdGzY6RWKnbFX6/emMAjhN5EjpDw dK6NCtAsGrEkXmU0Vfti5IDgUKKLzoa4ZY3rJHZzB+p+8mL8dXBKlbNYGYkW1F0QE1nP vqHQ== X-Gm-Message-State: AO0yUKVd21RPpAvZVgjxSECmQC/vsXqGddnbo++hRUENm9TaE4/56bJx OarNYVqIyW3n7e8biQBjBA73+TD2o87x8xNpVQ== 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 X-Rspamd-Queue-Id: 0309B8000E X-Rspamd-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4L 6C3Nrz3Bunu3u4E5h2fuGUjXByWhxPGYJdhLPJjBQ2b9FdgQr8hOcZxxhFI864NbB3ZqLsyM4Q6pGr9XYVlxo7v3M0GiTI0HwKhESB1lpzX4keZg+QfMB2TnFN+cBtAd4/xZTvt1V7UudK9636OsRE4+LLb3YodILPuLl8TbZ9MtB2u/ApymWyO+K/lCW5AJIw54s+/k4LQtdb7sHBPhUyjBtEgeGF6Olg0AtCdiOffZrPc2lrrqdKc9F5OSN/cW/lm9KKjYrFdaRFNEvvbaEJAhcjgAA8vmxnBLCzzLHGuib0y03rvanfKRg21g92sLQcCRSaFpDrmCUH1UP+ZUEcwoSvt6iVbifmYU8S6VbC7BxKX4TuOD1GCNm4sO5Bu6DkBTINGsSB2KJZADupSwP3z6/b76mZzjy4hVTwl662TciTE8Pd0yuPL3v+/jwq1CudZP5GWaZxp5woR6s4zL1T5+01AqFoYD4Bwjqk73ornXYCB7athR1FdzX9frOiXZWhR4JhIuY24EOA98T3toGkcXKYUuHtugRqOzHkVWQY5pYogiWrpDNIx1du8p4ycSXeDINWYpE8THQONxhIkz3Oxtrqetuqj1N+mWXYSfbNERSYAMGZ/lnt+3/Ik08gF+MG2TlmDBsF92W84BsSY+MdvD6BbiwzumOIMWNS2vMyb68IqJ5OJ9ItNimOLOBJP0CNkp77TY5swPsCTIkItd6AZv/cDGk7qWMWvgtoxQvvc9dgIn8tJE/wUsAzkIG8T5Y5skn8qxJ6MQpiGaCOE6Tkhap6/sR889OdX5jfr8iZvGXfMyL84D2djn42V/sWZ8q248wRXI2scHBLcTTJBgeAVAv97M0Tt4iAwK+8S5JWxS5uqiWs+GKEGOmkdfbixLmLuy/dCUaywA9ky3+yqu+Pod7pkPcGH2Ec8nraZCbVmJAsS0= 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: Hello, This patchset builds upon the memfd_restricted() system call that has been discussed in the ‘KVM: mm: fd-based approach for supporting KVM’ patch series, at https://lore.kernel.org/lkml/20221202061347.1070246-1-chao.p.peng@linux.intel.com/T/#m7e944d7892afdd1d62a03a287bd488c56e377b0c The tree can be found at: https://github.com/googleprodkernel/linux-cc/tree/restrictedmem-rmfd-hugepage 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’s iteration of the ‘KVM: mm: fd-based approach for supporting KVM’ 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.googlers.com/ + Hugh’s 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