Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp4863821rwl; Mon, 10 Apr 2023 18:52:01 -0700 (PDT) X-Google-Smtp-Source: AKy350Z7BzY5Ylq8V7zzDAuzLA9jl5sycNZ5AVF631LZxjidH1RH0KFq54Mfz7ffKZLhzH4670mV X-Received: by 2002:a17:907:7b9f:b0:94a:5d8e:ddb0 with SMTP id ne31-20020a1709077b9f00b0094a5d8eddb0mr7683542ejc.62.1681177920852; Mon, 10 Apr 2023 18:52:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681177920; cv=none; d=google.com; s=arc-20160816; b=utxkXHC6IXBEigDhAehjQ9dhIwD9h5UsG3jz7zXJnmaJQOxrGTXyomkhOp9PF5f7WU UNUHqBwsUjuE1X1Knlmjs6yCkjjjwstVe43wYdb1weQHG9eYfA6YPIJGWUX3yeyZVBY8 15mlsJtq87cWWQ3zcRIt2HQesVUVz8KzNfn7Ac2NVgJWVegdCUGZPIvFdnnZUGbMrxs2 7OwPNyUO8JuVXKp92tYEFYIr4Sff8jQwGIbKX4G0+UyA4J9yrAytTjVWtfeDU8AD48TZ H3X7O+Oun3KI7//sbCYF4229Va8g5mjpicHn/dWgWFjtQkQV1vCWAUMPm96Vqr4Nj9at WMEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:mime-version :in-reply-to:date:dkim-signature; bh=P3v7tjSHGZNeYf6fkHAGvkufX/1T+vrTWm+HxnUGut4=; b=OVABs3l/a/mOTlUrmfsNyw955IrepieRfsxDKlTvuRPfPoIAFLKHo8tU4QaMgZVePe wITMB4OBveHtI8FqgdQPPpgfT9AX/4EPVYS+/q0vG99uWJGVK10YkYepQCLe68wWU9Mb 4fF8nrwEah7ZxJR4w4w2wjPVdWsLXgmBVckYcN1xjYxkeikbw/BJIe3Sw5pFnzPkS81n Jjw1gKZkNZRvHrfQt8mg2ZX3i4gaA8bAKzcofp8YoN1ZfqTUtwiUvEsOs1NWdFSNYIqs YAuPuw7zPi+LqJ6WSoBLFA/TYWId0zmZXQA2bC2EaBMOMDKztKrlJJmkIoHXbVb0p1Om YREA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=ckDnI+qY; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ho20-20020a1709070e9400b0094a5a281168si2977210ejc.801.2023.04.10.18.51.34; Mon, 10 Apr 2023 18:52:00 -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=ckDnI+qY; 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 S229700AbjDKBfa (ORCPT + 99 others); Mon, 10 Apr 2023 21:35:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230055AbjDKBf1 (ORCPT ); Mon, 10 Apr 2023 21:35:27 -0400 Received: from mail-pj1-x104a.google.com (mail-pj1-x104a.google.com [IPv6:2607:f8b0:4864:20::104a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36634272E for ; Mon, 10 Apr 2023 18:35:22 -0700 (PDT) Received: by mail-pj1-x104a.google.com with SMTP id k1-20020a17090a3e8100b002466844d0f7so1915350pjc.1 for ; Mon, 10 Apr 2023 18:35:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1681176921; h=cc:to:from:subject:message-id:mime-version:in-reply-to:date:from:to :cc:subject:date:message-id:reply-to; bh=P3v7tjSHGZNeYf6fkHAGvkufX/1T+vrTWm+HxnUGut4=; b=ckDnI+qYpROoTcufCDcwOgr9iK1RPksPsWmIOeBsLNA/uyUeqNZdzhUf9sXthlctPf F+wMi3ClOnexsABXRbEypc3cqMNPH6Z0tNPVuwd8fhbDH8ln+SkWrpjNxEGwPxC/2glt FMI52wFhtuuDKkOMoaifJqIS9sTG7C5BknJRLtVbUZ9NqSkywnTZ/Opexpr9pbApTgcj GvPQtEzR7qQ4/fxydRQd5pWtJ5dgkv7JwSBfm07pT8ToRPItu6TrUnHKJfJ+avfBnkLl UgRpWyM2oduh/jLdoDELNXyYnRgcaaN+uD3VPgKEYl1EqI5ru4nTcuI8zBQ1sZRVNTWk QFdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681176921; h=cc:to:from:subject:message-id:mime-version:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=P3v7tjSHGZNeYf6fkHAGvkufX/1T+vrTWm+HxnUGut4=; b=i4qsQCuxO1R8yc4zGLCOaJ7ILuQdZsXW8GmRhAKf6E2os8n0FgPMzoEd915RR0Elfa TG2x8AOPVJto/i/My7KIxbD/j9oSiMJsKa7EWD0cA9i6V9cQ9Cg5VmJ870QjV9dwty3X xjG5C74t6YA+xTxNjvbcgmysL0lfssyqsG1fghlvyhZgRuAciZK5M6y2a/TzkrJdpVSz 0cY+5nB6BoHzNyjPO8woKuEvuaESLeuieku0/mAKa/tmpKVfQE/znbp2OslHF+dlBxwj XVGbiqrXkUQiiQ9TsTp3eCr7pvVXwsfmfqjtoEolyvNh8vwcZFz7vgu5F5/LA8DL2YpL 1l6w== X-Gm-Message-State: AAQBX9eXMjGFUHJu9SXD4U4SvGHwMyIiN/0yDxQG1y8Tubg5Bv7WQPKK pj3MROyoMchO2J1BqSwGoNXFByYpoHKm/O+cDg== X-Received: from ackerleytng-cloudtop.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:1f5f]) (user=ackerleytng job=sendgmr) by 2002:a63:4c1c:0:b0:518:1f4d:3dbc with SMTP id z28-20020a634c1c000000b005181f4d3dbcmr213711pga.10.1681176921489; Mon, 10 Apr 2023 18:35:21 -0700 (PDT) Date: Tue, 11 Apr 2023 01:35:20 +0000 In-Reply-To: <9bbdc378-e66e-0a44-244b-33dffe888a2b@redhat.com> (message from David Hildenbrand on Mon, 3 Apr 2023 10:24:37 +0200) Mime-Version: 1.0 Message-ID: Subject: Re: [RFC PATCH v3 2/2] selftests: restrictedmem: Check hugepage-ness of shmem file backing restrictedmem fd From: Ackerley Tng To: David Hildenbrand Cc: 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, 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, 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 Content-Type: text/plain; charset="UTF-8"; format=flowed; delsp=yes X-Spam-Status: No, score=-7.7 required=5.0 tests=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 David Hildenbrand writes: > On 01.04.23 01:50, Ackerley Tng wrote: >> For memfd_restricted() calls without a userspace mount, the backing >> file should be the shmem mount in the kernel, and the size of backing >> pages should be as defined by system-wide shmem configuration. >> If a userspace mount is provided, the size of backing pages should be >> as defined in the mount. >> Also includes negative tests for invalid inputs, including fds >> representing read-only superblocks/mounts. > When you talk about "hugepage" in this patch, do you mean THP or > hugetlb? I suspect thp, so it might be better to spell that out. IIRC, > there are plans to support actual huge pages in the future, at which > point "hugepage" terminology could be misleading. Thanks for pointing this out! I've replaced references to hugepage with thp, please see RFC v4 at https://lore.kernel.org/lkml/cover.1681176340.git.ackerleytng@google.com/T/ >> Signed-off-by: Ackerley Tng >> --- >> 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 | 486 ++++++++++++++++++ >> 6 files changed, 522 insertions(+) >> 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 >> ...