lkml.org 
[lkml]   [2018]   [Aug]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] mm/page_alloc: Clean up check_for_memory
On Thu, Aug 30, 2018 at 01:55:29AM +0000, Pasha Tatashin wrote:
> I would re-write the above function like this:
> static void check_for_memory(pg_data_t *pgdat, int nid)
> {
> enum zone_type zone_type;
>
> for (zone_type = 0; zone_type < ZONE_MOVABLE; zone_type++) {
> if (populated_zone(&pgdat->node_zones[zone_type])) {
> node_set_state(nid, zone_type <= ZONE_NORMAL ?
> N_NORMAL_MEMORY: N_HIGH_MEMORY);
> break;
> }
> }
> }

Hi Pavel,

the above would not work fine.
You set either N_NORMAL_MEMORY or N_HIGH_MEMORY, but a node can have both
types of memory at the same time (on CONFIG_HIGHMEM systems).

N_HIGH_MEMORY stands for regular or high memory
while N_NORMAL_MEMORY stands only for regular memory,
that is why we set it only in case the zone is <= ZONE_NORMAL.

> zone_type <= ZONE_MOVABLE - 1
> is the same as:
> zone_type < ZONE_MOVABLE

This makes sense.

--
Oscar Salvador
SUSE L3

\
 
 \ /
  Last update: 2018-08-31 14:25    [W:0.079 / U:0.504 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site