Skip to content

Commit

Permalink
n_tty: Avoid false-sharing echo buffer indices
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Peter Hurley authored and Greg Kroah-Hartman committed Jul 24, 2013
1 parent 29c7c5c commit 9dfd16d
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions drivers/tty/n_tty.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ struct n_tty_data {
/* producer-published */
size_t read_head;
size_t canon_head;
size_t echo_head;
size_t echo_commit;
DECLARE_BITMAP(process_char_map, 256);

/* private to n_tty_receive_overrun (single-threaded) */
Expand All @@ -105,20 +107,17 @@ struct n_tty_data {
/* shared by producer and consumer */
char *read_buf;
DECLARE_BITMAP(read_flags, N_TTY_BUF_SIZE);
unsigned char *echo_buf;

int minimum_to_wake;

/* consumer-published */
size_t read_tail;

unsigned char *echo_buf;
size_t echo_head;
size_t echo_tail;
size_t echo_commit;

/* protected by output lock */
unsigned int column;
unsigned int canon_column;
size_t echo_tail;

struct mutex atomic_read_lock;
struct mutex output_lock;
Expand Down

0 comments on commit 9dfd16d

Please sign in to comment.