From: Jeremy Fitzhardinge <jeremy@goop.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Greg KH <gregkh@suse.de>, Alan Cox <alan@lxorguk.ukuu.org.uk>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Arjan van de Ven <arjan@linux.intel.com>,
Ian Jackson <Ian.Jackson@eu.citrix.com>,
Steven Rostedt <rostedt@goodmis.org>,
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Subject: Powertop shows events/0 waking at high rate due to ptys
Date: Mon, 27 Sep 2010 10:37:36 -0700 [thread overview]
Message-ID: <4CA0D660.3010804@goop.org> (raw)
[-- Attachment #1: Type: text/plain, Size: 1086 bytes --]
Hi,
I noticed on one of my systems that powertop was showing events/0 waking
at a high rate (~2000 times/sec, HZ=1000). After a lot of tracing I
found it was due to writes pending to ptys which hadn't been read.
Specifically, in flush_to_ldisc(), these lines seem to be causing the
repeated wakeups:
if (!tty->receive_room) {
schedule_delayed_work(&tty->buf.work, 1);
break;
}
After reading the pending writes the system settles down and wakeups
drops to a normal low level.
The program provoking this was Xen's xenconsoled, which manages running
domains' consoles; the unread output was various domains console
output. This doesn't seem to be related to Xen at all: Ian Jackson put
together a small standalone program (attached) which reproduces the
problem; he reports that this wakeup behaviour is a regression compared
to a 2.6.16 Debian kernel.
Compile ptypolling with: gcc -o ptypolling ptypolling.c -g -lutil
After running ptypolling, powertop shows events/0 waking at a high
rate. ptypolling itself is blocked in a select() and is idle.
Thanks,
J
[-- Attachment #2: ptypolling.c --]
[-- Type: text/x-csrc, Size: 1175 bytes --]
/* demonstrate polling wakeup */
#include <unistd.h>
#include <pty.h>
#include <assert.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
static int master, slave;
int main(void) {
int r;
r = openpty(&master,&slave,0,0,0);
fprintf(stdout,"openpty=%d master=%d slave=%d\n", r, master, slave);
assert(!r);
r = fcntl(master, F_GETFL); assert(r>=0);
r = fcntl(master, F_SETFL, r | O_NONBLOCK);
char buf[400];
int i;
for (i=0; i<sizeof(buf)-2; i+=2)
sprintf(buf+i, "%02x", i);
buf[sizeof(buf)-2]= '\r';
buf[sizeof(buf)-1]= '\n';
fd_set writefds;
for (;;) {
FD_ZERO(&writefds);
FD_SET(master, &writefds);
fprintf(stdout,"select\n");
r= select(master+1, 0,&writefds,0, 0);
if (r==-1) {
fprintf(stdout,"select-fail %s\n", strerror(errno));
continue;
}
assert(r==1);
assert(FD_ISSET(master, &writefds));
fprintf(stdout,"write\n");
r= write(master,buf,sizeof(buf));
if (r==-1) {
fprintf(stdout,"write-fail %s\n", strerror(errno));
continue;
}
assert(r>=0 && r<=sizeof(buf));
fprintf(stdout,"wrote %d\n",r);
}
}
next reply other threads:[~2010-09-27 17:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-27 17:37 Jeremy Fitzhardinge [this message]
2010-09-27 18:15 ` Powertop shows events/0 waking at high rate due to ptys Alan Cox
2010-09-28 0:27 ` Jeremy Fitzhardinge
2010-09-30 7:19 ` Pavel Machek
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=4CA0D660.3010804@goop.org \
--to=jeremy@goop.org \
--cc=Ian.Jackson@eu.citrix.com \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=arjan@linux.intel.com \
--cc=gregkh@suse.de \
--cc=hirofumi@mail.parknet.co.jp \
--cc=linux-kernel@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=torvalds@linux-foundation.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