convert uses of ZONE_HIGHMEM to is_highmem
Subsystems (2)
PATCH 1/1 convert uses of ZONE_HIGHMEM to is_highmem
As the comments in mmzone.h indicate is_highmem() is designed to reduce the proliferation of the constant ZONE_HIGHMEM. This patch updates three references to ZONE_HIGHMEM to use is_highmem(). None appear to be on critical paths.
Revision: $Rev: 305 $
--- arch/i386/mm/discontig.c | 17 +++++++++++------ mm/page_alloc.c | 9 +++++---- 2 files changed, 16 insertions(+), 10 deletions(-)
arch/i386/mm/discontig.c +11 -6
@@ -411,17 +411,22 @@ void __init zone_sizes_init(void)void __init set_highmem_pages_init (int bad_ppro) {#ifdef CONFIG_HIGHMEM -int nid; +struct zone *zone; -for (nid =0 ; nid < numnodes; nid++) { +for_each_zone (zone) {unsigned long node_pfn, node_high_size, zone_start_pfn;struct page * zone_mem_map; - node_high_size =NODE_DATA (nid)->node_zones[ZONE_HIGHMEM ].spanned_pages; - zone_mem_map =NODE_DATA (nid)->node_zones[ZONE_HIGHMEM ].zone_mem_map; - zone_start_pfn =NODE_DATA (nid)->node_zones[ZONE_HIGHMEM ].zone_start_pfn; +if (!is_highmem (zone)) +continue ; + +printk ("Initializing %s for node %d\n" , zone->name, + zone->zone_pgdat->node_id); + + node_high_size = zone->spanned_pages; + zone_mem_map = zone->zone_mem_map; + zone_start_pfn = zone->zone_start_pfn; -printk ("Initializing highpages for node %d\n" , nid);for (node_pfn =0 ; node_pfn < node_high_size; node_pfn++) {one_highpage_init ((struct page *)(zone_mem_map + node_pfn), zone_start_pfn + node_pfn, bad_ppro);
mm/page_alloc.c +5 -4
@@ -930,11 +930,12 @@ unsigned int nr_free_pagecache_pages(voi#ifdef CONFIG_HIGHMEM unsigned int nr_free_highpages (void ) { -pg_data_t *pgdat; +struct zone *zone;unsigned int pages =0 ; -for_each_pgdat (pgdat) - pages += pgdat->node_zones[ZONE_HIGHMEM ].free_pages; +for_each_zone (zone) +if (is_highmem (zone)) + pages += zone->free_pages;return pages; }
@@ -1422,7 +1423,7 @@ void __init memmap_init_zone(struct pageINIT_LIST_HEAD (&page->lru);#ifdef WANT_PAGE_VIRTUAL /* The shift won't overflow because ZONE_NORMAL is below 4G. */ -if (zone !=ZONE_HIGHMEM ) +if (!is_highmem (zone))set_page_address (page,__va (start_pfn <<PAGE_SHIFT ));#endif start_pfn++;
Quoted 26 lines · Andy Whitcroft
As the comments in
mmzone.hindicateis_highmem()is designed to reduce the proliferation of the constantZONE_HIGHMEM. This patch updates three references toZONE_HIGHMEMto useis_highmem(). None appear to be on critical paths.Revision: $Rev: 305 $
void
__initset_highmem_pages_init(int bad_ppro)
{
#ifdefCONFIG_HIGHMEMarch/i386/mm/discontig.c +6
-5-int nid; +struct zone *zone; -for (nid =0 ; nid < numnodes; nid++) { +for_each_zone (zone) {unsigned long node_pfn, node_high_size, zone_start_pfn;struct page * zone_mem_map; - node_high_size =NODE_DATA (nid)->node_zones[ZONE_HIGHMEM ].spanned_pages; - zone_mem_map =NODE_DATA (nid)->node_zones[ZONE_HIGHMEM ].zone_mem_map; - zone_start_pfn =NODE_DATA (nid)->node_zones[ZONE_HIGHMEM ].zone_start_pfn; +if (!is_highmem (zone)) +continue ; + + printk("Initializing %s for node %d\n", zone->name,
arch/i386/mm/discontig.c void __init zone_sizes_init(void) · line 432
Quoted 10 lines
arch/i386/mm/discontig.c +5
-1+ zone->zone_pgdat->node_id); + + node_high_size = zone->spanned_pages; + zone_mem_map = zone->zone_mem_map; + zone_start_pfn = zone->zone_start_pfn; -printk ("Initializing highpages for node %d\n" , nid);for (node_pfn =0 ; node_pfn < node_high_size; node_pfn++) {one_highpage_init ((struct page *)(zone_mem_map + node_pfn), zone_start_pfn + node_pfn, bad_ppro);
Fair enough.
mm/page_alloc.c unsigned int nr_free_pagecache_pages(voi · line 938
Quoted 13 lines
mm/page_alloc.c +4
-3@@ -930,11 +930,12 @@ unsigned int nr_free_pagecache_pages(voi#ifdef CONFIG_HIGHMEM unsigned int nr_free_highpages (void ) { -pg_data_t *pgdat; +struct zone *zone;unsigned int pages =0 ; -for_each_pgdat (pgdat) - pages += pgdat->node_zones[ZONE_HIGHMEM ].free_pages; +for_each_zone (zone) +if (is_highmem (zone)) + pages += zone->free_pages;
but that's slower.
Quoted 50 lines · --On 25 June 2004 15:27 -0700 Andrew Morton <[email protected]> wrote:
Quoted 28 lines · Andy Whitcroft
As the comments in
mmzone.hindicateis_highmem()is designed to reduce the proliferation of the constantZONE_HIGHMEM. This patch updates three references toZONE_HIGHMEMto useis_highmem(). None appear to be on critical paths.Revision: $Rev: 305 $
void
__initset_highmem_pages_init(int bad_ppro)
{# ifdef CONFIG_HIGHMEMarch/i386/mm/discontig.c +2
-3-int nid; +struct zone *zone; -for (nid =0 ; nid < numnodes; nid++) { +for_each_zone (zone) {unsigned long node_pfn, node_high_size, zone_start_pfn;struct page * zone_mem_map; - node_high_size =NODE_DATA(nid)->node_zones[ZONE_HIGHMEM].spanned_pages; -
zone_mem_map
= NODE_DATA(nid)->node_zones[ZONE_HIGHMEM].zone_mem_map; -
zone_start_pfn=
NODE_DATA(nid)->node_zones[ZONE_HIGHMEM].zone_start_pfn; + if
(!is_highmem(zone))arch/i386/mm/discontig.c +3
-0+continue ; + + printk("Initializing %s for node %d\n", zone->name,arch/i386/mm/discontig.c void __init zone_sizes_init(void) · line 432
Quoted 10 lines
arch/i386/mm/discontig.c +5
-1+ zone->zone_pgdat->node_id); + + node_high_size = zone->spanned_pages; + zone_mem_map = zone->zone_mem_map; + zone_start_pfn = zone->zone_start_pfn; -printk ("Initializing highpages for node %d\n" , nid);for (node_pfn =0 ; node_pfn < node_high_size; node_pfn++) {one_highpage_init ((struct page *)(zone_mem_map + node_pfn), zone_start_pfn + node_pfn, bad_ppro);Fair enough.
Quoted 8 lines
mm/page_alloc.c +1
-1@@ -930,11 +930,12 @@ unsigned int nr_free_pagecache_pages(voi# ifdef CONFIG_HIGHMEM unsigned int nr_free_highpages (void ) { -pg_data_t *pgdat; +struct zone *zone;unsigned int pages =0 ;
Quoted 7 lines
mm/page_alloc.c unsigned int nr_free_pagecache_pages(voi · line 938
Quoted 5 lines
mm/page_alloc.c +3
-2-for_each_pgdat (pgdat) - pages += pgdat->node_zones[ZONE_HIGHMEM ].free_pages; +for_each_zone (zone) +if (is_highmem (zone)) + pages += zone->free_pages;but that's slower.
Yes. Although I didn't think any of the users were particularly performance critical. The routine counts the number of free pages in the zones which count as highmem, ie memory not direct mapped into KVA. In theory there could be more than one zone per node which was highmem, ZONE_HIGHMEM is currently the only one.
I'll have a think if there is a more performant way to 'fix' that.
-apw
Quoted 9 lines · [email protected] wrote:
Quoted 7 lines · Andy Whitcroft
As the comments in
mmzone.hindicateis_highmem()is designed to reduce the proliferation of the constantZONE_HIGHMEM. This patch updates three references toZONE_HIGHMEMto useis_highmem(). None appear to be on critical paths.Revision: $Rev: 305 $
[...]
Quoted 9 lines
Fair enough.
Quoted 7 lines
#ifdef
CONFIG_HIGHMEM
unsigned intnr_free_highpages(void)
{(quoted diff) +1
-1- pg_data_t *pgdat; + struct zone *zone; unsigned int pages = 0;
Quoted 7 lines
Review
Quoted 5 lines
(quoted diff) +3
-2- for_each_pgdat(pgdat) - pages += pgdat->node_zones[ZONE_HIGHMEM].free_pages; + for_each_zone(zone) + if (is_highmem(zone)) + pages += zone->free_pages;but that's slower.
Fair point. This patch only changes the first which is inialisation only and the last which is the same code via inline. The other I'll hold onto and think about more.
-apw
=== 8< ===
As the comments in mmzone.h indicate is_highmem() is designed to reduce the proliferation of the constant ZONE_HIGHMEM. This patch updates references to ZONE_HIGHMEM to use is_highmem(). None appear to be on critical paths.
Revision: $Rev: 377 $
--- arch/i386/mm/discontig.c | 17 +++++++++++------ mm/page_alloc.c | 2 +- 2 files changed, 12 insertions(+), 7 deletions(-)
arch/i386/mm/discontig.c +11 -6
@@ -409,17 +409,22 @@ void __init zone_sizes_init(void)void __init set_highmem_pages_init (int bad_ppro) {#ifdef CONFIG_HIGHMEM -int nid; +struct zone *zone; -for (nid =0 ; nid < numnodes; nid++) { +for_each_zone (zone) {unsigned long node_pfn, node_high_size, zone_start_pfn;struct page * zone_mem_map; - node_high_size =NODE_DATA (nid)->node_zones[ZONE_HIGHMEM ].spanned_pages; - zone_mem_map =NODE_DATA (nid)->node_zones[ZONE_HIGHMEM ].zone_mem_map; - zone_start_pfn =NODE_DATA (nid)->node_zones[ZONE_HIGHMEM ].zone_start_pfn; +if (!is_highmem (zone)) +continue ; + +printk ("Initializing %s for node %d\n" , zone->name, + zone->zone_pgdat->node_id); + + node_high_size = zone->spanned_pages; + zone_mem_map = zone->zone_mem_map; + zone_start_pfn = zone->zone_start_pfn; -printk ("Initializing highpages for node %d\n" , nid);for (node_pfn =0 ; node_pfn < node_high_size; node_pfn++) {one_highpage_init ((struct page *)(zone_mem_map + node_pfn), zone_start_pfn + node_pfn, bad_ppro);
mm/page_alloc.c +1 -1
@@ -1421,7 +1421,7 @@ void __init memmap_init_zone(struct pageINIT_LIST_HEAD (&page->lru);#ifdef WANT_PAGE_VIRTUAL /* The shift won't overflow because ZONE_NORMAL is below 4G. */ -if (zone !=ZONE_HIGHMEM ) +if (!is_highmem (zone))set_page_address (page,__va (start_pfn <<PAGE_SHIFT ));#endif start_pfn++;