Message ID | cover.1679428901.git.ackerleytng@google.com |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp1995976wrt; Tue, 21 Mar 2023 13:34:11 -0700 (PDT) X-Google-Smtp-Source: AK7set++JyEMSA7tCTWxH37p8EW6O/lDagyZVIJBChAlSidNNcL4LCnQ1HRRpmi2bR7l4St6CoQY X-Received: by 2002:a05:6a20:6a83:b0:d9:dfd3:367c with SMTP id bi3-20020a056a206a8300b000d9dfd3367cmr2739618pzb.12.1679430851379; Tue, 21 Mar 2023 13:34:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679430851; cv=none; d=google.com; s=arc-20160816; b=nFx9GECyDIt6I7D7XOlef6mufzL+Y6vKeQYScKOz9lyMlUGVBYTlU/jTBED/o2Zmwb cV9BEmVI/pl0eK0D26IMKqGi2vWD7w+BIziZQDPp/KXyMqcMVSQ0f9Uvf+WfP7DKmLZx BvWCkBLT9CfbfFSgdMzfCfxESZvnXEb8lp9SCKFNb8AQI4qwkHcCmmXJ0FOkDj21G3el RXO5V3ZuEievVy5Y69QOfCSlriGUiKMDpNHJP8mHmK7hovqXseWSGr+yenQi0PDlSACV RwOvsJBMCRiKMTDr99rPJT7BDpkDjozUBBt8ybpe35vpQtQA7jd1Tlmj3W1i4vm6OXYs RgSQ== 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=e2RhtQenWH6Mmh2njKfsOonde6iRcUbhqsfef2trssA=; b=JO48sg2UluhWMezYN1jskns2jQyd7sNhdbwzdF+tEdElqjb/IQxefWp6TT1yhZE2xa EviMOq44e+EsmOo+Nnfhhpqwfq8nHbRmmn2ikiM8ZKiXwdhrV9wgCvgIPHTlA2ekpw2z JNIYQlE5gYAjB2zsI384bgOydJAcu9n2VX9NRlNpjqgVduezVMPFQbs8i8VPx/B1q6sG iSwM13Ojiy2lmt6ib1c0kgqH96xXKkjJPWD1XhnH0efvCx81YStjTeXkTqkwqymTrxCF W6sIXiuHgLY92DAOpoRMD4DoxOenoVb+7NAY3HWNlDaI71/Nj0lJaULzZwDHiiFub5+F Yy9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=dnKqgSgE; 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 j63-20020a638b42000000b0050faaed4f76si2841056pge.751.2023.03.21.13.33.58; Tue, 21 Mar 2023 13:34:11 -0700 (PDT) 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=dnKqgSgE; 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 S230169AbjCUUQR (ORCPT <rfc822;ezelljr.billy@gmail.com> + 99 others); Tue, 21 Mar 2023 16:16:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230098AbjCUUQC (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 21 Mar 2023 16:16:02 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD3FF4FABC for <linux-kernel@vger.kernel.org>; Tue, 21 Mar 2023 13:15:44 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-54476ef9caeso164701297b3.6 for <linux-kernel@vger.kernel.org>; Tue, 21 Mar 2023 13:15:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1679429742; h=content-transfer-encoding:cc:to:from:subject:message-id :mime-version:date:from:to:cc:subject:date:message-id:reply-to; bh=e2RhtQenWH6Mmh2njKfsOonde6iRcUbhqsfef2trssA=; b=dnKqgSgEzV+DXuBj2wvXDWtPBqMuV2pwg2Ct8dJ2rJdc95M/lMmTlgUP2dyyQzQZCx Iq/GSx8zfNi6cjpPXlkvFiOhBlsMCmXfLOq2dWRkj0Zbu4B9VrBzE1cjAeJDG4LmIiwg a9p667GlxYr1b3vFk56oQTORyucJI5+lnS4aHOLrWZKn48LKgZbwlngGZRNrH23IiQia BTjGsvcRLxI3EBaHYPgl4POvKLFsuX54uyRRVU32IC2UmWI9FBGXUcJ03hDcw7BY7FEu rCQmjrE3DmckWD6OUpMbPS8UMoHoyUpzCmWhtOkP6a7Lv2e0ND7qGYcbxH/6oa0I4dOE 4qTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679429742; 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=e2RhtQenWH6Mmh2njKfsOonde6iRcUbhqsfef2trssA=; b=RxTU3xJ3zfWpZ4v3jiXZ8ihaqOlmEYvFs/Rz0BVLvMXBizb7v4/imTTdlVI1w8N2WA fxCbRHA0kNOjK6lsyZVxkepMk65N7+/PIl7fdS2qp+uCthGktA3vnVqqEwdjyAvln8qP r/VZP0wGb7eTqhWEh8CMZ3BFP5yTuzoIXYvo5Q8GvyFjRjqX7Z0gmjD56PWvhTaNgyu+ EpxpxBY3ypOHqFf90CqHGXPSGs5WYhuF2U2uq39m/nGsRgnt8IS4dXxoZpDWEvhZhzir iZeKYhLNcH1NQK199UxKrwK2Yys0L47yIbJBtNkbBKo2X9HOCGENj9Qnupr29TcLn7J4 pviA== X-Gm-Message-State: AO0yUKWov4hYoG25eA/ag2C3HF6F1yMAdWj+mkNrY03q5gfICjw52y/Q eYHRMGfmGN3oFSWtAmkQDziVw8vYZ0QaCU2UiQ== X-Received: from ackerleytng-cloudtop.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:1f5f]) (user=ackerleytng job=sendgmr) by 2002:a05:690c:d88:b0:544:bbd2:74be with SMTP id da8-20020a05690c0d8800b00544bbd274bemr11229418ywb.4.1679429742690; Tue, 21 Mar 2023 13:15:42 -0700 (PDT) Date: Tue, 21 Mar 2023 20:15:31 +0000 Mime-Version: 1.0 X-Mailer: git-send-email 2.40.0.rc2.332.ga46443480c-goog Message-ID: <cover.1679428901.git.ackerleytng@google.com> Subject: [RFC PATCH v2 0/2] Providing mount in memfd_restricted() syscall From: Ackerley Tng <ackerleytng@google.com> 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 <ackerleytng@google.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761010884387304679?= X-GMAIL-MSGID: =?utf-8?q?1761010884387304679?= |
Series |
Providing mount in memfd_restricted() syscall
|
|
Message
Ackerley Tng
March 21, 2023, 8:15 p.m. UTC
Hello, This patchset builds upon the memfd_restricted() system call that was 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-provide-mount-fd In this patchset, a modification to the memfd_restricted() syscall is proposed, which allows userspace to provide a mount, on which the restrictedmem file will be created and returned from the memfd_restricted(). Allowing userspace to provide a mount allows userspace to control various memory binding policies via tmpfs mount options, such as Transparent HugePage memory allocation policy through 'huge=always/never' and NUMA memory allocation policy through 'mpol=local/bind:*'. Changes since RFCv1: + Use fd to represent mount instead of path string, as Kirill suggested. I believe using fds makes this syscall interface more aligned with the other syscalls like fsopen(), fsconfig(), and fsmount() in terms of using and passing around fds + Remove unused variable char *orig_shmem_enabled from selftests 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 fixes for these issues mentioned on the mailing list: + https://lore.kernel.org/lkml/diqzzga0fv96.fsf@ackerleytng-cloudtop-sg.c.googlers.com/ Links to earlier patch series: + RFC v1: https://lore.kernel.org/lkml/cover.1676507663.git.ackerleytng@google.com/T/ Ackerley Tng (2): mm: restrictedmem: Allow userspace to specify mount for memfd_restricted selftests: restrictedmem: Check hugepage-ness of shmem file backing restrictedmem fd include/linux/syscalls.h | 2 +- include/uapi/linux/restrictedmem.h | 8 + mm/restrictedmem.c | 63 ++- tools/testing/selftests/Makefile | 1 + .../selftests/restrictedmem/.gitignore | 3 + .../testing/selftests/restrictedmem/Makefile | 15 + .../testing/selftests/restrictedmem/common.c | 9 + .../testing/selftests/restrictedmem/common.h | 8 + .../restrictedmem_hugepage_test.c | 459 ++++++++++++++++++ 9 files changed, 561 insertions(+), 7 deletions(-) create mode 100644 include/uapi/linux/restrictedmem.h create mode 100644 tools/testing/selftests/restrictedmem/.gitignore create mode 100644 tools/testing/selftests/restrictedmem/Makefile create mode 100644 tools/testing/selftests/restrictedmem/common.c create mode 100644 tools/testing/selftests/restrictedmem/common.h create mode 100644 tools/testing/selftests/restrictedmem/restrictedmem_hugepage_test.c -- 2.40.0.rc2.332.ga46443480c-goog