aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Hurley <peter@hurleysoftware.com>2013-06-15 10:04:29 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-07-23 20:02:22 -0400
commit9dfd16ddea9bdbc8343340e543732db0a467ae32 (patch)
treef5ab13fd7bbc7ff99ccc44ecf127fede65452dc2
parent29c7c5ca36d9c132cf9c37a09bc43626e790fb4c (diff)
n_tty: Avoid false-sharing echo buffer indices
Separate the head & commit indices from the tail index to avoid cache-line contention (so called 'false-sharing') between concurrent threads. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/tty/n_tty.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
index 7f15b269cf3e..d4d71350a71d 100644
--- a/drivers/tty/n_tty.c
+++ b/drivers/tty/n_tty.c
@@ -90,6 +90,8 @@ struct n_tty_data {
90 /* producer-published */ 90 /* producer-published */
91 size_t read_head; 91 size_t read_head;
92 size_t canon_head; 92 size_t canon_head;
93 size_t echo_head;
94 size_t echo_commit;
93 DECLARE_BITMAP(process_char_map, 256); 95 DECLARE_BITMAP(process_char_map, 256);
94 96
95 /* private to n_tty_receive_overrun (single-threaded) */ 97 /* private to n_tty_receive_overrun (single-threaded) */
@@ -105,20 +107,17 @@ struct n_tty_data {
105 /* shared by producer and consumer */ 107 /* shared by producer and consumer */
106 char *read_buf; 108 char *read_buf;
107 DECLARE_BITMAP(read_flags, N_TTY_BUF_SIZE); 109 DECLARE_BITMAP(read_flags, N_TTY_BUF_SIZE);
110 unsigned char *echo_buf;
108 111
109 int minimum_to_wake; 112 int minimum_to_wake;
110 113
111 /* consumer-published */ 114 /* consumer-published */
112 size_t read_tail; 115 size_t read_tail;
113 116
114 unsigned char *echo_buf;
115 size_t echo_head;
116 size_t echo_tail;
117 size_t echo_commit;
118
119 /* protected by output lock */ 117 /* protected by output lock */
120 unsigned int column; 118 unsigned int column;
121 unsigned int canon_column; 119 unsigned int canon_column;
120 size_t echo_tail;
122 121
123 struct mutex atomic_read_lock; 122 struct mutex atomic_read_lock;
124 struct mutex output_lock; 123 struct mutex output_lock;