Displaying 20 results from an estimated 25 matches for "__tickets_equal".
2015 Feb 13
3
[PATCH V4] x86 spinlock: Fix memory corruption on completing completions
...d long *)&lock->tickets.tail);
+ set_bit(0, (volatile unsigned long *)&lock->tickets.head);
}
#else /* !CONFIG_PARAVIRT_SPINLOCKS */
@@ -60,10 +60,30 @@ static inline void __ticket_unlock_kick(arch_spinlock_t *lock,
}
#endif /* CONFIG_PARAVIRT_SPINLOCKS */
+static inline int __tickets_equal(__ticket_t one, __ticket_t two)
+{
+ return !((one ^ two) & ~TICKET_SLOWPATH_FLAG);
+}
+
+static inline void __ticket_check_and_clear_slowpath(arch_spinlock_t *lock,
+ __ticket_t head)
+{
+ if (head & TICKET_SLOWPATH_FLAG) {
+ arch_spinlock_t old, new;
+
+ old.tickets.head = head;
+...
2015 Feb 13
3
[PATCH V4] x86 spinlock: Fix memory corruption on completing completions
...d long *)&lock->tickets.tail);
+ set_bit(0, (volatile unsigned long *)&lock->tickets.head);
}
#else /* !CONFIG_PARAVIRT_SPINLOCKS */
@@ -60,10 +60,30 @@ static inline void __ticket_unlock_kick(arch_spinlock_t *lock,
}
#endif /* CONFIG_PARAVIRT_SPINLOCKS */
+static inline int __tickets_equal(__ticket_t one, __ticket_t two)
+{
+ return !((one ^ two) & ~TICKET_SLOWPATH_FLAG);
+}
+
+static inline void __ticket_check_and_clear_slowpath(arch_spinlock_t *lock,
+ __ticket_t head)
+{
+ if (head & TICKET_SLOWPATH_FLAG) {
+ arch_spinlock_t old, new;
+
+ old.tickets.head = head;
+...
2015 Feb 12
8
[PATCH V3] x86 spinlock: Fix memory corruption on completing completions
...d long *)&lock->tickets.tail);
+ set_bit(0, (volatile unsigned long *)&lock->tickets.head);
}
#else /* !CONFIG_PARAVIRT_SPINLOCKS */
@@ -60,10 +60,30 @@ static inline void __ticket_unlock_kick(arch_spinlock_t *lock,
}
#endif /* CONFIG_PARAVIRT_SPINLOCKS */
+static inline int __tickets_equal(__ticket_t one, __ticket_t two)
+{
+ return !((one ^ two) & ~TICKET_SLOWPATH_FLAG);
+}
+
+static inline void __ticket_check_and_clear_slowpath(arch_spinlock_t *lock,
+ __ticket_t head)
+{
+ if (head & TICKET_SLOWPATH_FLAG) {
+ arch_spinlock_t old, new;
+
+ old.tickets.head = head;
+...
2015 Feb 12
8
[PATCH V3] x86 spinlock: Fix memory corruption on completing completions
...d long *)&lock->tickets.tail);
+ set_bit(0, (volatile unsigned long *)&lock->tickets.head);
}
#else /* !CONFIG_PARAVIRT_SPINLOCKS */
@@ -60,10 +60,30 @@ static inline void __ticket_unlock_kick(arch_spinlock_t *lock,
}
#endif /* CONFIG_PARAVIRT_SPINLOCKS */
+static inline int __tickets_equal(__ticket_t one, __ticket_t two)
+{
+ return !((one ^ two) & ~TICKET_SLOWPATH_FLAG);
+}
+
+static inline void __ticket_check_and_clear_slowpath(arch_spinlock_t *lock,
+ __ticket_t head)
+{
+ if (head & TICKET_SLOWPATH_FLAG) {
+ arch_spinlock_t old, new;
+
+ old.tickets.head = head;
+...
2015 Feb 15
7
[PATCH V5] x86 spinlock: Fix memory corruption on completing completions
...;lock->tickets.tail);
+ set_bit(0, (volatile unsigned long *)&lock->tickets.head);
+ barrier();
}
#else /* !CONFIG_PARAVIRT_SPINLOCKS */
@@ -60,10 +61,30 @@ static inline void __ticket_unlock_kick(arch_spinlock_t *lock,
}
#endif /* CONFIG_PARAVIRT_SPINLOCKS */
+static inline int __tickets_equal(__ticket_t one, __ticket_t two)
+{
+ return !((one ^ two) & ~TICKET_SLOWPATH_FLAG);
+}
+
+static inline void __ticket_check_and_clear_slowpath(arch_spinlock_t *lock,
+ __ticket_t head)
+{
+ if (head & TICKET_SLOWPATH_FLAG) {
+ arch_spinlock_t old, new;
+
+ old.tickets.head = head;
+...
2015 Feb 15
7
[PATCH V5] x86 spinlock: Fix memory corruption on completing completions
...;lock->tickets.tail);
+ set_bit(0, (volatile unsigned long *)&lock->tickets.head);
+ barrier();
}
#else /* !CONFIG_PARAVIRT_SPINLOCKS */
@@ -60,10 +61,30 @@ static inline void __ticket_unlock_kick(arch_spinlock_t *lock,
}
#endif /* CONFIG_PARAVIRT_SPINLOCKS */
+static inline int __tickets_equal(__ticket_t one, __ticket_t two)
+{
+ return !((one ^ two) & ~TICKET_SLOWPATH_FLAG);
+}
+
+static inline void __ticket_check_and_clear_slowpath(arch_spinlock_t *lock,
+ __ticket_t head)
+{
+ if (head & TICKET_SLOWPATH_FLAG) {
+ arch_spinlock_t old, new;
+
+ old.tickets.head = head;
+...
2015 Feb 15
0
[PATCH V5] x86 spinlock: Fix memory corruption on completing completions
...d long *)&lock->tickets.tail);
+ set_bit(0, (volatile unsigned long *)&lock->tickets.head);
}
#else /* !CONFIG_PARAVIRT_SPINLOCKS */
@@ -60,10 +60,30 @@ static inline void __ticket_unlock_kick(arch_spinlock_t *lock,
}
#endif /* CONFIG_PARAVIRT_SPINLOCKS */
+static inline int __tickets_equal(__ticket_t one, __ticket_t two)
+{
+ return !((one ^ two) & ~TICKET_SLOWPATH_FLAG);
+}
+
+static inline void __ticket_check_and_clear_slowpath(arch_spinlock_t *lock,
+ __ticket_t head)
+{
+ if (head & TICKET_SLOWPATH_FLAG) {
+ arch_spinlock_t old, new;
+
+ old.tickets.head = head;
+...
2015 Feb 15
0
[PATCH V5] x86 spinlock: Fix memory corruption on completing completions
...d long *)&lock->tickets.tail);
+ set_bit(0, (volatile unsigned long *)&lock->tickets.head);
}
#else /* !CONFIG_PARAVIRT_SPINLOCKS */
@@ -60,10 +60,30 @@ static inline void __ticket_unlock_kick(arch_spinlock_t *lock,
}
#endif /* CONFIG_PARAVIRT_SPINLOCKS */
+static inline int __tickets_equal(__ticket_t one, __ticket_t two)
+{
+ return !((one ^ two) & ~TICKET_SLOWPATH_FLAG);
+}
+
+static inline void __ticket_check_and_clear_slowpath(arch_spinlock_t *lock,
+ __ticket_t head)
+{
+ if (head & TICKET_SLOWPATH_FLAG) {
+ arch_spinlock_t old, new;
+
+ old.tickets.head = head;
+...
2015 Feb 24
2
[PATCH for stable] x86/spinlocks/paravirt: Fix memory corruption on unlock
...d long *)&lock->tickets.tail);
+ set_bit(0, (volatile unsigned long *)&lock->tickets.head);
}
#else /* !CONFIG_PARAVIRT_SPINLOCKS */
@@ -60,10 +60,30 @@ static inline void __ticket_unlock_kick(arch_spinlock_t *lock,
}
#endif /* CONFIG_PARAVIRT_SPINLOCKS */
+static inline int __tickets_equal(__ticket_t one, __ticket_t two)
+{
+ return !((one ^ two) & ~TICKET_SLOWPATH_FLAG);
+}
+
+static inline void __ticket_check_and_clear_slowpath(arch_spinlock_t *lock,
+ __ticket_t head)
+{
+ if (head & TICKET_SLOWPATH_FLAG) {
+ arch_spinlock_t old, new;
+
+ old.tickets.head = head;
+...
2015 Feb 24
2
[PATCH for stable] x86/spinlocks/paravirt: Fix memory corruption on unlock
...d long *)&lock->tickets.tail);
+ set_bit(0, (volatile unsigned long *)&lock->tickets.head);
}
#else /* !CONFIG_PARAVIRT_SPINLOCKS */
@@ -60,10 +60,30 @@ static inline void __ticket_unlock_kick(arch_spinlock_t *lock,
}
#endif /* CONFIG_PARAVIRT_SPINLOCKS */
+static inline int __tickets_equal(__ticket_t one, __ticket_t two)
+{
+ return !((one ^ two) & ~TICKET_SLOWPATH_FLAG);
+}
+
+static inline void __ticket_check_and_clear_slowpath(arch_spinlock_t *lock,
+ __ticket_t head)
+{
+ if (head & TICKET_SLOWPATH_FLAG) {
+ arch_spinlock_t old, new;
+
+ old.tickets.head = head;
+...
2015 Feb 15
1
[PATCH V4] x86 spinlock: Fix memory corruption on completing completions
...e int arch_spin_is_locked(arch_spinlock_t *lock)
>> {
>> struct __raw_tickets tmp = READ_ONCE(lock->tickets);
>>
>> - return tmp.tail != tmp.head;
>> + return tmp.tail != (tmp.head & ~TICKET_SLOWPATH_FLAG);
>> }
>
> Well, this can probably use __tickets_equal() too. But this is cosmetic.
That looks good. Added.
> It seems that arch_spin_is_contended() should be fixed with this change,
>
> (__ticket_t)(tmp.tail - tmp.head) > TICKET_LOCK_INC
>
> can be true because of TICKET_SLOWPATH_FLAG in .head, even if it is actually
> unlocked...
2015 Feb 15
1
[PATCH V4] x86 spinlock: Fix memory corruption on completing completions
...e int arch_spin_is_locked(arch_spinlock_t *lock)
>> {
>> struct __raw_tickets tmp = READ_ONCE(lock->tickets);
>>
>> - return tmp.tail != tmp.head;
>> + return tmp.tail != (tmp.head & ~TICKET_SLOWPATH_FLAG);
>> }
>
> Well, this can probably use __tickets_equal() too. But this is cosmetic.
That looks good. Added.
> It seems that arch_spin_is_contended() should be fixed with this change,
>
> (__ticket_t)(tmp.tail - tmp.head) > TICKET_LOCK_INC
>
> can be true because of TICKET_SLOWPATH_FLAG in .head, even if it is actually
> unlocked...
2015 Feb 12
0
[PATCH V3] x86 spinlock: Fix memory corruption on completing completions
...oid arch_spin_unlock_wait(arch_spinlock_t *lock)
> * We need to check "unlocked" in a loop, tmp.head == head
> * can be false positive because of overflow.
> */
> - if (tmp.head == (tmp.tail & ~TICKET_SLOWPATH_FLAG) ||
> - tmp.head != head)
> + if (__tickets_equal(tmp.head, tmp.tail) || tmp.head != head)
> break;
Ah, it seems that "tmp.head != head" should be turned into
!__tickets_equal(), no?
Suppose that TICKET_SLOWPATH_FLAG is set after the first ACCESS_ONCE(head),
then tmp.head != head will be true before the first unlock we are waiti...
2015 Feb 13
0
[PATCH V4] x86 spinlock: Fix memory corruption on completing completions
...gt; @@ -164,7 +161,7 @@ static inline int arch_spin_is_locked(arch_spinlock_t *lock)
> {
> struct __raw_tickets tmp = READ_ONCE(lock->tickets);
>
> - return tmp.tail != tmp.head;
> + return tmp.tail != (tmp.head & ~TICKET_SLOWPATH_FLAG);
> }
Well, this can probably use __tickets_equal() too. But this is cosmetic.
It seems that arch_spin_is_contended() should be fixed with this change,
(__ticket_t)(tmp.tail - tmp.head) > TICKET_LOCK_INC
can be true because of TICKET_SLOWPATH_FLAG in .head, even if it is actually
unlocked. And the "(__ticket_t)" typecast looks unn...
2015 Feb 12
0
[PATCH V3] x86 spinlock: Fix memory corruption on completing completions
...oid arch_spin_unlock_wait(arch_spinlock_t *lock)
> * We need to check "unlocked" in a loop, tmp.head == head
> * can be false positive because of overflow.
> */
> - if (tmp.head == (tmp.tail & ~TICKET_SLOWPATH_FLAG) ||
> - tmp.head != head)
> + if (__tickets_equal(tmp.head, tmp.tail) || tmp.head != head)
> break;
Ah, it seems that "tmp.head != head" should be turned into
!__tickets_equal(), no?
Suppose that TICKET_SLOWPATH_FLAG is set after the first ACCESS_ONCE(head),
then tmp.head != head will be true before the first unlock we are waiti...
2015 Feb 13
0
[PATCH V4] x86 spinlock: Fix memory corruption on completing completions
...gt; @@ -164,7 +161,7 @@ static inline int arch_spin_is_locked(arch_spinlock_t *lock)
> {
> struct __raw_tickets tmp = READ_ONCE(lock->tickets);
>
> - return tmp.tail != tmp.head;
> + return tmp.tail != (tmp.head & ~TICKET_SLOWPATH_FLAG);
> }
Well, this can probably use __tickets_equal() too. But this is cosmetic.
It seems that arch_spin_is_contended() should be fixed with this change,
(__ticket_t)(tmp.tail - tmp.head) > TICKET_LOCK_INC
can be true because of TICKET_SLOWPATH_FLAG in .head, even if it is actually
unlocked. And the "(__ticket_t)" typecast looks unn...
2015 Feb 16
1
[Xen-devel] [PATCH V5] x86 spinlock: Fix memory corruption on completing completions
...does not cross the read */
> + smp_mb__after_atomic();
> +
> /*
> * check again make sure it didn't become free while
> * we weren't looking
> */
> - if (ACCESS_ONCE(lock->tickets.head) == want) {
> + head = READ_ONCE(lock->tickets.head);
> + if (__tickets_equal(head, want)) {
> add_stats(TAKEN_SLOW_PICKUP, 1);
> goto out;
> }
> @@ -204,8 +209,8 @@ static void xen_unlock_kick(struct arch_spinlock *lock, __ticket_t next)
> const struct xen_lock_waiting *w = &per_cpu(lock_waiting, cpu);
>
> /* Make sure we read lock b...
2015 Feb 16
1
[Xen-devel] [PATCH V5] x86 spinlock: Fix memory corruption on completing completions
...does not cross the read */
> + smp_mb__after_atomic();
> +
> /*
> * check again make sure it didn't become free while
> * we weren't looking
> */
> - if (ACCESS_ONCE(lock->tickets.head) == want) {
> + head = READ_ONCE(lock->tickets.head);
> + if (__tickets_equal(head, want)) {
> add_stats(TAKEN_SLOW_PICKUP, 1);
> goto out;
> }
> @@ -204,8 +209,8 @@ static void xen_unlock_kick(struct arch_spinlock *lock, __ticket_t next)
> const struct xen_lock_waiting *w = &per_cpu(lock_waiting, cpu);
>
> /* Make sure we read lock b...
2015 Apr 30
0
[PATCH 3/6] x86: introduce new pvops function clear_slowpath
.../spinlock.h
+++ b/arch/x86/include/asm/spinlock.h
@@ -60,26 +60,16 @@ static inline void __ticket_unlock_kick(arch_spinlock_t *lock,
{
}
+static inline void __ticket_clear_slowpath(arch_spinlock_t *lock,
+ __ticket_t head)
+{
+}
#endif /* CONFIG_PARAVIRT_SPINLOCKS */
static inline int __tickets_equal(__ticket_t one, __ticket_t two)
{
return !((one ^ two) & ~TICKET_SLOWPATH_FLAG);
}
-static inline void __ticket_clear_slowpath(arch_spinlock_t *lock,
- __ticket_t head)
-{
- arch_spinlock_t old, new;
-
- old.tickets.head = head;
- new.tickets.head = head & ~TICKET_SLOWPATH_FLAG...
2015 Apr 30
0
[PATCH 2/6] x86: move decision about clearing slowpath flag into arch_spin_lock()
...+++++++++++------------
1 file changed, 11 insertions(+), 12 deletions(-)
diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
index 8ceec8d..268b9da 100644
--- a/arch/x86/include/asm/spinlock.h
+++ b/arch/x86/include/asm/spinlock.h
@@ -66,20 +66,18 @@ static inline int __tickets_equal(__ticket_t one, __ticket_t two)
return !((one ^ two) & ~TICKET_SLOWPATH_FLAG);
}
-static inline void __ticket_check_and_clear_slowpath(arch_spinlock_t *lock,
- __ticket_t head)
+static inline void __ticket_clear_slowpath(arch_spinlock_t *lock,
+ __ticket_t head)
{
- if (head...