public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Michael Tokarev <mjt@tls.msk.ru>
To: Professor Berkley Shands <berkley@seas.wustl.edu>
Cc: linux-kernel@vger.kernel.org
Subject: Re: 3.0.18 tcsetattr on fd 0 when detached freezes system (RCU timeouts) (Centos 6.1 x86_64)
Date: Sat, 28 Jan 2012 10:55:29 +0400	[thread overview]
Message-ID: <4F239BE1.4090106@msgid.tls.msk.ru> (raw)
In-Reply-To: <4F234498.5070800@seas.wustl.edu>

On 28.01.2012 04:43, Professor Berkley Shands wrote:
> 
> typedef struct
> {
>    struct termios term;
> } XKEY_DATA;
> 
> typedef XKEY_DATA *xkeyhandle;
> 
> static inline xkeyhandle xkeystart()
> {
> 
>    // Turn off echo.
>    struct termios temp;
>    err = tcgetattr(0, &temp);
>    if (err)
>    {
>       perror("tcgetattr failure");
>    }
> 
>    XKEY_DATA *handle = new XKEY_DATA;
>    handle->term = temp;
> 
>    temp.c_lflag &= ~ECHO;
>    temp.c_lflag &= ~ICANON;
> 
>    err = tcsetattr(0, TCSANOW, &temp);        // this line causes the kernel to get very sick
>    if (err)
>    {
>       perror("tcsetattr failure");
>    }
> 
>    return handle;
> 
> }
> 
> The above code, called from main() will produce an error from tcsh:
> 
> /home/bshands> ./a.out > /dev/null &
> [1] 3635
> /home/bshands>
> /home/bshands>
> [1]  + Suspended (tty output) ./a.out > /dev/null
> /home/bshands>
> 
> this does not appear on the redhat kernel, nor 2.6.32.43, but appeared infrequently in 3.0.9.
> in 3.0.18, doing this in the background does *EVIL* things.
> 
> ssh system "./a.out > /dev/null &" &
> 
> Now when the code reaches the tcsetattr() the system quits scheduling tasks.
> top shows 100%sy on 4/12 cores, kernel threads blocked, stalled tasks count increasing.

I used the following code:

=======================================
#include <termios.h>
#include <stdio.h>

int main() {
   struct termios temp;

   if (tcgetattr(0, &temp) != 0)
      perror("tcgetattr failure");

   temp.c_lflag &= ~ECHO;
   temp.c_lflag &= ~ICANON;

   if (tcsetattr(0, TCSANOW, &temp) != 0) // this line causes the kernel to get very sick
      perror("tcsetattr failure");

   return 0;
}
=======================================


But can't reproduce what you're observing.  It prints

 tcgetattr failure: Inappropriate ioctl for device
 tcsetattr failure: Inappropriate ioctl for device

and does not do any evil things.  I tried it on 3.0.18
on x86 on 32bits and 64bits.

What I'm doing wrong?

Thanks,

/mjt

  reply	other threads:[~2012-01-28  6:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-28  0:43 3.0.18 tcsetattr on fd 0 when detached freezes system (RCU timeouts) (Centos 6.1 x86_64) Professor Berkley Shands
2012-01-28  6:55 ` Michael Tokarev [this message]
     [not found]   ` <4F283B40.1070200@seas.wustl.edu>
2012-02-02  8:36     ` Michael Tokarev
2012-02-02 22:09       ` Professor Berkley Shands

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4F239BE1.4090106@msgid.tls.msk.ru \
    --to=mjt@tls.msk.ru \
    --cc=berkley@seas.wustl.edu \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox