linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Dan Williams <dan.j.williams@intel.com>
To: Randy Dunlap <rdunlap@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Mark Brown <broonie@kernel.org>,
	 linux-fsdevel <linux-fsdevel@vger.kernel.org>,
	 Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Linux MM <linux-mm@kvack.org>,
	 Linux-Next Mailing List <linux-next@vger.kernel.org>,
	Michal Hocko <mhocko@suse.cz>,
	mm-commits@vger.kernel.org,
	 Stephen Rothwell <sfr@canb.auug.org.au>
Subject: Re: [PATCH -mmotm] mm/memory_hotplug: fix for CONFIG_ZONE_DEVICE not enabled
Date: Tue, 19 Jan 2021 20:12:01 -0800	[thread overview]
Message-ID: <CAPcyv4iX+7LAgAeSqx7Zw-Zd=ZV9gBv8Bo7oTbwCOOqJoZ3+Yg@mail.gmail.com> (raw)
In-Reply-To: <5f8e2ede-5836-45e1-d8d7-ae949775e76e@infradead.org>

On Tue, Jan 19, 2021 at 7:05 PM Randy Dunlap <rdunlap@infradead.org> wrote:
>
> From: Randy Dunlap <rdunlap@infradead.org>
>
> Fix memory_hotplug.c when CONFIG_ZONE_DEVICE is not enabled.
>
> Fixes this build error:
>
> ../mm/memory_hotplug.c: In function ‘move_pfn_range_to_zone’:
> ../mm/memory_hotplug.c:772:24: error: ‘ZONE_DEVICE’ undeclared (first use in this function); did you mean ‘ZONE_MOVABLE’?
>   if (zone_idx(zone) == ZONE_DEVICE) {

Thanks Randy. Apologies for the thrash, obviously the kbuild-robot
does not include a CONFIG_ZONE_DEVICE=n.

I'd prefer to fix this without adding ifdefery in a .c file with
something like this:

diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 0b5c44f730b4..66ba38dae9ba 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -885,6 +885,18 @@ static inline int local_memory_node(int node_id)
{ return node_id; };
  */
 #define zone_idx(zone)         ((zone) - (zone)->zone_pgdat->node_zones)

+#ifdef CONFIG_ZONE_DEVICE
+static inline bool zone_is_zone_device(struct zone *zone)
+{
+       return zone_idx(zone) == ZONE_DEVICE;
+}
+#else
+static inline bool zone_is_zone_device(struct zone *zone)
+{
+       return false;
+}
+#endif
+
 /*
  * Returns true if a zone has pages managed by the buddy allocator.
  * All the reclaim decisions have to use this function rather than
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index c78a1bef561b..710e469fb3a1 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -769,7 +769,7 @@ void __ref move_pfn_range_to_zone(struct zone
*zone, unsigned long start_pfn,
         * ZONE_DEVICE pages in an otherwise  ZONE_{NORMAL,MOVABLE}
         * section.
         */
-       if (zone_idx(zone) == ZONE_DEVICE) {
+       if (zone_is_zone_device(zone)) {
                if (!IS_ALIGNED(start_pfn, PAGES_PER_SECTION))
                        section_taint_zone_device(start_pfn);
                if (!IS_ALIGNED(start_pfn + nr_pages, PAGES_PER_SECTION))


      reply	other threads:[~2021-01-20  4:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-19 21:37 mmotm 2021-01-19-13-36 uploaded akpm
2021-01-19 22:50 ` mmotm 2021-01-19-13-36 uploaded (ZONE_DEVICE) Randy Dunlap
2021-01-20  3:04 ` [PATCH -mmotm] mm/memory_hotplug: fix for CONFIG_ZONE_DEVICE not enabled Randy Dunlap
2021-01-20  4:12   ` Dan Williams [this message]

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='CAPcyv4iX+7LAgAeSqx7Zw-Zd=ZV9gBv8Bo7oTbwCOOqJoZ3+Yg@mail.gmail.com' \
    --to=dan.j.williams@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=broonie@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-next@vger.kernel.org \
    --cc=mhocko@suse.cz \
    --cc=mm-commits@vger.kernel.org \
    --cc=rdunlap@infradead.org \
    --cc=sfr@canb.auug.org.au \
    /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