[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <op.1786w1rxwjvjmi@hhuan26-mobl.amr.corp.intel.com>
Date: Mon, 17 Jul 2023 20:11:15 -0500
From: "Haitao Huang" <haitao.huang@...ux.intel.com>
To: "Tejun Heo" <tj@...nel.org>
Cc: "Jarkko Sakkinen" <jarkko@...nel.org>, dave.hansen@...ux.intel.com,
linux-kernel@...r.kernel.org, linux-sgx@...r.kernel.org,
cgroups@...r.kernel.org, "Zefan Li" <lizefan.x@...edance.com>,
"Johannes Weiner" <hannes@...xchg.org>, vipinsh@...gle.com,
kai.huang@...el.com, reinette.chatre@...el.com,
zhiquan1.li@...el.com, kristen@...ux.intel.com
Subject: Re: [PATCH] cgroup/misc: Fix an overflow
Hi
On Mon, 17 Jul 2023 15:37:08 -0500, Tejun Heo <tj@...nel.org> wrote:
> Hello,
>
> On Mon, Jul 17, 2023 at 03:19:38PM -0500, Haitao Huang wrote:
>> Actually, we are using atomic_long_t for 'current' which is the same
>> width
>> as long defined by arch/compiler. So new_usage should be long to be
>> consistent?
>
> We can use atomic64_t, right? It's slower on 32bit machines but I think
> it'd
> be better to guarantee resource counter range than micro-optimizing
> charge
> operations. None of the current users are hot enough for this to matter
> and
> if somebody becomes that hot, the difference between atomic_t and
> atomic64_t
> isn't gonna matter that much. We'd need to batch allocations per-cpu and
> so
> on.
>
>> ditto for event counter. Only max is plain unsigned long but I think it
>> is
>> also OK as it only compared with 'current' without any arithmetic ops
>> involved.
>> Did I miss something here?
>
> I'm saying that it'd be better to make everything explicitly 64bit.
>
Thanks for the explanation. I think I got it and sent it as a separate
patch now just to be sure.
BR
Haitao
Powered by blists - more mailing lists