From: Benjamin Marzinski <bmarzins@redhat.com>
To: Martin Wilck <martin.wilck@suse.com>
Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>,
device-mapper development <dm-devel@lists.linux.dev>
Subject: Re: [PATCH 2/4] multipathd: add infrastructure for uxlsnr waiting on events
Date: Tue, 1 Dec 2026 18:46:18 -0500 [thread overview]
Message-ID: <aw9cSjQfwyFJ3tVQ@redhat.com> (raw)
In-Reply-To: <aw2qaMZPG0gSeI8t@redhat.com>
On Mon, Nov 30, 2026 at 11:55:04AM -0500, Benjamin Marzinski wrote:
> On Thu, Nov 26, 2026 at 12:42:00PM +0100, Martin Wilck wrote:
> > > +/* must only be called by uxlsnr_thr */
> > > +static void stop_waiting_for_event(struct client *c)
> > > +{
> > > + /*
> > > + * As long as clients will only be added to wait lists by uxlsnr_thr
> > > + * and only removed with list_del_init(), it is safe to check if
> > > + * wait_node is empty without holding client_wait_lock. uxlsnr_thr
> > > + * can't miss a client being added to the list, since a process is
> > > + * guaranteed to see all memory changes it did. It can miss a client
> > > + * being removed from the list or see a torn write from a concurrent
> > > + * removal, but this will just cause it to unnecessarily grab the lock
> > > + * and redo the removal.
> > > + */
> > > + if (!list_empty(&c->wait_node)) {
> >
> > Tbh, I don't like this super-smart optimization. I would prefer just taking
> > the lock. If we find this to hurt performance, we could change the
> > implementation to RCU.
>
> It just seems wrong to grab the lock every time any client exits. Would
> you be o.k. with having a special return value from the client handler
> functions to signal that the client needs to wait and a flag that
> clients can set when they get this return? Clients who haven't set the
> flag can skip the lock, just like with the current list empty code. Only
> the uxlsnr thread would set and check the flag, so there's no locking
> needed.
O.k. so that specific idea won't work. If the uxlsnr thread gets
cancelled between when the wait_node got added to the list and when the
cli_handler returned, the flag wouldn't be set and thus dead_client()
wouldn't remove the client from the wait list. That opens a small window
where another thread could be accessing the freed memory while calling
wakeup_event_waiter(). Instead, I could just set the flag directly when
the client's wait_node is added to the list in wait_for_event(). The
rest of the argument is the same.
-Ben
next prev parent reply other threads:[~2026-12-01 23:46 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 5:24 [PATCH 0/4] multipath: add the ability to wait on events Benjamin Marzinski
2026-11-26 5:24 ` [PATCH 1/4] multipathd: make the wakeup and drain idle_fd code generic Benjamin Marzinski
2026-11-26 5:24 ` [PATCH 2/4] multipathd: add infrastructure for uxlsnr waiting on events Benjamin Marzinski
2026-11-26 11:42 ` Martin Wilck
2026-11-30 16:55 ` Benjamin Marzinski
2026-12-01 23:46 ` Benjamin Marzinski [this message]
2026-11-26 5:24 ` [PATCH 3/4] multipathd: make cli_handlers take a wait_node Benjamin Marzinski
2026-11-26 5:24 ` [PATCH 4/4] multipathd: add commands to wait for reconfigures to complete Benjamin Marzinski
2026-11-26 11:42 ` Martin Wilck
2026-11-30 19:05 ` Benjamin Marzinski
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=aw9cSjQfwyFJ3tVQ@redhat.com \
--to=bmarzins@redhat.com \
--cc=christophe.varoqui@opensvc.com \
--cc=dm-devel@lists.linux.dev \
--cc=martin.wilck@suse.com \
/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.