atomic64_t proposal
Quoted 8 lines · Dean Nelson
I'm proposing the creation of an
atomic64_tvariable, which is a 64-bit version ofatomic_t, and the usage of the__typeof__keyword in macro versions of the atomic operations to enable them to operate on either type (atomic_tandatomic64_t).I submitted the following patch to David Mosberger to be considered for inclusion in the IA-64 linux kernel. He suggested that I bring the topic up on this list so that the other 64-bit platform maintainers can commment.
Wouldn't it be much cleaner to just define atomic64_add/sub/read etc. ? That would make the macros much nicer.
On x86-64 it would be fine this way.
Is it supposed to only work on 64bit or do you plan to supply it for 32 bit too? If no, I don't see how drivers etc. should ever use it. linux is supposed to have a common kernel api.
If yes, the implementation on 32bit could be a problem. e.g. some archs need space in there for spinlocks, so it would be needed to limit the usable range.
-Andi
From: Andi Kleen <[email protected]>
Date: 27 Aug 2002 21:58:45 +0200
If yes, the implementation on 32bit could be a problem. e.g. some archs need space in there for spinlocks, so it would be needed to limit the usable range.
x86 would need 1 bit, some other 32-bit platforms would be ok with just a byte (ie. 8 bits).
I don't like this whole transparent idea just like you Andi.
People should ask for the types they want, if they want 64-bits of counter, they should explicitly use atomic64_t and use the atomic64_t operations on that type.
Quoted 6 lines · Andi Kleen
Is it supposed to only work on 64bit or do you plan to supply it for 32 bit too? If no, I don't see how drivers etc. should ever use it. linux is supposed to have a common kernel api.
If yes, the implementation on 32bit could be a problem. e.g. some archs need space in there for spinlocks, so it would be needed to limit the usable range.
There are a couple of options for implementations to use that don't require space for a spinlock: a hash table of spinlocks can be used to protect the data (parisc uses this technique). Andrea's lockless reader locks could be useful in this case. Most x86es can use cmpxchg8, and the 64 bit machines are already set. I suspect it would be a useful addition to the kernel APIs.
-ben
Signature · 1 line
"You will be reincarnated as a toad; and you will be much happier."
Quoted 15 lines · Andi Kleen
Quoted 8 lines · Dean Nelson
I'm proposing the creation of an
atomic64_tvariable, which is a 64-bit version ofatomic_t, and the usage of the__typeof__keyword in macro versions of the atomic operations to enable them to operate on either type (atomic_tandatomic64_t).I submitted the following patch to David Mosberger to be considered for inclusion in the IA-64 linux kernel. He suggested that I bring the topic up on this list so that the other 64-bit platform maintainers can commment.
Wouldn't it be much cleaner to just define atomic64_add/sub/read etc. ? That would make the macros much nicer.
Quoted 8 lines
On x86-64 it would be fine this way.
Is it supposed to only work on 64bit or do you plan to supply it for 32 bit too? If no, I don't see how drivers etc. should ever use it. linux is supposed to have a common kernel api.
If yes, the implementation on 32bit could be a problem. e.g. some archs need space in there for spinlocks, so it would be needed to limit the usable range.
Your point about a common kernel api (across all architectures) is valid and leads me to reconsider the use of common macros for the two atomic types. So I guess I would lean in the direction you suggested of separate macros (atomic64_add/sub/read etc.) for the atomic64_t type.
But I'm wondering if it would be acceptable to have the atomic64_t implemented (initially) on only one platform?
My original intent was to get atomic64_t into the IA-64 linux kernel. Mosberger suggested that the other 64-bit architecture maintainers should weigh in on this issue and that I send the proposal to lkml.
I have no plans on implementing this for anything but the IA-64 linux kernel. But its api should be discussed and approved (or disapproved) by this list. The implementations for the other platforms can come as other people feel so moved to do them.
Dean