Re: __{read,write}_once

2019-11-22 Thread Kamil Rytarowski
On 22.11.2019 02:42, Robert Elz wrote:
> Date:Fri, 22 Nov 2019 01:04:56 +0100
> From:Kamil Rytarowski 
> Message-ID:  <1a9d9b40-42fe-be08-d7b3-e6ecead5b...@gmx.com>
> 
> 
>   | I think that picking C11 terminology is the way forward.
> 
> Use a name like that iff the intent is to also exactly match the
> semantics implied, otherwise it will only create more confusion.
> 
> kre
> 

I think this matches. We want to make operation in 'single operation'
(or looking like so) and 'atomic' is a settled name in English (there
are options like: 'integral', 'intrinsic', 'elemental', 'essential',
'fundamental' or 'single operation').

If there are stronger feelings against it, I would go for
'__write_singleop()', '__read_singleop()'.



signature.asc
Description: OpenPGP digital signature


Re: PT32_[GS]ETXMMREGS for amd64 (Was: netbsd32_{,u}int64 in sys/types.h for compat/sys/siginfo.h)

2019-11-22 Thread Rin Okuyama

On 2019/11/22 15:58, Michał Górny wrote:

On Fri, 2019-11-22 at 10:10 +0900, Rin Okuyama wrote:

Hi, thank you for your review!

On 2019/11/22 0:48, Kamil Rytarowski wrote:

On 21.11.2019 10:49, Rin Okuyama wrote:

...

I wrote a draft version of patch which adds PT32_[GS]ETXMMREGS support:

http://www.netbsd.org/~rin/amd64-PT32_GSETXMMREGS-20191121.patch

With this patch, XMM-related tests pass for COMPAT_NETBSD32 on amd64.

Some remarks:

(1) PT_[GS]ETXMMREGS ptrace(2) commands are added to .
  These are only used for COMPAT_NETBSD32, and not exposed to userland.



This is correct.
We don't want to export XMMREGS to amd64 users.

Pleae remove /* */ from this part:

+/*
+   "PT_GETXMMREGS", \
+   "PT_SETXMMREGS"
+ */


Yes, I will.


This will allow ktruss and related software to have meaningful form for
compat32 ptracing.


(2) COMPAT_NETBSD32 codes are called from process_machdep.c via
  module_hook framework. This may be too much though...



I have no opinion here.


Now, Paul and I are discussed how to improve the usage of module_hook.
I will update this part in accordance with his advice.


Comments?



I will leave this to be reviewed by mgorny@. Adding him to CC.


I see. Hi, mgorny@. Please look into it!

http://www.netbsd.org/~rin/amd64-PT32_GSETXMMREGS-20191121.patch




It seems correct at a first glance.  The hook logic is unknown to me, so
I can't comment on that.  If I was to be picky, I'd prefer if changes
in existing code that are not exactly relevant to adding this were split
into a separate patches (e.g. changing int to bool, renaming valid*
func).



Thank you for your comments! Yes, I will split changes.

I will commit them after finding out appropriate places where hook and
its definition should be.

Thanks,
rin


Re: __{read,write}_once

2019-11-22 Thread Andreas Gustafsson
Maxime Villard wrote:
> How about _onestep()? Or _nosplit()?

Or just conclude that there are no good options and we might as well
call it _once() to be compatible with other OSes.
-- 
Andreas Gustafsson, g...@gson.org


Re: __{read,write}_once

2019-11-22 Thread Maxime Villard

Le 21/11/2019 à 23:08, David Young a écrit :

On Thu, Nov 21, 2019 at 07:19:51PM +0100, Maxime Villard wrote:

Le 18/11/2019 à 19:49, David Holland a écrit :

On Sun, Nov 17, 2019 at 02:35:43PM +, Mindaugas Rasiukevicius wrote:
  > David Holland  wrote:
  > >  > I see the potential source of confusion, but just think about: what
  > >  > could "atomic" possibly mean for loads or stores?  A load is just a
  > >  > load, there is no RMW cycle, conceptually; inter-locking the operation
  > >  > does not make sense.  For anybody who attempts to reason about this,
  > >  > it should not be too confusing, plus there are man pages.
  > >
  > > ...that it's not torn.
  > >
  > > As far as names... there are increasingly many slightly different
  > > types of atomic and semiatomic operations.
  > >
  > > I think it would be helpful if someone came up with a comprehensive
  > > naming scheme for all of them (including ones we don't currently have
  > > that we're moderately likely to end up with later...)
  >
  > Yes, the meaning of "atomic" has different flavours and describes different
  > set of properties in different fields (operating systems vs databases vs
  > distributed systems vs ...) and, as we can see, even within the fields.
  >
  > Perhaps not ideal, but "atomic loads/stores" and "relaxed" are already the
  > dominant terms.

Yes, but "relaxed" means something else... let me be clearer since I
wasn't before: I would expect e.g. atomic_inc_32_relaxed() to be
distinguished from atomic_inc_32() or maybe atomic_inc_32_ordered() by
whether or not multiple instances of it are globally ordered, not by
whether or not it's actually atomic relative to other cpus.

Checking the prior messages indicates we aren't currently talking
about atomic_inc_32_relaxed() but only about atomic_load_32_relaxed()
and atomic_store_32_relaxed(), which would be used together to
generate a local counter. This is less misleading, but I'm still not
convinced it's a good choice of names given that we might reasonably
later on want to have atomic_inc_32_relaxed() and
atomic_inc_32_ordered() that differ as above.

  > I think it is pointless to attempt to reinvent the wheel
  > here.  It is terminology used by C11 (and C++11) and accepted by various
  > technical literature and, at this point, by academia (if you look at the
  > recent papers on memory models -- it's pretty much settled).  These terms
  > are not too bad; it could be worse; and this bit is certainly not the worst
  > part of C11.  So, I would just move on.

Is it settled? My experience with the academic literature has been
that everyone uses their own terminology and the same words are
routinely found to have subtly different meanings from one paper to
the next and occasionally even within the same paper. :-/  But I
haven't been paying much attention lately due to being preoccupied
with other things.


So in the end which name do we use? Are people really unhappy with _racy()?
At least it has a general meaning, and does not imply atomicity or ordering.


_racy() doesn't really get at the intended meaning, and everything in
C11 is racy unless you arrange otherwise by using mutexes, atomics, etc.
The suffix has very little content.

Names such as load_/store_fully() or load_/store_entire() or
load_/store_completely() get to the actual semantics: at the program
step implied by the load_/store_entire() expression, the memory
constituting the named variable is loaded/stored in its entirety.  In
other words, the load cannot be drawn out over more than one local
program step.  Whether or not the load/store is performed in one step
with respect to interrupts or other threads is not defined.


Sounds like the right definition of the semantic. However:


I feel like load_entire() and store_entire() get to the heart of the
matter while being easy to speak, but _fully() or _completely() seem
fine.


I'm not a really big fan of _entire(), because it gives the impression that
the load/store is not entire otherwise - which it is, but just possibly not
in one step.

How about _onestep()? Or _nosplit()?