Skip to content

Commit

Permalink
proc: don't use READ_ONCE/WRITE_ONCE for /proc/*/fail-nth
Browse files Browse the repository at this point in the history
READ_ONCE and WRITE_ONCE are useless when there is only one read/write
is being made.

Link: http://lkml.kernel.org/r/20171120204033.GA9446@avx2
Signed-off-by: Alexey Dobriyan <[email protected]>
Cc: Akinobu Mita <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Alexey Dobriyan authored and torvalds committed Feb 7, 2018
1 parent e3912ac commit 9f7118b
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions fs/proc/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -1370,7 +1370,7 @@ static ssize_t proc_fail_nth_write(struct file *file, const char __user *buf,
task = get_proc_task(file_inode(file));
if (!task)
return -ESRCH;
WRITE_ONCE(task->fail_nth, n);
task->fail_nth = n;
put_task_struct(task);

return count;
Expand All @@ -1386,8 +1386,7 @@ static ssize_t proc_fail_nth_read(struct file *file, char __user *buf,
task = get_proc_task(file_inode(file));
if (!task)
return -ESRCH;
len = snprintf(numbuf, sizeof(numbuf), "%u\n",
READ_ONCE(task->fail_nth));
len = snprintf(numbuf, sizeof(numbuf), "%u\n", task->fail_nth);
len = simple_read_from_buffer(buf, count, ppos, numbuf, len);
put_task_struct(task);

Expand Down

0 comments on commit 9f7118b

Please sign in to comment.