[Devel] Re: [PATCH 2/4] Switch caches notification dynamically

Christoph Lameter clameter at sgi.com
Mon Sep 17 11:32:42 PDT 2007


On Mon, 17 Sep 2007, Pavel Emelyanov wrote:

>  struct kmem_cache kmalloc_caches[PAGE_SHIFT] __cacheline_aligned;
>  EXPORT_SYMBOL(kmalloc_caches);
>  
> +static inline int is_kmalloc_cache(struct kmem_cache *s)
> +{
> +	int km_idx;
> +
> +	km_idx = s - kmalloc_caches;
> +	return km_idx >= 0 && km_idx < ARRAY_SIZE(kmalloc_caches);
> +}


Could be as simple at

	return s > kmalloc_caches && s < kmalloc_caches + 
ARRAY_SIZE(kmalloc_caches);


> +	if (buf[0] == '0') {
> +		if (any_slab_objects(s))
> +			/*
> +			 * we cannot turn this off because of the
> +			 * full slabs cannot be found in this case
> +			 */
> +			return -EBUSY;

The full slabs can be checked by subtracting the partial slabs from the 
allocated slabs in the per node structure.




More information about the Devel mailing list