linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm, slab: Move memcg_cache_params structure to mm/slab.h
@ 2019-07-18 18:08 Waiman Long
  2019-07-19  7:05 ` Michal Hocko
  2019-07-21  5:31 ` David Rientjes
  0 siblings, 2 replies; 3+ messages in thread
From: Waiman Long @ 2019-07-18 18:08 UTC (permalink / raw)
  To: Christoph Lameter, Pekka Enberg, David Rientjes, Joonsoo Kim,
	Andrew Morton
  Cc: linux-mm, linux-kernel, Michal Hocko, Roman Gushchin,
	Johannes Weiner, Shakeel Butt, Vladimir Davydov, Waiman Long

The memcg_cache_params structure is only embedded into the kmem_cache
of slab and slub allocators as defined in slab_def.h and slub_def.h
and used internally by mm code. There is no needed to expose it in
a public header. So move it from include/linux/slab.h to mm/slab.h.
It is just a refactoring patch with no code change.

In fact both the slub_def.h and slab_def.h should be moved into the mm
directory as well, but that will probably cause many merge conflicts.

Signed-off-by: Waiman Long <longman@redhat.com>
---
 include/linux/slab.h | 62 -------------------------------------------
 mm/slab.h            | 63 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 63 insertions(+), 62 deletions(-)

diff --git a/include/linux/slab.h b/include/linux/slab.h
index 56c9c7eed34e..ab2b98ad76e1 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -595,68 +595,6 @@ static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
 	return __kmalloc_node(size, flags, node);
 }
 
-struct memcg_cache_array {
-	struct rcu_head rcu;
-	struct kmem_cache *entries[0];
-};
-
-/*
- * This is the main placeholder for memcg-related information in kmem caches.
- * Both the root cache and the child caches will have it. For the root cache,
- * this will hold a dynamically allocated array large enough to hold
- * information about the currently limited memcgs in the system. To allow the
- * array to be accessed without taking any locks, on relocation we free the old
- * version only after a grace period.
- *
- * Root and child caches hold different metadata.
- *
- * @root_cache:	Common to root and child caches.  NULL for root, pointer to
- *		the root cache for children.
- *
- * The following fields are specific to root caches.
- *
- * @memcg_caches: kmemcg ID indexed table of child caches.  This table is
- *		used to index child cachces during allocation and cleared
- *		early during shutdown.
- *
- * @root_caches_node: List node for slab_root_caches list.
- *
- * @children:	List of all child caches.  While the child caches are also
- *		reachable through @memcg_caches, a child cache remains on
- *		this list until it is actually destroyed.
- *
- * The following fields are specific to child caches.
- *
- * @memcg:	Pointer to the memcg this cache belongs to.
- *
- * @children_node: List node for @root_cache->children list.
- *
- * @kmem_caches_node: List node for @memcg->kmem_caches list.
- */
-struct memcg_cache_params {
-	struct kmem_cache *root_cache;
-	union {
-		struct {
-			struct memcg_cache_array __rcu *memcg_caches;
-			struct list_head __root_caches_node;
-			struct list_head children;
-			bool dying;
-		};
-		struct {
-			struct mem_cgroup *memcg;
-			struct list_head children_node;
-			struct list_head kmem_caches_node;
-			struct percpu_ref refcnt;
-
-			void (*work_fn)(struct kmem_cache *);
-			union {
-				struct rcu_head rcu_head;
-				struct work_struct work;
-			};
-		};
-	};
-};
-
 int memcg_update_all_caches(int num_memcgs);
 
 /**
diff --git a/mm/slab.h b/mm/slab.h
index 5bf615cb3f99..68e455f2b698 100644
--- a/mm/slab.h
+++ b/mm/slab.h
@@ -30,6 +30,69 @@ struct kmem_cache {
 	struct list_head list;	/* List of all slab caches on the system */
 };
 
+#else /* !CONFIG_SLOB */
+
+struct memcg_cache_array {
+	struct rcu_head rcu;
+	struct kmem_cache *entries[0];
+};
+
+/*
+ * This is the main placeholder for memcg-related information in kmem caches.
+ * Both the root cache and the child caches will have it. For the root cache,
+ * this will hold a dynamically allocated array large enough to hold
+ * information about the currently limited memcgs in the system. To allow the
+ * array to be accessed without taking any locks, on relocation we free the old
+ * version only after a grace period.
+ *
+ * Root and child caches hold different metadata.
+ *
+ * @root_cache:	Common to root and child caches.  NULL for root, pointer to
+ *		the root cache for children.
+ *
+ * The following fields are specific to root caches.
+ *
+ * @memcg_caches: kmemcg ID indexed table of child caches.  This table is
+ *		used to index child cachces during allocation and cleared
+ *		early during shutdown.
+ *
+ * @root_caches_node: List node for slab_root_caches list.
+ *
+ * @children:	List of all child caches.  While the child caches are also
+ *		reachable through @memcg_caches, a child cache remains on
+ *		this list until it is actually destroyed.
+ *
+ * The following fields are specific to child caches.
+ *
+ * @memcg:	Pointer to the memcg this cache belongs to.
+ *
+ * @children_node: List node for @root_cache->children list.
+ *
+ * @kmem_caches_node: List node for @memcg->kmem_caches list.
+ */
+struct memcg_cache_params {
+	struct kmem_cache *root_cache;
+	union {
+		struct {
+			struct memcg_cache_array __rcu *memcg_caches;
+			struct list_head __root_caches_node;
+			struct list_head children;
+			bool dying;
+		};
+		struct {
+			struct mem_cgroup *memcg;
+			struct list_head children_node;
+			struct list_head kmem_caches_node;
+			struct percpu_ref refcnt;
+
+			void (*work_fn)(struct kmem_cache *);
+			union {
+				struct rcu_head rcu_head;
+				struct work_struct work;
+			};
+		};
+	};
+};
 #endif /* CONFIG_SLOB */
 
 #ifdef CONFIG_SLAB
-- 
2.18.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] mm, slab: Move memcg_cache_params structure to mm/slab.h
  2019-07-18 18:08 [PATCH] mm, slab: Move memcg_cache_params structure to mm/slab.h Waiman Long
@ 2019-07-19  7:05 ` Michal Hocko
  2019-07-21  5:31 ` David Rientjes
  1 sibling, 0 replies; 3+ messages in thread
From: Michal Hocko @ 2019-07-19  7:05 UTC (permalink / raw)
  To: Waiman Long
  Cc: Christoph Lameter, Pekka Enberg, David Rientjes, Joonsoo Kim,
	Andrew Morton, linux-mm, linux-kernel, Roman Gushchin,
	Johannes Weiner, Shakeel Butt, Vladimir Davydov

On Thu 18-07-19 14:08:27, Waiman Long wrote:
> The memcg_cache_params structure is only embedded into the kmem_cache
> of slab and slub allocators as defined in slab_def.h and slub_def.h
> and used internally by mm code. There is no needed to expose it in
> a public header. So move it from include/linux/slab.h to mm/slab.h.
> It is just a refactoring patch with no code change.

No objection from me. As long as this survives all weird config
combinations and implicit header files dependencies...

