public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH] locks:Remove spinlock in unshare_files
@ 2020-03-13  3:10 ling.ma.program
  2020-03-16 13:25 ` Ling Ma
  0 siblings, 1 reply; 4+ messages in thread
From: ling.ma.program @ 2020-03-13  3:10 UTC (permalink / raw)
  To: linux-kernel; +Cc: ling.ml

From: Ma Ling <ling.ml@antfin.com>

Processor support atomic operation for long/int/short/char type,
we use the feature to avoid spinlock, which cost hundreds cycles.

Appreciate your comments
Ling

Signed-off-by: Ma Ling <ling.ml@antfin.com>
---
 kernel/fork.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/kernel/fork.c b/kernel/fork.c
index 60a1295..fe54600 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -3041,9 +3041,7 @@ int unshare_files(struct files_struct **displaced)
 		return error;
 	}
 	*displaced = task->files;
-	task_lock(task);
-	task->files = copy;
-	task_unlock(task);
+	WRITE_ONCE(task->files, copy);
 	return 0;
 }
 
-- 
1.8.3.1


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

end of thread, other threads:[~2020-03-16 18:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-13  3:10 [RFC PATCH] locks:Remove spinlock in unshare_files ling.ma.program
2020-03-16 13:25 ` Ling Ma
2020-03-16 13:39   ` Peter Zijlstra
2020-03-16 18:35     ` Al Viro

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox