Re: adding linux syscall fallocate

2019-11-06 Thread r0ller
Hi Maciej, Thanks for the detailed answer! Unfortunately, I don't think that I could accomplish this task in my spare time:( Please, don't take this as an offence but as a fix for my case I thought of an utter hack: I do know that writing a file by calling fallocate can be tricked and redirec

__{read,write}_once

2019-11-06 Thread Maxime Villard
There are cases in the kernel where we read/write global memory locklessly, and accept the races either because it is part of the design (eg low-level scheduling) or we simply don't care (eg global stats). In these cases, we want to access the memory only once, and need to ensure the compiler doe

Re: __{read,write}_once

2019-11-06 Thread Martin Husemann
On Wed, Nov 06, 2019 at 12:31:37PM +0100, Maxime Villard wrote: > __read_once(x) > __write_once(x, val) The names are really not helpfull for understanding what is supposed to happen here. Martin

Re: __{read,write}_once

2019-11-06 Thread Maxime Villard
Le 06/11/2019 à 12:38, Martin Husemann a écrit : On Wed, Nov 06, 2019 at 12:31:37PM +0100, Maxime Villard wrote: __read_once(x) __write_once(x, val) The names are really not helpfull for understanding what is supposed to happen here. I don't know if you have a better suggesti

Re: __{read,write}_once

2019-11-06 Thread Kamil Rytarowski
On 06.11.2019 12:51, Maxime Villard wrote: > Le 06/11/2019 à 12:38, Martin Husemann a écrit : >> On Wed, Nov 06, 2019 at 12:31:37PM +0100, Maxime Villard wrote: >>> __read_once(x) >>> __write_once(x, val) >> >> The names are really not helpfull for understanding what is supposed >> to happe

Re: __{read,write}_once

2019-11-06 Thread Kamil Rytarowski
On 06.11.2019 14:37, Jason Thorpe wrote: > > >> On Nov 6, 2019, at 4:45 AM, Kamil Rytarowski wrote: >> >> I propose __write_relaxed() / __read_relaxed(). > > ...except that seems to imply the opposite of what these do. > > -- thorpej > Rationale? This matches atomic_load_relaxed() / atomic_

Re: __{read,write}_once

2019-11-06 Thread Jason Thorpe
> On Nov 6, 2019, at 4:45 AM, Kamil Rytarowski wrote: > > I propose __write_relaxed() / __read_relaxed(). ...except that seems to imply the opposite of what these do. -- thorpej

Re: __{read,write}_once

2019-11-06 Thread Jason Thorpe
> On Nov 6, 2019, at 5:41 AM, Kamil Rytarowski wrote: > > On 06.11.2019 14:37, Jason Thorpe wrote: >> >> >>> On Nov 6, 2019, at 4:45 AM, Kamil Rytarowski wrote: >>> >>> I propose __write_relaxed() / __read_relaxed(). >> >> ...except that seems to imply the opposite of what these do. >> >

Re: __{read,write}_once

2019-11-06 Thread Martin Husemann
On Wed, Nov 06, 2019 at 06:57:07AM -0800, Jason Thorpe wrote: > > This matches atomic_load_relaxed() / atomic_write_relaxed(), but we do > > not deal with atomics here. > > Fair enough. To me, the names suggest "compiler is allowed to apply > relaxed constraints and tear the access if it wants"..

Re: __{read,write}_once

2019-11-06 Thread Kamil Rytarowski
On 06.11.2019 15:57, Jason Thorpe wrote: > > >> On Nov 6, 2019, at 5:41 AM, Kamil Rytarowski wrote: >> >> On 06.11.2019 14:37, Jason Thorpe wrote: >>> >>> On Nov 6, 2019, at 4:45 AM, Kamil Rytarowski wrote: I propose __write_relaxed() / __read_relaxed(). >>> >>> ...except that se

Re: __{read,write}_once

2019-11-06 Thread Kamil Rytarowski
On 06.11.2019 16:44, Kamil Rytarowski wrote: > On 06.11.2019 15:57, Jason Thorpe wrote: >> >> >>> On Nov 6, 2019, at 5:41 AM, Kamil Rytarowski wrote: >>> >>> On 06.11.2019 14:37, Jason Thorpe wrote: > On Nov 6, 2019, at 4:45 AM, Kamil Rytarowski wrote: > > I propose __write_

Re: __{read,write}_once

2019-11-06 Thread David Young
On Wed, Nov 06, 2019 at 06:57:07AM -0800, Jason Thorpe wrote: > > > > On Nov 6, 2019, at 5:41 AM, Kamil Rytarowski wrote: > > > > On 06.11.2019 14:37, Jason Thorpe wrote: > >> > >> > >>> On Nov 6, 2019, at 4:45 AM, Kamil Rytarowski wrote: > >>> > >>> I propose __write_relaxed() / __read_rel

Re: __{read,write}_once

2019-11-06 Thread Andrew Cagney
On Wed, 6 Nov 2019 at 09:57, Jason Thorpe wrote: > > > > > On Nov 6, 2019, at 5:41 AM, Kamil Rytarowski wrote: > > > > On 06.11.2019 14:37, Jason Thorpe wrote: > >> > >> > >>> On Nov 6, 2019, at 4:45 AM, Kamil Rytarowski wrote: > >>> > >>> I propose __write_relaxed() / __read_relaxed(). > >> > >

Re: __{read,write}_once

2019-11-06 Thread Kamil Rytarowski
On 06.11.2019 16:58, David Young wrote: > I *think* the intention is for __read_once()/__write_once() to > load/store the entire variable from/to memory precisely once. They > provide no guarantees about atomicity of the load/store. Should > something be said about ordering and visibility of stor

Re: __{read,write}_once

2019-11-06 Thread Marco Elver
On Wed, 6 Nov 2019 at 16:51, Kamil Rytarowski wrote: > > On 06.11.2019 16:44, Kamil Rytarowski wrote: > > On 06.11.2019 15:57, Jason Thorpe wrote: > >> > >> > >>> On Nov 6, 2019, at 5:41 AM, Kamil Rytarowski wrote: > >>> > >>> On 06.11.2019 14:37, Jason Thorpe wrote: > > > > On Nov

Re: __{read,write}_once

2019-11-06 Thread Maxime Villard
Le 06/11/2019 à 17:37, Marco Elver a écrit : On Wed, 6 Nov 2019 at 16:51, Kamil Rytarowski wrote: On 06.11.2019 16:44, Kamil Rytarowski wrote: On 06.11.2019 15:57, Jason Thorpe wrote: On Nov 6, 2019, at 5:41 AM, Kamil Rytarowski wrote: On 06.11.2019 14:37, Jason Thorpe wrote: On Nov

Re: __{read,write}_once

2019-11-06 Thread Mouse
> - Is 'volatile' a guarantee that the compiler will emit only one > instruction to fetch the value? No. For some types, some compilers, and some architectures, it may be, but it is implementation-dependent. (For some types, on some architectures, it cannot be; for example, consider a 64-b

Re: __{read,write}_once

2019-11-06 Thread Marco Elver
On Wed, 6 Nov 2019 at 18:08, Maxime Villard wrote: > > Le 06/11/2019 à 17:37, Marco Elver a écrit : > > On Wed, 6 Nov 2019 at 16:51, Kamil Rytarowski wrote: > >> > >> On 06.11.2019 16:44, Kamil Rytarowski wrote: > >>> On 06.11.2019 15:57, Jason Thorpe wrote: > > > > On Nov 6, 2019,

C11 memory fences, atomics, memory model

2019-11-06 Thread Mindaugas Rasiukevicius
Hi, There have been some discussions amongst the developers about the C11 memory model. It seemed that there was a lot of confusion and a general lack of clarity in this subject. I wrote a quick summary describing some of the key points of the C11 memory model and key aspects of the memory fence

Re: __{read,write}_once

2019-11-06 Thread Mindaugas Rasiukevicius
Maxime Villard wrote: > There are cases in the kernel where we read/write global memory > locklessly, and accept the races either because it is part of the design > (eg low-level scheduling) or we simply don't care (eg global stats). > > In these cases, we want to access the memory only once, and

Re: __{read,write}_once

2019-11-06 Thread Maxime Villard
Le 06/11/2019 à 20:38, Mindaugas Rasiukevicius a écrit : Maxime Villard wrote: There are cases in the kernel where we read/write global memory locklessly, and accept the races either because it is part of the design (eg low-level scheduling) or we simply don't care (eg global stats). In these

re: __{read,write}_once

2019-11-06 Thread matthew green
> - If we do not want to stick with the C11 API (its emulation), then I > would suggest to use the similar terminology, e.g. atomic_load_relaxed() > and atomic_store_relaxed(), or Linux READ_ONCE()/WRITE_ONCE(). There is > no reason invent new terminology; it might just add more confusion. i real

Re: __{read,write}_once

2019-11-06 Thread Kamil Rytarowski
On 06.11.2019 20:38, Mindaugas Rasiukevicius wrote: > Maxime Villard wrote: >> There are cases in the kernel where we read/write global memory >> locklessly, and accept the races either because it is part of the design >> (eg low-level scheduling) or we simply don't care (eg global stats). >> >> I

Re: __{read,write}_once

2019-11-06 Thread Mindaugas Rasiukevicius
Maxime Villard wrote: > > - If we do not want to stick with the C11 API (its emulation), then I > > would suggest to use the similar terminology, e.g. atomic_load_relaxed() > > and atomic_store_relaxed(), or Linux READ_ONCE()/WRITE_ONCE(). There is > > no reason invent new terminology; it might j