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

From: Sergey Senozhatsky

Date: Sun Dec 06 2026 - 01:22:34 EST


On (26/12/06 14:19), Barry Song wrote:
> > > diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
> > > index cadce71c2d2a..820e693f0593 100644
> > > --- a/drivers/block/zram/zram_drv.c
> > > +++ b/drivers/block/zram/zram_drv.c
> > > @@ -106,7 +106,9 @@ 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]);
> > > + u64_stats_update_begin(&stats->syncp);
> > > + __local64_add(amount, &stats->stat[item]);
> > > + u64_stats_update_end(&stats->syncp);
> >
> > I did a combo of syncp and s64 [1]
>
> Nice, thanks!
> That's exactly the approach Hongfeng proposed in his original RFC:

Yes, kudos to Hongfeng.