lkml.org 
[lkml]   [2019]   [Mar]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] mm, memory_hotplug: Fix the wrong usage of N_HIGH_MEMORY
On 03/20/19 at 09:46am, Michal Hocko wrote:
> On Wed 20-03-19 16:07:32, Baoquan He wrote:
> > In function node_states_check_changes_online(), N_HIGH_MEMORY is used
> > to substitute ZONE_HIGHMEM directly. This is not right. N_HIGH_MEMORY
> > always has value '3' if CONFIG_HIGHMEM=y, while ZONE_HIGHMEM's value
> > is not. It depends on whether CONFIG_ZONE_DMA/CONFIG_ZONE_DMA32 are
> > enabled. Obviously it's not true for CONFIG_ZONE_DMA32 on 32bit system,
> > and CONFIG_ZONE_DMA is also optional.
> >
> > Replace it with ZONE_HIGHMEM.
>
> N*MEMORY is confusing as hell but I am really curious whether we have
> ZONE_DMA32 and ZONE_HIGMEM together?

Not sure. AFAIK, on x86_32 it can't be.

>
> That being said N.*MEMORY is intended to check for nodes rather than
> zones so the patch looks good to me but I think the above explanation is
> misleading and will add even more mud to the picture when somebody tries
> to understand what the heck is going on here.

Yes, agree. I also thought this again after I sent out patch, feel log is not
good. As you said, they are value of enum node_states and enum zone_type
separately.

How about this:

~~~
In function node_states_check_changes_online(), N_HIGH_MEMORY is used
to substitute ZONE_HIGHMEM directly. This is not right. N_HIGH_MEMORY
is to mark the memory state of node. Here zone index is checked, which
should be compared with 'ZONE_HIGHMEM' accordingly.

Replace it with ZONE_HIGHMEM.
~~~
>
> > Fixes: 8efe33f40f3e ("mm/memory_hotplug.c: simplify node_states_check_changes_online")
> > Signed-off-by: Baoquan He <bhe@redhat.com>
> > ---
> > mm/memory_hotplug.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
> > index 6b05576fb4ec..09911d34a3be 100644
> > --- a/mm/memory_hotplug.c
> > +++ b/mm/memory_hotplug.c
> > @@ -712,7 +712,7 @@ static void node_states_check_changes_online(unsigned long nr_pages,
> > if (zone_idx(zone) <= ZONE_NORMAL && !node_state(nid, N_NORMAL_MEMORY))
> > arg->status_change_nid_normal = nid;
> > #ifdef CONFIG_HIGHMEM
> > - if (zone_idx(zone) <= N_HIGH_MEMORY && !node_state(nid, N_HIGH_MEMORY))
> > + if (zone_idx(zone) <= ZONE_HIGHMEM && !node_state(nid, N_HIGH_MEMORY))
> > arg->status_change_nid_high = nid;
> > #endif
> > }
> > --
> > 2.17.2
>
> --
> Michal Hocko
> SUSE Labs

\
 
 \ /
  Last update: 2019-03-20 10:06    [W:0.290 / U:0.560 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site