> In fact both the slub_def.h and slab_def.h should be moved into the mm
> directory as well, but that will probably cause many merge conflicts.
> 
> Signed-off-by: Waiman Long <longman@redhat.com>
> ---
>  include/linux/slab.h | 62 -------------------------------------------
>  mm/slab.h            | 63 ++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 63 insertions(+), 62 deletions(-)
> 
> diff --git a/include/linux/slab.h b/include/linux/slab.h
> index 56c9c7eed34e..ab2b98ad76e1 100644
> --- a/include/linux/slab.h
> +++ b/include/linux/slab.h
> @@ -595,68 +595,6 @@ static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
>  	return __kmalloc_node(size, flags, node);
>  }
>  
> -struct memcg_cache_array {
> -	struct rcu_head rcu;
> -	struct kmem_cache *entries[0];
> -};
> -
> -/*
> - * This is the main placeholder for memcg-related information in kmem caches.
> - * Both the root cache and the child caches will have it. For the root cache,
> - * this will hold a dynamically allocated array large enough to hold
> - * information about the currently limited memcgs in the system. To allow the
> - * array to be accessed without taking any locks, on relocation we free the old
> - * version only after a grace period.
> - *
> - * Root and child caches hold different metadata.
> - *
> - * @root_cache:	Common to root and child caches.  NULL for root, pointer to
> - *		the root cache for children.
> - *
> - * The following fields are specific to root caches.
> - *
> - * @memcg_caches: kmemcg ID indexed table of child caches.  This table is
> - *		used to index child cachces during allocation and cleared
> - *		early during shutdown.
> - *
> - * @root_caches_node: List node for slab_root_caches list.
> - *
> - * @children:	List of all child caches.  While the child caches are also
> - *		reachable through @memcg_caches, a child cache remains on
> - *		this list until it is actually destroyed.
> - *
> - * The following fields are specific to child caches.
> - *
> - * @memcg:	Pointer to the memcg this cache belongs to.
> - *
> - * @children_node: List node for @root_cache->children list.
> - *
> - * @kmem_caches_node: List node for @memcg->kmem_caches list.
> - */
> -struct memcg_cache_params {
> -	struct kmem_cache *root_cache;
> -	union {
> -		struct {
> -			struct memcg_cache_array __rcu *memcg_caches;
> -			struct list_head __root_caches_node;
> -			struct list_head children;
> -			bool dying;
> -		};
> -		struct {
> -			struct mem_cgroup *memcg;
> -			struct list_head children_node;
> -			struct list_head kmem_caches_node;
> -			struct percpu_ref refcnt;
> -
> -			void (*work_fn)(struct kmem_cache *);
> -			union {
> -				struct rcu_head rcu_head;
> -				struct work_struct work;
> -			};
> -		};
> -	};
> -};
> -
>  int memcg_update_all_caches(int num_memcgs);
>  
>  /**
> diff --git a/mm/slab.h b/mm/slab.h
> index 5bf615cb3f99..68e455f2b698 100644
> --- a/mm/slab.h
> +++ b/mm/slab.h
> @@ -30,6 +30,69 @@ struct kmem_cache {
>  	struct list_head list;	/* List of all slab caches on the system */
>  };
>  
> +#else /* !CONFIG_SLOB */
> +
> +struct memcg_cache_array {
> +	struct rcu_head rcu;
> +	struct kmem_cache *entries[0];
> +};
> +
> +/*
> + * This is the main placeholder for memcg-related information in kmem caches.
> + * Both the root cache and the child caches will have it. For the root cache,
> + * this will hold a dynamically allocated array large enough to hold
> + * information about the currently limited memcgs in the system. To allow the
> + * array to be accessed without taking any locks, on relocation we free the old
> + * version only after a grace period.
> + *
> + * Root and child caches hold different metadata.
> + *
> + * @root_cache:	Common to root and child caches.  NULL for root, pointer to
> + *		the root cache for children.
> + *
> + * The following fields are specific to root caches.
> + *
> + * @memcg_caches: kmemcg ID indexed table of child caches.  This table is
> + *		used to index child cachces during allocation and cleared
> + *		early during shutdown.
> + *
> + * @root_caches_node: List node for slab_root_caches list.
> + *
> + * @children:	List of all child caches.  While the child caches are also
> + *		reachable through @memcg_caches, a child cache remains on
> + *		this list until it is actually destroyed.
> + *
> + * The following fields are specific to child caches.
> + *
> + * @memcg:	Pointer to the memcg this cache belongs to.
> + *
> + * @children_node: List node for @root_cache->children list.
> + *
> + * @kmem_caches_node: List node for @memcg->kmem_caches list.
> + */
> +struct memcg_cache_params {
> +	struct kmem_cache *root_cache;
> +	union {
> +		struct {
> +			struct memcg_cache_array __rcu *memcg_caches;
> +			struct list_head __root_caches_node;
> +			struct list_head children;
> +			bool dying;
> +		};
> +		struct {
> +			struct mem_cgroup *memcg;
> +			struct list_head children_node;
> +			struct list_head kmem_caches_node;
> +			struct percpu_ref refcnt;
> +
> +			void (*work_fn)(struct kmem_cache *);
> +			union {
> +				struct rcu_head rcu_head;
> +				struct work_struct work;
> +			};
> +		};
> +	};
> +};
>  #endif /* CONFIG_SLOB */
>  
>  #ifdef CONFIG_SLAB
> -- 
> 2.18.1

-- 
Michal Hocko
SUSE Labs


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mm, slab: Move memcg_cache_params structure to mm/slab.h
  2019-07-18 18:08 [PATCH] mm, slab: Move memcg_cache_params structure to mm/slab.h Waiman Long
  2019-07-19  7:05 ` Michal Hocko
@ 2019-07-21  5:31 ` David Rientjes
  1 sibling, 0 replies; 3+ messages in thread
From: David Rientjes @ 2019-07-21  5:31 UTC (permalink / raw)
  To: Waiman Long
  Cc: Christoph Lameter, Pekka Enberg, Joonsoo Kim, Andrew Morton,
	linux-mm, linux-kernel, Michal Hocko, Roman Gushchin,
	Johannes Weiner, Shakeel Butt, Vladimir Davydov

On Thu, 18 Jul 2019, Waiman Long wrote:

> The memcg_cache_params structure is only embedded into the kmem_cache
> of slab and slub allocators as defined in slab_def.h and slub_def.h
> and used internally by mm code. There is no needed to expose it in
> a public header. So move it from include/linux/slab.h to mm/slab.h.
> It is just a refactoring patch with no code change.
> 
> In fact both the slub_def.h and slab_def.h should be moved into the mm
> directory as well, but that will probably cause many merge conflicts.
> 
> Signed-off-by: Waiman Long <longman@redhat.com>

Acked-by: David Rientjes <rientjes@google.com>

Thanks Waiman!


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-07-21  5:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-18 18:08 [PATCH] mm, slab: Move memcg_cache_params structure to mm/slab.h Waiman Long
2019-07-19  7:05 ` Michal Hocko
2019-07-21  5:31 ` David Rientjes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).