linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* linux-next: manual merge of the akpm-current tree with the slab tree
@ 2021-12-03  7:19 Stephen Rothwell
  2021-12-17 12:39 ` Stephen Rothwell
  0 siblings, 1 reply; 5+ messages in thread
From: Stephen Rothwell @ 2021-12-03  7:19 UTC (permalink / raw)
  To: Andrew Morton, Vlastimil Babka
  Cc: Linux Kernel Mailing List, Linux Next Mailing List, Waiman Long

[-- Attachment #1: Type: text/plain, Size: 3078 bytes --]

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.

-- 
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;
  

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: linux-next: manual merge of the akpm-current tree with the slab tree
  2021-12-03  7:19 linux-next: manual merge of the akpm-current tree with the slab tree Stephen Rothwell
@ 2021-12-17 12:39 ` Stephen Rothwell
  2021-12-21  0:10   ` Vlastimil Babka
  0 siblings, 1 reply; 5+ messages in thread
From: Stephen Rothwell @ 2021-12-17 12:39 UTC (permalink / raw)
  To: Vlastimil Babka
  Cc: Andrew Morton, Linux Kernel Mailing List,
	Linux Next Mailing List, Waiman Long

[-- Attachment #1: Type: text/plain, Size: 3412 bytes --]

Hi all,

On Fri, 3 Dec 2021 18:19:51 +1100 Stephen Rothwell <sfr@canb.auug.org.au> wrote:
>
> 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.
> 
> 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;
>   

This is now a conflict between the slab tree and Linus' tree.

-- 
Cheers,
Stephen Rothwell

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: linux-next: manual merge of the akpm-current tree with the slab tree
  2021-12-17 12:39 ` Stephen Rothwell
@ 2021-12-21  0:10   ` Vlastimil Babka
  0 siblings, 0 replies; 5+ messages in thread
From: Vlastimil Babka @ 2021-12-21  0:10 UTC (permalink / raw)
  To: Stephen Rothwell
  Cc: Andrew Morton, Linux Kernel Mailing List,
	Linux Next Mailing List, Waiman Long

On 12/17/21 13:39, Stephen Rothwell wrote:
> Hi all,
> 
> On Fri, 3 Dec 2021 18:19:51 +1100 Stephen Rothwell <sfr@canb.auug.org.au> wrote:
>>
>> 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.
>> 
...
>>  -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.

Thanks, rebased slab-next to v5.16-rc6 to avoid the conflict.

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

* Re: linux-next: manual merge of the akpm-current tree with the slab tree
  2021-12-03  7:22 Stephen Rothwell
@ 2022-01-11 11:51 ` Stephen Rothwell
  0 siblings, 0 replies; 5+ messages in thread
From: Stephen Rothwell @ 2022-01-11 11:51 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Vlastimil Babka, Linux Kernel Mailing List,
	Linux Next Mailing List, Matthew Wilcox (Oracle),
	Minchan Kim

[-- Attachment #1: Type: text/plain, Size: 2311 bytes --]

Hi all,

On Fri, 3 Dec 2021 18:22:55 +1100 Stephen Rothwell <sfr@canb.auug.org.au> wrote:
>
> Today's linux-next merge of the akpm-current tree got a conflict in:
> 
>   mm/zsmalloc.c
> 
> between commit:
> 
>   5718b5cdd6e5 ("zsmalloc: Stop using slab fields in struct page")
> 
> from the slab tree and commit:
> 
>   efcc1718fe08 ("zsmalloc: move huge compressed obj from page to zspage")
> 
> 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.
> 
> diff --cc mm/zsmalloc.c
> index 0d3b65939016,7e03cc9363bb..000000000000
> --- a/mm/zsmalloc.c
> +++ b/mm/zsmalloc.c
> @@@ -824,10 -820,12 +820,12 @@@ static struct zspage *get_zspage(struc
>   
>   static struct page *get_next_page(struct page *page)
>   {
> - 	if (unlikely(PageHugeObject(page)))
> + 	struct zspage *zspage = get_zspage(page);
> + 
> + 	if (unlikely(ZsHugePage(zspage)))
>   		return NULL;
>   
>  -	return page->freelist;
>  +	return (struct page *)page->index;
>   }
>   
>   /**
> @@@ -900,8 -893,7 +893,7 @@@ static void reset_page(struct page *pag
>   	ClearPagePrivate(page);
>   	set_page_private(page, 0);
>   	page_mapcount_reset(page);
> - 	ClearPageHugeObject(page);
>  -	page->freelist = NULL;
>  +	page->index = 0;
>   }
>   
>   static int trylock_zspage(struct zspage *zspage)
> @@@ -1042,9 -1039,9 +1039,9 @@@ static void create_page_chain(struct si
>   			SetPagePrivate(page);
>   			if (unlikely(class->objs_per_zspage == 1 &&
>   					class->pages_per_zspage == 1))
> - 				SetPageHugeObject(page);
> + 				SetZsHugePage(zspage);
>   		} else {
>  -			prev_page->freelist = page;
>  +			prev_page->index = (unsigned long)page;
>   		}
>   		prev_page = page;
>   	}

This is now a conflict between the akpm-current tree and Linus' tree -
that slab tree commit is now commit ffedd09fa9b0 ("zsmalloc: Stop using
slab fields in struct page") in Linus' tree.

-- 
Cheers,
Stephen Rothwell

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* linux-next: manual merge of the akpm-current tree with the slab tree
@ 2021-12-03  7:22 Stephen Rothwell
  2022-01-11 11:51 ` Stephen Rothwell
  0 siblings, 1 reply; 5+ messages in thread
From: Stephen Rothwell @ 2021-12-03  7:22 UTC (permalink / raw)
  To: Andrew Morton, Vlastimil Babka
  Cc: Linux Kernel Mailing List, Linux Next Mailing List,
	Matthew Wilcox (Oracle),
	Minchan Kim

[-- Attachment #1: Type: text/plain, Size: 1909 bytes --]

Hi all,

Today's linux-next merge of the akpm-current tree got a conflict in:

  mm/zsmalloc.c

between commit:

  5718b5cdd6e5 ("zsmalloc: Stop using slab fields in struct page")

from the slab tree and commit:

  efcc1718fe08 ("zsmalloc: move huge compressed obj from page to zspage")

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.

-- 
Cheers,
Stephen Rothwell

diff --cc mm/zsmalloc.c
index 0d3b65939016,7e03cc9363bb..000000000000
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@@ -824,10 -820,12 +820,12 @@@ static struct zspage *get_zspage(struc
  
  static struct page *get_next_page(struct page *page)
  {
- 	if (unlikely(PageHugeObject(page)))
+ 	struct zspage *zspage = get_zspage(page);
+ 
+ 	if (unlikely(ZsHugePage(zspage)))
  		return NULL;
  
 -	return page->freelist;
 +	return (struct page *)page->index;
  }
  
  /**
@@@ -900,8 -893,7 +893,7 @@@ static void reset_page(struct page *pag
  	ClearPagePrivate(page);
  	set_page_private(page, 0);
  	page_mapcount_reset(page);
- 	ClearPageHugeObject(page);
 -	page->freelist = NULL;
 +	page->index = 0;
  }
  
  static int trylock_zspage(struct zspage *zspage)
@@@ -1042,9 -1039,9 +1039,9 @@@ static void create_page_chain(struct si
  			SetPagePrivate(page);
  			if (unlikely(class->objs_per_zspage == 1 &&
  					class->pages_per_zspage == 1))
- 				SetPageHugeObject(page);
+ 				SetZsHugePage(zspage);
  		} else {
 -			prev_page->freelist = page;
 +			prev_page->index = (unsigned long)page;
  		}
  		prev_page = page;
  	}

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

end of thread, other threads:[~2022-01-11 11:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-03  7:19 linux-next: manual merge of the akpm-current tree with the slab tree Stephen Rothwell
2021-12-17 12:39 ` Stephen Rothwell
2021-12-21  0:10   ` Vlastimil Babka
2021-12-03  7:22 Stephen Rothwell
2022-01-11 11:51 ` Stephen Rothwell

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).