linux-next: manual merge of the akpm-current tree with the slab tree
Hi all,
Today's linux-next merge of the akpm-current tree got a conflict in:
mm/memcontrol.c
between commit:
eefa12e18a92 ("mm/memcg: Convert slab objcgs from struct page to struct slab")
from the slab tree and commit:
93e959c235eb ("mm/memcg: relocate mod_objcg_mlstate(), get_obj_stock() and put_obj_stock()")
from the akpm-current tree.
I fixed it up (see below) and can carry the fix as necessary. This is now fixed as far as linux-next is concerned, but any non trivial conflicts should be mentioned to your upstream maintainer when your tree is submitted for merging. You may also want to consider cooperating with the maintainer of the conflicting tree to minimise any particularly complex conflicts.
Signature · 73 lines
Cheers,
Stephen Rothwell
diff --cc mm/memcontrol.c
index 522fff11d6d1,69d4fdafbb80..000000000000
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@@ -2816,10 -2769,63 +2769,63 @@@ retry
*/
#define OBJCGS_CLEAR_MASK (__GFP_DMA | __GFP_RECLAIMABLE | __GFP_ACCOUNT)
+ /*
+ * Most kmem_cache_alloc() calls are from user context. The irq disable/enable
+ * sequence used in this case to access content from object stock is slow.
+ * To optimize for user context access, there are now two object stocks for
+ * task context and interrupt context access respectively.
+ *
+ * The task context object stock can be accessed by disabling preemption only
+ * which is cheap in non-preempt kernel. The interrupt context object stock
+ * can only be accessed after disabling interrupt. User context code can
+ * access interrupt object stock, but not vice versa.
+ */
+ static inline struct obj_stock *get_obj_stock(unsigned long *pflags)
+ {
+ struct memcg_stock_pcp *stock;
+
+ if (likely(in_task())) {
+ *pflags = 0UL;
+ preempt_disable();
+ stock = this_cpu_ptr(&memcg_stock);
+ return &stock->task_obj;
+ }
+
+ local_irq_save(*pflags);
+ stock = this_cpu_ptr(&memcg_stock);
+ return &stock->irq_obj;
+ }
+
+ static inline void put_obj_stock(unsigned long flags)
+ {
+ if (likely(in_task()))
+ preempt_enable();
+ else
+ local_irq_restore(flags);
+ }
+
+ /*
+ * mod_objcg_mlstate() may be called with irq enabled, so
+ * mod_memcg_lruvec_state() should be used.
+ */
+ static inline void mod_objcg_mlstate(struct obj_cgroup *objcg,
+ struct pglist_data *pgdat,
+ enum node_stat_item idx, int nr)
+ {
+ struct mem_cgroup *memcg;
+ struct lruvec *lruvec;
+
+ rcu_read_lock();
+ memcg = obj_cgroup_memcg(objcg);
+ lruvec = mem_cgroup_lruvec(memcg, pgdat);
+ mod_memcg_lruvec_state(lruvec, idx, nr);
+ rcu_read_unlock();
+ }
+
-int memcg_alloc_page_obj_cgroups(struct page *page, struct kmem_cache *s,
- gfp_t gfp, bool new_page)
+int memcg_alloc_slab_cgroups(struct slab *slab, struct kmem_cache *s,
+ gfp_t gfp, bool new_slab)
{
- unsigned int objects = objs_per_slab_page(s, page);
+ unsigned int objects = objs_per_slab(s, slab);
unsigned long memcg_data;
void *vec;Hi all,
Quoted 83 lines · On Fri, 3 Dec 2021 18:19:51 +1100 Stephen Rothwell <[email protected]> wrote:
Today's linux-next merge of the akpm-current tree got a conflict in:
mm/memcontrol.cbetween commit:
eefa12e18a92("mm/memcg: Convert slab objcgs from struct page to struct slab")from the slab tree and commit:
93e959c235eb("mm/memcg: relocatemod_objcg_mlstate(),get_obj_stock()andput_obj_stock()")from the akpm-current tree.
I fixed it up (see below) and can carry the fix as necessary. This is now fixed as far as linux-next is concerned, but any non trivial conflicts should be mentioned to your upstream maintainer when your tree is submitted for merging. You may also want to consider cooperating with the maintainer of the conflicting tree to minimise any particularly complex conflicts.
mm/memcontrol.c +52
-0@@@ -2816,10 -2769,63 +2769,63 @@@ retry*/ #define OBJCGS_CLEAR_MASK (__GFP_DMA | __GFP_RECLAIMABLE | __GFP_ACCOUNT) +/* +* Most kmem_cache_alloc() calls are from user context. The irq disable/enable +* sequence used in this case to access content from object stock is slow. +* To optimize for user context access, there are now two object stocks for +* task context and interrupt context access respectively. +* +* The task context object stock can be accessed by disabling preemption only +* which is cheap in non-preempt kernel. The interrupt context object stock +* can only be accessed after disabling interrupt. User context code can +* access interrupt object stock, but not vice versa. +*/ +static inline struct obj_stock *get_obj_stock (unsigned long *pflags) + { +struct memcg_stock_pcp *stock; + +if (likely (in_task ())) { + *pflags =0UL ; +preempt_disable (); + stock =this_cpu_ptr (&memcg_stock); +return &stock->task_obj; + } + +local_irq_save (*pflags); + stock =this_cpu_ptr (&memcg_stock); +return &stock->irq_obj; + } + +static inline void put_obj_stock (unsigned long flags) + { +if (likely (in_task ())) +preempt_enable (); +else +local_irq_restore (flags); + } + +/* +* mod_objcg_mlstate() may be called with irq enabled, so +* mod_memcg_lruvec_state() should be used. +*/ +static inline void mod_objcg_mlstate (struct obj_cgroup *objcg, +struct pglist_data *pgdat, +enum node_stat_item idx,int nr) + { +struct mem_cgroup *memcg; +struct lruvec *lruvec; + +rcu_read_lock (); + memcg =obj_cgroup_memcg (objcg); + lruvec =mem_cgroup_lruvec (memcg, pgdat); +mod_memcg_lruvec_state (lruvec, idx, nr); +rcu_read_unlock (); + }
mm/memcontrol.c
Quoted 10 lines
mm/memcontrol.c +1
-0+ -int memcg_alloc_page_obj_cgroups(struct page *page, struct kmem_cache *s, - gfp_t gfp, bool new_page) +int memcg_alloc_slab_cgroups(struct slab *slab, struct kmem_cache *s, + gfp_t gfp, bool new_slab) { - unsigned int objects = objs_per_slab_page(s, page); + unsigned int objects = objs_per_slab(s, slab);unsigned long memcg_data;void *vec;
This is now a conflict between the slab tree and Linus' tree.
Signature · 2 lines
Cheers, Stephen Rothwell
Quoted 25 lines · Stephen Rothwell
Hi all,
Quoted 22 lines · On Fri, 3 Dec 2021 18:19:51 +1100 Stephen Rothwell <[email protected]> wrote:
Today's linux-next merge of the akpm-current tree got a conflict in:
mm/memcontrol.cbetween commit:
eefa12e18a92("mm/memcg: Convert slab objcgs from struct page to struct slab")from the slab tree and commit:
93e959c235eb("mm/memcg: relocatemod_objcg_mlstate(),get_obj_stock()andput_obj_stock()")from the akpm-current tree.
I fixed it up (see below) and can carry the fix as necessary. This is now fixed as far as linux-next is concerned, but any non trivial conflicts should be mentioned to your upstream maintainer when your tree is submitted for merging. You may also want to consider cooperating with the maintainer of the conflicting tree to minimise any particularly complex conflicts.
...
Quoted 11 lines
Quoted 10 lines
-int memcg_alloc_page_obj_cgroups(struct page *page, struct
kmem_cache*s,
-gfp_tgfp, boolnew_page)
+int memcg_alloc_slab_cgroups(struct slab *slab, structkmem_cache*s,
+gfp_tgfp, boolnew_slab)
{
- unsigned int objects =objs_per_slab_page(s, page);
+ unsigned int objects =objs_per_slab(s, slab);
unsigned longmemcg_data;
void *vec;
Quoted 1 line
This is now a conflict between the slab tree and Linus' tree.
Thanks, rebased slab-next to v5.16-rc6 to avoid the conflict.