2016-04-01 02:10:20

by Joonsoo Kim

[permalink] [raw]
Subject: [PATCH 1/4] mm/writeback: correct dirty page calculation for highmem

From: Joonsoo Kim <[email protected]>

ZONE_MOVABLE could be treated as highmem so we need to consider it for
accurate calculation of dirty pages. And, in following patches, ZONE_CMA
will be introduced and it can be treated as highmem, too. So, instead of
manually adding stat of ZONE_MOVABLE, looping all zones and check whether
the zone is highmem or not and add stat of the zone which can be treated
as highmem.

Signed-off-by: Joonsoo Kim <[email protected]>
---
mm/page-writeback.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index 11ff8f7..6a72809 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -296,11 +296,15 @@ static unsigned long highmem_dirtyable_memory(unsigned long total)
#ifdef CONFIG_HIGHMEM
int node;
unsigned long x = 0;
+ int i;

for_each_node_state(node, N_HIGH_MEMORY) {
- struct zone *z = &NODE_DATA(node)->node_zones[ZONE_HIGHMEM];
+ for (i = 0; i < MAX_NR_ZONES; i++) {
+ struct zone *z = &NODE_DATA(node)->node_zones[i];

- x += zone_dirtyable_memory(z);
+ if (is_highmem(z))
+ x += zone_dirtyable_memory(z);
+ }
}
/*
* Unreclaimable memory (kernel memory or anonymous memory
--
1.9.1


2016-04-01 02:10:29

by Joonsoo Kim

[permalink] [raw]
Subject: [PATCH 3/4] mm/highmem: make nr_free_highpages() handles all highmem zones by itself

From: Joonsoo Kim <[email protected]>

nr_free_highpages() manually add statistics per each highmem zone
and return total value for them. Whenever we add a new highmem zone,
we need to consider this function and it's really troublesome. Make
it handles all highmem zones by itself.

Signed-off-by: Joonsoo Kim <[email protected]>
---
mm/highmem.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/mm/highmem.c b/mm/highmem.c
index 123bcd3..50b4ca6 100644
--- a/mm/highmem.c
+++ b/mm/highmem.c
@@ -112,16 +112,12 @@ EXPORT_PER_CPU_SYMBOL(__kmap_atomic_idx);

unsigned int nr_free_highpages (void)
{
- pg_data_t *pgdat;
+ struct zone *zone;
unsigned int pages = 0;

- for_each_online_pgdat(pgdat) {
- pages += zone_page_state(&pgdat->node_zones[ZONE_HIGHMEM],
- NR_FREE_PAGES);
- if (zone_movable_is_highmem())
- pages += zone_page_state(
- &pgdat->node_zones[ZONE_MOVABLE],
- NR_FREE_PAGES);
+ for_each_populated_zone(zone) {
+ if (is_highmem(zone))
+ pages += zone_page_state(zone, NR_FREE_PAGES);
}

return pages;
--
1.9.1

2016-04-01 02:10:38

by Joonsoo Kim

[permalink] [raw]
Subject: [PATCH 4/4] mm/vmstat: make node_page_state() handles all zones by itself

From: Joonsoo Kim <[email protected]>

node_page_state() manually add statistics per each zone and return
total value for all zones. Whenever we add a new zone, we need to
consider this function and it's really troublesome. Make it handles
all zones by itself.

Signed-off-by: Joonsoo Kim <[email protected]>
---
mm/vmstat.c | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/mm/vmstat.c b/mm/vmstat.c
index 0a726e3..a7de9ad 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -600,19 +600,13 @@ void zone_statistics(struct zone *preferred_zone, struct zone *z, gfp_t flags)
unsigned long node_page_state(int node, enum zone_stat_item item)
{
struct zone *zones = NODE_DATA(node)->node_zones;
+ int i;
+ unsigned long count = 0;

- return
-#ifdef CONFIG_ZONE_DMA
- zone_page_state(&zones[ZONE_DMA], item) +
-#endif
-#ifdef CONFIG_ZONE_DMA32
- zone_page_state(&zones[ZONE_DMA32], item) +
-#endif
-#ifdef CONFIG_HIGHMEM
- zone_page_state(&zones[ZONE_HIGHMEM], item) +
-#endif
- zone_page_state(&zones[ZONE_NORMAL], item) +
- zone_page_state(&zones[ZONE_MOVABLE], item);
+ for (i = 0; i < MAX_NR_ZONES; i++)
+ count += zone_page_state(zones + i, item);
+
+ return count;
}

#endif
--
1.9.1

2016-04-01 02:10:26

by Joonsoo Kim

[permalink] [raw]
Subject: [PATCH 2/4] mm/page_alloc: correct highmem memory statistics

From: Joonsoo Kim <[email protected]>

ZONE_MOVABLE could be treated as highmem so we need to consider it for
accurate statistics. And, in following patches, ZONE_CMA will be
introduced and it can be treated as highmem, too. So, instead of
manually adding stat of ZONE_MOVABLE, looping all zones and check whether
the zone is highmem or not and add stat of the zone which can be treated
as highmem.

Signed-off-by: Joonsoo Kim <[email protected]>
---
mm/page_alloc.c | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 437a934..173e616 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -3897,6 +3897,8 @@ void si_meminfo_node(struct sysinfo *val, int nid)
{
int zone_type; /* needs to be signed */
unsigned long managed_pages = 0;
+ unsigned long managed_highpages = 0;
+ unsigned long free_highpages = 0;
pg_data_t *pgdat = NODE_DATA(nid);

