Re: [PATCH v2 2/2] zram: keep the hot statistics per CPU
From: Sergey Senozhatsky
Date: Mon Nov 23 2026 - 00:39:10 EST
On (26/11/23 14:36), Sergey Senozhatsky wrote:
[..]
> +static u64 zram_stat_read(struct zram *zram, enum zram_pcpu_stat item)
> +{
> + struct zram_pcpu_stats *stats;
> + s64 sum;
> + int cpu;
> +
> + /*
> + * Other CPUs keep updating while the values are added up: a page
> + * stored on a CPU already summed and freed on one not yet summed
> + * can make the sum negative. Sum them up again then.
> + */
> + for (;;) {
> + sum = 0;
> + for_each_possible_cpu(cpu) {
> + stats = per_cpu_ptr(zram->pcpu_stats, cpu);
> + sum += local64_read(&stats->stat[item]);
> + }
> + if (sum >= 0)
> + return sum;
> + cond_resched();
> + }
> +}
Oh god... and, of course, I forgot to quash the clamping patch...
What a muppet.