From: Andreea-Cristina Bernat <bernat.ada@gmail.com>
To: axboe@kernel.dk, linux-kernel@vger.kernel.org
Cc: paulmck@linux.vnet.ibm.com
Subject: [PATCH] block: genhd: Replace rcu_assign_pointer() with RCU_INIT_POINTER()
Date: Wed, 27 Aug 2014 16:15:13 +0300 [thread overview]
Message-ID: <20140827131513.GA31290@ada> (raw)
According to RCU_INIT_POINTER()'s block comment 3.a, it can be used if
"3. The referenced data structure has already been exposed to readers either
at compile time or via rcu_assign_pointer() -and-
a. You have not made -any- reader-visible changes to this structure since
then".
This case fulfills the conditions above because between the rcu_dereference()
call and the rcu_assign_pointer() call there is no update of the "part"
variable.
Therefore, this patch makes the replacement.
The following Coccinelle semantic patch was used:
@@
identifier v;
@@
v = rcu_dereference(...);
... when != rcu_dereference(...);
when != v = ...;
when != (<+...v...+>)++;
when != \(memcpy\|memset\)(...);
(
- rcu_assign_pointer
+ RCU_INIT_POINTER
(..., v);
|
if(...) {
... when != v = ...;
- rcu_assign_pointer
+ RCU_INIT_POINTER
(..., v);
... when any
}
)
Because there are cases where between a “rcu_dereference()” call and a
“rcu_assign_pointer()” call might be updates of the value that interests
us, the Coccinelle semantic patch ignores them and replaces with
"RCU_INIT_POINTER()" only when the update is not happening.
Signed-off-by: Andreea-Cristina Bernat <bernat.ada@gmail.com>
---
block/genhd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/block/genhd.c b/block/genhd.c
index 3aec057..f7e29d8 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -228,7 +228,7 @@ struct hd_struct *disk_map_sector_rcu(struct gendisk *disk, sector_t sector)
part = rcu_dereference(ptbl->part[i]);
if (part && sector_in_part(part, sector)) {
- rcu_assign_pointer(ptbl->last_lookup, part);
+ RCU_INIT_POINTER(ptbl->last_lookup, part);
return part;
}
}
--
1.9.1
reply other threads:[~2014-08-27 13:15 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20140827131513.GA31290@ada \
--to=bernat.ada@gmail.com \
--cc=axboe@kernel.dk \
--cc=linux-kernel@vger.kernel.org \
--cc=paulmck@linux.vnet.ibm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox