summaryrefslogtreecommitdiff
path: root/include/linux/tty_ldisc.h
diff options
context:
space:
mode:
authorPeter Zijlstra <peterz@infradead.org>2018-06-05 17:53:34 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-06-28 15:07:55 +0300
commit5fd691afdf929061c391d897fa627822c3b2fd5a (patch)
tree005d50f2b2bc10ce6e6af270feaa1fc1efe77eae /include/linux/tty_ldisc.h
parent9d9398944488cd3a3e1e0912b26fbc4d5921e547 (diff)
downloadlinux-5fd691afdf929061c391d897fa627822c3b2fd5a.tar.xz
atomic/tty: Fix up atomic abuse in ldsem
Mark found ldsem_cmpxchg() needed an (atomic_long_t *) cast to keep working after making the atomic_long interface type safe. Needing casts is bad form, which made me look at the code. There are no ld_semaphore::count users outside of these functions so there is no reason why it can not be an atomic_long_t in the first place, obviating the need for this cast. That also ensures the loads use atomic_long_read(), which implies (at least) READ_ONCE() in order to guarantee single-copy-atomic loads. When using atomic_long_try_cmpxchg() the ldsem_cmpxchg() wrapper gets very thin (the only difference is not changing *old on success, which most callers don't seem to care about). So rework the whole thing to use atomic_long_t and its accessors directly. While there, fixup all the horrible comment styles. Cc: Peter Hurley <peter@hurleysoftware.com> Reported-by: Mark Rutland <mark.rutland@arm.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Acked-by: Mark Rutland <mark.rutland@arm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux/tty_ldisc.h')
-rw-r--r--include/linux/tty_ldisc.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
index 1ef64d4ad887..840894ca3fc0 100644
--- a/include/linux/tty_ldisc.h
+++ b/include/linux/tty_ldisc.h
@@ -119,13 +119,13 @@
#include <linux/fs.h>
#include <linux/wait.h>
-
+#include <linux/atomic.h>
/*
* the semaphore definition
*/
struct ld_semaphore {
- long count;
+ atomic_long_t count;
raw_spinlock_t wait_lock;
unsigned int wait_readers;
struct list_head read_wait;