Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1493176

Re: [PATCH 7/8] mm/swap: Add cache for swap slots allocation

From "Hillf Danton" <hillf.zj@alibaba-inc.com>
Newsgroups linux.kernel
Subject Re: [PATCH 7/8] mm/swap: Add cache for swap slots allocation
Date 2016-09-29 09:20 +0200
Message-ID <smDNn-Ut-1@gated-at.bofh.it> (permalink)
References <sm4mB-3UT-15@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Wednesday, September 28, 2016 1:19 AM Tim Chen wrote
[...]
> +
> +static int alloc_swap_slot_cache(int cpu)
> +{
> +	struct swap_slots_cache *cache;
> +
> +	cache = &per_cpu(swp_slots, cpu);
> +	mutex_init(&cache->alloc_lock);
> +	spin_lock_init(&cache->free_lock);
> +	cache->nr = 0;
> +	cache->cur = 0;
> +	cache->n_ret = 0;
> +	cache->slots = vzalloc(sizeof(swp_entry_t) * SWAP_SLOTS_CACHE_SIZE);
> +	if (!cache->slots) {
> +		swap_slot_cache_enabled = false;
> +		return -ENOMEM;
> +	}
> +	cache->slots_ret = vzalloc(sizeof(swp_entry_t) * SWAP_SLOTS_CACHE_SIZE);
> +	if (!cache->slots_ret) {
> +		vfree(cache->slots);
> +		swap_slot_cache_enabled = false;
> +		return -ENOMEM;
> +	}
> +	return 0;
> +}
> +
[...]
> +
> +static void free_slot_cache(int cpu)
> +{
> +	struct swap_slots_cache *cache;
> +
> +	mutex_lock(&swap_slots_cache_mutex);
> +	drain_slots_cache_cpu(cpu, SLOTS_CACHE | SLOTS_CACHE_RET);
> +	cache = &per_cpu(swp_slots, cpu);
> +	cache->nr = 0;
> +	cache->cur = 0;
> +	cache->n_ret = 0;
> +	vfree(cache->slots);

Also free cache->slots_ret?
Or fold the relevant two allocations into one?
 
> +	mutex_unlock(&swap_slots_cache_mutex);
> +}
> 
thanks
Hillf

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 7/8] mm/swap: Add cache for swap slots allocation Tim Chen <tim.c.chen@linux.intel.com> - 2016-09-27 19:30 +0200
  Re: [PATCH 7/8] mm/swap: Add cache for swap slots allocation "Hillf Danton" <hillf.zj@alibaba-inc.com> - 2016-09-29 09:20 +0200
    Re: [PATCH 7/8] mm/swap: Add cache for swap slots allocation Tim Chen <tim.c.chen@linux.intel.com> - 2016-09-29 19:00 +0200

csiph-web