All of lore.kernel.org
 help / color / mirror / Atom feed
From: Martin Wilck <mwilck@suse.com>
To: Benjamin Marzinski <bmarzins@redhat.com>,
	device-mapper development <dm-devel@redhat.com>
Cc: Bart Van Assche <Bart.VanAssche@wdc.com>
Subject: Re: [PATCH v3 1/7] libmultipath: fix tur checker locking
Date: Tue, 13 Feb 2018 10:16:25 +0100	[thread overview]
Message-ID: <1518513385.8040.13.camel@suse.com> (raw)
In-Reply-To: <1518493334-18170-2-git-send-email-bmarzins@redhat.com>

On Mon, 2018-02-12 at 21:42 -0600, Benjamin Marzinski wrote:
> Commit 6e2423fd fixed a bug where the tur checker could cancel a
> detached thread after it had exitted. However in fixing this, the new
> code grabbed a mutex (to call condlog) while holding a spin_lock.  To
> deal with this, I've done away with the holder spin_lock completely,
> and
> replaced it with two atomic variables, based on a suggestion by
> Martin
> Wilck.
> 
> The holder variable works exactly like before.  When the checker is
> initialized, it is set to 1. When a thread is created it is
> incremented.
> When either the thread or the checker are done with the context, they
> atomically decrement the holder variable and check its value. If it
> is 0, they free the context. If it is 1, they never touch the context
> again.
> 
> The other variable has changed. First, ct->running and ct->thread
> have
> switched uses. ct->thread is now only ever accessed by the checker,
> never the thread.  If it is non-NULL, a thread has started up, but
> hasn't been dealt with by the checker yet. It is also obviously used
> by the checker to cancel the thread.
> 
> ct->running is now an atomic variable.  When the thread is started
> it is set to 1. When the checker wants to kill a thread, it
> atomically
> sets the value to 0 and reads the previous value.  If it was 1,
> the checker cancels the thread. If it was 0, the nothing needs to be
> done.  After the checker has dealt with the thread, it sets ct-
> >thread
> to NULL.
> 
> Right before the thread finishes and pops the cleanup handler, it
> atomically sets the value of ct->running to 0 and reads the previous
> value. If it was 1, the thread just pops the cleanup handler and
> exits.
> If it was 0, then the checker is trying to cancel the thread, and so
> the
> thread calls pause(), which is a cancellation point.
> 
> Cc: Martin Wilck <mwilck@suse.com>
> Cc: Bart Van Assche <Bart.VanAssche@wdc.com>
> Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
> ---

Reviewed-by: Martin Wilck <mwilck@suse.com>

Side note: a little voice in my head keeps whispering that it should be
possible to solve this problem with just one atomic variable instead of
two ("holders" and "running"). But I'm fine with the current approach
for now.

-- 
Dr. Martin Wilck <mwilck@suse.com>, Tel. +49 (0)911 74053 2107
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)

--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel

  reply	other threads:[~2018-02-13  9:16 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-13  3:42 [PATCH v3 0/7] multipath: miscellaneous bug fixes Benjamin Marzinski
2018-02-13  3:42 ` [PATCH v3 1/7] libmultipath: fix tur checker locking Benjamin Marzinski
2018-02-13  9:16   ` Martin Wilck [this message]
2018-02-13 10:20   ` Hannes Reinecke
2018-02-13 20:41     ` Benjamin Marzinski
2018-02-13  3:42 ` [PATCH v3 2/7] multipath: fix DEF_TIMEOUT use Benjamin Marzinski
2018-02-13  3:42 ` [PATCH v3 3/7] multipathd: remove coalesce_paths from ev_add_map Benjamin Marzinski
2018-02-13  3:42 ` [PATCH v3 4/7] multipathd: remove unused configure parameter Benjamin Marzinski
2018-02-13  3:42 ` [PATCH v3 5/7] Fix set_no_path_retry() regression Benjamin Marzinski
2018-02-13  3:42 ` [PATCH v3 6/7] multipathd: change spurious uevent msg priority Benjamin Marzinski
2018-02-13  3:42 ` [PATCH v3 7/7] multipath: print sysfs state in fast list mode 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=1518513385.8040.13.camel@suse.com \
    --to=mwilck@suse.com \
    --cc=Bart.VanAssche@wdc.com \
    --cc=bmarzins@redhat.com \
    --cc=dm-devel@redhat.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.