* [PATCH] fs: file: Replace rcu_assign_pointer() with RCU_INIT_POINTER()
@ 2014-08-22 14:02 Andreea-Cristina Bernat
0 siblings, 0 replies; only message in thread
From: Andreea-Cristina Bernat @ 2014-08-22 14:02 UTC (permalink / raw)
To: viro, linux-fsdevel, linux-kernel; +Cc: paulmck
The uses of "rcu_assign_pointer()" are NULLing out the pointers.
According to RCU_INIT_POINTER()'s block comment:
"1. This use of RCU_INIT_POINTER() is NULLing out the pointer"
it is better to use it instead of rcu_assign_pointer() because it has a
smaller overhead.
The following Coccinelle semantic patch was used:
@@
@@
- rcu_assign_pointer
+ RCU_INIT_POINTER
(..., NULL)
Signed-off-by: Andreea-Cristina Bernat <bernat.ada@gmail.com>
---
fs/file.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/fs/file.c b/fs/file.c
index 66923fe..cd6a471 100644
--- a/fs/file.c
+++ b/fs/file.c
@@ -491,7 +491,7 @@ repeat:
/* Sanity check */
if (rcu_access_pointer(fdt->fd[fd]) != NULL) {
printk(KERN_WARNING "alloc_fd: slot %d not NULL!\n", fd);
- rcu_assign_pointer(fdt->fd[fd], NULL);
+ RCU_INIT_POINTER(fdt->fd[fd], NULL);
}
#endif
@@ -582,7 +582,7 @@ int __close_fd(struct files_struct *files, unsigned fd)
file = fdt->fd[fd];
if (!file)
goto out_unlock;
- rcu_assign_pointer(fdt->fd[fd], NULL);
+ RCU_INIT_POINTER(fdt->fd[fd], NULL);
__clear_close_on_exec(fd, fdt);
__put_unused_fd(files, fd);
spin_unlock(&files->file_lock);
@@ -617,7 +617,7 @@ void do_close_on_exec(struct files_struct *files)
file = fdt->fd[fd];
if (!file)
continue;
- rcu_assign_pointer(fdt->fd[fd], NULL);
+ RCU_INIT_POINTER(fdt->fd[fd], NULL);
__put_unused_fd(files, fd);
spin_unlock(&files->file_lock);
filp_close(file, files);
--
1.9.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2014-08-22 14:02 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-22 14:02 [PATCH] fs: file: Replace rcu_assign_pointer() with RCU_INIT_POINTER() Andreea-Cristina Bernat
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).