From: "Michael S. Tsirkin" <mst@redhat.com>
To: Peter Xu <peterx@redhat.com>
Cc: Jason Wang <jasowang@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v3 4/4] intel_iommu: implement mru list for iotlb
Date: Wed, 26 Jul 2017 23:37:13 +0300 [thread overview]
Message-ID: <20170726233613-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20170717015327.GQ27284@pxdev.xzpeter.org>
On Mon, Jul 17, 2017 at 09:53:27AM +0800, Peter Xu wrote:
> On Fri, Jul 14, 2017 at 03:28:09PM +0800, Jason Wang wrote:
> >
> >
> > On 2017年07月14日 12:32, Peter Xu wrote:
> > >On Thu, Jul 13, 2017 at 04:48:42PM +0800, Jason Wang wrote:
> > >>
> > >>On 2017年07月12日 16:13, Peter Xu wrote:
> > >>>It is not wise to disgard all the IOTLB cache when cache size reaches
> > >>>max, but that's what we do now. A slightly better (but still simple) way
> > >>>to do this is, we just throw away the least recent used cache entry.
> > >>>
> > >>>This patch implemented MRU list algorithm for VT-d IOTLB. The main logic
> > >>>is to maintain a Most Recently Used list for the IOTLB entries. The hash
> > >>>table is still used for lookup, though a new list field is added to each
> > >>>IOTLB entry for a iotlb MRU list. For each active IOTLB entry, it's both
> > >>>in the hash table in s->iotlb, and also linked into the MRU list of
> > >>>s->iotlb_head. The hash helps in fast lookup, and the MRU list helps in
> > >>>knowing whether the cache is still hot.
> > >>>
> > >>>After we have such a MRU list, replacing all the iterators of IOTLB
> > >>>entries by using list iterations rather than hash table iterations.
> > >>Any reason of doing this, I thought hashtable was even a little bit faster?
> > >Could I ask why?
> > >
> > >I thought they are merely the same (when iterating all the items)?
> > >
> >
> > Ok, looks like I was wrong, but it they are merely the same, why bother?
>
> Because imho looping over list needs fewer LOCs and is also more
> direct. E.g., for domain flush, hash needs this:
>
> static gboolean vtd_hash_remove_by_domain(gpointer key, gpointer value,
> gpointer user_data)
> {
> VTDIOTLBEntry *entry = (VTDIOTLBEntry *)value;
> uint16_t domain_id = *(uint16_t *)user_data;
> return entry->domain_id == domain_id;
> }
>
> Then:
>
> g_hash_table_foreach_remove(s->iotlb, vtd_hash_remove_by_domain,
> &domain_id);
>
> For list it is only:
>
> FOREACH_IOTLB_SAFE(entry, s, entry_n) {
> if (entry->domain_id == domain_id) {
> vtd_iotlb_remove_entry(s, entry);
> }
> }
>
> Thanks,
Well the LOC seems to have gone up with this patch.
If we are trying to simplify code, please state this
in commit log.
> --
> Peter Xu
next prev parent reply other threads:[~2017-07-26 20:37 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-12 8:13 [Qemu-devel] [PATCH v3 0/4] VT-d: some enhancements on iotlb Peter Xu
2017-07-12 8:13 ` [Qemu-devel] [PATCH v3 1/4] intel_iommu: fix VTD_PAGE_MASK Peter Xu
2017-07-13 8:41 ` Jason Wang
2017-07-14 4:27 ` Peter Xu
2017-07-12 8:13 ` [Qemu-devel] [PATCH v3 2/4] intel_iommu: let iotlb size tunable Peter Xu
2017-07-13 17:47 ` Michael S. Tsirkin
2017-07-14 4:31 ` Peter Xu
2017-07-12 8:13 ` [Qemu-devel] [PATCH v3 3/4] intel_iommu: use access_flags for iotlb Peter Xu
2017-07-12 8:13 ` [Qemu-devel] [PATCH v3 4/4] intel_iommu: implement mru list " Peter Xu
2017-07-13 8:48 ` Jason Wang
2017-07-14 4:32 ` Peter Xu
2017-07-14 7:28 ` Jason Wang
2017-07-17 1:53 ` Peter Xu
2017-07-26 20:37 ` Michael S. Tsirkin [this message]
2017-07-27 2:19 ` Peter Xu
2017-07-13 17:49 ` Michael S. Tsirkin
2017-07-14 4:43 ` Peter Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170726233613-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=jasowang@redhat.com \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.