[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC PATCH v1 03/25] hw/xen: Implement XenStore watches
From: |
David Woodhouse |
Subject: |
Re: [RFC PATCH v1 03/25] hw/xen: Implement XenStore watches |
Date: |
Tue, 07 Mar 2023 12:20:53 +0000 |
User-agent: |
Evolution 3.44.4-0ubuntu1 |
On Tue, 2023-03-07 at 11:29 +0000, Paul Durrant wrote:
>
> I think you could stash a tail pointer here...
>
> > + }
> > +
> > + if (dom_id && s->nr_domu_watches >= XS_MAX_WATCHES) {
> > + return E2BIG;
> > + }
> > +
> > + w = g_new0(XsWatch, 1);
> > + w->token = g_strdup(token);
> > + w->cb = fn;
> > + w->cb_opaque = opaque;
> > + w->dom_id = dom_id;
> > + w->rel_prefix = strlen(abspath) - strlen(path);
> > +
> > + l = g_hash_table_lookup(s->watches, abspath);
>
> ... to avoid the duplicate hash lookup here.
Good point. The EEXIST check was added later as I was reviewing and
comparing with the real xenstored, so I didn't spot that. Thanks.
--- a/hw/i386/kvm/xenstore_impl.c
+++ b/hw/i386/kvm/xenstore_impl.c
@@ -673,7 +673,7 @@ int xs_impl_watch(XenstoreImplState *s, unsigned int
dom_id, const char *path,
}
/* Check for duplicates */
- w = g_hash_table_lookup(s->watches, abspath);
+ l = w = g_hash_table_lookup(s->watches, abspath);
while (w) {
if (!g_strcmp0(token, w->token) && opaque == w->cb_opaque &&
fn == w->cb && dom_id == w->dom_id) {
@@ -693,7 +693,7 @@ int xs_impl_watch(XenstoreImplState *s, unsigned int
dom_id, const char *path,
w->dom_id = dom_id;
w->rel_prefix = strlen(abspath) - strlen(path);
- l = g_hash_table_lookup(s->watches, abspath);
+ /* l was looked up above when checking for duplicates */
if (l) {
w->next = l->next;
l->next = w;
smime.p7s
Description: S/MIME cryptographic signature
- [RFC PATCH v1 15/25] hw/xen: Use XEN_PAGE_SIZE in PV backend drivers, (continued)
- [RFC PATCH v1 15/25] hw/xen: Use XEN_PAGE_SIZE in PV backend drivers, David Woodhouse, 2023/03/02
- [RFC PATCH v1 08/25] hw/xen: Create initial XenStore nodes, David Woodhouse, 2023/03/02
- [RFC PATCH v1 02/25] hw/xen: Add basic XenStore tree walk and write/read/directory support, David Woodhouse, 2023/03/02
- [RFC PATCH v1 14/25] hw/xen: Move xenstore_store_pv_console_info to xen_console.c, David Woodhouse, 2023/03/02
- [RFC PATCH v1 03/25] hw/xen: Implement XenStore watches, David Woodhouse, 2023/03/02
- [RFC PATCH v1 09/25] hw/xen: Add evtchn operations to allow redirection to internal emulation, David Woodhouse, 2023/03/02
- [RFC PATCH v1 16/25] hw/xen: Rename xen_common.h to xen_native.h, David Woodhouse, 2023/03/02
- [RFC PATCH v1 19/25] hw/xen: Only advertise ring-page-order for xen-block if gnttab supports it, David Woodhouse, 2023/03/02
- [RFC PATCH v1 21/25] hw/xen: Add emulated implementation of grant table operations, David Woodhouse, 2023/03/02
- [RFC PATCH v1 10/25] hw/xen: Add gnttab operations to allow redirection to internal emulation, David Woodhouse, 2023/03/02