Re: [PATCH v2 5/6] memcg: introduce swap_cgroup_init()/swap_cgroup_free()

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

 



On 01/29/2013 05:57 PM, Lord Glauber Costa of Sealand wrote:
> On 01/28/2013 02:54 PM, Jeff Liu wrote:
>> Introduce swap_cgroup_init()/swap_cgroup_free() to allocate buffers when creating the first
>> non-root memcg and deallocate buffers on the last non-root memcg is gone.
>>
>> Signed-off-by: Jie Liu <jeff.liu@xxxxxxxxxx>
>> CC: Glauber Costa <glommer@xxxxxxxxxxxxx>
>> CC: Michal Hocko <mhocko@xxxxxxx>
>> CC: Kamezawa Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx>
>> CC: Johannes Weiner <hannes@xxxxxxxxxxx>
>> CC: Mel Gorman <mgorman@xxxxxxx>
>> CC: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
>> CC: Sha Zhengju <handai.szj@xxxxxxxxxx>
>>
> 
> Looks sane.
> 
> Reviewed-by: Glauber Costa <glommer@xxxxxxxxxxxxx>
> 
> Only:
> 
>>  #endif /* !__GENERATING_BOUNDS_H */
>> diff --git a/mm/page_cgroup.c b/mm/page_cgroup.c
>> index 189fbf5..0ebd127 100644
>> --- a/mm/page_cgroup.c
>> +++ b/mm/page_cgroup.c
>> @@ -362,14 +362,28 @@ static int swap_cgroup_prepare(int type)
>>  	unsigned long idx, max;
>>  
>>  	ctrl = &swap_cgroup_ctrl[type];
>> +	if (!ctrl->length) {
>> +		/*
>> +		 * Bypass the buffer allocation if the corresponding swap
>> +		 * partition/file was turned off.
>> +		 */
>> +		pr_debug("couldn't allocate swap_cgroup on a disabled swap "
>> +			 "partition or file, index: %d\n", type);
>> +		return 0;
>> +	}
>> +
>>  	ctrl->map = vzalloc(ctrl->length * sizeof(void *));
>> -	if (!ctrl->map)
>> +	if (!ctrl->map) {
>> +		ctrl->length = 0;
> 
> Considering moving this assignment somewhere in the exit path in the
> labels region.
Nice point.  Both "ctrl->length = 0" statements in this function should be
moved down to the exit path of "nomem:" label.

Thanks,
-Jeff
 

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxx.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>


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