aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/n_tty.c
diff options
context:
space:
mode:
authorPeter Hurley <peter@hurleysoftware.com>2013-06-15 09:14:30 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-07-23 19:43:02 -0400
commitfb7aa03db605e4f0b9a62cd4c77177c2596edd95 (patch)
tree503946923a498b938aa849457310ceedaefbd806 /drivers/tty/n_tty.c
parentf95499c3030fe1bfad57745f2db1959c5b43dca8 (diff)
n_tty: Separate buffer indices to prevent cache-line sharing
If the read buffer indices are in the same cache-line, cpus will contended over the cache-line (so called 'false sharing'). Separate the producer-published fields from the consumer-published fields; document the locks relevant to each field. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/n_tty.c')
-rw-r--r--drivers/tty/n_tty.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
index a6eea30d0911..d0c8805d8131 100644
--- a/drivers/tty/n_tty.c
+++ b/drivers/tty/n_tty.c
@@ -82,29 +82,38 @@
82#endif 82#endif
83 83
84struct n_tty_data { 84struct n_tty_data {
85 unsigned int column; 85 /* producer-published */
86 size_t read_head;
87 size_t canon_head;
88 DECLARE_BITMAP(process_char_map, 256);
89
90 /* private to n_tty_receive_overrun (single-threaded) */
86 unsigned long overrun_time; 91 unsigned long overrun_time;
87 int num_overrun; 92 int num_overrun;
88 93
89 /* non-atomic */ 94 /* non-atomic */
90 bool no_room; 95 bool no_room;
91 96
97 /* must hold exclusive termios_rwsem to reset these */
92 unsigned char lnext:1, erasing:1, raw:1, real_raw:1, icanon:1; 98 unsigned char lnext:1, erasing:1, raw:1, real_raw:1, icanon:1;
93 unsigned char echo_overrun:1; 99 unsigned char echo_overrun:1;
94 100
95 DECLARE_BITMAP(process_char_map, 256); 101 /* shared by producer and consumer */
102 char *read_buf;
96 DECLARE_BITMAP(read_flags, N_TTY_BUF_SIZE); 103 DECLARE_BITMAP(read_flags, N_TTY_BUF_SIZE);
97 104
98 char *read_buf;
99 size_t read_head;
100 size_t read_tail;
101 int minimum_to_wake; 105 int minimum_to_wake;
102 106
107 /* consumer-published */
108 size_t read_tail;
109
110 /* protected by echo_lock */
103 unsigned char *echo_buf; 111 unsigned char *echo_buf;
104 unsigned int echo_pos; 112 unsigned int echo_pos;
105 unsigned int echo_cnt; 113 unsigned int echo_cnt;
106 114
107 size_t canon_head; 115 /* protected by output lock */
116 unsigned int column;
108 unsigned int canon_column; 117 unsigned int canon_column;
109 118
110 struct mutex atomic_read_lock; 119 struct mutex atomic_read_lock;