Linux Documentation
 help / color / mirror / Atom feed
From: Kamalesh Babulal <kamalesh.babulal@oracle.com>
To: Xiu Jianfeng <xiujianfeng@huawei.com>,
	tj@kernel.org, lizefan.x@bytedance.com, hannes@cmpxchg.org,
	corbet@lwn.net, haitao.huang@linux.intel.com
Cc: cgroups@vger.kernel.org, linux-doc@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 -next] cgroup/misc: Introduce misc.peak
Date: Tue, 2 Jul 2024 12:54:19 +0530	[thread overview]
Message-ID: <8bd9b2a6-e1c2-423c-9cea-45b14763e251@oracle.com> (raw)
In-Reply-To: <20240702004820.2645868-1-xiujianfeng@huawei.com>

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

  reply	other threads:[~2024-07-02  7:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-02  0:48 [PATCH v3 -next] cgroup/misc: Introduce misc.peak Xiu Jianfeng
2024-07-02  7:24 ` Kamalesh Babulal [this message]
2024-07-02  8:00   ` xiujianfeng

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=8bd9b2a6-e1c2-423c-9cea-45b14763e251@oracle.com \
    --to=kamalesh.babulal@oracle.com \
    --cc=cgroups@vger.kernel.org \
    --cc=corbet@lwn.net \
    --cc=haitao.huang@linux.intel.com \
    --cc=hannes@cmpxchg.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizefan.x@bytedance.com \
    --cc=tj@kernel.org \
    --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