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] [thread-next>] [day] [month] [year] [list]
Date: Tue, 2 Jul 2024 12:54:19 +0530
From: Kamalesh Babulal <kamalesh.babulal@...cle.com>
To: Xiu Jianfeng <xiujianfeng@...wei.com>, tj@...nel.org,
        lizefan.x@...edance.com, hannes@...xchg.org, corbet@....net,
        haitao.huang@...ux.intel.com
Cc: cgroups@...r.kernel.org, linux-doc@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 -next] cgroup/misc: Introduce misc.peak

Hi,

On 7/2/24 6:18 AM, Xiu Jianfeng wrote:
[...]

> diff --git a/kernel/cgroup/misc.c b/kernel/cgroup/misc.c
> index 79a3717a5803..7f5180a8f461 100644
> --- a/kernel/cgroup/misc.c
> +++ b/kernel/cgroup/misc.c
> @@ -121,6 +121,17 @@ static void misc_cg_cancel_charge(enum misc_res_type type, struct misc_cg *cg,
>  		  misc_res_name[type]);
>  }
>  
> +static void misc_cg_update_watermark(struct misc_res *res, u64 new_usage)
> +{
> +	u64 old;
> +
> +	do {
> +		old = READ_ONCE(res->watermark);
> +		if (cmpxchg(&res->watermark, old, new_usage) == old)
> +			break;
> +	} while (1);
> +}
> +
>  /**
>   * misc_cg_try_charge() - Try charging the misc cgroup.
>   * @type: Misc res type to charge.
> @@ -159,6 +170,7 @@ int misc_cg_try_charge(enum misc_res_type type, struct misc_cg *cg, u64 amount)
>  			ret = -EBUSY;
>  			goto err_charge;
>  		}

you may need to re-introduce the check:
	if (new_usage > READ_ONCE(res->watermark))

without it, the res->watermark will be updated unconditionally.

> +		misc_cg_update_watermark(res, new_usage);
>  	}
>  	return 0;
>  


-- 
Thanks,
Kamalesh

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