Re: [PATCH v3 2/2] zram: keep the hot statistics per CPU

From: Sergey Senozhatsky

Date: Sat Dec 05 2026 - 22:55:42 EST


On (26/12/04 11:56), Hongfeng Chen wrote:
[..]
> @@ -106,7 +106,7 @@ static void zram_stat_add(struct zram *zram, enum zram_pcpu_stat item,
> {
> struct zram_pcpu_stats *stats = get_cpu_ptr(zram->pcpu_stats);
>
> - local64_add(amount, &stats->stat[item]);
> + WRITE_ONCE(stats->stat[item], stats->stat[item] + amount);
> put_cpu_ptr(zram->pcpu_stats);
> }
>
> @@ -115,7 +115,7 @@ static void zram_stat_sub(struct zram *zram, enum zram_pcpu_stat item,
> {
> struct zram_pcpu_stats *stats = get_cpu_ptr(zram->pcpu_stats);
>
> - local64_sub(amount, &stats->stat[item]);
> + WRITE_ONCE(stats->stat[item], stats->stat[item] - amount);
> put_cpu_ptr(zram->pcpu_stats);

How about __local64_add() / __local64_sub()?

> struct zram_pcpu_stats {
> - local64_t stat[NR_ZRAM_PCPU_STATS];
> + s64 stat[NR_ZRAM_PCPU_STATS];
> };

Is {WRITE, READ}_ONCE of s64 is going to work on 32-bit arch?