stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Baoquan He <bhe@redhat.com>, linux-kernel@vger.kernel.org
Cc: linux-mm@kvack.org, akpm@linux-foundation.org, hch@lst.de,
	cl@linux.com, John.p.donnelly@oracle.com,
	kexec@lists.infradead.org, stable@vger.kernel.org
Subject: Re: [PATCH v3 3/5] mm_zone: add function to check if managed dma zone exists
Date: Thu, 16 Dec 2021 11:52:27 +0100	[thread overview]
Message-ID: <0091b689-54b6-7cc9-d5ee-ae12a2f8376d@redhat.com> (raw)
In-Reply-To: <20211213122712.23805-4-bhe@redhat.com>

On 13.12.21 13:27, Baoquan He wrote:
> In some places of the current kernel, it assumes that dma zone must have
> managed pages if CONFIG_ZONE_DMA is enabled. While this is not always true.
> E.g in kdump kernel of x86_64, only low 1M is presented and locked down
> at very early stage of boot, so that there's no managed pages at all in
> DMA zone. This exception will always cause page allocation failure if page
> is requested from DMA zone.
> 
> Here add function has_managed_dma() and the relevant helper functions to
> check if there's DMA zone with managed pages. It will be used in later
> patches.
> 
> Fixes: 6f599d84231f ("x86/kdump: Always reserve the low 1M when the crashkernel option is specified")
> Cc: stable@vger.kernel.org
> Signed-off-by: Baoquan He <bhe@redhat.com>
> ---
> v2->v3:
>  Rewrite has_managed_dma() in a simpler and more efficient way which is
>  sugggested by DavidH. 
> 
>  include/linux/mmzone.h |  9 +++++++++
>  mm/page_alloc.c        | 15 +++++++++++++++
>  2 files changed, 24 insertions(+)
> 
> diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
> index 58e744b78c2c..6e1b726e9adf 100644
> --- a/include/linux/mmzone.h
> +++ b/include/linux/mmzone.h
> @@ -1046,6 +1046,15 @@ static inline int is_highmem_idx(enum zone_type idx)
>  #endif
>  }
>  
> +#ifdef CONFIG_ZONE_DMA
> +bool has_managed_dma(void);
> +#else
> +static inline bool has_managed_dma(void)
> +{
> +	return false;
> +}
> +#endif
> +
>  /**
>   * is_highmem - helper function to quickly check if a struct zone is a
>   *              highmem zone or not.  This is an attempt to keep references
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index c5952749ad40..7c7a0b5de2ff 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -9460,3 +9460,18 @@ bool take_page_off_buddy(struct page *page)
>  	return ret;
>  }
>  #endif
> +
> +#ifdef CONFIG_ZONE_DMA
> +bool has_managed_dma(void)
> +{
> +	struct pglist_data *pgdat;
> +
> +	for_each_online_pgdat(pgdat) {
> +		struct zone *zone = &pgdat->node_zones[ZONE_DMA];
> +
> +		if (managed_zone(zone))
> +			return true;
> +	}
> +	return false;
> +}
> +#endif /* CONFIG_ZONE_DMA */
> 

Reviewed-by: David Hildenbrand <david@redhat.com>

-- 
Thanks,

David / dhildenb


  parent reply	other threads:[~2021-12-16 10:52 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20211213122712.23805-1-bhe@redhat.com>
2021-12-13 12:27 ` [PATCH v3 3/5] mm_zone: add function to check if managed dma zone exists Baoquan He
2021-12-13 14:22   ` john.p.donnelly
2021-12-16 10:52   ` David Hildenbrand [this message]
2021-12-13 12:27 ` [PATCH v3 4/5] dma/pool: create dma atomic pool only if dma zone has managed pages Baoquan He
2021-12-13 14:23   ` john.p.donnelly
2021-12-13 12:27 ` [PATCH v3 5/5] mm/slub: do not create dma-kmalloc if no managed pages in DMA zone Baoquan He
2021-12-13 13:43   ` Hyeonggon Yoo
2021-12-14  5:32     ` Baoquan He
2021-12-14 10:09       ` Vlastimil Babka
2021-12-14 10:28         ` Christoph Lameter
2021-12-15  4:48         ` Hyeonggon Yoo
2021-12-15  7:03           ` Hyeonggon Yoo
2021-12-15  7:27             ` Christoph Hellwig
2021-12-15 10:34               ` Vlastimil Babka
2021-12-15 11:51                 ` David Laight
2021-12-15 13:41                 ` Baoquan He
2021-12-17 11:38               ` Hyeonggon Yoo
2021-12-20  7:32                 ` Baoquan He
2022-01-07 11:56               ` Hyeonggon Yoo
2021-12-15 14:42             ` Baoquan He
2021-12-15 10:08         ` Baoquan He
2021-12-17 11:38       ` Hyeonggon Yoo
2021-12-21  8:56         ` Christoph Hellwig
2021-12-22 12:37           ` Hyeonggon Yoo
2021-12-23  8:52             ` Christoph Hellwig
2021-12-13 14:24   ` john.p.donnelly
2021-12-14 16:31   ` Christoph Hellwig
2021-12-14 17:07     ` john.p.donnelly
2021-12-15  7:27       ` Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0091b689-54b6-7cc9-d5ee-ae12a2f8376d@redhat.com \
    --to=david@redhat.com \
    --cc=John.p.donnelly@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=bhe@redhat.com \
    --cc=cl@linux.com \
    --cc=hch@lst.de \
    --cc=kexec@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).