From: Tejun Heo <tj@kernel.org>
To: Xiu Jianfeng <xiujianfeng@huawei.com>
Cc: lizefan.x@bytedance.com, hannes@cmpxchg.org, corbet@lwn.net,
kamalesh.babulal@oracle.com, haitao.huang@linux.intel.com,
cgroups@vger.kernel.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 -next] cgroup/misc: Introduce misc.peak
Date: Tue, 2 Jul 2024 06:44:41 -1000 [thread overview]
Message-ID: <ZoQueSY_8NYcApfi@slm.duckdns.org> (raw)
In-Reply-To: <20240702075718.2657635-1-xiujianfeng@huawei.com>
Hello,
On Tue, Jul 02, 2024 at 07:57:18AM +0000, Xiu Jianfeng wrote:
> struct misc_res {
> u64 max;
> + u64 watermark;
atomic64_t is probably better here.
> atomic64_t usage;
> atomic64_t events;
> };
...
> +static void misc_cg_update_watermark(struct misc_res *res, u64 new_usage)
> +{
> + u64 old;
> +
How about just while (true)?
> + do {
> + old = READ_ONCE(res->watermark);
here, you can use atomic64_read().
> + if (new_usage <= old)
> + break;
> + if (cmpxchg(&res->watermark, old, new_usage) == old)
and atomic64_cmpxchg().
> + break;
> + } while (1);
> +}
Thanks.
--
tejun
prev parent reply other threads:[~2024-07-02 16:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-02 7:57 [PATCH v4 -next] cgroup/misc: Introduce misc.peak Xiu Jianfeng
2024-07-02 8:41 ` Kamalesh Babulal
2024-07-02 16:44 ` Tejun Heo [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=ZoQueSY_8NYcApfi@slm.duckdns.org \
--to=tj@kernel.org \
--cc=cgroups@vger.kernel.org \
--cc=corbet@lwn.net \
--cc=haitao.huang@linux.intel.com \
--cc=hannes@cmpxchg.org \
--cc=kamalesh.babulal@oracle.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lizefan.x@bytedance.com \
--cc=xiujianfeng@huawei.com \
/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