All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Emilio G. Cota" <cota@braap.org>
To: "Alex Bennée" <alex.bennee@linaro.org>
Cc: qemu-devel@nongnu.org, Richard Henderson <richard.henderson@linaro.org>
Subject: Re: [Qemu-devel] [PATCH 2/6] qht: add qht_iter_remove
Date: Fri, 7 Sep 2018 11:45:45 -0400	[thread overview]
Message-ID: <20180907154545.GA1963@flamenco> (raw)
In-Reply-To: <87in3hz7hb.fsf@linaro.org>

On Fri, Sep 07, 2018 at 15:51:12 +0100, Alex Bennée wrote:
> 
> Emilio G. Cota <cota@braap.org> writes:
> 
> > This currently has no users, but the use case is so common that I
> > think we must support it.
> >
> > Note that without the appended we cannot safely remove a set of
> > elements; a 2-step approach (i.e. qht_iter first, keep track of
> > the to-be-deleted elements, and then a bunch of qht_remove calls)
> > would be racy, since between the iteration and the removals other
> > threads might insert additional elements.
> >
> > Signed-off-by: Emilio G. Cota <cota@braap.org>
> > ---
> >  include/qemu/qht.h | 19 ++++++++++++
> >  util/qht.c         | 74 +++++++++++++++++++++++++++++++++++++++++-----
> >  2 files changed, 85 insertions(+), 8 deletions(-)
> >
> > diff --git a/include/qemu/qht.h b/include/qemu/qht.h
> > index 1fb9116fa0..91bc9b00cf 100644
> > --- a/include/qemu/qht.h
> > +++ b/include/qemu/qht.h
> > @@ -44,6 +44,8 @@ struct qht_stats {
> >
> >  typedef bool (*qht_lookup_func_t)(const void *obj, const void *userp);
> >  typedef void (*qht_iter_func_t)(struct qht *ht, void *p, uint32_t h, void *up);
> > +typedef bool (*qht_iter_bool_func_t)(struct qht *ht, void *p, uint32_t h,
> > +                                     void *up);
> >
> >  #define QHT_MODE_AUTO_RESIZE 0x1 /* auto-resize when heavily loaded */
> >
> > @@ -178,9 +180,26 @@ bool qht_resize(struct qht *ht, size_t n_elems);
> >   *
> >   * Each time it is called, user-provided @func is passed a pointer-hash pair,
> >   * plus @userp.
> > + *
> > + * Note: @ht cannot be accessed from @func
> 
> I'm confused by this comment. If @ht cannot be accessed (or shouldn't be
> accessed) from @func then why are we passing it?

We could probably do without. My original thinking was to pass the *ht
to tell the iter function which ht his k-v pair comes from.
But that's not a common use case, so we should remove it to
simplify the interface.

I think the comment is important right now; note that we can't even
perform a lookup from the callback without deadlock.

So I'll take your R-b for this patch and remove the *ht in
another patch.

Thanks,

		Emilio

  reply	other threads:[~2018-09-07 15:46 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-17 23:29 [Qemu-devel] [PATCH 0/6] qht improvements for 3.1 Emilio G. Cota
2018-08-17 23:29 ` [Qemu-devel] [PATCH 1/6] qht: remove unused map param from qht_remove__locked Emilio G. Cota
2018-09-07 14:43   ` Alex Bennée
2018-08-17 23:29 ` [Qemu-devel] [PATCH 2/6] qht: add qht_iter_remove Emilio G. Cota
2018-09-07 14:51   ` Alex Bennée
2018-09-07 15:45     ` Emilio G. Cota [this message]
2018-08-17 23:29 ` [Qemu-devel] [PATCH 3/6] test-qht: test qht_iter_remove Emilio G. Cota
2018-09-07 15:15   ` Alex Bennée
2018-08-17 23:29 ` [Qemu-devel] [PATCH 4/6] test-qht: test removal of non-existent entries Emilio G. Cota
2018-09-07 15:16   ` Alex Bennée
2018-08-17 23:29 ` [Qemu-devel] [PATCH 5/6] test-qht: test deletion of the last entry in a bucket Emilio G. Cota
2018-09-07 15:17   ` Alex Bennée
2018-08-17 23:29 ` [Qemu-devel] [PATCH 6/6] test-qht: speed up + test qht_resize Emilio G. Cota
2018-09-07 15:34   ` Alex Bennée

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=20180907154545.GA1963@flamenco \
    --to=cota@braap.org \
    --cc=alex.bennee@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.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.