lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Tue, 2 Jul 2024 06:44:41 -1000
From: Tejun Heo <tj@...nel.org>
To: Xiu Jianfeng <xiujianfeng@...wei.com>
Cc: lizefan.x@...edance.com, hannes@...xchg.org, corbet@....net,
	kamalesh.babulal@...cle.com, haitao.huang@...ux.intel.com,
	cgroups@...r.kernel.org, linux-doc@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH v4 -next] cgroup/misc: Introduce misc.peak

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