Re: [PATCH] irqtop: add -c/--cpus option

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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)

Thanks again!

    Karel

-- 
 Karel Zak  <kzak@xxxxxxxxxx>
 http://karelzak.blogspot.com




[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux