All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>,
	Julien Grall <julien@xen.org>, Wei Liu <wl@xen.org>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	George Dunlap <George.Dunlap@eu.citrix.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>,
	xen-devel@lists.xenproject.org
Subject: Re: [Xen-devel] [PATCH 2/2] smp: convert cpu_hotplug_begin into a blocking lock acquisition
Date: Wed, 19 Feb 2020 15:45:49 +0100	[thread overview]
Message-ID: <20200219144549.GD4679@Air-de-Roger> (raw)
In-Reply-To: <960b4da8-4522-082a-42b9-ab870698a5ec@suse.com>

On Wed, Feb 19, 2020 at 02:44:12PM +0100, Jan Beulich wrote:
> On 19.02.2020 14:22, Roger Pau Monné wrote:
> > On Wed, Feb 19, 2020 at 01:59:51PM +0100, Jan Beulich wrote:
> >> On 13.02.2020 12:32, Roger Pau Monne wrote:
> >>> Don't allow cpu_hotplug_begin to fail by converting the trylock into a
> >>> blocking lock acquisition. Write users of the cpu_add_remove_lock are
> >>> limited to CPU plug/unplug operations, and cannot deadlock between
> >>> themselves or other users taking the lock in read mode as
> >>> cpu_add_remove_lock is always locked with interrupts enabled. There
> >>> are also no other locks taken during the plug/unplug operations.
> >>
> >> I don't think the goal was deadlock avoidance, but rather limiting
> >> of the time spent spinning while trying to acquire the lock, in
> >> favor of having the caller retry.
> > 
> > Now that the contention between read-only users is reduced as those
> > can take the lock in parallel I think it's safe to switch writers to
> > blocking mode.
> 
> I'd agree if writers couldn't be starved by (many) readers.

AFAICT from the rw lock implementation readers won't be able to pick
the lock as soon as there's a writer waiting, which should avoid this
starvation?

You still need to wait for current readers to drop the lock, but no
new readers would be able to lock it, which I think should givbe us
enough fairness. OTOH when using _trylock new readers can still pick
the lock in read mode, and hence I think using blocking mode for
writers is actually better, as you can assure that readers won't be
able to starve writers.

Thanks, Roger.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2020-02-19 14:46 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-13 11:32 [Xen-devel] [PATCH 0/2] smp: convert cpu_add_remove_lock int a rw lock Roger Pau Monne
2020-02-13 11:32 ` [Xen-devel] [PATCH 1/2] smp: convert the cpu maps lock into " Roger Pau Monne
2020-02-19 12:08   ` Julien Grall
2020-02-19 12:56   ` Jan Beulich
2020-02-19 13:19     ` Roger Pau Monné
2020-02-19 13:42       ` Jan Beulich
2020-02-19 14:38         ` Roger Pau Monné
2020-02-20  8:13   ` Jan Beulich
2020-02-20  8:27     ` Jürgen Groß
2020-02-20  8:36       ` Jan Beulich
2020-02-20  8:57         ` Julien Grall
2020-02-20  9:20           ` Roger Pau Monné
2020-02-13 11:32 ` [Xen-devel] [PATCH 2/2] smp: convert cpu_hotplug_begin into a blocking lock acquisition Roger Pau Monne
2020-02-19 12:59   ` Jan Beulich
2020-02-19 13:22     ` Roger Pau Monné
2020-02-19 13:44       ` Jan Beulich
2020-02-19 14:45         ` Roger Pau Monné [this message]
2020-02-19 14:57           ` Jan Beulich
2020-02-19 15:07             ` Andrew Cooper
2020-02-19 16:06               ` Jan Beulich
2020-02-19 16:26                 ` Roger Pau Monné
2020-02-19 17:06                   ` Jan Beulich
2020-02-19 16:54                 ` Andrew Cooper
2020-02-19 16:08               ` Roger Pau Monné
2020-02-19 17:03                 ` Jan Beulich
2020-02-20  8:16                   ` Jan Beulich
2020-02-21 10:23                     ` Roger Pau Monné
2020-02-21 13:06                       ` Jan Beulich
2020-02-19 14:58         ` Andrew Cooper
2020-02-19 12:22 ` [Xen-devel] [PATCH 0/2] smp: convert cpu_add_remove_lock int a rw lock Andrew Cooper

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=20200219144549.GD4679@Air-de-Roger \
    --to=roger.pau@citrix.com \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=jbeulich@suse.com \
    --cc=julien@xen.org \
    --cc=konrad.wilk@oracle.com \
    --cc=sstabellini@kernel.org \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.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.