License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 21:07:57 +07:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2009-05-14 05:56:29 +07:00
|
|
|
#ifndef _ASM_GENERIC_ATOMIC_LONG_H
|
|
|
|
#define _ASM_GENERIC_ATOMIC_LONG_H
|
2006-01-06 15:11:20 +07:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2005 Silicon Graphics, Inc.
|
2008-07-04 23:59:22 +07:00
|
|
|
* Christoph Lameter
|
2006-01-06 15:11:20 +07:00
|
|
|
*
|
|
|
|
* Allows to provide arch independent atomic definitions without the need to
|
|
|
|
* edit all arch specific atomic.h files.
|
|
|
|
*/
|
|
|
|
|
2006-01-08 16:00:29 +07:00
|
|
|
#include <asm/types.h>
|
2006-01-06 15:11:20 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Suppport for atomic_long_t
|
|
|
|
*
|
|
|
|
* Casts for parameters are avoided for existing atomic functions in order to
|
|
|
|
* avoid issues with cast-as-lval under gcc 4.x and other limitations that the
|
|
|
|
* macros of a platform may have.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#if BITS_PER_LONG == 64
|
|
|
|
|
|
|
|
typedef atomic64_t atomic_long_t;
|
|
|
|
|
|
|
|
#define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
|
2015-08-06 23:54:38 +07:00
|
|
|
#define ATOMIC_LONG_PFX(x) atomic64 ## x
|
locking/mutex: Optimize __mutex_trylock_fast()
Use try_cmpxchg to avoid the pointless TEST instruction..
And add the (missing) atomic_long_try_cmpxchg*() wrappery.
On x86_64 this gives:
0000000000000710 <mutex_lock>: 0000000000000710 <mutex_lock>:
710: 65 48 8b 14 25 00 00 mov %gs:0x0,%rdx 710: 65 48 8b 14 25 00 00 mov %gs:0x0,%rdx
717: 00 00 717: 00 00
715: R_X86_64_32S current_task 715: R_X86_64_32S current_task
719: 31 c0 xor %eax,%eax 719: 31 c0 xor %eax,%eax
71b: f0 48 0f b1 17 lock cmpxchg %rdx,(%rdi) 71b: f0 48 0f b1 17 lock cmpxchg %rdx,(%rdi)
720: 48 85 c0 test %rax,%rax 720: 75 02 jne 724 <mutex_lock+0x14>
723: 75 02 jne 727 <mutex_lock+0x17> 722: f3 c3 repz retq
725: f3 c3 repz retq 724: eb da jmp 700 <__mutex_lock_slowpath>
727: eb d7 jmp 700 <__mutex_lock_slowpath> 726: 66 2e 0f 1f 84 00 00 nopw %cs:0x0(%rax,%rax,1)
729: 0f 1f 80 00 00 00 00 nopl 0x0(%rax) 72d: 00 00 00
On ARM64 this gives:
000000000000638 <mutex_lock>: 0000000000000638 <mutex_lock>:
638: d5384101 mrs x1, sp_el0 638: d5384101 mrs x1, sp_el0
63c: d2800002 mov x2, #0x0 63c: d2800002 mov x2, #0x0
640: f9800011 prfm pstl1strm, [x0] 640: f9800011 prfm pstl1strm, [x0]
644: c85ffc03 ldaxr x3, [x0] 644: c85ffc03 ldaxr x3, [x0]
648: ca020064 eor x4, x3, x2 648: ca020064 eor x4, x3, x2
64c: b5000064 cbnz x4, 658 <mutex_lock+0x20> 64c: b5000064 cbnz x4, 658 <mutex_lock+0x20>
650: c8047c01 stxr w4, x1, [x0] 650: c8047c01 stxr w4, x1, [x0]
654: 35ffff84 cbnz w4, 644 <mutex_lock+0xc> 654: 35ffff84 cbnz w4, 644 <mutex_lock+0xc>
658: b40000c3 cbz x3, 670 <mutex_lock+0x38> 658: b5000043 cbnz x3, 660 <mutex_lock+0x28>
65c: a9bf7bfd stp x29, x30, [sp,#-16]! 65c: d65f03c0 ret
660: 910003fd mov x29, sp 660: a9bf7bfd stp x29, x30, [sp,#-16]!
664: 97ffffef bl 620 <__mutex_lock_slowpath> 664: 910003fd mov x29, sp
668: a8c17bfd ldp x29, x30, [sp],#16 668: 97ffffee bl 620 <__mutex_lock_slowpath>
66c: d65f03c0 ret 66c: a8c17bfd ldp x29, x30, [sp],#16
670: d65f03c0 ret 670: d65f03c0 ret
Reported-by: Matthew Wilcox <mawilcox@microsoft.com>
Acked-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2018-04-05 16:05:35 +07:00
|
|
|
#define ATOMIC_LONG_TYPE s64
|
2006-01-06 15:11:20 +07:00
|
|
|
|
2015-08-06 23:54:38 +07:00
|
|
|
#else
|
2006-01-06 15:11:20 +07:00
|
|
|
|
|
|
|
typedef atomic_t atomic_long_t;
|
|
|
|
|
|
|
|
#define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
|
2015-08-06 23:54:38 +07:00
|
|
|
#define ATOMIC_LONG_PFX(x) atomic ## x
|
locking/mutex: Optimize __mutex_trylock_fast()
Use try_cmpxchg to avoid the pointless TEST instruction..
And add the (missing) atomic_long_try_cmpxchg*() wrappery.
On x86_64 this gives:
0000000000000710 <mutex_lock>: 0000000000000710 <mutex_lock>:
710: 65 48 8b 14 25 00 00 mov %gs:0x0,%rdx 710: 65 48 8b 14 25 00 00 mov %gs:0x0,%rdx
717: 00 00 717: 00 00
715: R_X86_64_32S current_task 715: R_X86_64_32S current_task
719: 31 c0 xor %eax,%eax 719: 31 c0 xor %eax,%eax
71b: f0 48 0f b1 17 lock cmpxchg %rdx,(%rdi) 71b: f0 48 0f b1 17 lock cmpxchg %rdx,(%rdi)
720: 48 85 c0 test %rax,%rax 720: 75 02 jne 724 <mutex_lock+0x14>
723: 75 02 jne 727 <mutex_lock+0x17> 722: f3 c3 repz retq
725: f3 c3 repz retq 724: eb da jmp 700 <__mutex_lock_slowpath>
727: eb d7 jmp 700 <__mutex_lock_slowpath> 726: 66 2e 0f 1f 84 00 00 nopw %cs:0x0(%rax,%rax,1)
729: 0f 1f 80 00 00 00 00 nopl 0x0(%rax) 72d: 00 00 00
On ARM64 this gives:
000000000000638 <mutex_lock>: 0000000000000638 <mutex_lock>:
638: d5384101 mrs x1, sp_el0 638: d5384101 mrs x1, sp_el0
63c: d2800002 mov x2, #0x0 63c: d2800002 mov x2, #0x0
640: f9800011 prfm pstl1strm, [x0] 640: f9800011 prfm pstl1strm, [x0]
644: c85ffc03 ldaxr x3, [x0] 644: c85ffc03 ldaxr x3, [x0]
648: ca020064 eor x4, x3, x2 648: ca020064 eor x4, x3, x2
64c: b5000064 cbnz x4, 658 <mutex_lock+0x20> 64c: b5000064 cbnz x4, 658 <mutex_lock+0x20>
650: c8047c01 stxr w4, x1, [x0] 650: c8047c01 stxr w4, x1, [x0]
654: 35ffff84 cbnz w4, 644 <mutex_lock+0xc> 654: 35ffff84 cbnz w4, 644 <mutex_lock+0xc>
658: b40000c3 cbz x3, 670 <mutex_lock+0x38> 658: b5000043 cbnz x3, 660 <mutex_lock+0x28>
65c: a9bf7bfd stp x29, x30, [sp,#-16]! 65c: d65f03c0 ret
660: 910003fd mov x29, sp 660: a9bf7bfd stp x29, x30, [sp,#-16]!
664: 97ffffef bl 620 <__mutex_lock_slowpath> 664: 910003fd mov x29, sp
668: a8c17bfd ldp x29, x30, [sp],#16 668: 97ffffee bl 620 <__mutex_lock_slowpath>
66c: d65f03c0 ret 66c: a8c17bfd ldp x29, x30, [sp],#16
670: d65f03c0 ret 670: d65f03c0 ret
Reported-by: Matthew Wilcox <mawilcox@microsoft.com>
Acked-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2018-04-05 16:05:35 +07:00
|
|
|
#define ATOMIC_LONG_TYPE int
|
2015-08-06 23:54:38 +07:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2015-08-06 23:54:39 +07:00
|
|
|
#define ATOMIC_LONG_READ_OP(mo) \
|
2015-09-18 18:22:52 +07:00
|
|
|
static inline long atomic_long_read##mo(const atomic_long_t *l) \
|
2015-08-06 23:54:39 +07:00
|
|
|
{ \
|
|
|
|
ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l; \
|
|
|
|
\
|
|
|
|
return (long)ATOMIC_LONG_PFX(_read##mo)(v); \
|
2006-01-06 15:11:20 +07:00
|
|
|
}
|
2015-08-06 23:54:39 +07:00
|
|
|
ATOMIC_LONG_READ_OP()
|
|
|
|
ATOMIC_LONG_READ_OP(_acquire)
|
2006-01-06 15:11:20 +07:00
|
|
|
|
2015-08-06 23:54:39 +07:00
|
|
|
#undef ATOMIC_LONG_READ_OP
|
2006-01-06 15:11:20 +07:00
|
|
|
|
2015-08-06 23:54:39 +07:00
|
|
|
#define ATOMIC_LONG_SET_OP(mo) \
|
|
|
|
static inline void atomic_long_set##mo(atomic_long_t *l, long i) \
|
|
|
|
{ \
|
|
|
|
ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l; \
|
|
|
|
\
|
|
|
|
ATOMIC_LONG_PFX(_set##mo)(v, i); \
|
|
|
|
}
|
|
|
|
ATOMIC_LONG_SET_OP()
|
|
|
|
ATOMIC_LONG_SET_OP(_release)
|
|
|
|
|
|
|
|
#undef ATOMIC_LONG_SET_OP
|
|
|
|
|
|
|
|
#define ATOMIC_LONG_ADD_SUB_OP(op, mo) \
|
|
|
|
static inline long \
|
|
|
|
atomic_long_##op##_return##mo(long i, atomic_long_t *l) \
|
|
|
|
{ \
|
|
|
|
ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l; \
|
|
|
|
\
|
|
|
|
return (long)ATOMIC_LONG_PFX(_##op##_return##mo)(i, v); \
|
2006-01-06 15:11:20 +07:00
|
|
|
}
|
2015-08-06 23:54:39 +07:00
|
|
|
ATOMIC_LONG_ADD_SUB_OP(add,)
|
|
|
|
ATOMIC_LONG_ADD_SUB_OP(add, _relaxed)
|
|
|
|
ATOMIC_LONG_ADD_SUB_OP(add, _acquire)
|
|
|
|
ATOMIC_LONG_ADD_SUB_OP(add, _release)
|
|
|
|
ATOMIC_LONG_ADD_SUB_OP(sub,)
|
|
|
|
ATOMIC_LONG_ADD_SUB_OP(sub, _relaxed)
|
|
|
|
ATOMIC_LONG_ADD_SUB_OP(sub, _acquire)
|
|
|
|
ATOMIC_LONG_ADD_SUB_OP(sub, _release)
|
|
|
|
|
|
|
|
#undef ATOMIC_LONG_ADD_SUB_OP
|
|
|
|
|
|
|
|
#define atomic_long_cmpxchg_relaxed(l, old, new) \
|
|
|
|
(ATOMIC_LONG_PFX(_cmpxchg_relaxed)((ATOMIC_LONG_PFX(_t) *)(l), \
|
|
|
|
(old), (new)))
|
|
|
|
#define atomic_long_cmpxchg_acquire(l, old, new) \
|
|
|
|
(ATOMIC_LONG_PFX(_cmpxchg_acquire)((ATOMIC_LONG_PFX(_t) *)(l), \
|
|
|
|
(old), (new)))
|
|
|
|
#define atomic_long_cmpxchg_release(l, old, new) \
|
|
|
|
(ATOMIC_LONG_PFX(_cmpxchg_release)((ATOMIC_LONG_PFX(_t) *)(l), \
|
|
|
|
(old), (new)))
|
|
|
|
#define atomic_long_cmpxchg(l, old, new) \
|
|
|
|
(ATOMIC_LONG_PFX(_cmpxchg)((ATOMIC_LONG_PFX(_t) *)(l), (old), (new)))
|
|
|
|
|
locking/mutex: Optimize __mutex_trylock_fast()
Use try_cmpxchg to avoid the pointless TEST instruction..
And add the (missing) atomic_long_try_cmpxchg*() wrappery.
On x86_64 this gives:
0000000000000710 <mutex_lock>: 0000000000000710 <mutex_lock>:
710: 65 48 8b 14 25 00 00 mov %gs:0x0,%rdx 710: 65 48 8b 14 25 00 00 mov %gs:0x0,%rdx
717: 00 00 717: 00 00
715: R_X86_64_32S current_task 715: R_X86_64_32S current_task
719: 31 c0 xor %eax,%eax 719: 31 c0 xor %eax,%eax
71b: f0 48 0f b1 17 lock cmpxchg %rdx,(%rdi) 71b: f0 48 0f b1 17 lock cmpxchg %rdx,(%rdi)
720: 48 85 c0 test %rax,%rax 720: 75 02 jne 724 <mutex_lock+0x14>
723: 75 02 jne 727 <mutex_lock+0x17> 722: f3 c3 repz retq
725: f3 c3 repz retq 724: eb da jmp 700 <__mutex_lock_slowpath>
727: eb d7 jmp 700 <__mutex_lock_slowpath> 726: 66 2e 0f 1f 84 00 00 nopw %cs:0x0(%rax,%rax,1)
729: 0f 1f 80 00 00 00 00 nopl 0x0(%rax) 72d: 00 00 00
On ARM64 this gives:
000000000000638 <mutex_lock>: 0000000000000638 <mutex_lock>:
638: d5384101 mrs x1, sp_el0 638: d5384101 mrs x1, sp_el0
63c: d2800002 mov x2, #0x0 63c: d2800002 mov x2, #0x0
640: f9800011 prfm pstl1strm, [x0] 640: f9800011 prfm pstl1strm, [x0]
644: c85ffc03 ldaxr x3, [x0] 644: c85ffc03 ldaxr x3, [x0]
648: ca020064 eor x4, x3, x2 648: ca020064 eor x4, x3, x2
64c: b5000064 cbnz x4, 658 <mutex_lock+0x20> 64c: b5000064 cbnz x4, 658 <mutex_lock+0x20>
650: c8047c01 stxr w4, x1, [x0] 650: c8047c01 stxr w4, x1, [x0]
654: 35ffff84 cbnz w4, 644 <mutex_lock+0xc> 654: 35ffff84 cbnz w4, 644 <mutex_lock+0xc>
658: b40000c3 cbz x3, 670 <mutex_lock+0x38> 658: b5000043 cbnz x3, 660 <mutex_lock+0x28>
65c: a9bf7bfd stp x29, x30, [sp,#-16]! 65c: d65f03c0 ret
660: 910003fd mov x29, sp 660: a9bf7bfd stp x29, x30, [sp,#-16]!
664: 97ffffef bl 620 <__mutex_lock_slowpath> 664: 910003fd mov x29, sp
668: a8c17bfd ldp x29, x30, [sp],#16 668: 97ffffee bl 620 <__mutex_lock_slowpath>
66c: d65f03c0 ret 66c: a8c17bfd ldp x29, x30, [sp],#16
670: d65f03c0 ret 670: d65f03c0 ret
Reported-by: Matthew Wilcox <mawilcox@microsoft.com>
Acked-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2018-04-05 16:05:35 +07:00
|
|
|
|
|
|
|
#define atomic_long_try_cmpxchg_relaxed(l, old, new) \
|
|
|
|
(ATOMIC_LONG_PFX(_try_cmpxchg_relaxed)((ATOMIC_LONG_PFX(_t) *)(l), \
|
|
|
|
(ATOMIC_LONG_TYPE *)(old), (ATOMIC_LONG_TYPE)(new)))
|
|
|
|
#define atomic_long_try_cmpxchg_acquire(l, old, new) \
|
|
|
|
(ATOMIC_LONG_PFX(_try_cmpxchg_acquire)((ATOMIC_LONG_PFX(_t) *)(l), \
|
|
|
|
(ATOMIC_LONG_TYPE *)(old), (ATOMIC_LONG_TYPE)(new)))
|
|
|
|
#define atomic_long_try_cmpxchg_release(l, old, new) \
|
|
|
|
(ATOMIC_LONG_PFX(_try_cmpxchg_release)((ATOMIC_LONG_PFX(_t) *)(l), \
|
|
|
|
(ATOMIC_LONG_TYPE *)(old), (ATOMIC_LONG_TYPE)(new)))
|
|
|
|
#define atomic_long_try_cmpxchg(l, old, new) \
|
|
|
|
(ATOMIC_LONG_PFX(_try_cmpxchg)((ATOMIC_LONG_PFX(_t) *)(l), \
|
|
|
|
(ATOMIC_LONG_TYPE *)(old), (ATOMIC_LONG_TYPE)(new)))
|
|
|
|
|
|
|
|
|
2015-08-06 23:54:39 +07:00
|
|
|
#define atomic_long_xchg_relaxed(v, new) \
|
|
|
|
(ATOMIC_LONG_PFX(_xchg_relaxed)((ATOMIC_LONG_PFX(_t) *)(v), (new)))
|
|
|
|
#define atomic_long_xchg_acquire(v, new) \
|
|
|
|
(ATOMIC_LONG_PFX(_xchg_acquire)((ATOMIC_LONG_PFX(_t) *)(v), (new)))
|
|
|
|
#define atomic_long_xchg_release(v, new) \
|
|
|
|
(ATOMIC_LONG_PFX(_xchg_release)((ATOMIC_LONG_PFX(_t) *)(v), (new)))
|
|
|
|
#define atomic_long_xchg(v, new) \
|
|
|
|
(ATOMIC_LONG_PFX(_xchg)((ATOMIC_LONG_PFX(_t) *)(v), (new)))
|
2006-01-06 15:11:20 +07:00
|
|
|
|
2016-03-18 04:22:41 +07:00
|
|
|
static __always_inline void atomic_long_inc(atomic_long_t *l)
|
2006-01-06 15:11:20 +07:00
|
|
|
{
|
2015-08-06 23:54:38 +07:00
|
|
|
ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l;
|
2006-01-06 15:11:20 +07:00
|
|
|
|
2015-08-06 23:54:38 +07:00
|
|
|
ATOMIC_LONG_PFX(_inc)(v);
|
2006-01-06 15:11:20 +07:00
|
|
|
}
|
|
|
|
|
2016-03-18 04:22:41 +07:00
|
|
|
static __always_inline void atomic_long_dec(atomic_long_t *l)
|
2006-01-06 15:11:20 +07:00
|
|
|
{
|
2015-08-06 23:54:38 +07:00
|
|
|
ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l;
|
2006-01-06 15:11:20 +07:00
|
|
|
|
2015-08-06 23:54:38 +07:00
|
|
|
ATOMIC_LONG_PFX(_dec)(v);
|
2006-01-06 15:11:20 +07:00
|
|
|
}
|
|
|
|
|
locking/atomic: Implement atomic{,64,_long}_fetch_{add,sub,and,andnot,or,xor}{,_relaxed,_acquire,_release}()
Now that all the architectures have implemented support for these new
atomic primitives add on the generic infrastructure to expose and use
it.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Boqun Feng <boqun.feng@gmail.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: Davidlohr Bueso <dave@stgolabs.net>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Will Deacon <will.deacon@arm.com>
Cc: linux-arch@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2016-04-18 05:54:38 +07:00
|
|
|
#define ATOMIC_LONG_FETCH_OP(op, mo) \
|
|
|
|
static inline long \
|
|
|
|
atomic_long_fetch_##op##mo(long i, atomic_long_t *l) \
|
|
|
|
{ \
|
|
|
|
ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l; \
|
|
|
|
\
|
|
|
|
return (long)ATOMIC_LONG_PFX(_fetch_##op##mo)(i, v); \
|
|
|
|
}
|
|
|
|
|
|
|
|
ATOMIC_LONG_FETCH_OP(add, )
|
|
|
|
ATOMIC_LONG_FETCH_OP(add, _relaxed)
|
|
|
|
ATOMIC_LONG_FETCH_OP(add, _acquire)
|
|
|
|
ATOMIC_LONG_FETCH_OP(add, _release)
|
|
|
|
ATOMIC_LONG_FETCH_OP(sub, )
|
|
|
|
ATOMIC_LONG_FETCH_OP(sub, _relaxed)
|
|
|
|
ATOMIC_LONG_FETCH_OP(sub, _acquire)
|
|
|
|
ATOMIC_LONG_FETCH_OP(sub, _release)
|
|
|
|
ATOMIC_LONG_FETCH_OP(and, )
|
|
|
|
ATOMIC_LONG_FETCH_OP(and, _relaxed)
|
|
|
|
ATOMIC_LONG_FETCH_OP(and, _acquire)
|
|
|
|
ATOMIC_LONG_FETCH_OP(and, _release)
|
|
|
|
ATOMIC_LONG_FETCH_OP(andnot, )
|
|
|
|
ATOMIC_LONG_FETCH_OP(andnot, _relaxed)
|
|
|
|
ATOMIC_LONG_FETCH_OP(andnot, _acquire)
|
|
|
|
ATOMIC_LONG_FETCH_OP(andnot, _release)
|
|
|
|
ATOMIC_LONG_FETCH_OP(or, )
|
|
|
|
ATOMIC_LONG_FETCH_OP(or, _relaxed)
|
|
|
|
ATOMIC_LONG_FETCH_OP(or, _acquire)
|
|
|
|
ATOMIC_LONG_FETCH_OP(or, _release)
|
|
|
|
ATOMIC_LONG_FETCH_OP(xor, )
|
|
|
|
ATOMIC_LONG_FETCH_OP(xor, _relaxed)
|
|
|
|
ATOMIC_LONG_FETCH_OP(xor, _acquire)
|
|
|
|
ATOMIC_LONG_FETCH_OP(xor, _release)
|
|
|
|
|
2016-06-29 04:56:51 +07:00
|
|
|
#undef ATOMIC_LONG_FETCH_OP
|
|
|
|
|
|
|
|
#define ATOMIC_LONG_FETCH_INC_DEC_OP(op, mo) \
|
|
|
|
static inline long \
|
|
|
|
atomic_long_fetch_##op##mo(atomic_long_t *l) \
|
|
|
|
{ \
|
|
|
|
ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l; \
|
|
|
|
\
|
|
|
|
return (long)ATOMIC_LONG_PFX(_fetch_##op##mo)(v); \
|
|
|
|
}
|
|
|
|
|
|
|
|
ATOMIC_LONG_FETCH_INC_DEC_OP(inc,)
|
|
|
|
ATOMIC_LONG_FETCH_INC_DEC_OP(inc, _relaxed)
|
|
|
|
ATOMIC_LONG_FETCH_INC_DEC_OP(inc, _acquire)
|
|
|
|
ATOMIC_LONG_FETCH_INC_DEC_OP(inc, _release)
|
|
|
|
ATOMIC_LONG_FETCH_INC_DEC_OP(dec,)
|
|
|
|
ATOMIC_LONG_FETCH_INC_DEC_OP(dec, _relaxed)
|
|
|
|
ATOMIC_LONG_FETCH_INC_DEC_OP(dec, _acquire)
|
|
|
|
ATOMIC_LONG_FETCH_INC_DEC_OP(dec, _release)
|
|
|
|
|
|
|
|
#undef ATOMIC_LONG_FETCH_INC_DEC_OP
|
|
|
|
|
2015-09-18 20:04:59 +07:00
|
|
|
#define ATOMIC_LONG_OP(op) \
|
2016-03-18 04:22:41 +07:00
|
|
|
static __always_inline void \
|
2015-09-18 20:04:59 +07:00
|
|
|
atomic_long_##op(long i, atomic_long_t *l) \
|
|
|
|
{ \
|
|
|
|
ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l; \
|
|
|
|
\
|
|
|
|
ATOMIC_LONG_PFX(_##op)(i, v); \
|
2006-01-06 15:11:20 +07:00
|
|
|
}
|
|
|
|
|
2015-09-18 20:04:59 +07:00
|
|
|
ATOMIC_LONG_OP(add)
|
|
|
|
ATOMIC_LONG_OP(sub)
|
|
|
|
ATOMIC_LONG_OP(and)
|
locking/atomic: Implement atomic{,64,_long}_fetch_{add,sub,and,andnot,or,xor}{,_relaxed,_acquire,_release}()
Now that all the architectures have implemented support for these new
atomic primitives add on the generic infrastructure to expose and use
it.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Boqun Feng <boqun.feng@gmail.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: Davidlohr Bueso <dave@stgolabs.net>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Will Deacon <will.deacon@arm.com>
Cc: linux-arch@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2016-04-18 05:54:38 +07:00
|
|
|
ATOMIC_LONG_OP(andnot)
|
2015-09-18 20:04:59 +07:00
|
|
|
ATOMIC_LONG_OP(or)
|
|
|
|
ATOMIC_LONG_OP(xor)
|
2006-01-06 15:11:20 +07:00
|
|
|
|
2015-09-18 20:04:59 +07:00
|
|
|
#undef ATOMIC_LONG_OP
|
2006-01-06 15:11:20 +07:00
|
|
|
|
2007-05-08 14:34:19 +07:00
|
|
|
static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
|
|
|
|
{
|
2015-08-06 23:54:38 +07:00
|
|
|
ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l;
|
2007-05-08 14:34:19 +07:00
|
|
|
|
2015-08-06 23:54:38 +07:00
|
|
|
return ATOMIC_LONG_PFX(_sub_and_test)(i, v);
|
2007-05-08 14:34:19 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline int atomic_long_dec_and_test(atomic_long_t *l)
|
|
|
|
{
|
2015-08-06 23:54:38 +07:00
|
|
|
ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l;
|
2007-05-08 14:34:19 +07:00
|
|
|
|
2015-08-06 23:54:38 +07:00
|
|
|
return ATOMIC_LONG_PFX(_dec_and_test)(v);
|
2007-05-08 14:34:19 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline int atomic_long_inc_and_test(atomic_long_t *l)
|
|
|
|
{
|
2015-08-06 23:54:38 +07:00
|
|
|
ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l;
|
2007-05-08 14:34:19 +07:00
|
|
|
|
2015-08-06 23:54:38 +07:00
|
|
|
return ATOMIC_LONG_PFX(_inc_and_test)(v);
|
2007-05-08 14:34:19 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline int atomic_long_add_negative(long i, atomic_long_t *l)
|
|
|
|
{
|
2015-08-06 23:54:38 +07:00
|
|
|
ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l;
|
2007-05-08 14:34:19 +07:00
|
|
|
|
2015-08-06 23:54:38 +07:00
|
|
|
return ATOMIC_LONG_PFX(_add_negative)(i, v);
|
2007-05-08 14:34:19 +07:00
|
|
|
}
|
|
|
|
|
2015-10-01 03:03:11 +07:00
|
|
|
#define ATOMIC_LONG_INC_DEC_OP(op, mo) \
|
|
|
|
static inline long \
|
|
|
|
atomic_long_##op##_return##mo(atomic_long_t *l) \
|
|
|
|
{ \
|
|
|
|
ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l; \
|
|
|
|
\
|
|
|
|
return (long)ATOMIC_LONG_PFX(_##op##_return##mo)(v); \
|
2007-05-08 14:34:19 +07:00
|
|
|
}
|
2015-10-01 03:03:11 +07:00
|
|
|
ATOMIC_LONG_INC_DEC_OP(inc,)
|
|
|
|
ATOMIC_LONG_INC_DEC_OP(inc, _relaxed)
|
|
|
|
ATOMIC_LONG_INC_DEC_OP(inc, _acquire)
|
|
|
|
ATOMIC_LONG_INC_DEC_OP(inc, _release)
|
|
|
|
ATOMIC_LONG_INC_DEC_OP(dec,)
|
|
|
|
ATOMIC_LONG_INC_DEC_OP(dec, _relaxed)
|
|
|
|
ATOMIC_LONG_INC_DEC_OP(dec, _acquire)
|
|
|
|
ATOMIC_LONG_INC_DEC_OP(dec, _release)
|
|
|
|
|
|
|
|
#undef ATOMIC_LONG_INC_DEC_OP
|
2007-05-08 14:34:19 +07:00
|
|
|
|
2007-05-08 14:34:38 +07:00
|
|
|
static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
|
|
|
|
{
|
2015-08-06 23:54:38 +07:00
|
|
|
ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l;
|
2007-05-08 14:34:38 +07:00
|
|
|
|
2015-08-06 23:54:38 +07:00
|
|
|
return (long)ATOMIC_LONG_PFX(_add_unless)(v, a, u);
|
2007-05-08 14:34:38 +07:00
|
|
|
}
|
2007-05-08 14:34:19 +07:00
|
|
|
|
2015-08-06 23:54:38 +07:00
|
|
|
#define atomic_long_inc_not_zero(l) \
|
|
|
|
ATOMIC_LONG_PFX(_inc_not_zero)((ATOMIC_LONG_PFX(_t) *)(l))
|
2006-12-07 11:40:28 +07:00
|
|
|
|
2018-04-26 17:34:15 +07:00
|
|
|
#define atomic_long_cond_read_relaxed(v, c) \
|
|
|
|
ATOMIC_LONG_PFX(_cond_read_relaxed)((ATOMIC_LONG_PFX(_t) *)(v), (c))
|
2017-10-12 19:20:48 +07:00
|
|
|
#define atomic_long_cond_read_acquire(v, c) \
|
|
|
|
ATOMIC_LONG_PFX(_cond_read_acquire)((ATOMIC_LONG_PFX(_t) *)(v), (c))
|
|
|
|
|
2009-05-14 05:56:29 +07:00
|
|
|
#endif /* _ASM_GENERIC_ATOMIC_LONG_H */
|