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: 5587 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp148577wrn; Fri, 17 Feb 2023 16:49:59 -0800 (PST) X-Google-Smtp-Source: AK7set9vj6bsfo33EVc7fBLeu0XcOkY2v1jYrYlgEhZvIIhJ8jDy45Sq4d6frog1PG8+d6FaPVCe X-Received: by 2002:a05:6a20:7b11:b0:c7:32b8:d6b9 with SMTP id s17-20020a056a207b1100b000c732b8d6b9mr6036630pzh.13.1676681398711; Fri, 17 Feb 2023 16:49:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676681398; cv=none; d=google.com; s=arc-20160816; b=HhomtJ0/rJ0aRRpg1Tnb0EfwMi0ugt0rH/Je5doEI+qtazfDUJng8vRt2H7n1qO9uR fLKIlxbPiO/+8ybix/q5rz+7xtmV2G0Qt03SAFZgKuDpHCK9lu/HhWqSNa+7XptFduss RoI1FITO6Knwmg/+v5Fjxseidp6KUZRcAlh9XUreMBmywl8kcwl9yvlc5LfZwJIHEmSv 7dvmYodVOSA5iRNwPo3RSNMgMeDiPFJHkmrfBghUfjRzNV1sJgKI8jaDKuPV9jNs8i2u Il6N5PJajAa57tHX1Izlu2SDmTEffZp5kxSsZn9KNA5ULQr0pxhVkBhbOXyVwlNlt+JN HLLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:from:subject :message-id:mime-version:date:dkim-signature; bh=IBSmhJ9ipoo0Oy2qay0G1ptCUfzuQODOJj/hstMVcmk=; b=Ai57zLaF+amt2jPLwd7P5Rqtxlz2cBSUqkZBeOH743v1mYTlOId3wvQOA+QrMQX9GB KBlPeVRwBxUUv6uRtjj/cGaV9d9/drOoA8kVbUKZKpCpbljnt+LrNIUQSyiCsG4KvX5K Ee+xNPn9YG6GgO+a4G+dFgRed8jFzmjQGGHuNBJw08w9EWgMn2GfPxh3zfkX1r0eMnaT w2od6Qaq6It1MqAMxUDVpRI+j2vP9oXg8qrwtrKN8xpcFWbuMDbvXzGdQj8Ksy62ToCB qqHVCrPMSUvSQ+Us4OJOOog1+WOEfmxuRxCOA+MAa31eBDALbyS4ftcEBm7d96PKY9S1 w3mA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=imEYDxww; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 15-20020a63070f000000b004cb94362cb8si6146667pgh.195.2023.02.17.16.49.46; Fri, 17 Feb 2023 16:49:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=imEYDxww; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229949AbjBRAoz (ORCPT + 99 others); Fri, 17 Feb 2023 19:44:55 -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-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-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758127874327576779?= X-GMAIL-MSGID: =?utf-8?q?1758127874327576779?= 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