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 29E99D2E9D8 for ; Mon, 11 Nov 2024 11:02:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8546F6B007B; Mon, 11 Nov 2024 06:02:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7DE2F6B0083; Mon, 11 Nov 2024 06:02:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 60A436B0085; Mon, 11 Nov 2024 06:02:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 420936B007B for ; Mon, 11 Nov 2024 06:02:08 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id E3C031C4C02 for ; Mon, 11 Nov 2024 11:02:07 +0000 (UTC) X-FDA: 82773523518.22.950C8FD Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by imf26.hostedemail.com (Postfix) with ESMTP id CD79F14001B for ; Mon, 11 Nov 2024 11:01:34 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=P49p6Xb9; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=tkrmPWiL; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=P49p6Xb9; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=tkrmPWiL; dmarc=none; spf=pass (imf26.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=vbabka@suse.cz ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731322751; a=rsa-sha256; cv=none; b=LB3sr/Dj8t5Kt2tiyA2x8ZoYt81igykd5Y8Lo/+/INIljo8Yb6Hr+Wjf82vyBlTd0UbfNN aZRARCDLnyLLync56z8Yex9hK20TaQlHNmSCWWbhmaiBSQ0Y++4LKTnH3XvjL1ZkE1JqNd F7vSkp76m3QGAVUQkhcCG8hse+6Zk1w= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=P49p6Xb9; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=tkrmPWiL; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=P49p6Xb9; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=tkrmPWiL; dmarc=none; spf=pass (imf26.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=vbabka@suse.cz ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731322751; 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=uXHVH0ccgWFcGpeM6HgeltmGCkaKDRVIsW9/gEoqXsg=; b=tM0EqtBJODIqzgUwBGnQnOBVA3XxeYJ84bs6dPWCXOq4ibcB6Qp2F+mkApPtahcnT92WEI Q7cU2AnJQ91wyTBmsRd4CvyFTrwCuYjLU3J8osQQ7oGv5ILKMjILCNCV/2QiR5k5lzapoY naqWFRysUHKxjVF4rCeD25/QjAekka0= Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 9C1381F38E; Mon, 11 Nov 2024 11:02:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1731322923; h=from:from:reply-to: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:autocrypt:autocrypt; bh=uXHVH0ccgWFcGpeM6HgeltmGCkaKDRVIsW9/gEoqXsg=; b=P49p6Xb9X9EU2crk2y1oMy2KeTCSI+7k6Cf4qmPXhaV50qDusoH3M+AMdTpVGy/6Sw6I3k fnrYtFYt4WdUKE7CGto1/WoVovedVCYShD6+l5IRSG7wNAYlv48lXRP3KaFSgszfEodJWJ sO/nDG7MsI1U1JfpVZOXgSTrqJ10mdY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1731322923; h=from:from:reply-to: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:autocrypt:autocrypt; bh=uXHVH0ccgWFcGpeM6HgeltmGCkaKDRVIsW9/gEoqXsg=; b=tkrmPWiLNNj2qm3VuGpKD+E8ycRAHQNEVnHcYHSe5dia8bkPxhGQfF3p8F1nao0Gio6rFJ jN8zHuwwIRfhMYBw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1731322923; h=from:from:reply-to: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:autocrypt:autocrypt; bh=uXHVH0ccgWFcGpeM6HgeltmGCkaKDRVIsW9/gEoqXsg=; b=P49p6Xb9X9EU2crk2y1oMy2KeTCSI+7k6Cf4qmPXhaV50qDusoH3M+AMdTpVGy/6Sw6I3k fnrYtFYt4WdUKE7CGto1/WoVovedVCYShD6+l5IRSG7wNAYlv48lXRP3KaFSgszfEodJWJ sO/nDG7MsI1U1JfpVZOXgSTrqJ10mdY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1731322923; h=from:from:reply-to: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:autocrypt:autocrypt; bh=uXHVH0ccgWFcGpeM6HgeltmGCkaKDRVIsW9/gEoqXsg=; b=tkrmPWiLNNj2qm3VuGpKD+E8ycRAHQNEVnHcYHSe5dia8bkPxhGQfF3p8F1nao0Gio6rFJ jN8zHuwwIRfhMYBw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 60442137FB; Mon, 11 Nov 2024 11:02:03 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id ricQFyvkMWfuIwAAD6G6ig (envelope-from ); Mon, 11 Nov 2024 11:02:03 +0000 Message-ID: Date: Mon, 11 Nov 2024 12:02:02 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH 0/4] Add fbind() and NUMA mempolicy support for KVM guest_memfd Content-Language: en-US To: Paolo Bonzini , Matthew Wilcox , Shivank Garg Cc: x86@kernel.org, viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, akpm@linux-foundation.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-api@vger.kernel.org, linux-arch@vger.kernel.org, kvm@vger.kernel.org, chao.gao@intel.com, pgonda@google.com, thomas.lendacky@amd.com, seanjc@google.com, luto@kernel.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, arnd@arndb.de, kees@kernel.org, bharata@amd.com, nikunj@amd.com, michael.day@amd.com, Neeraj.Upadhyay@amd.com, linux-coco@lists.linux.dev References: <20241105164549.154700-1-shivankg@amd.com> <6004eaa4-934c-48f4-b502-cf7e436462fc@amd.com> <10ffac79-0dba-4c30-991e-f3ca2b5ff639@redhat.com> From: Vlastimil Babka Autocrypt: addr=vbabka@suse.cz; keydata= xsFNBFZdmxYBEADsw/SiUSjB0dM+vSh95UkgcHjzEVBlby/Fg+g42O7LAEkCYXi/vvq31JTB KxRWDHX0R2tgpFDXHnzZcQywawu8eSq0LxzxFNYMvtB7sV1pxYwej2qx9B75qW2plBs+7+YB 87tMFA+u+L4Z5xAzIimfLD5EKC56kJ1CsXlM8S/LHcmdD9Ctkn3trYDNnat0eoAcfPIP2OZ+ 9oe9IF/R28zmh0ifLXyJQQz5ofdj4bPf8ecEW0rhcqHfTD8k4yK0xxt3xW+6Exqp9n9bydiy tcSAw/TahjW6yrA+6JhSBv1v2tIm+itQc073zjSX8OFL51qQVzRFr7H2UQG33lw2QrvHRXqD Ot7ViKam7v0Ho9wEWiQOOZlHItOOXFphWb2yq3nzrKe45oWoSgkxKb97MVsQ+q2SYjJRBBH4 8qKhphADYxkIP6yut/eaj9ImvRUZZRi0DTc8xfnvHGTjKbJzC2xpFcY0DQbZzuwsIZ8OPJCc LM4S7mT25NE5kUTG/TKQCk922vRdGVMoLA7dIQrgXnRXtyT61sg8PG4wcfOnuWf8577aXP1x 6mzw3/jh3F+oSBHb/GcLC7mvWreJifUL2gEdssGfXhGWBo6zLS3qhgtwjay0Jl+kza1lo+Cv BB2T79D4WGdDuVa4eOrQ02TxqGN7G0Biz5ZLRSFzQSQwLn8fbwARAQABzSBWbGFzdGltaWwg QmFia2EgPHZiYWJrYUBzdXNlLmN6PsLBlAQTAQoAPgIbAwULCQgHAwUVCgkICwUWAgMBAAIe AQIXgBYhBKlA1DSZLC6OmRA9UCJPp+fMgqZkBQJkBREIBQkRadznAA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ACYCGwwWIQSpQNQ0mSwujpkQ PVAiT6fnzIKmZAUCZAUSmwUJDK5EZgAKCRAiT6fnzIKmZOJGEACOKABgo9wJXsbWhGWYO7mD 8R8mUyJHqbvaz+yTLnvRwfe/VwafFfDMx5GYVYzMY9TWpA8psFTKTUIIQmx2scYsRBUwm5VI EurRWKqENcDRjyo+ol59j0FViYysjQQeobXBDDE31t5SBg++veI6tXfpco/UiKEsDswL1WAr tEAZaruo7254TyH+gydURl2wJuzo/aZ7Y7PpqaODbYv727Dvm5eX64HCyyAH0s6sOCyGF5/p eIhrOn24oBf67KtdAN3H9JoFNUVTYJc1VJU3R1JtVdgwEdr+NEciEfYl0O19VpLE/PZxP4wX PWnhf5WjdoNI1Xec+RcJ5p/pSel0jnvBX8L2cmniYnmI883NhtGZsEWj++wyKiS4NranDFlA HdDM3b4lUth1pTtABKQ1YuTvehj7EfoWD3bv9kuGZGPrAeFNiHPdOT7DaXKeHpW9homgtBxj 8aX/UkSvEGJKUEbFL9cVa5tzyialGkSiZJNkWgeHe+jEcfRT6pJZOJidSCdzvJpbdJmm+eED w9XOLH1IIWh7RURU7G1iOfEfmImFeC3cbbS73LQEFGe1urxvIH5K/7vX+FkNcr9ujwWuPE9b 1C2o4i/yZPLXIVy387EjA6GZMqvQUFuSTs/GeBcv0NjIQi8867H3uLjz+mQy63fAitsDwLmR EP+ylKVEKb0Q2A== In-Reply-To: <10ffac79-0dba-4c30-991e-f3ca2b5ff639@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Stat-Signature: 8yur7rf6rnwh1cgq7b5w5dqp5iesyaho X-Rspamd-Queue-Id: CD79F14001B X-Rspamd-Server: rspam08 X-Rspam-User: X-HE-Tag: 1731322894-982428 X-HE-Meta: U2FsdGVkX1+7aAWnEWODpMntElw8w2+ycb5pRElBuARc2SxBBTzhg/9uG82m2jvW/19No0gMRrw1JWokG1xJf2pueImeUVsXp6JsgpYEdQueE8SiQbWuIJUscSsjtgzXrp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gpNlZiy4bMhyqxuExOTvc3iRWDgLpNzcuRUjTXNoRtXdfl8/ws7lJK28j2njfDuENlTEd/c/wVegqCegX2VXUs1asuzmdjfa5vXlEnhLFcEkgzHiYY3xIkrE7D+aHi6fm2hCKmI450IrHYLEnwG/FjaoHWNYPgfVEXBnXx8E 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: List-Subscribe: List-Unsubscribe: On 11/8/24 18:31, Paolo Bonzini wrote: > On 11/7/24 16:10, Matthew Wilcox wrote: >> On Thu, Nov 07, 2024 at 02:24:20PM +0530, Shivank Garg wrote: >>> The folio allocation path from guest_memfd typically looks like this... >>> >>> kvm_gmem_get_folio >>> filemap_grab_folio >>> __filemap_get_folio >>> filemap_alloc_folio >>> __folio_alloc_node_noprof >>> -> goes to the buddy allocator >>> >>> Hence, I am trying to have a version of filemap_alloc_folio() that takes an mpol. >> >> It only takes that path if cpuset_do_page_mem_spread() is true. Is the >> real problem that you're trying to solve that cpusets are being used >> incorrectly? > > If it's false it's not very different, it goes to alloc_pages_noprof(). > Then it respects the process's policy, but the policy is not > customizable without mucking with state that is global to the process. > > Taking a step back: the problem is that a VM can be configured to have > multiple guest-side NUMA nodes, each of which will pick memory from the > right NUMA node in the host. Without a per-file operation it's not > possible to do this on guest_memfd. The discussion was whether to use > ioctl() or a new system call. The discussion ended with the idea of > posting a *proposal* asking for *comments* as to whether the system call > would be useful in general beyond KVM. > > Commenting on the system call itself I am not sure I like the > file_operations entry, though I understand that it's the simplest way to > implement this in an RFC series. It's a bit surprising that fbind() is > a total no-op for everything except KVM's guest_memfd. > > Maybe whatever you pass to fbind() could be stored in the struct file *, > and used as the default when creating VMAs; as if every mmap() was > followed by an mbind(), except that it also does the right thing with > MAP_POPULATE for example. Or maybe that's a horrible idea? mbind() manpage has this: 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(). So that seems like we're not very keen on having one user of a file set a policy that would affect other users of the file? Now the next paragraph of the manpage says that shmem is different, and guest_memfd is more like shmem than a regular file. My conclusion from that is that fbind() might be too broad and we don't want this for actual filesystem-backed files? And if it's limited to guest_memfd, it shouldn't be an fbind()? > Adding linux-api to get input; original thread is at > https://lore.kernel.org/kvm/20241105164549.154700-1-shivankg@amd.com/. > > Paolo > >> Backing up, it seems like you want to make a change to the page cache, >> you've had a long discussion with people who aren't the page cache >> maintainer, and you all understand the pros and cons of everything, >> and here you are dumping a solution on me without talking to me, even >> though I was at Plumbers, you didn't find me to tell me I needed to go >> to your talk. >> >> So you haven't explained a damned thing to me, and I'm annoyed at you. >> Do better. Starting with your cover letter. >> > >