[lkml]   [2019]   [Oct]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRE: [PATCH 4.19 56/81] kernel/sysctl.c: do not override max_threads provided by userspace
From: Michal Hocko
> Sent: 17 October 2019 12:05
> > Plus, I don't see any locking here, should this be WRITE_ONCE() at
> > minimum?
> Why would that matter? Do you expect several root processes race to set
> the value?

One of them wins. No one is going to notice is the value is set an extra time.

WRITE_ONCE() is rarely required.
Probably only if other code is going to update the value after seeing the first write.
(eg if you are unlocking a mutex - although they have to be more complex)

READ_ONCE() is a different matter.
IMHO the compiler shouldn't be allowed to do more reads than the source requests.


Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

 \ /
  Last update: 2019-10-17 13:27    [W:0.116 / U:3.080 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site