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 lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 36639C38A2D for ; Mon, 24 Oct 2022 16:19:06 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1omzLi-0005T2-2x; Mon, 24 Oct 2022 11:26:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1omzLf-0005Rg-NW for qemu-devel@nongnu.org; Mon, 24 Oct 2022 11:26:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1omzLc-0000W0-TY for qemu-devel@nongnu.org; Mon, 24 Oct 2022 11:26:43 -0400 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-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-410-cFxDQatgN9iE-l2saw3BXQ-1; Mon, 24 Oct 2022 11:26:39 -0400 X-MC-Unique: cFxDQatgN9iE-l2saw3BXQ-1 Received: by mail-wm1-f72.google.com with SMTP id r203-20020a1c44d4000000b003c3a87d8abdso4286236wma.2 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=aiZma/rO2MkU1legtK+wZLMBeln8W3pR+65LEUfi8W5OcI7kLJ39UrgScM5vEG+mgl vrMEy9FXItJYPqc6kthdBW6EEQcQ8Zj/BCiHY7P7KG1ms1cFEhVddg5/64YP/DiCEAQs wDf2GEqDWc3gSp8D2yvcC3ABqYhBKHyVX5/ZOs5Ko4z2BlHWnr9Gvb0en1CHpAWx57co ewOnfYBiKKLKm7tDetpK2mrwb54VTHWPewDw6erI8D15+uzliROAGuaAjaAH9YfkJqeP jjZGvHz8wct3g6+qt0A/wPMpdAKrjcF7vPr4sOFByp7oX4AOh5tXk8pkMtSt/b0uvgnc zQaQ== X-Gm-Message-State: ACrzQf3MbASYQSIC1+KwgGFl9ML4KseWyRA0pBrf0yTG+PV/hnTuHcjl 5oFsZleDXsoPyfnofQH3YKJ55fcLFw/EAFl+fXg1DvPnVWiVfKFGtWKyZeR+rS4yiqhOVnKL4DP md5p96tMCE8/yTNo= X-Received: by 2002:a5d:5a11:0:b0:22e:3ed1:e426 with SMTP id bq17-20020a5d5a11000000b0022e3ed1e426mr21883690wrb.642.1666625197884; 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 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 Received-SPF: pass client-ip=170.10.133.124; envelope-from=david@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.503, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, NICE_REPLY_A=-0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.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