ftrace/jprobes/x86: Fix conflict between jprobes and function graph tracing
[pandora-kernel.git] / drivers / tty / tty_buffer.c
index f1a7918..4f02f9c 100644 (file)
@@ -114,11 +114,14 @@ static void __tty_buffer_flush(struct tty_struct *tty)
 {
        struct tty_buffer *thead;
 
-       while ((thead = tty->buf.head) != NULL) {
-               tty->buf.head = thead->next;
-               tty_buffer_free(tty, thead);
+       if (tty->buf.head == NULL)
+               return;
+       while ((thead = tty->buf.head->next) != NULL) {
+               tty_buffer_free(tty, tty->buf.head);
+               tty->buf.head = thead;
        }
-       tty->buf.tail = NULL;
+       WARN_ON(tty->buf.head != tty->buf.tail);
+       tty->buf.head->read = tty->buf.head->commit;
 }
 
 /**
@@ -413,8 +416,7 @@ static void flush_to_ldisc(struct work_struct *work)
        spin_lock_irqsave(&tty->buf.lock, flags);
 
        if (!test_and_set_bit(TTY_FLUSHING, &tty->flags)) {
-               struct tty_buffer *head, *tail = tty->buf.tail;
-               int seen_tail = 0;
+               struct tty_buffer *head;
                while ((head = tty->buf.head) != NULL) {
                        int count;
                        char *char_buf;
@@ -424,15 +426,6 @@ static void flush_to_ldisc(struct work_struct *work)
                        if (!count) {
                                if (head->next == NULL)
                                        break;
-                               /*
-                                 There's a possibility tty might get new buffer
-                                 added during the unlock window below. We could
-                                 end up spinning in here forever hogging the CPU
-                                 completely. To avoid this let's have a rest each
-                                 time we processed the tail buffer.
-                               */
-                               if (tail == head)
-                                       seen_tail = 1;
                                tty->buf.head = head->next;
                                tty_buffer_free(tty, head);
                                continue;
@@ -442,7 +435,7 @@ static void flush_to_ldisc(struct work_struct *work)
                           line discipline as we want to empty the queue */
                        if (test_bit(TTY_FLUSHPENDING, &tty->flags))
                                break;
-                       if (!tty->receive_room || seen_tail)
+                       if (!tty->receive_room)
                                break;
                        if (count > tty->receive_room)
                                count = tty->receive_room;