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

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

 




On 2024/7/2 15:24, Kamalesh Babulal wrote:
> 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.

Thanks for your review, will fix it.

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




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [Monitors]

  Powered by Linux