Util-Linux package development
 help / color / mirror / Atom feed
From: Peter Seiderer <ps.report@gmx.net>
To: Karel Zak <kzak@redhat.com>
Cc: zhenwei pi <pizhenwei@bytedance.com>, util-linux@vger.kernel.org
Subject: Re: [PATCH] irqtop: add -c/--cpus option
Date: Wed, 10 Nov 2021 19:50:51 +0100	[thread overview]
Message-ID: <20211110195051.66091d14@gmx.net> (raw)
In-Reply-To: <20211110095843.lfg6c7zxhrst42xb@ws.net.home>

Hello Karel,

On Wed, 10 Nov 2021 10:58:43 +0100, Karel Zak <kzak@redhat.com> wrote:

> On Wed, Nov 10, 2021 at 11:16:42AM +0800, zhenwei pi wrote:
> > Since a23aecc1bf("irqtop: add per-cpu stats"), irqtop always shows
> > per-cpu stats. Test on a modern AMD server with 2 socket(256 CPU),
> > irqtop shows like following:
>
> Thanks! This was on my TODO list too.
>
> > +	/* print cpus table or not by -c option */
> > +	do {
> > +		int x, y;
> > +
> > +		if (ctl->cpus == irqtop_cpus_table_disable)
> > +			break;
> > +
> > +		scols_print_table_to_string(cpus, &data);
> > +		if (ctl->cpus == irqtop_cpus_table_auto) {
> > +			/* detect window size */
> > +			getmaxyx(ctl->win, y, x);
> > +			y = y;	/* avoid build warning*/
> > +			p = strchr(data, '\n');
> > +			if (p) {
> > +				/* line is too long */
> > +				if ((p - data) > x) {
> > +					free(data);
> > +					break;
> > +				}
> > +			}
> > +		}
>
> libsmartcols provides scols_table_enable_nowrap(), this function
> forces the library trim the output. It seems more elegant.
>
> I have applied your patch with some changes
> https://github.com/util-linux/util-linux/commit/17f7caa45105f0cbf8bf9b562468fba2c5d4a549
>
> (and https://github.com/util-linux/util-linux/commit/d1732bba383a95786b5ec7bc1f4a173b644fe871
>  as I forgot update bash-completion in the first commit)

@@ -275,6 +289,7 @@ static void parse_args(	struct irqtop_ctl *ctl,
 {
 	const char *outarg = NULL;
 	static const struct option longopts[] = {
+		{"cpus", required_argument, NULL, 'c'},
 		{"delay", required_argument, NULL, 'd'},
 		{"sort", required_argument, NULL, 's'},
 		{"output", required_argument, NULL, 'o'},

s/cpus/cpu-stat/ ?

Regards,
Peter

>
> Thanks again!
>
>     Karel
>


  parent reply	other threads:[~2021-11-10 18:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-10  3:16 [PATCH] irqtop: add -c/--cpus option zhenwei pi
2021-11-10  9:58 ` Karel Zak
2021-11-10 10:24   ` zhenwei pi
2021-11-10 18:50   ` Peter Seiderer [this message]
2021-11-11 10:37     ` Karel Zak

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=20211110195051.66091d14@gmx.net \
    --to=ps.report@gmx.net \
    --cc=kzak@redhat.com \
    --cc=pizhenwei@bytedance.com \
    --cc=util-linux@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