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.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (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 3CDA5CAC5A5 for ; Thu, 25 Sep 2025 14:05:29 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4cXb8Q4sSVz2yqR; Fri, 26 Sep 2025 00:05:26 +1000 (AEST) Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip="2607:f8b0:4864:20::1049" ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1758809126; cv=none; b=Nop69ZwSKIeBRpvB2PC4BKtLHRKyjRy4XpqlmBzEktk5XT3ZaaY6Rm4rW4D+XQusCGlwQSgnOWo0rv0B/8AmRlOCVIIN6depcWguOjy7LYykhccnc2VC/oGqLFRSZwTM+4G27vYRvg0t+TaM0qyRS1PInVmWxepXe0I4irgEEskvlVlAwuHTHyTFHctZqafHWtO7deqe519shVPgeZjN1WvNBtTLoZnWKRMoVvqpBQI/hF/VRtBqbgKBT8UStYuVzSRdar59aA5KNVjAN6dzXqG3RjfE/FK4uuUVDUPd0MNKXaTCq0SEmXcvhQxHr/LTHLHXRRE2X3T+nzCQj2Fv2g== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1758809126; c=relaxed/relaxed; bh=K3Nb5Uy/w9+ATOrN88r3+4hXRo3JqcPtuKmPJ0+uxMw=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=A5AHWDPcyYkBtRiCYTyqOB9BoAmeTdacE1MttAyKNYf8/AkLI82YLFJmp2VxExr/nlFWYUEhMuJ7rKr9Nq4AI+0ejMO+bRB1hKn0OQJQ1mA/mfCAQlngSwI4OYGVW949A8s8xYehNtwT1mDkWFXTOySOeqE13DFMzN5FKq/pF63Vv+1SaOLTTTChxc6oKrV+y7HDBVDpWs2Jwd7lNbvo4JFeHXpOJYTeeSmR2Rxj9cLxptzweOckYMJ7w9m29xmrTcmRvKM2EtIT0YROei5o7xVyYaHKW7cmWH7VyrFNLoDsGiOIE1C4Quf1ZIgSmagXkSceFspuco0mPuu5RVt7Cw== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=reject dis=none) header.from=google.com; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20230601 header.b=h5B5dFvr; dkim-atps=neutral; spf=pass (client-ip=2607:f8b0:4864:20::1049; helo=mail-pj1-x1049.google.com; envelope-from=3ikzvaaykc10n95ie7bjjbg9.7jhgdips-9mjangdnon.jug56n.jmb@flex--seanjc.bounces.google.com; receiver=lists.ozlabs.org) smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: lists.ozlabs.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20230601 header.b=h5B5dFvr; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=flex--seanjc.bounces.google.com (client-ip=2607:f8b0:4864:20::1049; helo=mail-pj1-x1049.google.com; envelope-from=3ikzvaaykc10n95ie7bjjbg9.7jhgdips-9mjangdnon.jug56n.jmb@flex--seanjc.bounces.google.com; receiver=lists.ozlabs.org) Received: from mail-pj1-x1049.google.com (mail-pj1-x1049.google.com [IPv6:2607:f8b0:4864:20::1049]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4cXb8P4cvNz2yqP for ; Fri, 26 Sep 2025 00:05:24 +1000 (AEST) Received: by mail-pj1-x1049.google.com with SMTP id 98e67ed59e1d1-32eae48beaaso1058165a91.0 for ; Thu, 25 Sep 2025 07:05:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1758809123; x=1759413923; darn=lists.ozlabs.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=K3Nb5Uy/w9+ATOrN88r3+4hXRo3JqcPtuKmPJ0+uxMw=; b=h5B5dFvriEl4b4IrHpRULQFgPa1cRrzOP/DzXhQxH5oPKxIiC6IYZs+nU81JYVRFIz XBFYrppBEqYLVuVa2wXEbQ7WIZzqyfiM8VCfPSbtZJMygU/Q/uOMc5s64CzmOtJ0kTXn Lk8d7NieJUtqBdgaIQq7BW44sU08qgsqlWJ7YlaqlCNnkFaibZEAoSIQbT+SgDHLqmEO Hjt+sZXEXSJcIqxSP6UMvssKLvJERRujT/Y9gRS1/yI5Omv5G6YQWGN+39fdpUxXyfgC fJiFlUeA7ziFZC2i7FQxc956JTjgFdCGIYfnSIX7IIdiL5ACt+Xh5CSGqzXNMsTwuCYP LXzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758809123; x=1759413923; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=K3Nb5Uy/w9+ATOrN88r3+4hXRo3JqcPtuKmPJ0+uxMw=; b=suDs8bma6yX/9FLeQQDdAwH9UfS87DUGbWxV1PNLl7PyzKFbvMdBNa4snzwYbFmTk4 d5fv2mGtqi8tt18xkqK2XSaBGSE9vfBGOXNMLwyo2j5QcjKePhdOxiz6lLdujYlcnrCP 4eNJfNRgRRULP/JlrAc3PJahfYjA1UuX/vu3MUno4XAt3YzYsZ8qipnwRRzJOwp8wQ3w vWGe5YvcQYLOQCv23fRKD69ZTbxaZWrM4fn6xRo/pHuOiZgEpwVPpyiWIatQjuGBm/4D Q2nXd6zyFFpxkuDQ2UoF+idG+KyRSxbFfhzIaa/vlnkuEoBD8wqwpSSpkW3EuCUc9HkW UOcw== X-Forwarded-Encrypted: i=1; AJvYcCVsFuAehi9f7xEen5dE2n6MxHN7+IQehKRoiN56PnifJcV/7+RUUxn3zqZs6QCsF3ma3cncRY2B/Y0J3A==@lists.ozlabs.org X-Gm-Message-State: AOJu0YxQjn9PgRhZTSaZg8zBo0R6Lj6ys4Fbq6ihBYwnIy3EQF7WyTN5 rxs252gKMX0lJ5ftdQv5kH42N0qvUVCk9sbGgJzqH8i4S0oShTijoPTHPwor35avAolew8vLUUh T8RzP7A== X-Google-Smtp-Source: AGHT+IEkjjemcop0vI/vs3xI7IyH1QWjecMMGslQWYv6HGbBMSaTE77RWNjTkPN4A7aBZK5WeU4rCe73+w4= X-Received: from pjo9.prod.google.com ([2002:a17:90b:5669:b0:32e:e155:ee48]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:4f8e:b0:32e:7270:94a4 with SMTP id 98e67ed59e1d1-3342a22f5c5mr3557648a91.14.1758809122488; Thu, 25 Sep 2025 07:05:22 -0700 (PDT) Date: Thu, 25 Sep 2025 07:05:21 -0700 In-Reply-To: <20250827175247.83322-8-shivankg@amd.com> X-Mailing-List: linux-erofs@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Subscribe: , , List-Unsubscribe: Precedence: list Mime-Version: 1.0 References: <20250827175247.83322-2-shivankg@amd.com> <20250827175247.83322-8-shivankg@amd.com> Message-ID: Subject: Re: [PATCH kvm-next V11 5/7] KVM: guest_memfd: Add slab-allocated inode cache From: Sean Christopherson To: Shivank Garg Cc: willy@infradead.org, akpm@linux-foundation.org, david@redhat.com, pbonzini@redhat.com, shuah@kernel.org, vbabka@suse.cz, brauner@kernel.org, viro@zeniv.linux.org.uk, dsterba@suse.com, xiang@kernel.org, chao@kernel.org, jaegeuk@kernel.org, clm@fb.com, josef@toxicpanda.com, kent.overstreet@linux.dev, zbestahu@gmail.com, jefflexu@linux.alibaba.com, dhavale@google.com, lihongbo22@huawei.com, lorenzo.stoakes@oracle.com, Liam.Howlett@oracle.com, rppt@kernel.org, surenb@google.com, mhocko@suse.com, ziy@nvidia.com, matthew.brost@intel.com, joshua.hahnjy@gmail.com, rakie.kim@sk.com, byungchul@sk.com, gourry@gourry.net, ying.huang@linux.alibaba.com, apopple@nvidia.com, tabba@google.com, ackerleytng@google.com, paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com, pvorel@suse.cz, bfoster@redhat.com, vannapurve@google.com, chao.gao@intel.com, bharata@amd.com, nikunj@amd.com, michael.day@amd.com, shdhiman@amd.com, yan.y.zhao@intel.com, Neeraj.Upadhyay@amd.com, thomas.lendacky@amd.com, michael.roth@amd.com, aik@amd.com, jgg@nvidia.com, kalyazin@amazon.com, peterx@redhat.com, jack@suse.cz, hch@infradead.org, cgzones@googlemail.com, ira.weiny@intel.com, rientjes@google.com, roypat@amazon.co.uk, chao.p.peng@intel.com, amit@infradead.org, ddutile@redhat.com, dan.j.williams@intel.com, ashish.kalra@amd.com, gshan@redhat.com, jgowans@amazon.com, pankaj.gupta@amd.com, papaluri@amd.com, yuzhao@google.com, suzuki.poulose@arm.com, quic_eberman@quicinc.com, linux-bcachefs@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-erofs@lists.ozlabs.org, linux-f2fs-devel@lists.sourceforge.net, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-coco@lists.linux.dev Content-Type: text/plain; charset="us-ascii" On Wed, Aug 27, 2025, Shivank Garg wrote: > Add dedicated inode structure (kvm_gmem_inode_info) and slab-allocated > inode cache for guest memory backing, similar to how shmem handles inodes. > > This adds the necessary allocation/destruction functions and prepares > for upcoming guest_memfd NUMA policy support changes. > > Signed-off-by: Shivank Garg > --- > virt/kvm/guest_memfd.c | 70 ++++++++++++++++++++++++++++++++++++++++-- > 1 file changed, 68 insertions(+), 2 deletions(-) > > diff --git a/virt/kvm/guest_memfd.c b/virt/kvm/guest_memfd.c > index 6c66a0974055..356947d36a47 100644 > --- a/virt/kvm/guest_memfd.c > +++ b/virt/kvm/guest_memfd.c > @@ -17,6 +17,15 @@ struct kvm_gmem { > struct list_head entry; > }; > > +struct kvm_gmem_inode_info { What about naming this simply gmem_inode? > + struct inode vfs_inode; > +}; > + > +static inline struct kvm_gmem_inode_info *KVM_GMEM_I(struct inode *inode) And then GMEM_I()? And then (in a later follow-up if we target this for 6.18, or as a prep patch if we push this out to 6.19), rename kvm_gmem to gmem_file? That would make guest_memfd look a bit more like other filesystems, and I don't see a need to preface the local structures and helpers with "kvm_", e.g. GMEM_I() is analogous to x86's to_vmx() and to_svm(). As for renaming kvm_gmem => gmem_file, I wandered back into this code via Ackerley's in-place conversion series, and it took me a good long while to remember the roles of files vs. inodes in gmem. That's probably a sign that the code needs clarification given that I wrote the original code. :-) Leveraging an old discussion[*], my thought is to get to this: /* * A guest_memfd instance can be associated multiple VMs, each with its own * "view" of the underlying physical memory. * * The gmem's inode is effectively the raw underlying physical storage, and is * used to track properties of the physical memory, while each gmem file is * effectively a single VM's view of that storage, and is used to track assets * specific to its associated VM, e.g. memslots=>gmem bindings. */ struct gmem_file { struct kvm *kvm; struct xarray bindings; struct list_head entry; }; struct gmem_inode { struct shared_policy policy; struct inode vfs_inode; }; [*] https://lore.kernel.org/all/ZLGiEfJZTyl7M8mS@google.com