From: Jens Axboe <axboe@kernel.dk>
To: Jan Kara <jack@suse.cz>
Cc: Andrew Morton <akpm@linux-foundation.org>,
LKML <linux-kernel@vger.kernel.org>,
linux-mm@kvack.org
Subject: Re: [PATCH RFC] lib: Make radix_tree_node_alloc() irq safe
Date: Wed, 17 Jul 2013 14:14:53 -0600 [thread overview]
Message-ID: <20130717201453.GH22392@kernel.dk> (raw)
In-Reply-To: <1373994390-5479-1-git-send-email-jack@suse.cz>
On Tue, Jul 16 2013, Jan Kara wrote:
> With users of radix_tree_preload() run from interrupt (CFQ is one such
> possible user), the following race can happen:
>
> radix_tree_preload()
> ...
> radix_tree_insert()
> radix_tree_node_alloc()
> if (rtp->nr) {
> ret = rtp->nodes[rtp->nr - 1];
> <interrupt>
> ...
> radix_tree_preload()
> ...
> radix_tree_insert()
> radix_tree_node_alloc()
> if (rtp->nr) {
> ret = rtp->nodes[rtp->nr - 1];
>
> And we give out one radix tree node twice. That clearly results in radix
> tree corruption with different results (usually OOPS) depending on which
> two users of radix tree race.
>
> Fix the problem by disabling interrupts when working with rtp variable.
> In-interrupt user can still deplete our preloaded nodes but at least we
> won't corrupt radix trees.
Looks good to me, great catch Jan.
--
Jens Axboe
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
WARNING: multiple messages have this Message-ID (diff)
From: Jens Axboe <axboe@kernel.dk>
To: Jan Kara <jack@suse.cz>
Cc: Andrew Morton <akpm@linux-foundation.org>,
LKML <linux-kernel@vger.kernel.org>,
linux-mm@kvack.org
Subject: Re: [PATCH RFC] lib: Make radix_tree_node_alloc() irq safe
Date: Wed, 17 Jul 2013 14:14:53 -0600 [thread overview]
Message-ID: <20130717201453.GH22392@kernel.dk> (raw)
In-Reply-To: <1373994390-5479-1-git-send-email-jack@suse.cz>
On Tue, Jul 16 2013, Jan Kara wrote:
> With users of radix_tree_preload() run from interrupt (CFQ is one such
> possible user), the following race can happen:
>
> radix_tree_preload()
> ...
> radix_tree_insert()
> radix_tree_node_alloc()
> if (rtp->nr) {
> ret = rtp->nodes[rtp->nr - 1];
> <interrupt>
> ...
> radix_tree_preload()
> ...
> radix_tree_insert()
> radix_tree_node_alloc()
> if (rtp->nr) {
> ret = rtp->nodes[rtp->nr - 1];
>
> And we give out one radix tree node twice. That clearly results in radix
> tree corruption with different results (usually OOPS) depending on which
> two users of radix tree race.
>
> Fix the problem by disabling interrupts when working with rtp variable.
> In-interrupt user can still deplete our preloaded nodes but at least we
> won't corrupt radix trees.
Looks good to me, great catch Jan.
--
Jens Axboe
next prev parent reply other threads:[~2013-07-17 20:14 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-16 17:06 [PATCH RFC] lib: Make radix_tree_node_alloc() irq safe Jan Kara
2013-07-16 17:06 ` Jan Kara
2013-07-17 20:14 ` Jens Axboe [this message]
2013-07-17 20:14 ` Jens Axboe
2013-07-17 23:12 ` Andrew Morton
2013-07-17 23:12 ` Andrew Morton
2013-07-17 23:16 ` David Daney
2013-07-17 23:16 ` David Daney
2013-07-18 13:09 ` Jan Kara
2013-07-18 13:09 ` Jan Kara
2013-07-18 21:30 ` Jens Axboe
2013-07-18 21:30 ` Jens Axboe
2013-07-22 15:21 ` Jan Kara
2013-07-22 15:21 ` Jan Kara
2013-07-22 15:38 ` Jens Axboe
2013-07-22 15:38 ` Jens Axboe
2013-07-18 21:37 ` Andrew Morton
2013-07-18 21:37 ` Andrew Morton
2013-07-22 20:30 ` Jan Kara
2013-07-22 20:30 ` Jan Kara
2013-07-18 21:25 ` Jens Axboe
2013-07-18 21:25 ` Jens Axboe
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=20130717201453.GH22392@kernel.dk \
--to=axboe@kernel.dk \
--cc=akpm@linux-foundation.org \
--cc=jack@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.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.