linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] vfs: use RCU_INIT_POINTER when NULLing
@ 2016-04-30 20:09 Muhammad Falak R Wani
  2016-05-01 17:34 ` Christoph Hellwig
  0 siblings, 1 reply; 2+ messages in thread
From: Muhammad Falak R Wani @ 2016-04-30 20:09 UTC (permalink / raw)
  To: Alexander Viro; +Cc: linux-fsdevel, linux-kernel

It is always safe to use RCU_INIT_POINTER to NULL a pointer. This
results in slightly smaller/faster code.

The following semantic patch used:
<smpl>
@@
@@
- rcu_assign_pointer
+ RCU_INIT_POINTER
  (..., NULL)

</smpl>

Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
---
 fs/file.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/file.c b/fs/file.c
index 1fbc5c0..e027b33 100644
--- a/fs/file.c
+++ b/fs/file.c
@@ -543,7 +543,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
 
@@ -644,7 +644,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);
@@ -679,7 +679,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] 2+ messages in thread

* Re: [PATCH] vfs: use RCU_INIT_POINTER when NULLing
  2016-04-30 20:09 [PATCH] vfs: use RCU_INIT_POINTER when NULLing Muhammad Falak R Wani
@ 2016-05-01 17:34 ` Christoph Hellwig
  0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2016-05-01 17:34 UTC (permalink / raw)
  To: Muhammad Falak R Wani; +Cc: Alexander Viro, linux-fsdevel, linux-kernel

On Sun, May 01, 2016 at 01:39:12AM +0530, Muhammad Falak R Wani wrote:
> It is always safe to use RCU_INIT_POINTER to NULL a pointer. This
> results in slightly smaller/faster code.

Just fix rcu_assign_pointer to do the right thing for a NULL
argument instead. 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-05-01 17:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-30 20:09 [PATCH] vfs: use RCU_INIT_POINTER when NULLing Muhammad Falak R Wani
2016-05-01 17:34 ` Christoph Hellwig

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).