Re: [PATCH v4 -next] cgroup/misc: Introduce misc.peak

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux