public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: SeongJae Park <sjpark@amazon.com>
To: "Jürgen Groß" <jgross@suse.com>
Cc: SeongJae Park <sjpark@amazon.com>, <axboe@kernel.dk>,
	<linux-block@vger.kernel.org>, <konrad.wilk@oracle.com>,
	<pdurrant@amazon.com>, SeongJae Park <sjpark@amazon.de>,
	<linux-kernel@vger.kernel.org>, <sj38.park@gmail.com>,
	<xen-devel@lists.xenproject.org>, <roger.pau@citrix.com>
Subject: Re: Re: [Xen-devel] [PATCH v12 2/5] xenbus/backend: Protect xenbus callback with lock
Date: Wed, 18 Dec 2019 18:32:17 +0100	[thread overview]
Message-ID: <20191218173217.7501-1-sjpark@amazon.com> (raw)
In-Reply-To: <7edb266e-3185-5adc-1121-1b61feaf5a34@suse.com> (raw)

On Wed, 18 Dec 2019 16:11:51 +0100 "Jürgen Groß" <jgross@suse.com> wrote:

> On 18.12.19 15:40, SeongJae Park wrote:
> > On Wed, 18 Dec 2019 14:30:44 +0100 "Jürgen Groß" <jgross@suse.com> wrote:
> > 
> >> On 18.12.19 13:42, SeongJae Park wrote:
> >>> On Wed, 18 Dec 2019 13:27:37 +0100 "Jürgen Groß" <jgross@suse.com> wrote:
> >>>
> >>>> On 18.12.19 11:42, SeongJae Park wrote:
> >>>>> From: SeongJae Park <sjpark@amazon.de>
> >>>>>
> >>>>> 'reclaim_memory' callback can race with a driver code as this callback
> >>>>> will be called from any memory pressure detected context.  To deal with
> >>>>> the case, this commit adds a spinlock in the 'xenbus_device'.  Whenever
> >>>>> 'reclaim_memory' callback is called, the lock of the device which passed
> >>>>> to the callback as its argument is locked.  Thus, drivers registering
> >>>>> their 'reclaim_memory' callback should protect the data that might race
> >>>>> with the callback with the lock by themselves.
> >>>>
> >>>> Any reason you don't take the lock around the .probe() and .remove()
> >>>> calls of the backend (xenbus_dev_probe() and xenbus_dev_remove())? This
> >>>> would eliminate the need to do that in each backend instead.
> >>>
> >>> First of all, I would like to keep the critical section as small as possible.
> >>> With my small test, I could see slightly increasing memory pressure as the
> >>> critical section becomes wider.  Also, some drivers might share the data their
> >>> 'reclaim_memory' callback touches with other functions.  I think only the
> >>> driver owners can know what data is shared and what is the minimum critical
> >>> section to protect it.
> >>
> >> But this kind of serialization can still be added on top.
> > 
> > I'm still worrying about the unnecessarily large critical section, but it might
> > be small enough to be ignored.  If no others have strong objection, I will take
> > the lock around the '->probe()' and '->remove()'.
> 
> The lock is per device, so contention is possible only for the
> reclaim case. In case probe or remove are running reclaim will have
> nothing to free (in probe case nothing is allocated yet, in remove
> case everything should be freed anyway). So the larger critical section
> is no problem at all IMO.

Agreed.  I think I was worried about nothing really existing now.

> 
> >> And with the trylock in the reclaim path I believe you can even avoid
> >> the irq variants of the spinlock. But I might be wrong, so you should
> >> try that with lockdep enabled. If it is working there is no harm done
> >> when making the critical section larger, as memory allocations will
> >> work as before.
> > 
> > Yes, you're right.  I will try test with lockdep.
> 
> Thanks,

Good news, lockdep says it's okay :)

Will post next version soon.


Thanks,
SeongJae Park

> 
> 
> Juergen

  reply	other threads:[~2019-12-18 17:32 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-18 10:42 [PATCH v12 0/5] xenbus/backend: Add memory pressure handler callback SeongJae Park
2019-12-18 10:42 ` [PATCH v12 1/5] " SeongJae Park
2019-12-18 10:42 ` [PATCH v12 2/5] xenbus/backend: Protect xenbus callback with lock SeongJae Park
2019-12-18 12:27   ` Jürgen Groß
2019-12-18 12:42     ` Re: [Xen-devel] " SeongJae Park
2019-12-18 13:30       ` Jürgen Groß
2019-12-18 14:40         ` SeongJae Park
2019-12-18 15:11           ` Jürgen Groß
2019-12-18 17:32             ` SeongJae Park [this message]
2019-12-18 10:42 ` [PATCH v12 3/5] xen/blkback: Squeeze page pools if a memory pressure is detected SeongJae Park
2019-12-18 10:42 ` [PATCH v12 4/5] xen/blkback: Remove unnecessary static variable name prefixes SeongJae Park
2019-12-18 10:44 ` [PATCH v12 5/5] xen/blkback: Consistently insert one empty line between functions SeongJae Park

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=20191218173217.7501-1-sjpark@amazon.com \
    --to=sjpark@amazon.com \
    --cc=axboe@kernel.dk \
    --cc=jgross@suse.com \
    --cc=konrad.wilk@oracle.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pdurrant@amazon.com \
    --cc=roger.pau@citrix.com \
    --cc=sj38.park@gmail.com \
    --cc=sjpark@amazon.de \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox