From: "Boy Wu (吳勃誼)" <Boy.Wu@mediatek.com>
To: "tj@kernel.org" <tj@kernel.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"boris@bur.io" <boris@bur.io>,
"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
"linux-mediatek@lists.infradead.org"
<linux-mediatek@lists.infradead.org>,
"cgroups@vger.kernel.org" <cgroups@vger.kernel.org>,
"axboe@kernel.dk" <axboe@kernel.dk>,
"Iverlin Wang (王苳霖)" <Iverlin.Wang@mediatek.com>,
"josef@toxicpanda.com" <josef@toxicpanda.com>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>,
"angelogioacchino.delregno@collabora.com"
<angelogioacchino.delregno@collabora.com>
Subject: Re: [PATCH v4] blk-cgroup: Replace u64 sync with spinlock for iostat
Date: Fri, 9 Aug 2024 07:50:41 +0000 [thread overview]
Message-ID: <4f06abd438009266997bd41901c05c9139e19472.camel@mediatek.com> (raw)
In-Reply-To: <ZqlD5WXx39E8xVnA@slm.duckdns.org>
On Tue, 2024-07-30 at 09:49 -1000, tj@kernel.org wrote:
>
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
> Hello, Boy.
>
> On Fri, Jul 26, 2024 at 03:43:27AM +0000, Boy Wu (吳勃誼) wrote:
> ...
> > The use of a spinlock with u64 sync is suggested in
> > include/linux/u64_stats_sync.h:33.
> >
> > * Usage :
> > *
> > * Stats producer (writer) should use following template granted it
> > already got
> > * an exclusive access to counters (a lock is already taken, or per
> cpu
> > * data is used [in a non preemptable context])
> > *
> > * spin_lock_bh(...) or other synchronization to get exclusive
> access
> > * ...
> > * u64_stats_update_begin(&stats->syncp);
> > * u64_stats_add(&stats->bytes64, len); // non atomic operation
> > * u64_stats_inc(&stats->packets64); // non atomic operation
> > * u64_stats_update_end(&stats->syncp);
> >
> > Is this a incorrect statment?
>
> That's not incorrect and it'd make sense if we really want to use
> u64_sync -
> e.g. the reader is hot path. Here, just a spinlock would be simpler
> and do
> fine.
>
> Thanks.
>
> --
> tejun
u64_sync with spin lock has the benefit of locking only when writing
iostat, but replacing u64_sync with spin lock will lock not only when
writing iostat but also when reading iostat. Does it have enough
benefit to replace u64_sync and add the cost of locking when reading
iostat?
--
Boy.Wu
prev parent reply other threads:[~2024-08-09 7:50 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-18 8:41 [PATCH v4] blk-cgroup: Replace u64 sync with spinlock for iostat boy.wu
2024-07-18 21:15 ` Tejun Heo
2024-07-19 1:47 ` Boy Wu (吳勃誼)
2024-07-19 17:31 ` tj
2024-07-26 3:43 ` Boy Wu (吳勃誼)
2024-07-30 19:49 ` tj
2024-08-09 7:50 ` Boy Wu (吳勃誼) [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=4f06abd438009266997bd41901c05c9139e19472.camel@mediatek.com \
--to=boy.wu@mediatek.com \
--cc=Iverlin.Wang@mediatek.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=axboe@kernel.dk \
--cc=boris@bur.io \
--cc=cgroups@vger.kernel.org \
--cc=josef@toxicpanda.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=tj@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