mm: zone & pgdat accessors plus some cleanup
Subsystems (6)
PATCH v2 1/9 mm: add SECTION_IN_PAGE_FLAGS
In reply to Cody P SchaferInstead of directly utilizing a combination of config options to determine this, add a macro to specifically address it.
--- include/linux/mm.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
include/linux/mm.h +6 -2
@@ -625,6 +625,10 @@ static inline pte_t maybe_mkwrite(pte_t pte, struct vm_area_struct *vma)#define NODE_NOT_IN_PAGE_FLAGS #endif +#if defined(CONFIG_SPARSEMEM ) && !defined(CONFIG_SPARSEMEM_VMEMMAP ) +#define SECTION_IN_PAGE_FLAGS +#endif +/* * Define the bit shifts to access each section. For non-existent * sections we define the shift as 0; that plus a 0 mask ensures
@@ -727,7 +731,7 @@ static inline struct zone *page_zone(const struct page *page)return &NODE_DATA (page_to_nid (page))->node_zones[page_zonenum (page)]; } -#if defined(CONFIG_SPARSEMEM ) && !defined(CONFIG_SPARSEMEM_VMEMMAP ) +#ifdef SECTION_IN_PAGE_FLAGS static inline void set_page_section (struct page *page,unsigned long section) { page->flags &= ~(SECTIONS_MASK <<SECTIONS_PGSHIFT );
@@ -757,7 +761,7 @@ static inline void set_page_links(struct page *page, enum zone_type zone, {set_page_zone (page, zone);set_page_node (page, node); -#if defined(CONFIG_SPARSEMEM ) && !defined(CONFIG_SPARSEMEM_VMEMMAP ) +#ifdef SECTION_IN_PAGE_FLAGS set_page_section (page,pfn_to_section_nr (pfn));#endif }
Signature · 7 lines
1.8.0.3 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
v2 cover mm: zone & pgdat accessors plus some cleanup
Summaries:
1 - avoid repeating checks for section in page flags by adding a define. 2 - add & switch to zone_end_pfn() and zone_spans_pfn()
3 - adds zone_is_initialized() & zone_is_empty()
4 - adds a VM_BUG using zone_is_initialized() in __free_one_page() 5 - add pgdat_end_pfn() and pgdat_is_empty()
6 - add debugging message to VM_BUG check.
7 - add ensure_zone_is_initialized() (for memory_hotplug)
8 - use the above addition in memory_hotplug
9 - use pgdat_end_pfn()
As a general concern: spanned_pages & start_pfn (in pgdat & zone) are supposed to be locked (via a seqlock) when read (due to changes to them via memory_hotplug), but very few (only 1?) of their users appear to actually lock them.
--
Since v1:
- drop zone+pgdat growth factoring (I use this in some WIP code to resign the NUMA node a page belongs to, will send with that patchset)
- merge zone_end_pfn() & zone_spans_pfn() introduction & usage
- split zone_is_initialized() & zone_is_empty() out from the above.
- add a missing semicolon
include/linux/mm.h | 8 ++++++-- include/linux/mmzone.h | 34 +++++++++++++++++++++++++++++---- mm/compaction.c | 10 +++++----- mm/kmemleak.c | 5 ++--- mm/memory_hotplug.c | 52 ++++++++++++++++++++++++++------------------------ mm/page_alloc.c | 31 +++++++++++++++++------------- mm/vmstat.c | 2 +- 7 files changed, 89 insertions(+), 53 deletions(-)
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 2/9 mm: add & use zone_end_pfn() and zone_spans_pfn()
Add 2 helpers (zone_end_pfn() and zone_spans_pfn()) to reduce code duplication.
This also switches to using them in compaction (where an additional variable needed to be renamed), page_alloc, vmstat, memory_hotplug, and kmemleak.
---
Note that in compaction.c I avoid calling zone_end_pfn() repeatedly because I expect at some point the sycronization issues with start_pfn & spanned_pages will need fixing, either by actually using the seqlock or clever memory barrier usage.
include/linux/mmzone.h | 10 ++++++++++ mm/compaction.c | 10 +++++----- mm/kmemleak.c | 5 ++--- mm/memory_hotplug.c | 10 +++++----- mm/page_alloc.c | 22 +++++++++------------- mm/vmstat.c | 2 +- 6 files changed, 32 insertions(+), 27 deletions(-)
include/linux/mmzone.h +10 -0
@@ -543,6 +543,16 @@ static inline int zone_is_oom_locked(const struct zone *zone)return test_bit (ZONE_OOM_LOCKED , &zone->flags); } +static inline unsigned zone_end_pfn (const struct zone *zone) +{ +return zone->zone_start_pfn + zone->spanned_pages; +} + +static inline bool zone_spans_pfn (const struct zone *zone,unsigned long pfn) +{ +return zone->zone_start_pfn <= pfn && pfn <zone_end_pfn (zone); +} +/* * The "priority" of VM scanning is how much of the queues we will scan in one * go. A value of 12 for DEF_PRIORITY implies that we will scan 1/4096th of the
mm/compaction.c +5 -5
@@ -85,7 +85,7 @@ static inline bool isolation_suitable(struct compact_control *cc,static void __reset_isolation_suitable (struct zone *zone) {unsigned long start_pfn = zone->zone_start_pfn; -unsigned long end_pfn = zone->zone_start_pfn + zone->spanned_pages; +unsigned long end_pfn =zone_end_pfn (zone);unsigned long pfn; zone->compact_cached_migrate_pfn = start_pfn;
@@ -644,7 +644,7 @@ static void isolate_freepages(struct zone *zone, struct compact_control *cc) {struct page *page; -unsigned long high_pfn, low_pfn, pfn, zone_end_pfn, end_pfn; +unsigned long high_pfn, low_pfn, pfn, z_end_pfn, end_pfn;int nr_freepages = cc->nr_freepages;struct list_head *freelist = &cc->freepages;
@@ -663,7 +663,7 @@ static void isolate_freepages(struct zone *zone,*/ high_pfn =min (low_pfn, pfn); - zone_end_pfn = zone->zone_start_pfn + zone->spanned_pages; + z_end_pfn =zone_end_pfn (zone);/* * Isolate free pages until enough are available to migrate the
@@ -706,7 +706,7 @@ static void isolate_freepages(struct zone *zone,* only scans within a pageblock */ end_pfn =ALIGN (pfn +1 , pageblock_nr_pages); - end_pfn =min (end_pfn, zone_end_pfn); + end_pfn =min (end_pfn, z_end_pfn); isolated =isolate_freepages_block (cc, pfn, end_pfn, freelist, false); nr_freepages += isolated;
@@ -920,7 +920,7 @@ static int compact_zone(struct zone *zone, struct compact_control *cc) {int ret;unsigned long start_pfn = zone->zone_start_pfn; -unsigned long end_pfn = zone->zone_start_pfn + zone->spanned_pages; +unsigned long end_pfn =zone_end_pfn (zone); ret =compaction_suitable (zone, cc->order);switch (ret) {
mm/kmemleak.c +2 -3
@@ -1300,9 +1300,8 @@ static void kmemleak_scan(void)*/ lock_memory_hotplug ();for_each_online_node (i) { -pg_data_t *pgdat =NODE_DATA (i); -unsigned long start_pfn = pgdat->node_start_pfn; -unsigned long end_pfn = start_pfn + pgdat->node_spanned_pages; +unsigned long start_pfn =node_start_pfn (i); +unsigned long end_pfn =node_end_pfn (i);unsigned long pfn;for (pfn = start_pfn; pfn < end_pfn; pfn++) {
mm/memory_hotplug.c +5 -5
@@ -270,7 +270,7 @@ static int __meminit move_pfn_range_left(struct zone *z1, struct zone *z2,pgdat_resize_lock (z1->zone_pgdat, &flags);/* can't move pfns which are higher than @z2 */ -if (end_pfn > z2->zone_start_pfn + z2->spanned_pages) +if (end_pfn >zone_end_pfn (z2)) goto out_fail;/* the move out part mast at the left most of @z2 */ if (start_pfn > z2->zone_start_pfn)
@@ -286,7 +286,7 @@ static int __meminit move_pfn_range_left(struct zone *z1, struct zone *z2, z1_start_pfn = start_pfn;resize_zone (z1, z1_start_pfn, end_pfn); -resize_zone (z2, end_pfn, z2->zone_start_pfn + z2->spanned_pages); +resize_zone (z2, end_pfn,zone_end_pfn (z2));pgdat_resize_unlock (z1->zone_pgdat, &flags);
@@ -318,15 +318,15 @@ static int __meminit move_pfn_range_right(struct zone *z1, struct zone *z2,if (z1->zone_start_pfn > start_pfn) goto out_fail;/* the move out part mast at the right most of @z1 */ -if (z1->zone_start_pfn + z1->spanned_pages > end_pfn) +if (zone_end_pfn (z1) > end_pfn) goto out_fail;/* must included/overlap */ -if (start_pfn >= z1->zone_start_pfn + z1->spanned_pages) +if (start_pfn >=zone_end_pfn (z1)) goto out_fail;/* use end_pfn for z2's end_pfn if z2 is empty */ if (z2->spanned_pages) - z2_end_pfn = z2->zone_start_pfn + z2->spanned_pages; + z2_end_pfn =zone_end_pfn (z2);else z2_end_pfn = end_pfn;
mm/page_alloc.c +9 -13
@@ -242,9 +242,7 @@ static int page_outside_zone_boundaries(struct zone *zone, struct page *page)do { seq =zone_span_seqbegin (zone); -if (pfn >= zone->zone_start_pfn + zone->spanned_pages) - ret =1 ; -else if (pfn < zone->zone_start_pfn) +if (!zone_spans_pfn (zone, pfn)) ret =1 ; }while (zone_span_seqretry (zone, seq));
@@ -976,9 +974,9 @@ int move_freepages_block(struct zone *zone, struct page *page, end_pfn = start_pfn + pageblock_nr_pages -1 ;/* Do not cross zone boundaries */ -if (start_pfn < zone->zone_start_pfn) +if (!zone_spans_pfn (zone, start_pfn)) start_page = page; -if (end_pfn >= zone->zone_start_pfn + zone->spanned_pages) +if (!zone_spans_pfn (zone, end_pfn))return 0 ;return move_freepages (zone, start_page, end_page, migratetype);
@@ -1272,7 +1270,7 @@ void mark_free_pages(struct zone *zone)spin_lock_irqsave (&zone->lock, flags); - max_zone_pfn = zone->zone_start_pfn + zone->spanned_pages; + max_zone_pfn =zone_end_pfn (zone);for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++)if (pfn_valid (pfn)) {struct page *page =pfn_to_page (pfn);
@@ -3775,7 +3773,7 @@ static void setup_zone_migrate_reserve(struct zone *zone)* the block. */ start_pfn = zone->zone_start_pfn; - end_pfn = start_pfn + zone->spanned_pages; + end_pfn =zone_end_pfn (zone); start_pfn =roundup (start_pfn, pageblock_nr_pages); reserve =roundup (min_wmark_pages (zone), pageblock_nr_pages) >> pageblock_order;
@@ -3889,7 +3887,7 @@ void __meminit memmap_init_zone(unsigned long size, int nid, unsigned long zone,* pfn out of zone. */ if ((z->zone_start_pfn <= pfn) - && (pfn < z->zone_start_pfn + z->spanned_pages) + && (pfn <zone_end_pfn (z)) && !(pfn & (pageblock_nr_pages -1 )))set_pageblock_migratetype (page,MIGRATE_MOVABLE );
@@ -4617,7 +4615,7 @@ static void __init_refok alloc_node_mem_map(struct pglist_data *pgdat)* for the buddy allocator to function correctly. */ start = pgdat->node_start_pfn & ~(MAX_ORDER_NR_PAGES -1 ); - end = pgdat->node_start_pfn + pgdat->node_spanned_pages; + end =pgdat_end_pfn (pgdat); end =ALIGN (end,MAX_ORDER_NR_PAGES ); size = (end - start) *sizeof (struct page ); map =alloc_remap (pgdat->node_id, size);
@@ -5637,8 +5635,7 @@ void set_pageblock_flags_group(struct page *page, unsigned long flags, pfn =page_to_pfn (page); bitmap =get_pageblock_bitmap (zone, pfn); bitidx =pfn_to_bitidx (zone, pfn); -VM_BUG_ON (pfn < zone->zone_start_pfn); -VM_BUG_ON (pfn >= zone->zone_start_pfn + zone->spanned_pages); +VM_BUG_ON (!zone_spans_pfn (zone, pfn));for (; start_bitidx <= end_bitidx; start_bitidx++, value <<=1 )if (flags & value)
@@ -5736,8 +5733,7 @@ bool is_pageblock_removable_nolock(struct page *page) zone =page_zone (page); pfn =page_to_pfn (page); -if (zone->zone_start_pfn > pfn || - zone->zone_start_pfn + zone->spanned_pages <= pfn) +if (!zone_spans_pfn (zone, pfn))return false;return !has_unmovable_pages (zone, page,0 , true);
mm/vmstat.c +1 -1
@@ -890,7 +890,7 @@ static void pagetypeinfo_showblockcount_print(struct seq_file *m,int mtype;unsigned long pfn;unsigned long start_pfn = zone->zone_start_pfn; -unsigned long end_pfn = start_pfn + zone->spanned_pages; +unsigned long end_pfn =zone_end_pfn (zone);unsigned long count[MIGRATE_TYPES ] = {0 , };for (pfn = start_pfn; pfn < end_pfn; pfn += pageblock_nr_pages) {
Signature · 7 lines
1.8.0.3 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 3/9 mm: add zone_is_empty() and zone_is_initialized()
In reply to Cody P SchaferFactoring out these 2 checks makes it more clear what we are actually checking for.
--- include/linux/mmzone.h | 10 ++++++++++ 1 file changed, 10 insertions(+)
include/linux/mmzone.h +10 -0
@@ -553,6 +553,16 @@ static inline bool zone_spans_pfn(const struct zone *zone, unsigned long pfn)return zone->zone_start_pfn <= pfn && pfn <zone_end_pfn (zone); } +static inline bool zone_is_initialized (struct zone *zone) +{ +return !!zone->wait_table; +} + +static inline bool zone_is_empty (struct zone *zone) +{ +return zone->spanned_pages ==0 ; +} +/* * The "priority" of VM scanning is how much of the queues we will scan in one * go. A value of 12 for DEF_PRIORITY implies that we will scan 1/4096th of the
Signature · 7 lines
1.8.0.3 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 4/9 mm/page_alloc: add a VM_BUG in __free_one_page() if the zone is uninitialized.
In reply to Cody P SchaferFrom: Cody P Schafer <[email protected]>
Freeing pages to uninitialized zones is not handled by __free_one_page(), and should never happen when the code is correct.
Ran into this while writing some code that dynamically onlines extra zones.
--- mm/page_alloc.c | 2 ++ 1 file changed, 2 insertions(+)
mm/page_alloc.c +2 -0
@@ -530,6 +530,8 @@ static inline void __free_one_page(struct page *page,unsigned long uninitialized_var (buddy_idx );struct page *buddy; +VM_BUG_ON (!zone_is_initialized (zone)); +if (unlikely (PageCompound (page)))if (unlikely (destroy_compound_page (page, order)))return ;
Signature · 7 lines
1.8.0.3 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 6/9 mm/page_alloc: add informative debugging message in page_outside_zone_boundaries()
In reply to Cody P SchaferAdd a debug message which prints when a page is found outside of the boundaries of the zone it should belong to. Format is:
"page $pfn outside zone [ $start_pfn - $end_pfn ]"
--- mm/page_alloc.c | 7 +++++++ 1 file changed, 7 insertions(+)
mm/page_alloc.c +7 -0
@@ -239,13 +239,20 @@ static int page_outside_zone_boundaries(struct zone *zone, struct page *page)int ret =0 ;unsigned seq;unsigned long pfn =page_to_pfn (page); +unsigned long sp, start_pfn;do { seq =zone_span_seqbegin (zone); + start_pfn = zone->zone_start_pfn; + sp = zone->spanned_pages;if (!zone_spans_pfn (zone, pfn)) ret =1 ; }while (zone_span_seqretry (zone, seq)); +if (ret) +pr_debug ("page %lu outside zone [ %lu - %lu ]\n" , + pfn, start_pfn, start_pfn + sp); +return ret; }
Signature · 7 lines
1.8.0.3 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 7/9 mm: add helper ensure_zone_is_initialized()
In reply to Cody P SchaferFrom: Cody P Schafer <[email protected]>
ensure_zone_is_initialized() checks if a zone is in a empty & not initialized state (typically occuring after it is created in memory hotplugging), and, if so, calls init_currently_empty_zone() to initialize the zone.
--- mm/memory_hotplug.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
mm/memory_hotplug.c +11 -0
@@ -253,6 +253,17 @@ static void fix_zone_id(struct zone *zone, unsigned long start_pfn,set_page_links (pfn_to_page (pfn), zid, nid, pfn); } +/* Can fail with -ENOMEM from allocating a wait table with vmalloc() or +* alloc_bootmem_node_nopanic() */ +static int __ref ensure_zone_is_initialized (struct zone *zone, +unsigned long start_pfn,unsigned long num_pages) +{ +if (!zone_is_initialized (zone)) +return init_currently_empty_zone (zone, start_pfn, num_pages, +MEMMAP_HOTPLUG ); +return 0 ; +} +static int __meminit move_pfn_range_left (struct zone *z1,struct zone *z2,unsigned long start_pfn,unsigned long end_pfn) {
Signature · 7 lines
1.8.0.3 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 8/9 mm/memory_hotplug: use ensure_zone_is_initialized()
In reply to Cody P SchaferRemove open coding of ensure_zone_is_initialzied().
--- mm/memory_hotplug.c | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-)
mm/memory_hotplug.c +10 -19
@@ -271,12 +271,9 @@ static int __meminit move_pfn_range_left(struct zone *z1, struct zone *z2,unsigned long flags;unsigned long z1_start_pfn; -if (!z1->wait_table) { - ret =init_currently_empty_zone (z1, start_pfn, - end_pfn - start_pfn,MEMMAP_HOTPLUG ); -if (ret) -return ret; - } + ret =ensure_zone_is_initialized (z1, start_pfn, end_pfn - start_pfn); +if (ret) +return ret;pgdat_resize_lock (z1->zone_pgdat, &flags);
@@ -316,12 +313,9 @@ static int __meminit move_pfn_range_right(struct zone *z1, struct zone *z2,unsigned long flags;unsigned long z2_end_pfn; -if (!z2->wait_table) { - ret =init_currently_empty_zone (z2, start_pfn, - end_pfn - start_pfn,MEMMAP_HOTPLUG ); -if (ret) -return ret; - } + ret =ensure_zone_is_initialized (z2, start_pfn, end_pfn - start_pfn); +if (ret) +return ret;pgdat_resize_lock (z1->zone_pgdat, &flags);
@@ -374,16 +368,13 @@ static int __meminit __add_zone(struct zone *zone, unsigned long phys_start_pfn)int nid = pgdat->node_id;int zone_type;unsigned long flags; +int ret; zone_type = zone - pgdat->node_zones; -if (!zone->wait_table) { -int ret; + ret =ensure_zone_is_initialized (zone, phys_start_pfn, nr_pages); +if (ret) +return ret; - ret =init_currently_empty_zone (zone, phys_start_pfn, - nr_pages,MEMMAP_HOTPLUG ); -if (ret) -return ret; - }pgdat_resize_lock (zone->zone_pgdat, &flags);grow_zone_span (zone, phys_start_pfn, phys_start_pfn + nr_pages); grow_pgdat_span(zone->zone_pgdat, phys_start_pfn,
Signature · 7 lines
1.8.0.3 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 9/9 mm/memory_hotplug: use pgdat_end_pfn() instead of open coding the same.
In reply to Cody P SchaferReplace open coded pgdat_end_pfn() with helper function.
--- mm/memory_hotplug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/memory_hotplug.c +1 -1
@@ -189,7 +189,7 @@ void register_page_bootmem_info_node(struct pglist_data *pgdat) } pfn = pgdat->node_start_pfn; - end_pfn = pfn + pgdat->node_spanned_pages; + end_pfn =pgdat_end_pfn (pgdat);/* register_section info */ for (; pfn < end_pfn; pfn +=PAGES_PER_SECTION ) {
Signature · 7 lines
1.8.0.3 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 5/9 mmzone: add pgdat_{end_pfn,is_empty}() helpers & consolidate.
In reply to Cody P SchaferFrom: Cody P Schafer <[email protected]>
Add pgdat_end_pfn() and pgdat_is_empty() helpers which match the similar zone_*() functions.
Change node_end_pfn() to be a wrapper of pgdat_end_pfn().
--- include/linux/mmzone.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
include/linux/mmzone.h +10 -4
@@ -772,11 +772,17 @@ typedef struct pglist_data {#define nid_page_nr (nid, pagenr) pgdat_page_nr(NODE_DATA(nid),(pagenr))#define node_start_pfn (nid) (NODE_DATA(nid)->node_start_pfn) +#define node_end_pfn (nid) pgdat_end_pfn(NODE_DATA(nid)) -#define node_end_pfn (nid) ({\ - pg_data_t *__pgdat = NODE_DATA(nid);\ - __pgdat->node_start_pfn + __pgdat->node_spanned_pages;\ -}) +static inline unsigned long pgdat_end_pfn (pg_data_t *pgdat) +{ +return pgdat->node_start_pfn + pgdat->node_spanned_pages; +} + +static inline bool pgdat_is_empty (pg_data_t *pgdat) +{ +return !pgdat->node_start_pfn && !pgdat->node_spanned_pages; +}#include <linux/memory_hotplug.h>
Signature · 7 lines
1.8.0.3 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Andrew Morton
maintainerRe: [PATCH 1/9] mm: add SECTION_IN_PAGE_FLAGS
In reply to Cody P SchaferQuoted 8 lines · On Thu, 17 Jan 2013 14:52:53 -0800 Cody P Schafer <[email protected]>…
Instead of directly utilizing a combination of config options to determine this, add a macro to specifically address it.
...
include/linux/mm.h static inline pte_t maybe_mkwrite(pte_t pte, struct vm_area_struct *vma) · line 630
Quoted 6 lines
include/linux/mm.h +3
-0@@ -625,6 +625,10 @@ static inline pte_t maybe_mkwrite(pte_t pte, struct vm_area_struct *vma)#define NODE_NOT_IN_PAGE_FLAGS #endif +#if defined(CONFIG_SPARSEMEM ) && !defined(CONFIG_SPARSEMEM_VMEMMAP ) +#define SECTION_IN_PAGE_FLAGS +#endif
We could do this in Kconfig itself, in the definition of a new CONFIG_SECTION_IN_PAGE_FLAGS.
I'm not sure that I like that sort of thing a lot though - it's rather a pain to have to switch from .[ch] over to Kconfig to find the definitions of things. I should get off my tail and teach my ctags scripts to handle this.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Andrew Morton
maintainerRe: [PATCH 5/9] mmzone: add pgdat_{end_pfn,is_empty}() helpers & consolidate.
In reply to Cody P SchaferQuoted 12 lines · On Thu, 17 Jan 2013 14:52:57 -0800 Cody P Schafer <[email protected]>…
From: Cody P Schafer <[email protected]>
Add
pgdat_end_pfn()andpgdat_is_empty()helpers which match the similar zone_*() functions.Change
node_end_pfn()to be a wrapper ofpgdat_end_pfn()....
include/linux/mmzone.h typedef struct pglist_data { · line 775
Quoted 4 lines
include/linux/mmzone.h +1
-0@@ -772,11 +772,17 @@ typedef struct pglist_data {#define nid_page_nr (nid, pagenr) pgdat_page_nr(NODE_DATA(nid),(pagenr))#define node_start_pfn (nid) (NODE_DATA(nid)->node_start_pfn) +#define node_end_pfn (nid) pgdat_end_pfn(NODE_DATA(nid))
I wonder if these could be implemented in nice C code rather than nasty cpp code.
include/linux/mmzone.h typedef struct pglist_data { · line 780
Quoted 8 lines
include/linux/mmzone.h +4
-4-#define node_end_pfn (nid) ({\ - pg_data_t *__pgdat = NODE_DATA(nid);\ - __pgdat->node_start_pfn + __pgdat->node_spanned_pages;\ -}) +static inline unsigned long pgdat_end_pfn (pg_data_t *pgdat) +{ +return pgdat->node_start_pfn + pgdat->node_spanned_pages; +}
It wouldn't hurt to add a little comment pointing out that this returns "end pfn plus one", or similar. ie, it is exclusive, not inclusive. Ditto the "zone_*() functions", if needed.
include/linux/mmzone.h typedef struct pglist_data { · line 785
Quoted 4 lines
include/linux/mmzone.h +4
-0+static inline bool pgdat_is_empty (pg_data_t *pgdat) +{ +return !pgdat->node_start_pfn && !pgdat->node_spanned_pages; +}
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Andrew Morton
maintainerRe: [PATCH 6/9] mm/page_alloc: add informative debugging message in page_outside_zone_boundaries()
In reply to Cody P SchaferQuoted 23 lines · On Thu, 17 Jan 2013 14:52:58 -0800 Cody P Schafer <[email protected]>…
Add a debug message which prints when a page is found outside of the boundaries of the zone it should belong to. Format is:
"page $pfn outside zone [ $start_pfn - $end_pfn ]"Signed-off-by Cody P Schafer <[email protected]>--- mm/page_alloc.c | 7 +++++++ 1 file changed, 7 insertions(+)mm/page_alloc.c +3
-0@@ -239,13 +239,20 @@ static int page_outside_zone_boundaries(struct zone *zone, struct page *page)int ret =0 ;unsigned seq;unsigned long pfn =page_to_pfn (page); +unsigned long sp, start_pfn; do { seq = zone_span_seqbegin(zone); + start_pfn = zone->zone_start_pfn; + sp = zone->spanned_pages;
mm/page_alloc.c static int page_outside_zone_boundaries(struct zone *zone, struct page *page) · line 257
Quoted 10 lines
mm/page_alloc.c +4
-0if (!zone_spans_pfn (zone, pfn)) ret =1 ; }while (zone_span_seqretry (zone, seq)); +if (ret) +pr_debug ("page %lu outside zone [ %lu - %lu ]\n" , + pfn, start_pfn, start_pfn + sp); +return ret; }
As this condition leads to a VM_BUG_ON(), "pr_debug" seems rather wimpy and I doubt if we need to be concerned about flooding the console.
I'll switch it to pr_err.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Andrew Morton
maintainerRe: [PATCH 6/9] mm/page_alloc: add informative debugging message in page_outside_zone_boundaries()
Quoted 11 lines · On Fri, 1 Feb 2013 16:28:48 -0800 Andrew Morton <[email protected]>…
mm/page_alloc.c static int page_outside_zone_boundaries(struct zone *zone, struct page *page) · line 257
Quoted 6 lines
mm/page_alloc.c +4
-0+if (ret) +pr_debug ("page %lu outside zone [ %lu - %lu ]\n" , + pfn, start_pfn, start_pfn + sp); +return ret; }As this condition leads to a
VM_BUG_ON(), "pr_debug" seems rather wimpy and I doubt if we need to be concerned about flooding the console.I'll switch it to
pr_err.
otoh, as nobody has ever hit that VM_BUG_ON() (yes?), do we really need the patch?
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Andrew Morton
maintainerQuoted 10 lines · On Thu, 17 Jan 2013 14:52:52 -0800 Cody P Schafer <[email protected]>…
Summaries:
1 - avoid repeating checks for section in page flags by adding a define. 2 - add & switch tozone_end_pfn()andzone_spans_pfn()
3 - addszone_is_initialized()&zone_is_empty()
4 - adds aVM_BUGusingzone_is_initialized()in__free_one_page()5 - addpgdat_end_pfn()andpgdat_is_empty()
6 - add debugging message toVM_BUGcheck.
7 - addensure_zone_is_initialized()(formemory_hotplug)
8 - use the above addition inmemory_hotplug
9 - usepgdat_end_pfn()
Well that's a nice little patchset.
Some of the patches were marked From:[email protected] and others were From:[email protected]. This is strange. If you want me to fix that up, please let me know which is preferred.
Quoted 4 lines
As a general concern:
spanned_pages&start_pfn(in pgdat & zone) are supposed to be locked (via a seqlock) when read (due to changes to them viamemory_hotplug), but very few (only 1?) of their users appear to actually lock them.
OK, thanks. Perhaps this is something which the memory-hotplug developers could take a look at?
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 6/9] mm/page_alloc: add informative debugging message in page_outside_zone_boundaries()
In reply to Andrew MortonQuoted 13 lines · Andrew Morton
Quoted 10 lines · On Fri, 1 Feb 2013 16:28:48 -0800 Andrew Morton <[email protected]>…
mm/page_alloc.c static int page_outside_zone_boundaries(struct zone *zone, struct page *page) · line 257
Quoted 6 lines
mm/page_alloc.c +4
-0+if (ret) +pr_debug ("page %lu outside zone [ %lu - %lu ]\n" , + pfn, start_pfn, start_pfn + sp); +return ret; }As this condition leads to a
VM_BUG_ON(), "pr_debug" seems rather wimpy and I doubt if we need to be concerned about flooding the console.
Quoted 4 lines
Quoted 1 line
I'll switch it to
pr_err.otoh, as nobody has ever hit that
VM_BUG_ON()(yes?), do we really need the patch?
I've hit this bug while developing some code that moves pages between zones.
As it helped me debug that issue with my own code, I could see how another developer might be helped by it.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 1/9] mm: add SECTION_IN_PAGE_FLAGS
In reply to Andrew MortonQuoted 14 lines · Andrew Morton
Quoted 11 lines · On Thu, 17 Jan 2013 14:52:53 -0800 Cody P Schafer <[email protected]>…
Instead of directly utilizing a combination of config options to determine this, add a macro to specifically address it.
...
include/linux/mm.h +0
-0@@ -625,6 +625,10 @@ static inline pte_t maybe_mkwrite(pte_t pte, struct vm_area_struct *vma)#define NODE_NOT_IN_PAGE_FLAGS #endif
Quoted 6 lines
include/linux/mm.h static inline pte_t maybe_mkwrite(pte_t pte, struct vm_area_struct *vma) · line 630
Quoted 3 lines
include/linux/mm.h +3
-0+#if defined(CONFIG_SPARSEMEM ) && !defined(CONFIG_SPARSEMEM_VMEMMAP ) +#define SECTION_IN_PAGE_FLAGS +#endif We could do this in
Kconfigitself, in the definition of a newCONFIG_SECTION_IN_PAGE_FLAGS.
Yep, I only put it here because it "sounds" the similar to NODE_NOT_IN_PAGE_FLAGS, but (of course) NODE_NOT_IN_PAGE_FLAGS isn't defined based on pure dependencies, while this is.
Quoted 4 lines
I'm not sure that I like that sort of thing a lot though - it's rather a pain to have to switch from .[ch] over to
Kconfigto find the definitions of things. I should get off my tail and teach my ctags scripts to handle this.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 14 lines · Andrew Morton
Quoted 10 lines · On Thu, 17 Jan 2013 14:52:52 -0800 Cody P Schafer <[email protected]>…
Summaries:
1 - avoid repeating checks for section in page flags by adding a define. 2 - add & switch tozone_end_pfn()andzone_spans_pfn()
3 - addszone_is_initialized()&zone_is_empty()
4 - adds aVM_BUGusingzone_is_initialized()in__free_one_page()5 - addpgdat_end_pfn()andpgdat_is_empty()
6 - add debugging message toVM_BUGcheck.
7 - addensure_zone_is_initialized()(formemory_hotplug)
8 - use the above addition inmemory_hotplug
9 - usepgdat_end_pfn()
Quoted 5 lines
Well that's a nice little patchset.
Some of the patches were marked From:[email protected] and others were From:[email protected]. This is strange. If you want me to fix that up, please let me know which is preferred.
They should all be "From:[email protected]", other address was me messing up gitconfig (which I've since fixed).
Quoted 7 lines
Quoted 4 lines
As a general concern:
spanned_pages&start_pfn(in pgdat & zone) are supposed to be locked (via a seqlock) when read (due to changes to them viamemory_hotplug), but very few (only 1?) of their users appear to actually lock them.OK, thanks. Perhaps this is something which the memory-hotplug developers could take a look at?
Yep. It's not immediately clear that not locking on read would do terrible things, but at the least the documentation needs fixing and explanation as to why the locking is not used some (or all) places.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>