Re: [PATCH 13/16] mm/huge_memory: add helper __get_deferred_split_queue

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

 



On Thu, Jun 23, 2022 at 01:06:24AM +0800, Miaohe Lin wrote:
> Add helper __get_deferred_split_queue to remove the duplicated codes of
> getting ds_queue. No functional change intended.
>

Sorry, I suggest dropping this change since I have reworked the code here [1].

[1] https://lore.kernel.org/all/20220621125658.64935-7-songmuchun@xxxxxxxxxxxxx/

> Signed-off-by: Miaohe Lin <linmiaohe@xxxxxxxxxx>
> ---
>  mm/huge_memory.c | 35 ++++++++++++-----------------------
>  1 file changed, 12 insertions(+), 23 deletions(-)
> 
> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
> index 0030b4f67cd9..de8155ff584c 100644
> --- a/mm/huge_memory.c
> +++ b/mm/huge_memory.c
> @@ -555,25 +555,23 @@ pmd_t maybe_pmd_mkwrite(pmd_t pmd, struct vm_area_struct *vma)
>  	return pmd;
>  }
>  
> -#ifdef CONFIG_MEMCG
> -static inline struct deferred_split *get_deferred_split_queue(struct page *page)
> +static inline struct deferred_split *__get_deferred_split_queue(struct pglist_data *pgdat,
> +								struct mem_cgroup *memcg)
>  {
> -	struct mem_cgroup *memcg = page_memcg(compound_head(page));
> -	struct pglist_data *pgdat = NODE_DATA(page_to_nid(page));
> -
> +#ifdef CONFIG_MEMCG
>  	if (memcg)
>  		return &memcg->deferred_split_queue;
> -	else
> -		return &pgdat->deferred_split_queue;
> +#endif
> +	return &pgdat->deferred_split_queue;
>  }
> -#else
> +
>  static inline struct deferred_split *get_deferred_split_queue(struct page *page)
>  {
> +	struct mem_cgroup *memcg = page_memcg(compound_head(page));
>  	struct pglist_data *pgdat = NODE_DATA(page_to_nid(page));
>  
> -	return &pgdat->deferred_split_queue;
> +	return __get_deferred_split_queue(pgdat, memcg);
>  }
> -#endif
>  
>  void prep_transhuge_page(struct page *page)
>  {
> @@ -2774,31 +2772,22 @@ void deferred_split_huge_page(struct page *page)
>  static unsigned long deferred_split_count(struct shrinker *shrink,
>  		struct shrink_control *sc)
>  {
> -	struct pglist_data *pgdata = NODE_DATA(sc->nid);
> -	struct deferred_split *ds_queue = &pgdata->deferred_split_queue;
> +	struct deferred_split *ds_queue;
>  
> -#ifdef CONFIG_MEMCG
> -	if (sc->memcg)
> -		ds_queue = &sc->memcg->deferred_split_queue;
> -#endif
> +	ds_queue = __get_deferred_split_queue(NODE_DATA(sc->nid), sc->memcg);
>  	return READ_ONCE(ds_queue->split_queue_len);
>  }
>  
>  static unsigned long deferred_split_scan(struct shrinker *shrink,
>  		struct shrink_control *sc)
>  {
> -	struct pglist_data *pgdata = NODE_DATA(sc->nid);
> -	struct deferred_split *ds_queue = &pgdata->deferred_split_queue;
> +	struct deferred_split *ds_queue;
>  	unsigned long flags;
>  	LIST_HEAD(list), *pos, *next;
>  	struct page *page;
>  	int split = 0;
>  
> -#ifdef CONFIG_MEMCG
> -	if (sc->memcg)
> -		ds_queue = &sc->memcg->deferred_split_queue;
> -#endif
> -
> +	ds_queue = __get_deferred_split_queue(NODE_DATA(sc->nid), sc->memcg);
>  	spin_lock_irqsave(&ds_queue->split_queue_lock, flags);
>  	/* Take pin on all head pages to avoid freeing them under us */
>  	list_for_each_safe(pos, next, &ds_queue->split_queue) {
> -- 
> 2.23.0
> 
> 




[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