for (zone_type = 0; zone_type < MAX_NR_ZONES; zone_type++)
@@ -3905,12 +3907,19 @@ void si_meminfo_node(struct sysinfo *val, int nid)
val->sharedram = node_page_state(nid, NR_SHMEM);
val->freeram = node_page_state(nid, NR_FREE_PAGES);
#ifdef CONFIG_HIGHMEM
- val->totalhigh = pgdat->node_zones[ZONE_HIGHMEM].managed_pages;
- val->freehigh = zone_page_state(&pgdat->node_zones[ZONE_HIGHMEM],
- NR_FREE_PAGES);
+ for (zone_type = 0; zone_type < MAX_NR_ZONES; zone_type++) {
+ struct zone *zone = &pgdat->node_zones[zone_type];
+
+ if (is_highmem(zone)) {
+ managed_highpages += zone->managed_pages;
+ free_highpages += zone_page_state(zone, NR_FREE_PAGES);
+ }
+ }
+ val->totalhigh = managed_highpages;
+ val->freehigh = free_highpages;
#else
- val->totalhigh = 0;
- val->freehigh = 0;
+ val->totalhigh = managed_highpages;
+ val->freehigh = free_highpages;
#endif
val->mem_unit = PAGE_SIZE;
}
--
1.9.1

2016-04-05 01:34:22

by Joonsoo Kim

[permalink] [raw]
Subject: Re: [PATCH 1/4] mm/writeback: correct dirty page calculation for highmem

On Fri, Apr 01, 2016 at 11:10:07AM +0900, [email protected] wrote:
> From: Joonsoo Kim <[email protected]>
>
> ZONE_MOVABLE could be treated as highmem so we need to consider it for
> accurate calculation of dirty pages. And, in following patches, ZONE_CMA
> will be introduced and it can be treated as highmem, too. So, instead of
> manually adding stat of ZONE_MOVABLE, looping all zones and check whether
> the zone is highmem or not and add stat of the zone which can be treated
> as highmem.
>
> Signed-off-by: Joonsoo Kim <[email protected]>
> ---
> mm/page-writeback.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)

Hello, Andrew.

Could you review and merge these simple fixup and cleanup patches?
I'd like to send ZONE_CMA patchset v2 based on linux-next after this
series is merged to linux-next.

Thanks.

2016-04-05 03:40:10

by Aneesh Kumar K.V

[permalink] [raw]
Subject: Re: [PATCH 1/4] mm/writeback: correct dirty page calculation for highmem

Joonsoo Kim <[email protected]> writes:

> [ text/plain ]
> On Fri, Apr 01, 2016 at 11:10:07AM +0900, [email protected] wrote:
>> From: Joonsoo Kim <[email protected]>
>>
>> ZONE_MOVABLE could be treated as highmem so we need to consider it for
>> accurate calculation of dirty pages. And, in following patches, ZONE_CMA
>> will be introduced and it can be treated as highmem, too. So, instead of
>> manually adding stat of ZONE_MOVABLE, looping all zones and check whether
>> the zone is highmem or not and add stat of the zone which can be treated
>> as highmem.
>>
>> Signed-off-by: Joonsoo Kim <[email protected]>
>> ---
>> mm/page-writeback.c | 8 ++++++--
>> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> Hello, Andrew.
>
> Could you review and merge these simple fixup and cleanup patches?
> I'd like to send ZONE_CMA patchset v2 based on linux-next after this
> series is merged to linux-next.
>

I searched with ZONE_HIGHMEM and AFAICS this series do handle all the
highmem path.

For the series:
Reviewed-by: Aneesh Kumar K.V <[email protected]>

-aneesh