[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220105060918.GB25009@chaop.bj.intel.com>
Date: Wed, 5 Jan 2022 14:09:18 +0800
From: Chao Peng <chao.p.peng@...ux.intel.com>
To: Sean Christopherson <seanjc@...gle.com>
Cc: kvm@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-mm@...ck.org, linux-fsdevel@...r.kernel.org,
qemu-devel@...gnu.org, Paolo Bonzini <pbonzini@...hat.com>,
Jonathan Corbet <corbet@....net>,
Vitaly Kuznetsov <vkuznets@...hat.com>,
Wanpeng Li <wanpengli@...cent.com>,
Jim Mattson <jmattson@...gle.com>,
Joerg Roedel <joro@...tes.org>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
x86@...nel.org, "H . Peter Anvin" <hpa@...or.com>,
Hugh Dickins <hughd@...gle.com>,
Jeff Layton <jlayton@...nel.org>,
"J . Bruce Fields" <bfields@...ldses.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Yu Zhang <yu.c.zhang@...ux.intel.com>,
"Kirill A . Shutemov" <kirill.shutemov@...ux.intel.com>,
luto@...nel.org, john.ji@...el.com, susie.li@...el.com,
jun.nakajima@...el.com, dave.hansen@...el.com, ak@...ux.intel.com,
david@...hat.com
Subject: Re: [PATCH v3 kvm/queue 05/16] KVM: Maintain ofs_tree for fast
memslot lookup by file offset
On Tue, Jan 04, 2022 at 05:43:50PM +0000, Sean Christopherson wrote:
> On Fri, Dec 31, 2021, Chao Peng wrote:
> > On Tue, Dec 28, 2021 at 09:48:08PM +0000, Sean Christopherson wrote:
> > >KVM handles
> > > reverse engineering the memslot to get the offset and whatever else it needs.
> > > notify_fallocate() and other callbacks are unchanged, though they probably can
> > > drop the inode.
> > >
> > > E.g. likely with bad math and handwaving on the overlap detection:
> > >
> > > int kvm_private_fd_fallocate_range(void *owner, pgoff_t start, pgoff_t end)
> > > {
> > > struct kvm_memory_slot *slot = owner;
> > > struct kvm_gfn_range gfn_range = {
> > > .slot = slot,
> > > .start = (start - slot->private_offset) >> PAGE_SHIFT,
> > > .end = (end - slot->private_offset) >> PAGE_SHIFT,
> > > .may_block = true,
> > > };
> > >
> > > if (!has_overlap(slot, start, end))
> > > return 0;
> > >
> > > gfn_range.end = min(gfn_range.end, slot->base_gfn + slot->npages);
> > >
> > > kvm_unmap_gfn_range(slot->kvm, &gfn_range);
> > > return 0;
> > > }
> >
> > I understand this KVM side handling, but again one fd can have multiple
> > memslots. How shmem decides to notify which memslot from a list of
> > memslots when it invokes the notify_fallocate()? Or just notify all
> > the possible memslots then let KVM to check?
>
> Heh, yeah, those are the two choices. :-)
>
> Either the backing store needs to support registering callbacks for specific,
> arbitrary ranges, or it needs to invoke all registered callbacks. Invoking all
> callbacks has my vote; it's much simpler to implement and is unlikely to incur
> meaningful overhead. _Something_ has to find the overlapping ranges, that cost
> doesn't magically go away if it's pushed into the backing store.
>
> Note, invoking all notifiers is also aligned with the mmu_notifier behavior.
Sounds a good reason. Then shmem side only needs to maintain a list of
users.
Chao
Powered by blists - more mailing lists