summaryrefslogtreecommitdiffstats
path: root/mm/page_alloc.c
diff options
context:
space:
mode:
authorMel Gorman <mgorman@suse.de>2015-06-30 17:56:59 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-06-30 22:44:56 -0400
commit75a592a47129dcfc1aec40e7d3cdf239a767d441 (patch)
tree366cbe1aaf6f6b70ea2f3bb47bdccf2a9d97fbad /mm/page_alloc.c
parent8a942fdea560d4ac0e9d9fabcd5201ad20e0c382 (diff)
mm: meminit: inline some helper functions
early_pfn_in_nid() and meminit_pfn_in_nid() are small functions that are unnecessarily visible outside memory initialisation. As well as unnecessary visibility, it's unnecessary function call overhead when initialising pages. This patch moves the helpers inline. [akpm@linux-foundation.org: fix build] [mhocko@suse.cz: fix build] Signed-off-by: Mel Gorman <mgorman@suse.de> Tested-by: Nate Zimmer <nzimmer@sgi.com> Tested-by: Waiman Long <waiman.long@hp.com> Tested-by: Daniel J Blueman <daniel@numascale.com> Acked-by: Pekka Enberg <penberg@kernel.org> Cc: Robin Holt <robinmholt@gmail.com> Cc: Nate Zimmer <nzimmer@sgi.com> Cc: Dave Hansen <dave.hansen@intel.com> Cc: Waiman Long <waiman.long@hp.com> Cc: Scott Norton <scott.norton@hp.com> Cc: "Luck, Tony" <tony.luck@intel.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Michal Hocko <mhocko@suse.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/page_alloc.c')
-rw-r--r--mm/page_alloc.c89
1 files changed, 52 insertions, 37 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index ffdb2308848d..12a81870815f 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -899,6 +899,58 @@ void __init __free_pages_bootmem(struct page *page, unsigned long pfn,
899 __free_pages(page, order); 899 __free_pages(page, order);
900} 900}
901 901
902#if defined(CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID) || \
903 defined(CONFIG_HAVE_MEMBLOCK_NODE_MAP)
904/* Only safe to use early in boot when initialisation is single-threaded */
905static struct mminit_pfnnid_cache early_pfnnid_cache __meminitdata;
906
907int __meminit early_pfn_to_nid(unsigned long pfn)
908{
909 int nid;
910
911 /* The system will behave unpredictably otherwise */
912 BUG_ON(system_state != SYSTEM_BOOTING);
913
914 nid = __early_pfn_to_nid(pfn, &early_pfnnid_cache);
915 if (nid >= 0)
916 return nid;
917 /* just returns 0 */
918 return 0;
919}
920#endif
921
922#ifdef CONFIG_NODES_SPAN_OTHER_NODES
923static inline bool __meminit meminit_pfn_in_nid(unsigned long pfn, int node,
924 struct mminit_pfnnid_cache *state)
925{
926 int nid;
927
928 nid = __early_pfn_to_nid(pfn, state);
929 if (nid >= 0 && nid != node)
930 return false;
931 return true;
932}
933
934/* Only safe to use early in boot when initialisation is single-threaded */
935static inline bool __meminit early_pfn_in_nid(unsigned long pfn, int node)
936{
937 return meminit_pfn_in_nid(pfn, node, &early_pfnnid_cache);
938}
939
940#else
941
942static inline bool __meminit early_pfn_in_nid(unsigned long pfn, int node)
943{
944 return true;
945}
946static inline bool __meminit meminit_pfn_in_nid(unsigned long pfn, int node,
947 struct mminit_pfnnid_cache *state)
948{
949 return true;
950}
951#endif
952
953
902#ifdef CONFIG_CMA 954#ifdef CONFIG_CMA
903/* Free whole pageblock and set its migration type to MIGRATE_CMA. */ 955/* Free whole pageblock and set its migration type to MIGRATE_CMA. */
904void __init init_cma_reserved_pageblock(struct page *page) 956void __init init_cma_reserved_pageblock(struct page *page)
@@ -4575,43 +4627,6 @@ int __meminit __early_pfn_to_nid(unsigned long pfn,
4575} 4627}
4576#endif /* CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID */ 4628#endif /* CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID */
4577 4629
4578static struct mminit_pfnnid_cache early_pfnnid_cache __meminitdata;
4579
4580/* Only safe to use early in boot when initialisation is single-threaded */
4581int __meminit early_pfn_to_nid(unsigned long pfn)
4582{
4583 int nid;
4584
4585 /* The system will behave unpredictably otherwise */
4586 BUG_ON(system_state != SYSTEM_BOOTING);
4587
4588 nid = __early_pfn_to_nid(pfn, &early_pfnnid_cache);
4589 if (nid >= 0)
4590 return nid;
4591 /* just returns 0 */
4592 return 0;
4593}
4594
4595#ifdef CONFIG_NODES_SPAN_OTHER_NODES
4596bool __meminit meminit_pfn_in_nid(unsigned long pfn, int node,
4597 struct mminit_pfnnid_cache *state)
4598{
4599 int nid;
4600
4601 nid = __early_pfn_to_nid(pfn, state);
4602 if (nid >= 0 && nid != node)
4603 return false;
4604 return true;
4605}
4606
4607/* Only safe to use early in boot when initialisation is single-threaded */
4608bool __meminit early_pfn_in_nid(unsigned long pfn, int node)
4609{
4610 return meminit_pfn_in_nid(pfn, node, &early_pfnnid_cache);
4611}
4612
4613#endif
4614
4615/** 4630/**
4616 * free_bootmem_with_active_regions - Call memblock_free_early_nid for each active range 4631 * free_bootmem_with_active_regions - Call memblock_free_early_nid for each active range
4617 * @nid: The node to free memory on. If MAX_NUMNODES, all nodes are freed. 4632 * @nid: The node to free memory on. If MAX_NUMNODES, all nodes are freed.