From mboxrd@z Thu Jan 1 00:00:00 1970 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 2E47EECAAA1 for ; Mon, 24 Oct 2022 15:26:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B28CA940008; Mon, 24 Oct 2022 11:26:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AB1C2940007; Mon, 24 Oct 2022 11:26:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 92BF0940008; Mon, 24 Oct 2022 11:26:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 823C5940007 for ; Mon, 24 Oct 2022 11:26:42 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 533BE140DC0 for ; Mon, 24 Oct 2022 15:26:42 +0000 (UTC) X-FDA: 80056220244.26.784BA85 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf04.hostedemail.com (Postfix) with ESMTP id 5CF9D40037 for ; Mon, 24 Oct 2022 15:26:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666625200; h=from:from: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:in-reply-to:references:references; bh=UBAegUasNa5RuqJ7q9GZwuYTzFErEwMDb+Eg1mrTrvE=; b=Bf6K+ywIiuvLBIKKRrUP39dmMwFcgNefQxA4dO3oi3HFUaByQEC3liHAa/WTmbSHjqP3UA Y+q9Ilo0xYZxzNlFVNFFP4+jaRx/1yzA2LmDtMov0jwTu+dzE0x6C7Mh79wdW0sOURDBb/ ap3tA5yDdHgaP4W/UH5ILaRgq21M80k= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-445-8i-cROb0NsC0fu-PIWw17w-1; Mon, 24 Oct 2022 11:26:39 -0400 X-MC-Unique: 8i-cROb0NsC0fu-PIWw17w-1 Received: by mail-wr1-f69.google.com with SMTP id h26-20020adfaa9a000000b002364ad63bbcso3546860wrc.10 for ; Mon, 24 Oct 2022 08:26:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=UBAegUasNa5RuqJ7q9GZwuYTzFErEwMDb+Eg1mrTrvE=; b=24a+IF2Q0c52ZA0cPqXhQ+9tqqv+DajRoLIcTT/ElaijGurkR5VLy+SLyv/x8tUxFW eqR3UxDwmlxveOpAZhPWgIghEsXhqLk/B93EmaOrMNeWwGg8QXjMhncXJoBEnUsW8Dd8 w6a+IGAPHnUT6inU1g67kOVWScbaJexp2h6jp575yG3IsSMjMjtI9xzDSBdzqgF8eJy0 7pl246MJ56nzsTXzcPFnWsz6VrsrkioqkZ7pVJbS1C/Zp2ezT5k+KgpuAd4SpKSxW3HF 1rJB7fgEbQBDTnDIIXyv9ry7fQzJIAkbXAFm7v7socSbFtZqgHJWE4YDoKMrDL8w7Wm6 xUrQ== X-Gm-Message-State: ACrzQf3I35M8ojQ1w+EH3lR1xg4bogJDNDEUKa1wZI/92MLlD0DBrGcP +qrBv8dqptCPLM6y4HzCQSEcA2jZcT31m8Gsp9YFMgl+LUurtghGaECZlG+mIn/vl5wYlPgcNZQ t0H6Nck2Im6k= X-Received: by 2002:a5d:5a11:0:b0:22e:3ed1:e426 with SMTP id bq17-20020a5d5a11000000b0022e3ed1e426mr21883687wrb.642.1666625197885; Mon, 24 Oct 2022 08:26:37 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4QYF0qpu+Yh4YQF+Y42ukyfMe46omRnCHz7TFmRMmq2+h+eVJ2IzD1faJk9A3cMFb5eNTxMw== X-Received: by 2002:a5d:5a11:0:b0:22e:3ed1:e426 with SMTP id bq17-20020a5d5a11000000b0022e3ed1e426mr21883650wrb.642.1666625197580; Mon, 24 Oct 2022 08:26:37 -0700 (PDT) Received: from ?IPV6:2003:cb:c704:f100:6371:a05b:e038:ac2c? (p200300cbc704f1006371a05be038ac2c.dip0.t-ipconnect.de. [2003:cb:c704:f100:6371:a05b:e038:ac2c]) by smtp.gmail.com with ESMTPSA id k21-20020a05600c0b5500b003cdf141f363sm194606wmr.11.2022.10.24.08.26.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 24 Oct 2022 08:26:37 -0700 (PDT) Message-ID: Date: Mon, 24 Oct 2022 17:26:34 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.1 Subject: Re: [PATCH v8 1/8] mm/memfd: Introduce userspace inaccessible memfd To: "Kirill A . Shutemov" , Sean Christopherson Cc: Chao Peng , Vishal Annapurve , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org, linux-doc@vger.kernel.org, qemu-devel@nongnu.org, Paolo Bonzini , Jonathan Corbet , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H . Peter Anvin" , Hugh Dickins , Jeff Layton , "J . Bruce Fields" , Andrew Morton , Shuah Khan , Mike Rapoport , Steven Price , "Maciej S . Szmigiero" , Vlastimil Babka , Yu Zhang , luto@kernel.org, jun.nakajima@intel.com, dave.hansen@intel.com, ak@linux.intel.com, aarcange@redhat.com, ddutile@redhat.com, dhildenb@redhat.com, Quentin Perret , Michael Roth , mhocko@suse.com, Muchun Song , wei.w.wang@intel.com References: <20220915142913.2213336-1-chao.p.peng@linux.intel.com> <20220915142913.2213336-2-chao.p.peng@linux.intel.com> <20221021134711.GA3607894@chaop.bj.intel.com> <20221024145928.66uehsokp7bpa2st@box.shutemov.name> From: David Hildenbrand Organization: Red Hat In-Reply-To: <20221024145928.66uehsokp7bpa2st@box.shutemov.name> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Bf6K+ywI; spf=pass (imf04.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666625201; a=rsa-sha256; cv=none; b=uu/YQCnsVUjUZzX0WeAEB07t3j9rOWO21e3MxMWHxxxhGjjW7bCgB5Nzd5PdjIor2BOmCA saF0jP59Mr53414VvfzJ52u1O70s3X7eZAYA7HhBFUVuQVjHHjYR177PW3um3i5JyZsnek 47E9l84qx4SghLB6aY6E7lKoDgvg1Is= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666625201; 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:in-reply-to:references:references:dkim-signature; bh=UBAegUasNa5RuqJ7q9GZwuYTzFErEwMDb+Eg1mrTrvE=; b=3MIurqFfe+OtI66pCPoOJZyaCfcT99EckYcakcIJGp6sBXaZsxq784h06jP4SgxjftBrC0 0PjCKcBKmvQ6XMJ0vBWyZ94q8v1ClvFwoaZqoC+iQZmnyBwHQC+6i2GoW6/pp4ENzn4pom 67KOrEbxwz29Yl9HbKlXoeGm8LJNamo= Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Bf6K+ywI; spf=pass (imf04.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Stat-Signature: x6nbkibtt4i5uotbbs8kwhxmf8y11awa X-Rspamd-Queue-Id: 5CF9D40037 X-Rspamd-Server: rspam02 X-Rspam-User: X-HE-Tag: 1666625201-59501 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: On 24.10.22 16:59, Kirill A . Shutemov wrote: > On Fri, Oct 21, 2022 at 04:18:14PM +0000, Sean Christopherson wrote: >> On Fri, Oct 21, 2022, Chao Peng wrote: >>>> >>>> In the context of userspace inaccessible memfd, what would be a >>>> suggested way to enforce NUMA memory policy for physical memory >>>> allocation? mbind[1] won't work here in absence of virtual address >>>> range. >>> >>> How about set_mempolicy(): >>> https://www.man7.org/linux/man-pages/man2/set_mempolicy.2.html >> >> Andy Lutomirski brought this up in an off-list discussion way back when the whole >> private-fd thing was first being proposed. >> >> : The current Linux NUMA APIs (mbind, move_pages) work on virtual addresses. If >> : we want to support them for TDX private memory, we either need TDX private >> : memory to have an HVA or we need file-based equivalents. Arguably we should add >> : fmove_pages and fbind syscalls anyway, since the current API is quite awkward >> : even for tools like numactl. > > Yeah, we definitely have gaps in API wrt NUMA, but I don't think it be > addressed in the initial submission. > > BTW, it is not regression comparing to old KVM slots, if the memory is > backed by memfd or other file: > > MBIND(2) > The specified policy will be ignored for any MAP_SHARED mappings in the > specified memory range. Rather the pages will be allocated according to > the memory policy of the thread that caused the page to be allocated. > Again, this may not be the thread that called mbind(). IIRC, that documentation is imprecise/incorrect especially when it comes to memfd. Page faults in shared mappings will similarly obey the set mbind() policy when allocating new pages. QEMU relies on that. The "fun" begins when we have multiple mappings, and only some have a policy set ... or if we already, previously allocated the pages. -- Thanks, David / dhildenb