Re-add local_lock_on type functions to locallock.h (from the 5.4-RT tree). To be used by remote page draining. The original commit message is: Introduce locallock. For !RT this maps to preempt_disable()/ local_irq_disable() so there is not much that changes. For RT this will map to a spinlock. This makes preemption possible and locked "ressource" gets the lockdep anotation it wouldn't have otherwise. The locks are recursive for owner == current. Also, all locks user migrate_disable() which ensures that the task is not migrated to another CPU while the lock is held and the owner is preempted. From: Thomas Gleixner <tglx@xxxxxxxxxxxxx> Signed-off-by: Marcelo Tosatti <mtosatti@xxxxxxxxxx> --- include/linux/locallock.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) Index: linux-rt-devel/include/linux/locallock.h =================================================================== --- linux-rt-devel.orig/include/linux/locallock.h +++ linux-rt-devel/include/linux/locallock.h @@ -51,6 +51,9 @@ static inline void __local_lock(struct l #define local_lock(lvar) \ do { __local_lock(&get_local_var(lvar)); } while (0) +#define local_lock_on(lvar, cpu) \ + do { __local_lock(&per_cpu(lvar, cpu)); } while (0) + static inline int __local_trylock(struct local_irq_lock *lv) { if (lv->owner != current && spin_trylock(&lv->lock)) { @@ -92,6 +95,9 @@ static inline void __local_unlock(struct put_local_var(lvar); \ } while (0) +#define local_unlock_on(lvar, cpu) \ + do { __local_unlock(&per_cpu(lvar, cpu)); } while (0) + static inline void __local_lock_irq(struct local_irq_lock *lv) { spin_lock_irqsave(&lv->lock, lv->flags); @@ -104,6 +110,9 @@ static inline void __local_lock_irq(stru #define local_lock_irq(lvar) \ do { __local_lock_irq(&get_local_var(lvar)); } while (0) +#define local_lock_irq_on(lvar, cpu) \ + do { __local_lock_irq(&per_cpu(lvar, cpu)); } while (0) + static inline void __local_unlock_irq(struct local_irq_lock *lv) { LL_WARN(!lv->nestcnt); @@ -119,6 +128,11 @@ static inline void __local_unlock_irq(st put_local_var(lvar); \ } while (0) +#define local_unlock_irq_on(lvar, cpu) \ + do { \ + __local_unlock_irq(&per_cpu(lvar, cpu)); \ + } while (0) + static inline int __local_lock_irqsave(struct local_irq_lock *lv) { if (lv->owner != current) { @@ -137,6 +151,12 @@ static inline int __local_lock_irqsave(s _flags = __this_cpu_read(lvar.flags); \ } while (0) +#define local_lock_irqsave_on(lvar, _flags, cpu) \ + do { \ + __local_lock_irqsave(&per_cpu(lvar, cpu)); \ + _flags = per_cpu(lvar, cpu).flags; \ + } while (0) + static inline int __local_unlock_irqrestore(struct local_irq_lock *lv, unsigned long flags) { @@ -156,6 +176,11 @@ static inline int __local_unlock_irqrest put_local_var(lvar); \ } while (0) +#define local_unlock_irqrestore_on(lvar, flags, cpu) \ + do { \ + __local_unlock_irqrestore(&per_cpu(lvar, cpu), flags); \ + } while (0) + #define local_spin_trylock_irq(lvar, lock) \ ({ \ int __locked; \