MCS Lock: MCS lock code cleanup and optimizations
Subsystems (20)
A message that is not in the archive (sent off-list or not yet received): [email protected]
v9 cover MCS Lock: MCS lock code cleanup and optimizations
This update to the patch series now make mcs_spin_lock and mcs_spin_unlock as inlined functions for better efficiency in the hot path. We order the files in the architecture of each Kbuild before we add mcs_spinlock.h for hooking in architecture specific arch_mcs_spin_{lock,unlock}_contended functions.
Peter, please review the last two patches and bless them with your signed-off if they look right.
This patch series fixes barriers of MCS lock and perform some optimizations. Proper passing of the mcs lock is now done with smp_load_acquire() in mcs_spin_lock() and smp_store_release() in mcs_spin_unlock. Note that this is not sufficient to form a full memory barrier across cpus on many architectures (except x86) for the mcs_unlock and mcs_lock pair. For code that needs a full memory barrier with mcs_unlock and mcs_lock pair, smp_mb__after_unlock_lock() should be used after mcs_lock.
Will also added hooks to allow for architecture specific implementation and optimization of the of the contended paths of lock and unlock of mcs_spin_lock and mcs_spin_unlock functions.
The original mcs lock code has potential leaks between critical sections, which was not a problem when MCS was embedded within the mutex but needs to be corrected when allowing the MCS lock to be used by itself for other locking purposes. The MCS lock code was previously embedded in the mutex.c and is now sepearted. This allows for easier reuse of MCS lock in other places like rwsem and qrwlock.
Tim
v9:
1. Inline mcs_spin_lock and mcs_spin_unlock for better efficiency in hot paths.
2. Sort files in each architecutre's Kbuild before adding mcs_spinlock.h.
v8:
1. Move order of patches by putting barrier corrections first.
2. Use generic-asm headers for hooking in arch specific mcs_spin_lock_contended and mcs_spin_lock_uncontended function.
3. Some minor cleanup and comments added.
v7:
1. Update architecture specific hooks with concise architecture specific arch_mcs_spin_lock_contended and arch_mcs_spin_lock_uncontended functions.
v6:
1. Fix a bug of improper xchg_acquire and extra space in barrier fixing patch.
2. Added extra hooks to allow for architecture specific version of mcs_spin_lock and mcs_spin_unlock to be used.
v5:
1. Rework barrier correction patch. We now use smp_load_acquire() in mcs_spin_lock() and smp_store_release() in mcs_spin_unlock() to allow for architecture dependent barriers to be automatically used. This is clean and will provide the right barriers for all architecture.
v4:
1. Move patch series to the latest tip after v3.12
v3:
1. modified memory barriers to support non x86 architectures that have weak memory ordering.
v2:
1. change export mcs_spin_lock as a GPL export symbol
2. corrected mcs_spin_lock to references
Jason Low (1):
MCS Lock: Optimizations and extra comments
Peter Zijlstra (2):
MCS Lock: Order the header files in Kbuild of each architecture in
alphabetical order
MCS Lock: Allow architecture specific asm files to be used for
contended case
Tim Chen (1):
MCS Lock: Restructure the MCS lock defines and locking code into its
own file
Waiman Long (1):
MCS Lock: Barrier corrections
Will Deacon (1):
MCS Lock: Allow architectures to hook in to contended paths
arch/alpha/include/asm/Kbuild | 5 +- arch/arc/include/asm/Kbuild | 7 ++- arch/arm/include/asm/Kbuild | 3 +- arch/arm64/include/asm/Kbuild | 5 +- arch/avr32/include/asm/Kbuild | 39 ++++++------- arch/blackfin/include/asm/Kbuild | 5 +- arch/c6x/include/asm/Kbuild | 3 +- arch/cris/include/asm/Kbuild | 3 +- arch/frv/include/asm/Kbuild | 3 +- arch/hexagon/include/asm/Kbuild | 7 ++- arch/ia64/include/asm/Kbuild | 5 +- arch/m32r/include/asm/Kbuild | 3 +- arch/m68k/include/asm/Kbuild | 5 +- arch/metag/include/asm/Kbuild | 3 +- arch/microblaze/include/asm/Kbuild | 5 +- arch/mips/include/asm/Kbuild | 3 +- arch/mn10300/include/asm/Kbuild | 3 +- arch/openrisc/include/asm/Kbuild | 9 +-- arch/parisc/include/asm/Kbuild | 27 +++++++-- arch/powerpc/include/asm/Kbuild | 6 +- arch/s390/include/asm/Kbuild | 3 +- arch/score/include/asm/Kbuild | 3 +- arch/sh/include/asm/Kbuild | 7 ++- arch/sparc/include/asm/Kbuild | 9 +-- arch/tile/include/asm/Kbuild | 3 +- arch/um/include/asm/Kbuild | 30 ++++++++-- arch/unicore32/include/asm/Kbuild | 3 +- arch/x86/include/asm/Kbuild | 1 + arch/xtensa/include/asm/Kbuild | 3 +- include/asm-generic/mcs_spinlock.h | 13 +++++ include/linux/mcs_spinlock.h | 114 +++++++++++++++++++++++++++++++++++++ include/linux/mutex.h | 5 +- kernel/locking/mutex.c | 60 +++---------------- 33 files changed, 275 insertions(+), 128 deletions(-) create mode 100644 include/asm-generic/mcs_spinlock.h create mode 100644 include/linux/mcs_spinlock.h
Signature · 8 lines
1.7.11.7 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v9 1/6 MCS Lock: Barrier corrections
In reply to a message not in the archiveFrom: Waiman Long <[email protected]>
This patch corrects the way memory barriers are used in the MCS lock with smp_load_acquire and smp_store_release fucnctions. The previous barriers could leak critical sections if mcs lock is used by itself. It is not a problem when mcs lock is embedded in mutex but will be an issue when the mcs_lock is used elsewhere.
The patch removes the incorrect barriers and put in correct barriers with the pair of functions smp_load_acquire and smp_store_release.
--- kernel/locking/mutex.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
kernel/locking/mutex.c +13 -5
@@ -136,9 +136,12 @@ void mspin_lock(struct mspin_node **lock, struct mspin_node *node)return ; }ACCESS_ONCE (prev->next) = node; -smp_wmb (); -/* Wait until the lock holder passes the lock down */ -while (!ACCESS_ONCE (node->locked)) +/* +* Wait until the lock holder passes the lock down. +* Using smp_load_acquire() provides a memory barrier that +* ensures subsequent operations happen after the lock is acquired. +*/ +while (!(smp_load_acquire (&node->locked)))arch_mutex_cpu_relax (); }
@@ -156,8 +159,13 @@ static void mspin_unlock(struct mspin_node **lock, struct mspin_node *node)while (!(next =ACCESS_ONCE (node->next)))arch_mutex_cpu_relax (); } -ACCESS_ONCE (next->locked) =1 ; -smp_wmb (); +/* +* Pass lock to next waiter. +* smp_store_release() provides a memory barrier to ensure +* all operations in the critical section has been completed +* before unlocking. +*/ +smp_store_release (&next->locked,1 ); }/*
Signature · 9 lines
1.7.11.7 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH v9 1/6] MCS Lock: Barrier corrections
Quoted 11 lines · Tim Chen
From: Waiman Long <[email protected]>
This patch corrects the way memory barriers are used in the MCS lock with
smp_load_acquireandsmp_store_releasefucnctions. The previous barriers could leak critical sections if mcs lock is used by itself. It is not a problem when mcs lock is embedded in mutex but will be an issue when themcs_lockis used elsewhere.The patch removes the incorrect barriers and put in correct barriers with the pair of functions
smp_load_acquireandsmp_store_release.
Quoted 8 lines
Suggested-by Michel Lespinasse <[email protected]>Reviewed-by Paul E. McKenney <[email protected]>Signed-off-by Waiman Long <[email protected]>Signed-off-by Jason Low <[email protected]>Signed-off-by Tim Chen <[email protected]>--- kernel/locking/mutex.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
Will
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
tip-bot for Waiman Long
merge bot[tip:core/locking] locking/mutexes/mcs: Correct barrier usage
In reply to Tim Chenlocking/mutexes/mcs: Correct barrier usage
Commit-ID: aff7385b5a16bca6b8d9243f01a9ea5a5b411e1d Gitweb: http://git.kernel.org/tip/aff7385b5a16bca6b8d9243f01a9ea5a5b411e1d Author: Waiman Long <[email protected]> AuthorDate: Tue, 21 Jan 2014 15:35:53 -0800 Committer: Ingo Molnar <[email protected]> CommitDate: Tue, 28 Jan 2014 13:13:26 +0100
locking/mutexes/mcs: Correct barrier usage
This patch corrects the way memory barriers are used in the MCS lock with smp_load_acquire and smp_store_release fucnctions. The previous barriers could leak critical sections if mcs lock is used by itself. It is not a problem when mcs lock is embedded in mutex but will be an issue when the mcs_lock is used elsewhere.
The patch removes the incorrect barriers and put in correct barriers with the pair of functions smp_load_acquire and smp_store_release.
--- kernel/locking/mutex.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
kernel/locking/mutex.c +13 -5
@@ -136,9 +136,12 @@ void mspin_lock(struct mspin_node **lock, struct mspin_node *node)return ; }ACCESS_ONCE (prev->next) = node; -smp_wmb (); -/* Wait until the lock holder passes the lock down */ -while (!ACCESS_ONCE (node->locked)) +/* +* Wait until the lock holder passes the lock down. +* Using smp_load_acquire() provides a memory barrier that +* ensures subsequent operations happen after the lock is acquired. +*/ +while (!(smp_load_acquire (&node->locked)))arch_mutex_cpu_relax (); }
@@ -156,8 +159,13 @@ static void mspin_unlock(struct mspin_node **lock, struct mspin_node *node)while (!(next =ACCESS_ONCE (node->next)))arch_mutex_cpu_relax (); } -ACCESS_ONCE (next->locked) =1 ; -smp_wmb (); +/* +* Pass lock to next waiter. +* smp_store_release() provides a memory barrier to ensure +* all operations in the critical section has been completed +* before unlocking. +*/ +smp_store_release (&next->locked,1 ); }/*
PATCH v9 2/6 MCS Lock: Restructure the MCS lock defines and locking code into its own file
In reply to a message not in the archiveWe will need the MCS lock code for doing optimistic spinning for rwsem and queued rwlock. Extracting the MCS code from mutex.c and put into its own file allow us to reuse this code easily.
We also inline mcs_spin_lock and mcs_spin_unlock functions for better efficiency.
Note that using the smp_load_acquire/smp_store_release pair used in mcs_lock and mcs_unlock is not sufficient to form a full memory barrier across cpus for many architectures (except x86). For applications that absolutely need a full barrier across multiple cpus with mcs_unlock and mcs_lock pair, smp_mb__after_unlock_lock() should be used after mcs_lock.
--- include/linux/mcs_spinlock.h | 77 ++++++++++++++++++++++++++++++++++++++++++++ include/linux/mutex.h | 5 +-- kernel/locking/mutex.c | 68 ++++---------------------------------- 3 files changed, 87 insertions(+), 63 deletions(-) create mode 100644 include/linux/mcs_spinlock.h
include/linux/mcs_spinlock.h new file +77 -0
@@ -0,0 +1,77 @@ +/* +* MCS lock defines +* +* This file contains the main data structure and API definitions of MCS lock. +* +* The MCS lock (proposed by Mellor-Crummey and Scott) is a simple spin-lock +* with the desirable properties of being fair, and with each cpu trying +* to acquire the lock spinning on a local variable. +* It avoids expensive cache bouncings that common test-and-set spin-lock +* implementations incur. +*/ +#ifndef __LINUX_MCS_SPINLOCK_H +#define __LINUX_MCS_SPINLOCK_H + +struct mcs_spinlock { +struct mcs_spinlock *next; +int locked;/* 1 if lock acquired */ +}; + +/* +* Note: the smp_load_acquire/smp_store_release pair is not +* sufficient to form a full memory barrier across +* cpus for many architectures (except x86) for mcs_unlock and mcs_lock. +* For applications that need a full barrier across multiple cpus +* with mcs_unlock and mcs_lock pair, smp_mb__after_unlock_lock() should be +* used after mcs_lock. +*/ +static inline +void mcs_spin_lock (struct mcs_spinlock **lock,struct mcs_spinlock *node) +{ +struct mcs_spinlock *prev; + +/* Init node */ + node->locked =0 ; + node->next =NULL ; + + prev =xchg (lock, node); +if (likely (prev ==NULL )) { +/* Lock acquired */ + node->locked =1 ; +return ; + } +ACCESS_ONCE (prev->next) = node; +/* +* Wait until the lock holder passes the lock down. +* Using smp_load_acquire() provides a memory barrier that +* ensures subsequent operations happen after the lock is acquired. +*/ +while (!(smp_load_acquire (&node->locked))) +arch_mutex_cpu_relax (); +} + +static inline +void mcs_spin_unlock (struct mcs_spinlock **lock,struct mcs_spinlock *node) +{ +struct mcs_spinlock *next =ACCESS_ONCE (node->next); + +if (likely (!next)) { +/* +* Release the lock by setting it to NULL +*/ +if (cmpxchg (lock, node,NULL ) == node) +return ; +/* Wait until the next pointer is set */ +while (!(next =ACCESS_ONCE (node->next))) +arch_mutex_cpu_relax (); + } +/* +* Pass lock to next waiter. +* smp_store_release() provides a memory barrier to ensure +* all operations in the critical section has been completed +* before unlocking. +*/ +smp_store_release (&next->locked,1 ); +} + +#endif /* __LINUX_MCS_SPINLOCK_H */
include/linux/mutex.h +3 -2
@@ -46,6 +46,7 @@* - detects multi-task circular deadlocks and prints out all affected * locks and tasks (and only those tasks) */ +struct mcs_spinlock ;struct mutex {/* 1: unlocked, 0: locked, negative: locked, possible waiters */ atomic_t count;
@@ -55,7 +56,7 @@ struct mutex {struct task_struct *owner;#endif #ifdef CONFIG_MUTEX_SPIN_ON_OWNER -void *spin_mlock;/* Spinner MCS lock */ +struct mcs_spinlock *mcs_lock;/* Spinner MCS lock */ #endif #ifdef CONFIG_DEBUG_MUTEXES const char *name;
@@ -179,4 +180,4 @@ extern int atomic_dec_and_mutex_lock(atomic_t *cnt, struct mutex *lock);# define arch_mutex_cpu_relax () cpu_relax()#endif -#endif +#endif /* __LINUX_MUTEX_H */
kernel/locking/mutex.c +7 -61
110 lines not on this page · raw message
Signature · 9 lines
1.7.11.7 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
tip-bot for Tim Chen
merge bot[tip:core/locking] locking/mutexes/mcs: Restructure the MCS lock defines and locking code into its own file
locking/mutexes/mcs: Restructure the MCS lock defines and locking code into its own file
Commit-ID: e72246748ff006ab928bc774e276e6ef5542f9c5 Gitweb: http://git.kernel.org/tip/e72246748ff006ab928bc774e276e6ef5542f9c5 Author: Tim Chen <[email protected]> AuthorDate: Tue, 21 Jan 2014 15:36:00 -0800 Committer: Ingo Molnar <[email protected]> CommitDate: Tue, 28 Jan 2014 13:13:27 +0100
locking/mutexes/mcs: Restructure the MCS lock defines and locking code into its own file
We will need the MCS lock code for doing optimistic spinning for rwsem and queued rwlock. Extracting the MCS code from mutex.c and put into its own file allow us to reuse this code easily.
We also inline mcs_spin_lock and mcs_spin_unlock functions for better efficiency.
Note that using the smp_load_acquire/smp_store_release pair used in mcs_lock and mcs_unlock is not sufficient to form a full memory barrier across cpus for many architectures (except x86). For applications that absolutely need a full barrier across multiple cpus with mcs_unlock and mcs_lock pair, smp_mb__after_unlock_lock() should be used after mcs_lock.
--- include/linux/mcs_spinlock.h | 77 ++++++++++++++++++++++++++++++++++++++++++++ include/linux/mutex.h | 5 +-- kernel/locking/mutex.c | 68 ++++---------------------------------- 3 files changed, 87 insertions(+), 63 deletions(-)
include/linux/mcs_spinlock.h new file +77 -0
@@ -0,0 +1,77 @@ +/* +* MCS lock defines +* +* This file contains the main data structure and API definitions of MCS lock. +* +* The MCS lock (proposed by Mellor-Crummey and Scott) is a simple spin-lock +* with the desirable properties of being fair, and with each cpu trying +* to acquire the lock spinning on a local variable. +* It avoids expensive cache bouncings that common test-and-set spin-lock +* implementations incur. +*/ +#ifndef __LINUX_MCS_SPINLOCK_H +#define __LINUX_MCS_SPINLOCK_H + +struct mcs_spinlock { +struct mcs_spinlock *next; +int locked;/* 1 if lock acquired */ +}; + +/* +* Note: the smp_load_acquire/smp_store_release pair is not +* sufficient to form a full memory barrier across +* cpus for many architectures (except x86) for mcs_unlock and mcs_lock. +* For applications that need a full barrier across multiple cpus +* with mcs_unlock and mcs_lock pair, smp_mb__after_unlock_lock() should be +* used after mcs_lock. +*/ +static inline +void mcs_spin_lock (struct mcs_spinlock **lock,struct mcs_spinlock *node) +{ +struct mcs_spinlock *prev; + +/* Init node */ + node->locked =0 ; + node->next =NULL ; + + prev =xchg (lock, node); +if (likely (prev ==NULL )) { +/* Lock acquired */ + node->locked =1 ; +return ; + } +ACCESS_ONCE (prev->next) = node; +/* +* Wait until the lock holder passes the lock down. +* Using smp_load_acquire() provides a memory barrier that +* ensures subsequent operations happen after the lock is acquired. +*/ +while (!(smp_load_acquire (&node->locked))) +arch_mutex_cpu_relax (); +} + +static inline +void mcs_spin_unlock (struct mcs_spinlock **lock,struct mcs_spinlock *node) +{ +struct mcs_spinlock *next =ACCESS_ONCE (node->next); + +if (likely (!next)) { +/* +* Release the lock by setting it to NULL +*/ +if (cmpxchg (lock, node,NULL ) == node) +return ; +/* Wait until the next pointer is set */ +while (!(next =ACCESS_ONCE (node->next))) +arch_mutex_cpu_relax (); + } +/* +* Pass lock to next waiter. +* smp_store_release() provides a memory barrier to ensure +* all operations in the critical section has been completed +* before unlocking. +*/ +smp_store_release (&next->locked,1 ); +} + +#endif /* __LINUX_MCS_SPINLOCK_H */
include/linux/mutex.h +3 -2
@@ -46,6 +46,7 @@* - detects multi-task circular deadlocks and prints out all affected * locks and tasks (and only those tasks) */ +struct mcs_spinlock ;struct mutex {/* 1: unlocked, 0: locked, negative: locked, possible waiters */ atomic_t count;
@@ -55,7 +56,7 @@ struct mutex {struct task_struct *owner;#endif #ifdef CONFIG_MUTEX_SPIN_ON_OWNER -void *spin_mlock;/* Spinner MCS lock */ +struct mcs_spinlock *mcs_lock;/* Spinner MCS lock */ #endif #ifdef CONFIG_DEBUG_MUTEXES const char *name;
@@ -179,4 +180,4 @@ extern int atomic_dec_and_mutex_lock(atomic_t *cnt, struct mutex *lock);# define arch_mutex_cpu_relax () cpu_relax()#endif -#endif +#endif /* __LINUX_MUTEX_H */
kernel/locking/mutex.c +7 -61
110 lines not on this page · raw message
PATCH v9 3/6 MCS Lock: Optimizations and extra comments
In reply to a message not in the archiveFrom: Jason Low <[email protected]>
Remove unnecessary operation to assign locked status to 1 if lock is acquired without contention. Lock status will not be checked by lock holder again once it is acquired and any lock
contenders will not be looking at the lock holder's lock status.
Make the cmpxchg(lock, node, NULL) == node check in mcs_spin_unlock() likely() as it is likely that a race did not occur most of the time.
Also add in more comments describing how the local node is used in MCS locks.
--- include/linux/mcs_spinlock.h | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-)
include/linux/mcs_spinlock.h +24 -3
@@ -25,6 +25,17 @@ struct mcs_spinlock {* with mcs_unlock and mcs_lock pair, smp_mb__after_unlock_lock() should be * used after mcs_lock. */ + +/* +* In order to acquire the lock, the caller should declare a local node and +* pass a reference of the node to this function in addition to the lock. +* If the lock has already been acquired, then this will proceed to spin +* on this node->locked until the previous lock holder sets the node->locked +* in mcs_spin_unlock(). +* +* We don't inline mcs_spin_lock() so that perf can correctly account for the +* time spent in this lock function. +*/ static inline void mcs_spin_lock (struct mcs_spinlock **lock,struct mcs_spinlock *node) {
@@ -36,8 +47,14 @@ void mcs_spin_lock(struct mcs_spinlock **lock, struct mcs_spinlock *node) prev =xchg (lock, node);if (likely (prev ==NULL )) { -/* Lock acquired */ - node->locked =1 ; +/* +* Lock acquired, don't need to set node->locked to 1. Threads +* only spin on its own node->locked value for lock acquisition. +* However, since this thread can immediately acquire the lock +* and does not proceed to spin on its own node->locked, this +* value won't be used. If a debug mode is needed to +* audit lock status, then set node->locked value here. +*/ return ; }ACCESS_ONCE (prev->next) = node;
@@ -50,6 +67,10 @@ void mcs_spin_lock(struct mcs_spinlock **lock, struct mcs_spinlock *node)arch_mutex_cpu_relax (); } +/* +* Releases the lock. The caller should pass in the corresponding node that +* was used to acquire the lock. +*/ static inline void mcs_spin_unlock (struct mcs_spinlock **lock,struct mcs_spinlock *node) {
@@ -59,7 +80,7 @@ void mcs_spin_unlock(struct mcs_spinlock **lock, struct mcs_spinlock *node)/* * Release the lock by setting it to NULL */ -if (cmpxchg (lock, node,NULL ) == node) +if (likely (cmpxchg (lock, node,NULL ) == node))return ;/* Wait until the next pointer is set */ while (!(next =ACCESS_ONCE (node->next)))
Signature · 9 lines
1.7.11.7 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
tip-bot for Jason Low
merge bot[tip:core/locking] locking/mcs: Micro-optimize the MCS code, add extra comments
locking/mcs: Micro-optimize the MCS code, add extra comments
Commit-ID: 5faeb8adb956a5ad6579c4e309e8689943ad8294 Gitweb: http://git.kernel.org/tip/5faeb8adb956a5ad6579c4e309e8689943ad8294 Author: Jason Low <[email protected]> AuthorDate: Tue, 21 Jan 2014 15:36:05 -0800 Committer: Ingo Molnar <[email protected]> CommitDate: Tue, 28 Jan 2014 13:13:28 +0100
locking/mcs: Micro-optimize the MCS code, add extra comments
Remove unnecessary operation to assign locked status to 1 if lock is acquired without contention. Lock status will not be checked by lock holder again once it is acquired and any lock
contenders will not be looking at the lock holder's lock status.
Make the cmpxchg(lock, node, NULL) == node check in mcs_spin_unlock() likely() as it is likely that a race did not occur most of the time.
Also add in more comments describing how the local node is used in MCS locks.
--- include/linux/mcs_spinlock.h | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-)
include/linux/mcs_spinlock.h +24 -3
@@ -25,6 +25,17 @@ struct mcs_spinlock {* with mcs_unlock and mcs_lock pair, smp_mb__after_unlock_lock() should be * used after mcs_lock. */ + +/* +* In order to acquire the lock, the caller should declare a local node and +* pass a reference of the node to this function in addition to the lock. +* If the lock has already been acquired, then this will proceed to spin +* on this node->locked until the previous lock holder sets the node->locked +* in mcs_spin_unlock(). +* +* We don't inline mcs_spin_lock() so that perf can correctly account for the +* time spent in this lock function. +*/ static inline void mcs_spin_lock (struct mcs_spinlock **lock,struct mcs_spinlock *node) {
@@ -36,8 +47,14 @@ void mcs_spin_lock(struct mcs_spinlock **lock, struct mcs_spinlock *node) prev =xchg (lock, node);if (likely (prev ==NULL )) { -/* Lock acquired */ - node->locked =1 ; +/* +* Lock acquired, don't need to set node->locked to 1. Threads +* only spin on its own node->locked value for lock acquisition. +* However, since this thread can immediately acquire the lock +* and does not proceed to spin on its own node->locked, this +* value won't be used. If a debug mode is needed to +* audit lock status, then set node->locked value here. +*/ return ; }ACCESS_ONCE (prev->next) = node;
@@ -50,6 +67,10 @@ void mcs_spin_lock(struct mcs_spinlock **lock, struct mcs_spinlock *node)arch_mutex_cpu_relax (); } +/* +* Releases the lock. The caller should pass in the corresponding node that +* was used to acquire the lock. +*/ static inline void mcs_spin_unlock (struct mcs_spinlock **lock,struct mcs_spinlock *node) {
@@ -59,7 +80,7 @@ void mcs_spin_unlock(struct mcs_spinlock **lock, struct mcs_spinlock *node)/* * Release the lock by setting it to NULL */ -if (cmpxchg (lock, node,NULL ) == node) +if (likely (cmpxchg (lock, node,NULL ) == node))return ;/* Wait until the next pointer is set */ while (!(next =ACCESS_ONCE (node->next)))
PATCH v9 4/6 MCS Lock: Allow architectures to hook in to contended paths
In reply to a message not in the archiveFrom: Will Deacon <[email protected]
When contended, architectures may be able to reduce the polling overhead in ways which aren't expressible using a simple relax() primitive.
This patch allows architectures to hook into the mcs_{lock,unlock} functions for the contended cases only.
--- include/linux/mcs_spinlock.h | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-)
include/linux/mcs_spinlock.h +28 -14
@@ -17,6 +17,28 @@ struct mcs_spinlock {int locked;/* 1 if lock acquired */ }; +#ifndef arch_mcs_spin_lock_contended +/* +* Using smp_load_acquire() provides a memory barrier that ensures +* subsequent operations happen after the lock is acquired. +*/ +#define arch_mcs_spin_lock_contended (l) \ +do { \ + while (!(smp_load_acquire(l))) \ + arch_mutex_cpu_relax(); \ +} while (0) +#endif + +#ifndef arch_mcs_spin_unlock_contended +/* +* smp_store_release() provides a memory barrier to ensure all +* operations in the critical section has been completed before +* unlocking. +*/ +#define arch_mcs_spin_unlock_contended (l) \ + smp_store_release((l), 1) +#endif +/* * Note: the smp_load_acquire/smp_store_release pair is not * sufficient to form a full memory barrier across
@@ -58,13 +80,9 @@ void mcs_spin_lock(struct mcs_spinlock **lock, struct mcs_spinlock *node)return ; }ACCESS_ONCE (prev->next) = node; -/* -* Wait until the lock holder passes the lock down. -* Using smp_load_acquire() provides a memory barrier that -* ensures subsequent operations happen after the lock is acquired. -*/ -while (!(smp_load_acquire (&node->locked))) -arch_mutex_cpu_relax (); + +/* Wait until the lock holder passes the lock down. */ +arch_mcs_spin_lock_contended (&node->locked); }/*
@@ -86,13 +104,9 @@ void mcs_spin_unlock(struct mcs_spinlock **lock, struct mcs_spinlock *node)while (!(next =ACCESS_ONCE (node->next))) arch_mutex_cpu_relax(); } -/* -* Pass lock to next waiter. -* smp_store_release() provides a memory barrier to ensure -* all operations in the critical section has been completed -* before unlocking. -*/ -smp_store_release (&next->locked,1 ); + +/* Pass lock to next waiter. */ +arch_mcs_spin_unlock_contended (&next->locked); }#endif /* __LINUX_MCS_SPINLOCK_H */
Signature · 9 lines
1.7.11.7 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
tip-bot for Will Deacon
merge bot[tip:core/locking] locking/mcs: Allow architectures to hook in to contended paths
locking/mcs: Allow architectures to hook in to contended paths
Commit-ID: e207552e64ea053a33e856828ad7915484911d06 Gitweb: http://git.kernel.org/tip/e207552e64ea053a33e856828ad7915484911d06 Author: Will Deacon <[email protected]> AuthorDate: Tue, 21 Jan 2014 15:36:10 -0800 Committer: Ingo Molnar <[email protected]> CommitDate: Tue, 28 Jan 2014 13:13:28 +0100
locking/mcs: Allow architectures to hook in to contended paths
When contended, architectures may be able to reduce the polling overhead in ways which aren't expressible using a simple relax() primitive.
This patch allows architectures to hook into the mcs_{lock,unlock} functions for the contended cases only.
--- include/linux/mcs_spinlock.h | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-)
include/linux/mcs_spinlock.h +28 -14
@@ -17,6 +17,28 @@ struct mcs_spinlock {int locked;/* 1 if lock acquired */ }; +#ifndef arch_mcs_spin_lock_contended +/* +* Using smp_load_acquire() provides a memory barrier that ensures +* subsequent operations happen after the lock is acquired. +*/ +#define arch_mcs_spin_lock_contended (l) \ +do { \ + while (!(smp_load_acquire(l))) \ + arch_mutex_cpu_relax(); \ +} while (0) +#endif + +#ifndef arch_mcs_spin_unlock_contended +/* +* smp_store_release() provides a memory barrier to ensure all +* operations in the critical section has been completed before +* unlocking. +*/ +#define arch_mcs_spin_unlock_contended (l) \ + smp_store_release((l), 1) +#endif +/* * Note: the smp_load_acquire/smp_store_release pair is not * sufficient to form a full memory barrier across
@@ -58,13 +80,9 @@ void mcs_spin_lock(struct mcs_spinlock **lock, struct mcs_spinlock *node)return ; }ACCESS_ONCE (prev->next) = node; -/* -* Wait until the lock holder passes the lock down. -* Using smp_load_acquire() provides a memory barrier that -* ensures subsequent operations happen after the lock is acquired. -*/ -while (!(smp_load_acquire (&node->locked))) -arch_mutex_cpu_relax (); + +/* Wait until the lock holder passes the lock down. */ +arch_mcs_spin_lock_contended (&node->locked); }/*
@@ -86,13 +104,9 @@ void mcs_spin_unlock(struct mcs_spinlock **lock, struct mcs_spinlock *node)while (!(next =ACCESS_ONCE (node->next))) arch_mutex_cpu_relax(); } -/* -* Pass lock to next waiter. -* smp_store_release() provides a memory barrier to ensure -* all operations in the critical section has been completed -* before unlocking. -*/ -smp_store_release (&next->locked,1 ); + +/* Pass lock to next waiter. */ +arch_mcs_spin_unlock_contended (&next->locked); }#endif /* __LINUX_MCS_SPINLOCK_H */
PATCH v9 5/6 MCS Lock: Order the header files in Kbuild of each architecture in alphabetical order
In reply to a message not in the archiveFrom: Peter Zijlstra <[email protected]>
We perform a clean up of the Kbuid files in each architecture. We order the files in each Kbuild in alphabetical order by running the below script on each Kbuild file:
gawk '/^generic-y/ {
i = 3;
do {
for (; i<=NF; i++) {
if ($i == "\\") {
getline;
i=1;
continue;
}
if ($i != "")
hdr[$i] = $i;
}
break;
} while (1);
next;
}
END {
n = asort(hdr);
for (i=1; i<=n; i++)
print "generic-y += " hdr[i];
}'--- arch/alpha/include/asm/Kbuild | 4 ++-- arch/arc/include/asm/Kbuild | 6 +++--- arch/arm/include/asm/Kbuild | 2 +- arch/arm64/include/asm/Kbuild | 4 ++-- arch/avr32/include/asm/Kbuild | 38 +++++++++++++++++++------------------- arch/blackfin/include/asm/Kbuild | 4 ++-- arch/c6x/include/asm/Kbuild | 2 +- arch/cris/include/asm/Kbuild | 2 +- arch/frv/include/asm/Kbuild | 2 +- arch/hexagon/include/asm/Kbuild | 6 +++--- arch/ia64/include/asm/Kbuild | 4 ++-- arch/m32r/include/asm/Kbuild | 2 +- arch/m68k/include/asm/Kbuild | 4 ++-- arch/metag/include/asm/Kbuild | 2 +- arch/microblaze/include/asm/Kbuild | 4 ++-- arch/mips/include/asm/Kbuild | 2 +- arch/mn10300/include/asm/Kbuild | 2 +- arch/openrisc/include/asm/Kbuild | 8 ++++---- arch/parisc/include/asm/Kbuild | 26 +++++++++++++++++++++----- arch/powerpc/include/asm/Kbuild | 4 ++-- arch/s390/include/asm/Kbuild | 2 +- arch/score/include/asm/Kbuild | 2 +- arch/sh/include/asm/Kbuild | 6 +++--- arch/sparc/include/asm/Kbuild | 8 ++++---- arch/tile/include/asm/Kbuild | 2 +- arch/um/include/asm/Kbuild | 29 ++++++++++++++++++++++++----- arch/unicore32/include/asm/Kbuild | 2 +- arch/xtensa/include/asm/Kbuild | 2 +- 28 files changed, 108 insertions(+), 73 deletions(-)
arch/alpha/include/asm/Kbuild +2 -2
@@ -1,6 +1,6 @@ -generic-y += clkdev.h +generic-y += clkdev.h generic-y += exec.h -generic-y += trace_clock.h generic-y += preempt.h +generic-y += trace_clock.h
arch/arc/include/asm/Kbuild +3 -3
@@ -1,15 +1,15 @@ generic-y += auxvec.h generic-y += barrier.h -generic-y += bugs.h generic-y += bitsperlong.h +generic-y += bugs.h generic-y += clkdev.h generic-y += cputime.h generic-y += device.h generic-y += div64.h generic-y += emergency-restart.h generic-y += errno.h -generic-y += fcntl.h generic-y += fb.h +generic-y += fcntl.h generic-y += ftrace.h generic-y += hardirq.h generic-y += hw_irq.h
@@ -29,6 +29,7 @@ generic-y += pci.h generic-y += percpu.h generic-y += poll.h generic-y += posix_types.h +generic-y += preempt.h generic-y += resource.h generic-y += scatterlist.h generic-y += sembuf.h
@@ -47,4 +48,3 @@ generic-y += ucontext.h generic-y += user.h generic-y += vga.h generic-y += xor.h -generic-y += preempt.h
arch/arm/include/asm/Kbuild +1 -1
@@ -17,6 +17,7 @@ generic-y += msgbuf.h generic-y += param.h generic-y += parport.h generic-y += poll.h +generic-y += preempt.h generic-y += resource.h generic-y += sections.h generic-y += segment.h
@@ -33,4 +34,3 @@ generic-y += termios.h generic-y += timex.h generic-y += trace_clock.h generic-y += unaligned.h -generic-y += preempt.h
arch/arm64/include/asm/Kbuild +2 -2
@@ -29,6 +29,7 @@ generic-y += pci.h generic-y += percpu.h generic-y += poll.h generic-y += posix_types.h +generic-y += preempt.h generic-y += resource.h generic-y += scatterlist.h generic-y += sections.h
@@ -39,8 +40,8 @@ generic-y += shmbuf.h generic-y += sizes.h generic-y += socket.h generic-y += sockios.h -generic-y += switch_to.h generic-y += swab.h +generic-y += switch_to.h generic-y += termbits.h generic-y += termios.h generic-y += topology.h
@@ -50,4 +51,3 @@ generic-y += unaligned.h generic-y += user.h generic-y += vga.h generic-y += xor.h -generic-y += preempt.h
arch/avr32/include/asm/Kbuild +19 -19
@@ -1,20 +1,20 @@ -generic-y += clkdev.h -generic-y += cputime.h -generic-y += delay.h -generic-y += device.h -generic-y += div64.h -generic-y += emergency-restart.h -generic-y += exec.h -generic-y += futex.h -generic-y += preempt.h -generic-y += irq_regs.h -generic-y += param.h -generic-y += local.h -generic-y += local64.h -generic-y += percpu.h -generic-y += scatterlist.h -generic-y += sections.h -generic-y += topology.h -generic-y += trace_clock.h -generic-y += xor.h +generic-y += clkdev.h +generic-y += cputime.h +generic-y += delay.h +generic-y += device.h +generic-y += div64.h +generic-y += emergency-restart.h +generic-y += exec.h +generic-y += futex.h +generic-y += irq_regs.h +generic-y += local.h +generic-y += local64.h +generic-y += param.h +generic-y += percpu.h +generic-y += preempt.h +generic-y += scatterlist.h +generic-y += sections.h +generic-y += topology.h +generic-y += trace_clock.h +generic-y += xor.h
arch/blackfin/include/asm/Kbuild +2 -2
@@ -17,14 +17,15 @@ generic-y += irq_regs.h generic-y += kdebug.h generic-y += kmap_types.h generic-y += kvm_para.h -generic-y += local64.h generic-y += local.h +generic-y += local64.h generic-y += mman.h generic-y += msgbuf.h generic-y += mutex.h generic-y += param.h generic-y += percpu.h generic-y += pgalloc.h +generic-y += preempt.h generic-y += resource.h generic-y += scatterlist.h generic-y += sembuf.h
@@ -44,4 +45,3 @@ generic-y += ucontext.h generic-y += unaligned.h generic-y += user.h generic-y += xor.h -generic-y += preempt.h
arch/c6x/include/asm/Kbuild +1 -1
@@ -34,6 +34,7 @@ generic-y += percpu.h generic-y += pgalloc.h generic-y += poll.h generic-y += posix_types.h +generic-y += preempt.h generic-y += resource.h generic-y += scatterlist.h generic-y += segment.h
@@ -56,4 +57,3 @@ generic-y += ucontext.h generic-y += user.h generic-y += vga.h generic-y += xor.h -generic-y += preempt.h
arch/cris/include/asm/Kbuild +1 -1
@@ -9,7 +9,7 @@ generic-y += exec.h generic-y += kvm_para.h generic-y += linkage.h generic-y += module.h +generic-y += preempt.h generic-y += trace_clock.h generic-y += vga.h generic-y += xor.h -generic-y += preempt.h
arch/frv/include/asm/Kbuild +1 -1
@@ -1,5 +1,5 @@ generic-y += clkdev.h generic-y += exec.h -generic-y += trace_clock.h generic-y += preempt.h +generic-y += trace_clock.h
arch/hexagon/include/asm/Kbuild +3 -3
@@ -24,14 +24,15 @@ generic-y += ipcbuf.h generic-y += irq_regs.h generic-y += kdebug.h generic-y += kmap_types.h -generic-y += local64.h generic-y += local.h +generic-y += local64.h generic-y += mman.h generic-y += msgbuf.h generic-y += pci.h generic-y += percpu.h generic-y += poll.h generic-y += posix_types.h +generic-y += preempt.h generic-y += resource.h generic-y += rwsem.h generic-y += scatterlist.h
@@ -44,8 +45,8 @@ generic-y += siginfo.h generic-y += sizes.h generic-y += socket.h generic-y += sockios.h -generic-y += statfs.h generic-y += stat.h +generic-y += statfs.h generic-y += termbits.h generic-y += termios.h generic-y += topology.h
@@ -54,4 +55,3 @@ generic-y += types.h generic-y += ucontext.h generic-y += unaligned.h generic-y += xor.h -generic-y += preempt.h
arch/ia64/include/asm/Kbuild +2 -2
@@ -2,6 +2,6 @@ generic-y += clkdev.h generic-y += exec.h generic-y += kvm_para.h -generic-y += trace_clock.h generic-y += preempt.h -generic-y += vtime.h +generic-y += trace_clock.h +generic-y += vtime.h
arch/m32r/include/asm/Kbuild +1 -1
@@ -2,5 +2,5 @@ generic-y += clkdev.h generic-y += exec.h generic-y += module.h -generic-y += trace_clock.h generic-y += preempt.h +generic-y += trace_clock.h
arch/m68k/include/asm/Kbuild +2 -2
@@ -13,11 +13,12 @@ generic-y += irq_regs.h generic-y += kdebug.h generic-y += kmap_types.h generic-y += kvm_para.h -generic-y += local64.h generic-y += local.h +generic-y += local64.h generic-y += mman.h generic-y += mutex.h generic-y += percpu.h +generic-y += preempt.h generic-y += resource.h generic-y += scatterlist.h generic-y += sections.h
@@ -31,4 +32,3 @@ generic-y += trace_clock.h generic-y += types.h generic-y += word-at-a-time.h generic-y += xor.h -generic-y += preempt.h
arch/metag/include/asm/Kbuild +1 -1
@@ -30,6 +30,7 @@ generic-y += pci.h generic-y += percpu.h generic-y += poll.h generic-y += posix_types.h +generic-y += preempt.h generic-y += scatterlist.h generic-y += sections.h generic-y += sembuf.h
@@ -52,4 +53,3 @@ generic-y += unaligned.h generic-y += user.h generic-y += vga.h generic-y += xor.h -generic-y += preempt.h
arch/microblaze/include/asm/Kbuild +2 -2
@@ -2,6 +2,6 @@ generic-y += barrier.h generic-y += clkdev.h generic-y += exec.h -generic-y += trace_clock.h -generic-y += syscalls.h generic-y += preempt.h +generic-y += syscalls.h +generic-y += trace_clock.h
arch/mips/include/asm/Kbuild +1 -1
@@ -6,11 +6,11 @@ generic-y += local64.h generic-y += mutex.h generic-y += parport.h generic-y += percpu.h +generic-y += preempt.h generic-y += scatterlist.h generic-y += sections.h generic-y += segment.h generic-y += serial.h generic-y += trace_clock.h -generic-y += preempt.h generic-y += ucontext.h generic-y += xor.h
arch/mn10300/include/asm/Kbuild +1 -1
@@ -2,5 +2,5 @@ generic-y += barrier.h generic-y += clkdev.h generic-y += exec.h -generic-y += trace_clock.h generic-y += preempt.h +generic-y += trace_clock.h
arch/openrisc/include/asm/Kbuild +4 -4
@@ -10,8 +10,8 @@ generic-y += bugs.h generic-y += cacheflush.h generic-y += checksum.h generic-y += clkdev.h -generic-y += cmpxchg.h generic-y += cmpxchg-local.h +generic-y += cmpxchg.h generic-y += cputime.h generic-y += current.h generic-y += device.h
@@ -41,6 +41,7 @@ generic-y += pci.h generic-y += percpu.h generic-y += poll.h generic-y += posix_types.h +generic-y += preempt.h generic-y += resource.h generic-y += scatterlist.h generic-y += sections.h
@@ -53,11 +54,11 @@ generic-y += siginfo.h generic-y += signal.h generic-y += socket.h generic-y += sockios.h -generic-y += statfs.h generic-y += stat.h +generic-y += statfs.h generic-y += string.h -generic-y += switch_to.h generic-y += swab.h +generic-y += switch_to.h generic-y += termbits.h generic-y += termios.h generic-y += topology.h
@@ -68,4 +69,3 @@ generic-y += user.h generic-y += vga.h generic-y += word-at-a-time.h generic-y += xor.h -generic-y += preempt.h
arch/parisc/include/asm/Kbuild +21 -5
@@ -1,8 +1,24 @@ +generic-y += auxvec.h generic-y += barrier.h -generic-y += word-at-a-time.h auxvec.h user.h cputime.h emergency-restart.h \ - segment.h topology.h vga.h device.h percpu.h hw_irq.h mutex.h \ - div64.h irq_regs.h kdebug.h kvm_para.h local64.h local.h param.h \ - poll.h xor.h clkdev.h exec.h -generic-y += trace_clock.h +generic-y += clkdev.h +generic-y += cputime.h +generic-y += device.h +generic-y += emergency-restart.h +generic-y += exec.h +generic-y += hw_irq.h +generic-y += irq_regs.h +generic-y += kdebug.h +generic-y += kvm_para.h +generic-y += local.h +generic-y += local64.h +generic-y += mutex.h +generic-y += param.h +generic-y += percpu.h generic-y += preempt.h +generic-y += topology.h +generic-y += trace_clock.h +generic-y += user.h +generic-y += vga.h +generic-y += word-at-a-time.h +generic-y += xor.h
arch/powerpc/include/asm/Kbuild +2 -2
@@ -1,6 +1,6 @@ generic-y += clkdev.h +generic-y += preempt.h generic-y += rwsem.h generic-y += trace_clock.h -generic-y += preempt.h -generic-y += vtime.h +generic-y += vtime.h
arch/s390/include/asm/Kbuild +1 -1
@@ -1,5 +1,5 @@ generic-y += clkdev.h -generic-y += trace_clock.h generic-y += preempt.h +generic-y += trace_clock.h
arch/score/include/asm/Kbuild +1 -1
@@ -3,6 +3,6 @@ header-y += generic-y += barrier.h generic-y += clkdev.h +generic-y += preempt.h generic-y += trace_clock.h generic-y += xor.h -generic-y += preempt.h
arch/sh/include/asm/Kbuild +3 -3
@@ -14,12 +14,13 @@ generic-y += irq_regs.h generic-y += kvm_para.h generic-y += local.h generic-y += local64.h +generic-y += mman.h +generic-y += msgbuf.h generic-y += param.h generic-y += parport.h generic-y += percpu.h generic-y += poll.h -generic-y += mman.h -generic-y += msgbuf.h +generic-y += preempt.h generic-y += resource.h generic-y += scatterlist.h generic-y += sembuf.h
@@ -34,4 +35,3 @@ generic-y += termios.h generic-y += trace_clock.h generic-y += ucontext.h generic-y += xor.h -generic-y += preempt.h
arch/sparc/include/asm/Kbuild +4 -4
@@ -6,14 +6,14 @@ generic-y += cputime.h generic-y += div64.h generic-y += emergency-restart.h generic-y += exec.h -generic-y += linkage.h -generic-y += local64.h -generic-y += mutex.h generic-y += irq_regs.h +generic-y += linkage.h generic-y += local.h +generic-y += local64.h generic-y += module.h +generic-y += mutex.h +generic-y += preempt.h generic-y += serial.h generic-y += trace_clock.h generic-y += types.h generic-y += word-at-a-time.h -generic-y += preempt.h
arch/tile/include/asm/Kbuild +1 -1
@@ -24,6 +24,7 @@ generic-y += param.h generic-y += parport.h generic-y += poll.h generic-y += posix_types.h +generic-y += preempt.h generic-y += resource.h generic-y += scatterlist.h generic-y += sembuf.h
@@ -38,4 +39,3 @@ generic-y += termios.h generic-y += trace_clock.h generic-y += types.h generic-y += xor.h -generic-y += preempt.h
arch/um/include/asm/Kbuild +24 -5
@@ -1,6 +1,25 @@ -generic-y += bug.h cputime.h device.h emergency-restart.h futex.h hardirq.h -generic-y += hw_irq.h irq_regs.h kdebug.h percpu.h sections.h topology.h xor.h -generic-y += ftrace.h pci.h io.h param.h delay.h mutex.h current.h exec.h -generic-y += switch_to.h clkdev.h -generic-y += trace_clock.h +generic-y += bug.h +generic-y += clkdev.h +generic-y += cputime.h +generic-y += current.h +generic-y += delay.h +generic-y += device.h +generic-y += emergency-restart.h +generic-y += exec.h +generic-y += ftrace.h +generic-y += futex.h +generic-y += hardirq.h +generic-y += hw_irq.h +generic-y += io.h +generic-y += irq_regs.h +generic-y += kdebug.h +generic-y += mutex.h +generic-y += param.h +generic-y += pci.h +generic-y += percpu.h generic-y += preempt.h +generic-y += sections.h +generic-y += switch_to.h +generic-y += topology.h +generic-y += trace_clock.h +generic-y += xor.h
arch/unicore32/include/asm/Kbuild +1 -1
@@ -32,6 +32,7 @@ generic-y += parport.h generic-y += percpu.h generic-y += poll.h generic-y += posix_types.h +generic-y += preempt.h generic-y += resource.h generic-y += scatterlist.h generic-y += sections.h
@@ -60,4 +61,3 @@ generic-y += unaligned.h generic-y += user.h generic-y += vga.h generic-y += xor.h -generic-y += preempt.h
arch/xtensa/include/asm/Kbuild +1 -1
@@ -19,6 +19,7 @@ generic-y += linkage.h generic-y += local.h generic-y += local64.h generic-y += percpu.h +generic-y += preempt.h generic-y += resource.h generic-y += scatterlist.h generic-y += sections.h
@@ -28,4 +29,3 @@ generic-y += termios.h generic-y += topology.h generic-y += trace_clock.h generic-y += xor.h -generic-y += preempt.h
Signature · 9 lines
1.7.11.7 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Peter Zijlstra
maintainerRe: [PATCH v9 5/6] MCS Lock: Order the header files in Kbuild of each architecture in alphabetical order
Quoted 19 lines · Tim Chen
From: Peter Zijlstra <[email protected]>
We perform a clean up of the Kbuid files in each architecture. We order the files in each
Kbuildin alphabetical order by running the below script on eachKbuildfile:gawk '/^generic-y/ { i = 3; do { for (; i<=NF; i++) { if ($i == "\\") { getline; i=1; continue; } if ($i != "") hdr[$i] = $i; } break;
Quoted 9 lines
} while (1);
next;
}
END {
n = asort(hdr);
for (i=1; i<=n; i++)
print "generic-y += " hdr[i];
}'I'll probably have to regenerate this patch once the merge window is done, but that's no biggie.
sfr, you might want to keep this script handy and distribute to others who are lazy and don't want to sort by hand.
I suppose running it requires a little something like:
for i in arch/*/include/asm/Kbuild
do
cat $i | gawk .... > ${i}.sorted;
mv ${i}.sorted $i;done
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH v9 5/6] MCS Lock: Order the header files in Kbuild of each architecture in alphabetical order
Quoted 36 lines · Peter Zijlstra
Quoted 19 lines · Tim Chen
From: Peter Zijlstra <[email protected]>
We perform a clean up of the Kbuid files in each architecture. We order the files in each
Kbuildin alphabetical order by running the below script on eachKbuildfile:gawk '/^generic-y/ { i = 3; do { for (; i<=NF; i++) { if ($i == "\\") { getline; i=1; continue; } if ($i != "") hdr[$i] = $i; } break;Quoted 9 lines
} while (1); next; } END { n = asort(hdr); for (i=1; i<=n; i++) print "generic-y += " hdr[i]; }'I'll probably have to regenerate this patch once the merge window is done, but that's no biggie.
sfr, you might want to keep this script handy and distribute to others who are lazy and don't want to sort by hand.
Quoted 7 lines
I suppose running it requires a little something like:
for i in
arch/*/include/asm/Kbuild
docat $i | gawk .... > ${i}.sorted; mv ${i}.sorted $i;done
Peter, if this patch and the next one that adds mcs_spinlock.h to Kbuild looks okay, can you add your signed-off? Thanks.
Tim
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Peter Zijlstra
maintainerRe: [PATCH v9 5/6] MCS Lock: Order the header files in Kbuild of each architecture in alphabetical order
Quoted 39 lines · Tim Chen
Quoted 38 lines · Peter Zijlstra
Quoted 19 lines · Tim Chen
From: Peter Zijlstra <[email protected]>
We perform a clean up of the Kbuid files in each architecture. We order the files in each
Kbuildin alphabetical order by running the below script on eachKbuildfile:gawk '/^generic-y/ { i = 3; do { for (; i<=NF; i++) { if ($i == "\\") { getline; i=1; continue; } if ($i != "") hdr[$i] = $i; } break;Quoted 9 lines
} while (1); next; } END { n = asort(hdr); for (i=1; i<=n; i++) print "generic-y += " hdr[i]; }'I'll probably have to regenerate this patch once the merge window is done, but that's no biggie.
sfr, you might want to keep this script handy and distribute to others who are lazy and don't want to sort by hand.
I suppose running it requires a little something like:
Quoted 8 lines
Quoted 5 lines
for i in
arch/*/include/asm/Kbuild
docat $i | gawk .... > ${i}.sorted; mv ${i}.sorted $i;done
Peter, if this patch and the next one that adds
mcs_spinlock.htoKbuildlooks okay, can you add your signed-off? Thanks.
Script did that when I queued the lot :-) Just haven't gotten around to building the entire thing yet -- been busy huntin' wabbits.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Peter Zijlstra
maintainerRe: [PATCH v9 5/6] MCS Lock: Order the header files in Kbuild of each architecture in alphabetical order
In reply to Peter ZijlstraQuoted 7 lines · Peter Zijlstra
Quoted 6 lines · Tim Chen
From: Peter Zijlstra <[email protected]>
We perform a clean up of the Kbuid files in each architecture. We order the files in each
Kbuildin alphabetical order by running the below script on eachKbuildfile:
Quoted 16 lines
Quoted 8 lines
gawk '/^generic-y/ { i = 3; do { for (; i<=NF; i++) { if ($i == "\\") { getline; i=1; continue;Quoted 8 lines
} if ($i != "") hdr[$i] = $i; } break; } while (1); next; }
// { print $0 }
Quoted 6 lines
Quoted 6 lines
END { n = asort(hdr); for (i=1; i<=n; i++) print "generic-y += " hdr[i]; }'
Just noticed you lost that rule, without that we'll loose !genericy-y lines.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Peter Zijlstra
maintainerRe: [PATCH v9 5/6] MCS Lock: Order the header files in Kbuild of each architecture in alphabetical order
In reply to Peter ZijlstraQuoted 7 lines · Peter Zijlstra
Quoted 6 lines · Tim Chen
From: Peter Zijlstra <[email protected]>
We perform a clean up of the Kbuid files in each architecture. We order the files in each
Kbuildin alphabetical order by running the below script on eachKbuildfile:
Amended the Changelog to read:
for i in arch/*/include/asm/Kbuild
do
cat $i | gawk '/^generic-y/ {
i = 3;
do {
for (; i <= NF; i++) {
if ($i == "\\") {
getline;
i = 1;
continue;
}
if ($i != "")
hdr[$i] = $i;
}
break;
} while (1);
next;
}
// {
print $0;
}
END {
n = asort(hdr);
for (i = 1; i <= n; i++)
print "generic-y += " hdr[i];
}' > ${i}.sorted;
mv ${i}.sorted $i;done
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH v9 5/6] MCS Lock: Order the header files in Kbuild of each architecture in alphabetical order
Quoted 38 lines · Peter Zijlstra
Quoted 7 lines · Peter Zijlstra
Quoted 6 lines · Tim Chen
From: Peter Zijlstra <[email protected]>
We perform a clean up of the Kbuid files in each architecture. We order the files in each
Kbuildin alphabetical order by running the below script on eachKbuildfile:Amended the Changelog to read:
for i in
arch/*/include/asm/Kbuild
docat $i | gawk '/^generic-y/ { i = 3; do { for (; i <= NF; i++) { if ($i == "\\") { getline; i = 1; continue; } if ($i != "") hdr[$i] = $i; } break; } while (1); next; } // { print $0; } END { n = asort(hdr); for (i = 1; i <= n; i++) print "generic-y += " hdr[i]; }' > ${i}.sorted; mv ${i}.sorted $i;
Quoted 3 lines
done
Thanks for catching my cut and paste error.
Tim
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v9 6/6 MCS Lock: Allow architecture specific asm files to be used for contended case
In reply to a message not in the archiveFrom: Peter Zijlstra <[email protected]>
This patch allows each architecture to add its specific assembly optimized arch_mcs_spin_lock_contended and arch_mcs_spinlock_uncontended for MCS lock and unlock functions.
--- arch/alpha/include/asm/Kbuild | 1 + arch/arc/include/asm/Kbuild | 1 + arch/arm/include/asm/Kbuild | 1 + arch/arm64/include/asm/Kbuild | 1 + arch/avr32/include/asm/Kbuild | 1 + arch/blackfin/include/asm/Kbuild | 1 + arch/c6x/include/asm/Kbuild | 1 + arch/cris/include/asm/Kbuild | 1 + arch/frv/include/asm/Kbuild | 1 + arch/hexagon/include/asm/Kbuild | 1 + arch/ia64/include/asm/Kbuild | 1 + arch/m32r/include/asm/Kbuild | 1 + arch/m68k/include/asm/Kbuild | 1 + arch/metag/include/asm/Kbuild | 1 + arch/microblaze/include/asm/Kbuild | 1 + arch/mips/include/asm/Kbuild | 1 + arch/mn10300/include/asm/Kbuild | 1 + arch/openrisc/include/asm/Kbuild | 1 + arch/parisc/include/asm/Kbuild | 1 + arch/powerpc/include/asm/Kbuild | 4 +++- arch/s390/include/asm/Kbuild | 1 + arch/score/include/asm/Kbuild | 1 + arch/sh/include/asm/Kbuild | 1 + arch/sparc/include/asm/Kbuild | 1 + arch/tile/include/asm/Kbuild | 1 + arch/um/include/asm/Kbuild | 1 + arch/unicore32/include/asm/Kbuild | 1 + arch/x86/include/asm/Kbuild | 1 + arch/xtensa/include/asm/Kbuild | 1 + include/asm-generic/mcs_spinlock.h | 13 +++++++++++++ include/linux/mcs_spinlock.h | 2 ++ 31 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 include/asm-generic/mcs_spinlock.h
arch/alpha/include/asm/Kbuild +1 -0
@@ -2,5 +2,6 @@ generic-y += clkdev.h generic-y += exec.h +generic-y += mcs_spinlock.h generic-y += preempt.h generic-y += trace_clock.h
arch/arc/include/asm/Kbuild +1 -0
@@ -21,6 +21,7 @@ generic-y += kmap_types.h generic-y += kvm_para.h generic-y += local.h generic-y += local64.h +generic-y += mcs_spinlock.h generic-y += mman.h generic-y += msgbuf.h generic-y += param.h
arch/arm/include/asm/Kbuild +1 -0
@@ -13,6 +13,7 @@ generic-y += irq_regs.h generic-y += kdebug.h generic-y += local.h generic-y += local64.h +generic-y += mcs_spinlock.h generic-y += msgbuf.h generic-y += param.h generic-y += parport.h
arch/arm64/include/asm/Kbuild +1 -0
@@ -22,6 +22,7 @@ generic-y += kmap_types.h generic-y += kvm_para.h generic-y += local.h generic-y += local64.h +generic-y += mcs_spinlock.h generic-y += mman.h generic-y += msgbuf.h generic-y += mutex.h
arch/avr32/include/asm/Kbuild +1 -0
@@ -10,6 +10,7 @@ generic-y += futex.h generic-y += irq_regs.h generic-y += local.h generic-y += local64.h +generic-y += mcs_spinlock.h generic-y += param.h generic-y += percpu.h generic-y += preempt.h
arch/blackfin/include/asm/Kbuild +1 -0
@@ -19,6 +19,7 @@ generic-y += kmap_types.h generic-y += kvm_para.h generic-y += local.h generic-y += local64.h +generic-y += mcs_spinlock.h generic-y += mman.h generic-y += msgbuf.h generic-y += mutex.h
arch/c6x/include/asm/Kbuild +1 -0
@@ -24,6 +24,7 @@ generic-y += irq_regs.h generic-y += kdebug.h generic-y += kmap_types.h generic-y += local.h +generic-y += mcs_spinlock.h generic-y += mman.h generic-y += mmu.h generic-y += mmu_context.h
arch/cris/include/asm/Kbuild +1 -0
@@ -8,6 +8,7 @@ generic-y += clkdev.h generic-y += exec.h generic-y += kvm_para.h generic-y += linkage.h +generic-y += mcs_spinlock.h generic-y += module.h generic-y += preempt.h generic-y += trace_clock.h
arch/frv/include/asm/Kbuild +1 -0
@@ -1,5 +1,6 @@ generic-y += clkdev.h generic-y += exec.h +generic-y += mcs_spinlock.h generic-y += preempt.h generic-y += trace_clock.h
arch/hexagon/include/asm/Kbuild +1 -0
@@ -26,6 +26,7 @@ generic-y += kdebug.h generic-y += kmap_types.h generic-y += local.h generic-y += local64.h +generic-y += mcs_spinlock.h generic-y += mman.h generic-y += msgbuf.h generic-y += pci.h
arch/ia64/include/asm/Kbuild +1 -0
@@ -2,6 +2,7 @@ generic-y += clkdev.h generic-y += exec.h generic-y += kvm_para.h +generic-y += mcs_spinlock.h generic-y += preempt.h generic-y += trace_clock.h generic-y += vtime.h
arch/m32r/include/asm/Kbuild +1 -0
@@ -1,6 +1,7 @@ generic-y += clkdev.h generic-y += exec.h +generic-y += mcs_spinlock.h generic-y += module.h generic-y += preempt.h generic-y += trace_clock.h
arch/m68k/include/asm/Kbuild +1 -0
@@ -15,6 +15,7 @@ generic-y += kmap_types.h generic-y += kvm_para.h generic-y += local.h generic-y += local64.h +generic-y += mcs_spinlock.h generic-y += mman.h generic-y += mutex.h generic-y += percpu.h
arch/metag/include/asm/Kbuild +1 -0
@@ -23,6 +23,7 @@ generic-y += kmap_types.h generic-y += kvm_para.h generic-y += local.h generic-y += local64.h +generic-y += mcs_spinlock.h generic-y += msgbuf.h generic-y += mutex.h generic-y += param.h
arch/microblaze/include/asm/Kbuild +1 -0
@@ -2,6 +2,7 @@ generic-y += barrier.h generic-y += clkdev.h generic-y += exec.h +generic-y += mcs_spinlock.h generic-y += preempt.h generic-y += syscalls.h generic-y += trace_clock.h
arch/mips/include/asm/Kbuild +1 -0
@@ -3,6 +3,7 @@ generic-y += cputime.h generic-y += current.h generic-y += emergency-restart.h generic-y += local64.h +generic-y += mcs_spinlock.h generic-y += mutex.h generic-y += parport.h generic-y += percpu.h
arch/mn10300/include/asm/Kbuild +1 -0
@@ -2,5 +2,6 @@ generic-y += barrier.h generic-y += clkdev.h generic-y += exec.h +generic-y += mcs_spinlock.h generic-y += preempt.h generic-y += trace_clock.h
arch/openrisc/include/asm/Kbuild +1 -0
@@ -34,6 +34,7 @@ generic-y += kdebug.h generic-y += kmap_types.h generic-y += kvm_para.h generic-y += local.h +generic-y += mcs_spinlock.h generic-y += mman.h generic-y += module.h generic-y += msgbuf.h
arch/parisc/include/asm/Kbuild +1 -0
@@ -12,6 +12,7 @@ generic-y += kdebug.h generic-y += kvm_para.h generic-y += local.h generic-y += local64.h +generic-y += mcs_spinlock.h generic-y += mutex.h generic-y += param.h generic-y += percpu.h
arch/powerpc/include/asm/Kbuild +3 -1
@@ -1,6 +1,8 @@ +generic-y += += generic-y += clkdev.h +generic-y += mcs_spinlock.h generic-y += preempt.h generic-y += rwsem.h generic-y += trace_clock.h -generic-y += vtime.h +generic-y += vtime.hgeneric-y
arch/s390/include/asm/Kbuild +1 -0
@@ -1,5 +1,6 @@ generic-y += clkdev.h +generic-y += mcs_spinlock.h generic-y += preempt.h generic-y += trace_clock.h
arch/score/include/asm/Kbuild +1 -0
@@ -3,6 +3,7 @@ header-y += generic-y += barrier.h generic-y += clkdev.h +generic-y += mcs_spinlock.h generic-y += preempt.h generic-y += trace_clock.h generic-y += xor.h
arch/sh/include/asm/Kbuild +1 -0
@@ -14,6 +14,7 @@ generic-y += irq_regs.h generic-y += kvm_para.h generic-y += local.h generic-y += local64.h +generic-y += mcs_spinlock.h generic-y += mman.h generic-y += msgbuf.h generic-y += param.h
arch/sparc/include/asm/Kbuild +1 -0
@@ -10,6 +10,7 @@ generic-y += irq_regs.h generic-y += linkage.h generic-y += local.h generic-y += local64.h +generic-y += mcs_spinlock.h generic-y += module.h generic-y += mutex.h generic-y += preempt.h
arch/tile/include/asm/Kbuild +1 -0
@@ -18,6 +18,7 @@ generic-y += ipcbuf.h generic-y += irq_regs.h generic-y += local.h generic-y += local64.h +generic-y += mcs_spinlock.h generic-y += msgbuf.h generic-y += mutex.h generic-y += param.h
arch/um/include/asm/Kbuild +1 -0
@@ -13,6 +13,7 @@ generic-y += hw_irq.h generic-y += io.h generic-y += irq_regs.h generic-y += kdebug.h +generic-y += mcs_spinlock.h generic-y += mutex.h generic-y += param.h generic-y += pci.h
arch/unicore32/include/asm/Kbuild +1 -0
@@ -24,6 +24,7 @@ generic-y += irq_regs.h generic-y += kdebug.h generic-y += kmap_types.h generic-y += local.h +generic-y += mcs_spinlock.h generic-y += mman.h generic-y += module.h generic-y += msgbuf.h
arch/x86/include/asm/Kbuild +1 -0
@@ -5,3 +5,4 @@ genhdr-y += unistd_64.h genhdr-y += unistd_x32.h generic-y += clkdev.h +generic-y += mcs_spinlock.h
arch/xtensa/include/asm/Kbuild +1 -0
@@ -18,6 +18,7 @@ generic-y += kvm_para.h generic-y += linkage.h generic-y += local.h generic-y += local64.h +generic-y += mcs_spinlock.h generic-y += percpu.h generic-y += preempt.h generic-y += resource.h
include/asm-generic/mcs_spinlock.h new file +13 -0
@@ -0,0 +1,13 @@ +#ifndef __ASM_MCS_SPINLOCK_H +#define __ASM_MCS_SPINLOCK_H + +/* +* Architectures can define their own: +* +* arch_mcs_spin_lock_contended(l) +* arch_mcs_spin_unlock_contended(l) +* +* See kernel/locking/mcs_spinlock.c. +*/ + +#endif /* __ASM_MCS_SPINLOCK_H */
include/linux/mcs_spinlock.h +2 -0
@@ -12,6 +12,8 @@ #ifndef __LINUX_MCS_SPINLOCK_H #define __LINUX_MCS_SPINLOCK_H +#include <asm/mcs_spinlock.h> + struct mcs_spinlock { struct mcs_spinlock *next; int locked; /* 1 if lock acquired */
Signature · 8 lines
1.7.11.7 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Peter Zijlstra
maintainerRe: [PATCH v9 6/6] MCS Lock: Allow architecture specific asm files to be used for contended case
Quoted 5 lines · Tim Chen
arch/powerpc/include/asm/Kbuild +0
-0
arch/powerpc/include/asm/Kbuild line 8
Quoted 9 lines
arch/powerpc/include/asm/Kbuild +3
-1@@ -1,6 +1,8 @@ +generic-y += += generic-y += clkdev.h +generic-y += mcs_spinlock.h generic-y += preempt.h generic-y += rwsem.h generic-y += trace_clock.h -generic-y += vtime.h +generic-y += vtime.hgeneric-y
Something went funny there, fixed it.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH v9 6/6] MCS Lock: Allow architecture specific asm files to be used for contended case
Quoted 7 lines · Peter Zijlstra
Quoted 6 lines · Tim Chen
arch/powerpc/include/asm/Kbuild +0
-0@@ -1,6 +1,8 @@
Quoted 10 lines
arch/powerpc/include/asm/Kbuild line 8
Quoted 8 lines
arch/powerpc/include/asm/Kbuild +3
-1+generic-y += += generic-y += clkdev.h +generic-y += mcs_spinlock.h generic-y += preempt.h generic-y += rwsem.h generic-y += trace_clock.h -generic-y += vtime.h +generic-y += vtime.hgeneric-ySomething went funny there, fixed it.
Thanks for fixing it. I assume Peter you have picked up the patch series and merged them?
Tim
Peter Zijlstra
maintainerRe: [PATCH v9 6/6] MCS Lock: Allow architecture specific asm files to be used for contended case
Quoted 19 lines · Tim Chen
Quoted 7 lines · Peter Zijlstra
Quoted 6 lines · Tim Chen
arch/powerpc/include/asm/Kbuild +0
-0@@ -1,6 +1,8 @@Quoted 10 lines
arch/powerpc/include/asm/Kbuild line 8
Quoted 8 lines
arch/powerpc/include/asm/Kbuild +3
-1+generic-y += += generic-y += clkdev.h +generic-y += mcs_spinlock.h generic-y += preempt.h generic-y += rwsem.h generic-y += trace_clock.h -generic-y += vtime.h +generic-y += vtime.hgeneric-ySomething went funny there, fixed it.
Quoted 2 lines
Thanks for fixing it. I assume Peter you have picked up the patch series and merged them?
I have picked up, Ingo generally doesn't merge new patches until after -rc1 closes though, with the obvious exception to 'urgent' patches that fix problems stemming from the merge window.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH v9 6/6] MCS Lock: Allow architecture specific asm files to be used for contended case
Quoted 4 lines · Peter Zijlstra
I have picked up, Ingo generally doesn't merge new patches until after -rc1 closes though, with the obvious exception to 'urgent' patches that fix problems stemming from the merge window.
Considering how long this has been brewing, I'd argue that we can just merge it during this merge window unless there are actual problems in testing.
Sure, there may still be details that need sorting out, but by now I think they might as well be handled in mainline.
But hey, I'm not going to force it either, so it's up to how comfy you guys are about the code.
Linus
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH v9 6/6] MCS Lock: Allow architecture specific asm files to be used for contended case
Quoted 10 lines · Linus Torvalds
Quoted 4 lines · Peter Zijlstra
I have picked up, Ingo generally doesn't merge new patches until after -rc1 closes though, with the obvious exception to 'urgent' patches that fix problems stemming from the merge window.
Considering how long this has been brewing, I'd argue that we can just merge it during this merge window unless there are actual problems in testing.
Quoted 5 lines
Sure, there may still be details that need sorting out, but by now I think they might as well be handled in mainline.
But hey, I'm not going to force it either, so it's up to how comfy you guys are about the code.
Suits me, then I can get the ARM parts in for 3.15.
Will
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
tip-bot for Tim Chen
merge bot[tip:core/locking] locking/mcs: Allow architecture specific asm files to be used for contended case
In reply to Tim Chenlocking/mcs: Allow architecture specific asm files to be used for contended case
Commit-ID: ddf1d169c0a489d498c1799a7043904a43b0c159 Gitweb: http://git.kernel.org/tip/ddf1d169c0a489d498c1799a7043904a43b0c159 Author: Tim Chen <[email protected]> AuthorDate: Tue, 21 Jan 2014 15:36:22 -0800 Committer: Ingo Molnar <[email protected]> CommitDate: Sun, 9 Feb 2014 21:18:52 +0100
locking/mcs: Allow architecture specific asm files to be used for contended case
This patch allows each architecture to add its specific assembly optimized arch_mcs_spin_lock_contended and arch_mcs_spinlock_uncontended for MCS lock and unlock functions.
--- arch/alpha/include/asm/Kbuild | 1 + arch/arc/include/asm/Kbuild | 1 + arch/arm/include/asm/Kbuild | 1 + arch/arm64/include/asm/Kbuild | 1 + arch/avr32/include/asm/Kbuild | 1 + arch/blackfin/include/asm/Kbuild | 1 + arch/c6x/include/asm/Kbuild | 1 + arch/cris/include/asm/Kbuild | 1 + arch/frv/include/asm/Kbuild | 1 + arch/hexagon/include/asm/Kbuild | 1 + arch/ia64/include/asm/Kbuild | 1 + arch/m32r/include/asm/Kbuild | 1 + arch/m68k/include/asm/Kbuild | 1 + arch/metag/include/asm/Kbuild | 1 + arch/microblaze/include/asm/Kbuild | 1 + arch/mips/include/asm/Kbuild | 1 + arch/mn10300/include/asm/Kbuild | 1 + arch/openrisc/include/asm/Kbuild | 1 + arch/parisc/include/asm/Kbuild | 1 + arch/powerpc/include/asm/Kbuild | 1 + arch/s390/include/asm/Kbuild | 1 + arch/score/include/asm/Kbuild | 1 + arch/sh/include/asm/Kbuild | 1 + arch/sparc/include/asm/Kbuild | 1 + arch/tile/include/asm/Kbuild | 1 + arch/um/include/asm/Kbuild | 1 + arch/unicore32/include/asm/Kbuild | 1 + arch/x86/include/asm/Kbuild | 1 + arch/xtensa/include/asm/Kbuild | 1 + include/asm-generic/mcs_spinlock.h | 13 +++++++++++++ include/linux/mcs_spinlock.h | 2 ++ 31 files changed, 44 insertions(+)
arch/alpha/include/asm/Kbuild +1 -0
@@ -3,5 +3,6 @@ generic-y += clkdev.h generic-y += exec.h generic-y += hash.h +generic-y += mcs_spinlock.h generic-y += preempt.h generic-y += trace_clock.h
arch/arc/include/asm/Kbuild +1 -0
@@ -22,6 +22,7 @@ generic-y += kmap_types.h generic-y += kvm_para.h generic-y += local.h generic-y += local64.h +generic-y += mcs_spinlock.h generic-y += mman.h generic-y += msgbuf.h generic-y += param.h
arch/arm/include/asm/Kbuild +1 -0
@@ -14,6 +14,7 @@ generic-y += irq_regs.h generic-y += kdebug.h generic-y += local.h generic-y += local64.h +generic-y += mcs_spinlock.h generic-y += msgbuf.h generic-y += param.h generic-y += parport.h
arch/arm64/include/asm/Kbuild +1 -0
@@ -23,6 +23,7 @@ generic-y += kmap_types.h generic-y += kvm_para.h generic-y += local.h generic-y += local64.h +generic-y += mcs_spinlock.h generic-y += mman.h generic-y += msgbuf.h generic-y += mutex.h
arch/avr32/include/asm/Kbuild +1 -0
@@ -11,6 +11,7 @@ generic-y += hash.h generic-y += irq_regs.h generic-y += local.h generic-y += local64.h +generic-y += mcs_spinlock.h generic-y += param.h generic-y += percpu.h generic-y += preempt.h
arch/blackfin/include/asm/Kbuild +1 -0
@@ -20,6 +20,7 @@ generic-y += kmap_types.h generic-y += kvm_para.h generic-y += local.h generic-y += local64.h +generic-y += mcs_spinlock.h generic-y += mman.h generic-y += msgbuf.h generic-y += mutex.h
arch/c6x/include/asm/Kbuild +1 -0
@@ -25,6 +25,7 @@ generic-y += irq_regs.h generic-y += kdebug.h generic-y += kmap_types.h generic-y += local.h +generic-y += mcs_spinlock.h generic-y += mman.h generic-y += mmu.h generic-y += mmu_context.h
arch/cris/include/asm/Kbuild +1 -0
@@ -9,6 +9,7 @@ generic-y += exec.h generic-y += hash.h generic-y += kvm_para.h generic-y += linkage.h +generic-y += mcs_spinlock.h generic-y += module.h generic-y += preempt.h generic-y += trace_clock.h
arch/frv/include/asm/Kbuild +1 -0
@@ -2,5 +2,6 @@ generic-y += clkdev.h generic-y += exec.h generic-y += hash.h +generic-y += mcs_spinlock.h generic-y += preempt.h generic-y += trace_clock.h
arch/hexagon/include/asm/Kbuild +1 -0
@@ -27,6 +27,7 @@ generic-y += kdebug.h generic-y += kmap_types.h generic-y += local.h generic-y += local64.h +generic-y += mcs_spinlock.h generic-y += mman.h generic-y += msgbuf.h generic-y += pci.h
arch/ia64/include/asm/Kbuild +1 -0
@@ -3,6 +3,7 @@ generic-y += clkdev.h generic-y += exec.h generic-y += hash.h generic-y += kvm_para.h +generic-y += mcs_spinlock.h generic-y += preempt.h generic-y += trace_clock.h generic-y += vtime.h
arch/m32r/include/asm/Kbuild +1 -0
@@ -2,6 +2,7 @@ generic-y += clkdev.h generic-y += exec.h generic-y += hash.h +generic-y += mcs_spinlock.h generic-y += module.h generic-y += preempt.h generic-y += trace_clock.h
arch/m68k/include/asm/Kbuild +1 -0
@@ -16,6 +16,7 @@ generic-y += kmap_types.h generic-y += kvm_para.h generic-y += local.h generic-y += local64.h +generic-y += mcs_spinlock.h generic-y += mman.h generic-y += mutex.h generic-y += percpu.h
arch/metag/include/asm/Kbuild +1 -0
@@ -24,6 +24,7 @@ generic-y += kmap_types.h generic-y += kvm_para.h generic-y += local.h generic-y += local64.h +generic-y += mcs_spinlock.h generic-y += msgbuf.h generic-y += mutex.h generic-y += param.h
arch/microblaze/include/asm/Kbuild +1 -0
@@ -3,6 +3,7 @@ generic-y += barrier.h generic-y += clkdev.h generic-y += exec.h generic-y += hash.h +generic-y += mcs_spinlock.h generic-y += preempt.h generic-y += syscalls.h generic-y += trace_clock.h
arch/mips/include/asm/Kbuild +1 -0
@@ -4,6 +4,7 @@ generic-y += current.h generic-y += emergency-restart.h generic-y += hash.h generic-y += local64.h +generic-y += mcs_spinlock.h generic-y += mutex.h generic-y += parport.h generic-y += percpu.h
arch/mn10300/include/asm/Kbuild +1 -0
@@ -3,5 +3,6 @@ generic-y += barrier.h generic-y += clkdev.h generic-y += exec.h generic-y += hash.h +generic-y += mcs_spinlock.h generic-y += preempt.h generic-y += trace_clock.h
arch/openrisc/include/asm/Kbuild +1 -0
@@ -35,6 +35,7 @@ generic-y += kdebug.h generic-y += kmap_types.h generic-y += kvm_para.h generic-y += local.h +generic-y += mcs_spinlock.h generic-y += mman.h generic-y += module.h generic-y += msgbuf.h
arch/parisc/include/asm/Kbuild +1 -0
@@ -14,6 +14,7 @@ generic-y += kdebug.h generic-y += kvm_para.h generic-y += local.h generic-y += local64.h +generic-y += mcs_spinlock.h generic-y += mutex.h generic-y += param.h generic-y += percpu.h
arch/powerpc/include/asm/Kbuild +1 -0
@@ -1,6 +1,7 @@ generic-y += clkdev.h generic-y += hash.h +generic-y += mcs_spinlock.h generic-y += preempt.h generic-y += rwsem.h generic-y += trace_clock.h
arch/s390/include/asm/Kbuild +1 -0
@@ -2,5 +2,6 @@ generic-y += clkdev.h generic-y += hash.h +generic-y += mcs_spinlock.h generic-y += preempt.h generic-y += trace_clock.h
arch/score/include/asm/Kbuild +1 -0
@@ -5,6 +5,7 @@ header-y += generic-y += barrier.h generic-y += clkdev.h generic-y += hash.h +generic-y += mcs_spinlock.h generic-y += preempt.h generic-y += trace_clock.h generic-y += xor.h
arch/sh/include/asm/Kbuild +1 -0
@@ -15,6 +15,7 @@ generic-y += irq_regs.h generic-y += kvm_para.h generic-y += local.h generic-y += local64.h +generic-y += mcs_spinlock.h generic-y += mman.h generic-y += msgbuf.h generic-y += param.h
arch/sparc/include/asm/Kbuild +1 -0
@@ -11,6 +11,7 @@ generic-y += irq_regs.h generic-y += linkage.h generic-y += local.h generic-y += local64.h +generic-y += mcs_spinlock.h generic-y += module.h generic-y += mutex.h generic-y += preempt.h
arch/tile/include/asm/Kbuild +1 -0
@@ -19,6 +19,7 @@ generic-y += ipcbuf.h generic-y += irq_regs.h generic-y += local.h generic-y += local64.h +generic-y += mcs_spinlock.h generic-y += msgbuf.h generic-y += mutex.h generic-y += param.h
arch/um/include/asm/Kbuild +1 -0
@@ -15,6 +15,7 @@ generic-y += hw_irq.h generic-y += io.h generic-y += irq_regs.h generic-y += kdebug.h +generic-y += mcs_spinlock.h generic-y += mutex.h generic-y += param.h generic-y += pci.h
arch/unicore32/include/asm/Kbuild +1 -0
@@ -25,6 +25,7 @@ generic-y += irq_regs.h generic-y += kdebug.h generic-y += kmap_types.h generic-y += local.h +generic-y += mcs_spinlock.h generic-y += mman.h generic-y += module.h generic-y += msgbuf.h
arch/x86/include/asm/Kbuild +1 -0
@@ -5,3 +5,4 @@ genhdr-y += unistd_64.h genhdr-y += unistd_x32.h generic-y += clkdev.h +generic-y += mcs_spinlock.h
arch/xtensa/include/asm/Kbuild +1 -0
@@ -18,6 +18,7 @@ generic-y += kvm_para.h generic-y += linkage.h generic-y += local.h generic-y += local64.h +generic-y += mcs_spinlock.h generic-y += percpu.h generic-y += preempt.h generic-y += resource.h
include/asm-generic/mcs_spinlock.h new file +13 -0
@@ -0,0 +1,13 @@ +#ifndef __ASM_MCS_SPINLOCK_H +#define __ASM_MCS_SPINLOCK_H + +/* +* Architectures can define their own: +* +* arch_mcs_spin_lock_contended(l) +* arch_mcs_spin_unlock_contended(l) +* +* See kernel/locking/mcs_spinlock.c. +*/ + +#endif /* __ASM_MCS_SPINLOCK_H */
include/linux/mcs_spinlock.h +2 -0
@@ -12,6 +12,8 @@ #ifndef __LINUX_MCS_SPINLOCK_H #define __LINUX_MCS_SPINLOCK_H +#include <asm/mcs_spinlock.h> + struct mcs_spinlock { struct mcs_spinlock *next; int locked; /* 1 if lock acquired */