From: Sergey Senozhatsky <senozhatsky@chromium.org>
To: Barry Song <baohua@kernel.org>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>,
Andrew Morton <akpm@linux-foundation.org>,
Hongfeng Chen <hongfengchen@xiaomi.com>,
Minchan Kim <minchan@kernel.org>,
linux-kernel@vger.kernel.org, linux-block@vger.kernel.org,
linux-mm@kvack.org
Subject: Re: [PATCH v2] zram: keep the hot statistics per CPU
Date: Sun, 6 Dec 2026 16:16:17 +0900 [thread overview]
Message-ID: <axUK_5bEhkfaJo5d@google.com> (raw)
In-Reply-To: <CAGsJ_4yBPX1f5rvrcN+OMdW_S+tcWB8A+6533pnn8PYq0HqaJg@mail.gmail.com>
On (26/12/06 14:53), Barry Song wrote:
> > ret = sysfs_emit(buf,
> > "%8llu %8llu %8llu %8lu %8ld %8llu %8lu %8llu %8llu\n",
> > orig_size << PAGE_SHIFT,
> > - (u64)atomic64_read(&zram->stats.compr_data_size),
> > + zram_stat_read(zram, ZRAM_STAT_COMPR_DATA_SIZE),
> > mem_used << PAGE_SHIFT,
> > zram->limit_pages << PAGE_SHIFT,
> > max_used << PAGE_SHIFT,
> > - (u64)atomic64_read(&zram->stats.same_pages),
> > + zram_stat_read(zram, ZRAM_STAT_SAME_PAGES),
> > atomic_long_read(&pool_stats.pages_compacted),
> > - (u64)atomic64_read(&zram->stats.huge_pages),
> > - (u64)atomic64_read(&zram->stats.huge_pages_since));
> > + zram_stat_read(zram, ZRAM_STAT_HUGE_PAGES),
> > + zram_stat_read(zram, ZRAM_STAT_HUGE_PAGES_SINCE));
> >
>
> I'm wondering if batching multiple counter updates and reads would
> help further, along the lines of what Hongfeng originally proposed
> (with the code adapted to Sergey's new implementation, of course):
>
> + stats = get_cpu_ptr(zram->pcpu_stats);
> + u64_stats_update_begin(&stats->syncp);
> + WRITE_ONCE(stats->pages_stored, stats->pages_stored + pages);
> + WRITE_ONCE(stats->compr_data_size, stats->compr_data_size + bytes);
> + WRITE_ONCE(stats->same_pages, stats->same_pages + same);
> + WRITE_ONCE(stats->huge_pages, stats->huge_pages + huge);
> + u64_stats_update_end(&stats->syncp);
> + put_cpu_ptr(zram->pcpu_stats);
I suppose on 64-bit this just saves preempt_disable/enable, as
__u64_stats_update_begin/end should be no-ops?
prev parent reply other threads:[~2026-12-06 7:16 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20261124001128.7408D1F000C6@smtp.kernel.org>
2026-12-06 5:29 ` [PATCH v2] zram: keep the hot statistics per CPU Sergey Senozhatsky
2026-12-06 5:35 ` Sergey Senozhatsky
2026-12-06 6:53 ` Barry Song
2026-12-06 7:16 ` Sergey Senozhatsky [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=axUK_5bEhkfaJo5d@google.com \
--to=senozhatsky@chromium.org \
--cc=akpm@linux-foundation.org \
--cc=baohua@kernel.org \
--cc=hongfengchen@xiaomi.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=minchan@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox