Re: [PATCH 1/2] cgroup: add cpu.stat_percpu

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

 



On Fri, Jan 07, 2022 at 03:41:37PM -0800, Josh Don wrote:

> +	seq_puts(seq, "usage_usec");
> +	for_each_possible_cpu(cpu) {
> +		cached_bstat = per_cpu_ptr(&cached_percpu_stats, cpu);
> +		val = cached_bstat->cputime.sum_exec_runtime;
> +		do_div(val, NSEC_PER_USEC);
> +		seq_printf(seq, " %llu", val);
> +	}
> +	seq_puts(seq, "\n");
> +
> +	seq_puts(seq, "user_usec");
> +	for_each_possible_cpu(cpu) {
> +		cached_bstat = per_cpu_ptr(&cached_percpu_stats, cpu);
> +		val = cached_bstat->cputime.utime;
> +		do_div(val, NSEC_PER_USEC);
> +		seq_printf(seq, " %llu", val);
> +	}
> +	seq_puts(seq, "\n");
> +
> +	seq_puts(seq, "system_usec");
> +	for_each_possible_cpu(cpu) {
> +		cached_bstat = per_cpu_ptr(&cached_percpu_stats, cpu);
> +		val = cached_bstat->cputime.stime;
> +		do_div(val, NSEC_PER_USEC);
> +		seq_printf(seq, " %llu", val);
> +	}
> +	seq_puts(seq, "\n");

This is an anti-pattern; given enough CPUs (easy) this will trivially
overflow the 1 page seq buffer.

People are already struggling to fix existing ABI, lets not make the
problem worse.



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [Monitors]

  Powered by Linux