On 10/11/2019 4:32:11 PM, Richard Elling <richard.ell...@richardelling.com> 
wrote:


On Oct 11, 2019, at 2:50 PM, Garrett D'Amore <garr...@damore.org 
[mailto:garr...@damore.org]> wrote:

The issue is that you can't just arbitrarily throw a mutex out there -- you 
have to have a place to *store* that, and you can't fit it inside the 64-bit 
value.  With a 64-bit ISA this isn't usually a problem, but with 32-bit ISAs it 
is.

I'm not sure how this affects the compiler builtin atomics since they don't add 
mutexes.
Garrett D'Amore: 

You're missing the point.  If you have a 32-bit ISA that doesn't offer a 64-bit 
atomic operation, then you have to fabricate one.  Fabricating one requires a 
mutex, spinlock, or some other value. 

What this means is that compiler builtins can't be used to solve the problem of 
supporting a 64-bit atomic when the underlying platform lacks support. So you 
have to solve it in software typically, which is what I think this whole 
discussion is about.

 - Garrett


 -- richard


The only way to store the mutex (which could just be a spinlock) is to have 
some other place that has it -- typically in library code.  Allocation of other 
objects like that normally falls outside the scope of a compiler builtin 
(modulo bringing in a separate runtime object file, which can work for user 
programs but generally not for kernels.)
On 10/11/2019 11:38:57 AM, Richard Elling <richard.ell...@richardelling.com 
[mailto:richard.ell...@richardelling.com]> wrote:


On Oct 9, 2019, at 11:41 AM, Garrett D'Amore <garr...@damore.org 
[mailto:garr...@damore.org]> wrote:

I don't think 32-bit compilers generally offer builtins for 64-bit atomics.  
Frankly, they can't really unless the underlying ISA provides some additional 
support for this in particular.

Yes, that is why the builtins exist... the underlying ISA may have a method 
that is not part of the C language.

Worst case, mutex protection will work... slowly.
 -- richard


To implement a 64-bit atomic on a 32-bit architecture, you generally needs some 
additional state somewhere -- typically some sort of mutex or spinlock.  That 
has to live somewhere.  (You *might* be able to have a compiler builtin that 
provides this along with a compiler runtime which provides an instance of the 
spinlock somewhere in the program's data section.  I think this sort of 
"builtin" (which isn't really builtin at all) generally can't be used in 
operating system kernels -- e.g. with --freestanding.)
On 10/9/2019 11:26:40 AM, Richard Elling <richard.ell...@richardelling.com 
[mailto:richard.ell...@richardelling.com]> wrote:
If it is possible to specify a compiler version, it might be easier to use the 
compiler
builtin atomics. Just sayin'
-- richard


------------------------------------------
openzfs: openzfs-developer
Permalink: 
https://openzfs.topicbox.com/groups/developer/T3ee8a81d5f09f2ec-Mabd6346845b79e16d16f57c2
 
[https://openzfs.topicbox.com/groups/developer/T3ee8a81d5f09f2ec-Mabd6346845b79e16d16f57c2]
Delivery options: https://openzfs.topicbox.com/groups/developer/subscription 
[https://openzfs.topicbox.com/groups/developer/subscription]



openzfs [https://openzfs.topicbox.com/latest] / openzfs-developer / see 
discussions [https://openzfs.topicbox.com/groups/developer] + participants 
[https://openzfs.topicbox.com/groups/developer/members] + delivery options 
[https://openzfs.topicbox.com/groups/developer/subscription] Permalink 
[https://openzfs.topicbox.com/groups/developer/T3ee8a81d5f09f2ec-M51858eebfe98f256ff2d7f42]
------------------------------------------
openzfs: openzfs-developer
Permalink: 
https://openzfs.topicbox.com/groups/developer/T3ee8a81d5f09f2ec-M620340096d08af342b9b67d2
Delivery options: https://openzfs.topicbox.com/groups/developer/subscription

Reply via email to