Re: Re: [RFC][PATCH 2/4] res_counter check usage under val

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

 



----- Original Message -----

>KAMEZAWA Hiroyuki wrote:
>> Add an interface to check usage is below "val"
>> 
>> Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx>
>> 
>>  include/linux/res_counter.h |   13 +++++++++++++
>>  1 file changed, 13 insertions(+)
>> 
>> Index: mmtom-stamp-2008-07-15-15-39/include/linux/res_counter.h
>> ===================================================================
>> --- mmtom-stamp-2008-07-15-15-39.orig/include/linux/res_counter.h
>> +++ mmtom-stamp-2008-07-15-15-39/include/linux/res_counter.h
>> @@ -191,4 +191,17 @@ static inline int res_counter_set_limit(
>>  	return ret;
>>  }
>>  
>> +static inline int res_counter_check_under_val(struct res_counter *cnt,
>> +	unsigned long long val)
>> +{
>> +	unsigned long flags;
>> +	int ret = 0;
>> +
>> +	spin_lock_irqsave(&cnt->flags, flags);
>
>Is this spilock protection *really* required? As far as I see
>from its usage it is racy itself wrt to res_counter update, so 
>this locking looks superfluous.
>
I get your point. Logically this lock is unnecessary.
(And seems this patch itself is buggy..(maybe refresh miss))

BTW, I'm sorry if I misunderstand. unsigned long long (on x86-32)
can be compared safely ? 

Thanks,
-Kame

>> +	if (cnt->usage < val)
>> +		ret = 1;
>> +	spin_unlock_irqrestore(&cnt->flags, flags);
>> +	return ret;
>> +}
>> +
>>  #endif
>> 
>> 
>

_______________________________________________
Containers mailing list
Containers@xxxxxxxxxxxxxxxxxxxxxxxxxx
https://lists.linux-foundation.org/mailman/listinfo/containers

[Index of Archives]     [Cgroups]     [Netdev]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux