Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp7173055rwi; Mon, 24 Oct 2022 10:43:57 -0700 (PDT) X-Google-Smtp-Source: AMsMyM41YEE8PrAjPpc0wePJ2e1M5c+SGOE2myHPD5s8/oc/lqiUIBkx2Du/2KbKSZjV9AXprHZX X-Received: by 2002:aa7:df04:0:b0:45b:cb0d:856a with SMTP id c4-20020aa7df04000000b0045bcb0d856amr32722952edy.180.1666633436879; Mon, 24 Oct 2022 10:43:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666633436; cv=none; d=google.com; s=arc-20160816; b=wFo9CR+xNv/mQMnn0UTjiTb8S/i6Jp98ztswph0wkFKtu/KXfeQ1yhMh4op7rs870q kua1TrlH4ABKw8SB15oukMBpGsKFn1e2+AmkHZmHESD1Xnlb/97R4gKwbTFISfwtYPcM UtUKd4JS4zuUsnTQsIWvnUnXxZ13c7L1ZkUi/rZRUn5EbLMHMyEQYULjEN9v0X7EhYPJ j6qtvNn5rtc4+PRH+jvSb03vora1YM0KkvDhjUJtVD56jCwIxyDSp/UnLUzw+oPTpoX7 77Xgyl3lSSEUgcWNQErOYcgVadmq4ZC2IkGV5PYXp0VE0Day4vtSHaa6eF5PaDR2Gaz1 NY9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=UBAegUasNa5RuqJ7q9GZwuYTzFErEwMDb+Eg1mrTrvE=; b=kJRWi9B72JRM5VvfyaQgi+F8nfnL3mP7vITuo40MJE+udqtF2aW7YSBhKNEYGoEKVS Xm17q0sqlr6NucQ08OCqLZIMLSJ5cKb6n38CPJJsSNL1QZIY0MZMhrBSMykKgnzjBeJL vSeglk9K7KbkvjsiOwiOVaf4BV5CNaNMeGjWer4D15c/E+Y6TzHO8mXXIXhHvtiBk72p ulImR20ztX18vZn4i37HklMs/yp2HqFgyxT+uVuR4V7GeD5oWPN/fuFOlCCgE7PsSbRS D8hCR2moqmuYlF6gu370jrTVyIv1qSM3IRT49PGIeEJh/JL1A+y7WwWGG0uaJ8O2ObO/ Q02A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GYNG67W+; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c19-20020a056402121300b00461acb2deebsi344541edw.198.2022.10.24.10.43.31; Mon, 24 Oct 2022 10:43:56 -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=@redhat.com header.s=mimecast20190719 header.b=GYNG67W+; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233782AbiJXRHY (ORCPT + 99 others); Mon, 24 Oct 2022 13:07:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233533AbiJXRG7 (ORCPT ); Mon, 24 Oct 2022 13:06:59 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 252F981111 for ; Mon, 24 Oct 2022 08:41:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666626018; 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=GYNG67W+DA8GF/NETLzBpt9k4MMmo7LfXTfmJXuPE8CWlMO95uNL0xknFBE8FcZYdp3sZ0 KlTgUJ6T8nXQ0c2ZoqsmqhuQljjTEN3vk9yvGEo/2R6yHZlpbmZ5cviPLlRWiPR9TcG6Aa TEYn2vhBBdgLAHSrCmQXcdkJuvi0z1M= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-580-yPoM1ZQVN3qBiIehV9rDaw-1; Mon, 24 Oct 2022 11:26:39 -0400 X-MC-Unique: yPoM1ZQVN3qBiIehV9rDaw-1 Received: by mail-wm1-f72.google.com with SMTP id h129-20020a1c2187000000b003bf635eac31so4275986wmh.4 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=mJJPiqgs9vraXtSSpiJKsYsGJhC3ZhPgpv9Ucr3ipOBMASyGUnGywEuVTyJa0dLvMT xDgCVfQIvmRkNVHGDjW/dqYgdtzY6Vl26e7ZsxAdy1QZU50iAfPNxD8Q3PBom6iGX9MB LpQxV3QrIatUI3IBLS6viFqiDoPc5bhoXXuk5KFnvkbeIMV6z3bPIlLsibtWo5AKhGxX 0LgRuvgiCDDmNwPZJkkW8LUbGf7DyGyQfD6fuc1Ki8vmFsMKqkjad6SgoMWvT70/AO/W CJGTlSidik10UYeddY+fx+EM4oqUjncKw75wHa0I5D/jIVzXCSoEwMeRgZ/o8dJdNbXg 3tkA== X-Gm-Message-State: ACrzQf0Xz5mQi2/lDyEyN+HUKaobGZwQUAWzwxJE7wmhAJ3rYlj+lXvK YhhSE2LhIBBzl0D2UzZulx5uNX0Q7gQnt1vPuPKkx600aewz3GNEvGgLMSBCRt/uyDJy+kbef+q rtJ9etN5fPU0B8a72R3mYwzkx X-Received: by 2002:a5d:5a11:0:b0:22e:3ed1:e426 with SMTP id bq17-20020a5d5a11000000b0022e3ed1e426mr21883714wrb.642.1666625197887; Mon, 24 Oct 2022 08:26:37 -0700 (PDT) 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 Content-Language: en-US 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> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham 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 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