From: "Jürgen Groß" <jgross@suse.com>
To: SeongJae Park <sjpark@amazon.com>,
axboe@kernel.dk, konrad.wilk@oracle.com, roger.pau@citrix.com
Cc: linux-block@vger.kernel.org, xen-devel@lists.xenproject.org,
pdurrant@amazon.com, sj38.park@gmail.com,
linux-kernel@vger.kernel.org
Subject: Re: [Xen-devel] [PATCH v10 2/4] xen/blkback: Squeeze page pools if a memory pressure is detected
Date: Mon, 16 Dec 2019 17:23:44 +0100 [thread overview]
Message-ID: <2ad62cc8-ae78-6087-f277-923dc076383a@suse.com> (raw)
In-Reply-To: <20191216161549.26976-1-sjpark@amazon.com>
On 16.12.19 17:15, SeongJae Park wrote:
> On Mon, 16 Dec 2019 15:37:20 +0100 SeongJae Park <sjpark@amazon.com> wrote:
>
>> On Mon, 16 Dec 2019 13:45:25 +0100 SeongJae Park <sjpark@amazon.com> wrote:
>>
>>> From: SeongJae Park <sjpark@amazon.de>
>>>
> [...]
>>> --- a/drivers/block/xen-blkback/xenbus.c
>>> +++ b/drivers/block/xen-blkback/xenbus.c
>>> @@ -824,6 +824,24 @@ static void frontend_changed(struct xenbus_device *dev,
>>> }
>>>
>>>
>>> +/* Once a memory pressure is detected, squeeze free page pools for a while. */
>>> +static unsigned int buffer_squeeze_duration_ms = 10;
>>> +module_param_named(buffer_squeeze_duration_ms,
>>> + buffer_squeeze_duration_ms, int, 0644);
>>> +MODULE_PARM_DESC(buffer_squeeze_duration_ms,
>>> +"Duration in ms to squeeze pages buffer when a memory pressure is detected");
>>> +
>>> +/*
>>> + * Callback received when the memory pressure is detected.
>>> + */
>>> +static void reclaim_memory(struct xenbus_device *dev)
>>> +{
>>> + struct backend_info *be = dev_get_drvdata(&dev->dev);
>>> +
>>> + be->blkif->buffer_squeeze_end = jiffies +
>>> + msecs_to_jiffies(buffer_squeeze_duration_ms);
>>
>> This callback might race with 'xen_blkbk_probe()'. The race could result in
>> __NULL dereferencing__, as 'xen_blkbk_probe()' sets '->blkif' after it links
>> 'be' to the 'dev'. Please _don't merge_ this patch now!
>>
>> I will do more test and share results. Meanwhile, if you have any opinion,
>> please let me know.
>
> Not only '->blkif', but 'be' itself also coule be a NULL. As similar
> concurrency issues could be in other drivers in their way, I suggest to change
> the reclaim callback ('->reclaim_memory') to be called for each driver instead
> of each device. Then, each driver could be able to deal with its concurrency
> issues by itself.
Hmm, I don't like that. This would need to be changed back in case we
add per-guest quota.
Wouldn't a get_device() before calling the callback and a put_device()
afterwards avoid that problem?
Juergen
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2019-12-16 16:24 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-16 12:45 [Xen-devel] [PATCH v10 0/4] xenbus/backend: Add a memory pressure handler callback SeongJae Park
2019-12-16 12:45 ` [Xen-devel] [PATCH v10 1/4] xenbus/backend: Add " SeongJae Park
2019-12-16 12:45 ` [Xen-devel] [PATCH v10 2/4] xen/blkback: Squeeze page pools if a memory pressure is detected SeongJae Park
2019-12-16 14:37 ` SeongJae Park
2019-12-16 16:15 ` SeongJae Park
2019-12-16 16:23 ` Jürgen Groß [this message]
2019-12-16 19:48 ` SeongJae Park
2019-12-17 6:23 ` Jürgen Groß
2019-12-17 7:59 ` SeongJae Park
2019-12-17 8:16 ` Jürgen Groß
2019-12-17 8:30 ` SeongJae Park
2019-12-17 16:17 ` SeongJae Park
2019-12-17 11:39 ` Roger Pau Monné
2019-12-17 13:15 ` SeongJae Park
2019-12-17 13:51 ` Jürgen Groß
2019-12-16 12:45 ` [Xen-devel] [PATCH v10 3/4] xen/blkback: Remove unnecessary static variable name prefixes SeongJae Park
2019-12-16 12:45 ` [Xen-devel] [PATCH v10 4/4] 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=2ad62cc8-ae78-6087-f277-923dc076383a@suse.com \
--to=jgross@suse.com \
--cc=axboe@kernel.dk \
--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.com \
--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;
as well as URLs for NNTP newsgroup(s).