Re: [RFC 3/8] slub: Add isolate() and migrate() methods

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

 



On Wed, Dec 27, 2017 at 04:06:39PM -0600, Christoph Lameter wrote:
> @@ -98,6 +98,9 @@ struct kmem_cache {
>  	gfp_t allocflags;	/* gfp flags to use on each alloc */
>  	int refcount;		/* Refcount for slab cache destroy */
>  	void (*ctor)(void *);
> +	kmem_isolate_func *isolate;
> +	kmem_migrate_func *migrate;
> +
>  	int inuse;		/* Offset to metadata */
>  	int align;		/* Alignment */
>  	int reserved;		/* Reserved bytes at the end of slabs */
[...]
> +/*
> + * kmem_cache_setup_mobility() is used to setup callbacks for a slab cache.
> + */
> +#ifdef CONFIG_SLUB
> +void kmem_cache_setup_mobility(struct kmem_cache *, kmem_isolate_func,
> +						kmem_migrate_func);
> +#else
> +static inline void kmem_cache_setup_mobility(struct kmem_cache *s,
> +	kmem_isolate_func isolate, kmem_migrate_func migrate) {}
> +#endif

Is this the right approach?  I could imagine there being more ops in
the future.  I suspect we should bite the bullet now and do:

struct kmem_cache_operations {
	void (*ctor)(void *);
	void *(*isolate)(struct kmem_cache *, void **objs, int nr);
	void (*migrate)(struct kmem_cache *, void **objs, int nr, int node,
			void *private);
};

Not sure how best to convert the existing constructor users to this scheme.
Perhaps cheat ...

- 	void (*ctor)(void *);
+	union {
+	 	void (*ctor)(void *);
+		const struct kmem_cache_operations *ops;
+	};

and use a slab flag to tell you which to use.		

> @@ -4969,6 +4987,20 @@ static ssize_t ops_show(struct kmem_cach
>  
>  	if (s->ctor)
>  		x += sprintf(buf + x, "ctor : %pS\n", s->ctor);
> +
> +	if (s->isolate) {
> +		x += sprintf(buf + x, "isolate : ");
> +		x += sprint_symbol(buf + x,
> +				(unsigned long)s->isolate);
> +		x += sprintf(buf + x, "\n");
> +	}

Here you could print the symbol of the ops vector instead of the function
pointer ...

--
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 OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]
  Powered by Linux