Skip to content

Commit 75a592a

Browse files
Mel Gormantorvalds
authored andcommitted
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>
1 parent 8a942fd commit 75a592a

File tree

2 files changed

+52
-46
lines changed

2 files changed

+52
-46
lines changed

include/linux/mmzone.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1227,15 +1227,6 @@ struct mminit_pfnnid_cache {
12271227
int last_nid;
12281228
};
12291229

1230-
#ifdef CONFIG_NODES_SPAN_OTHER_NODES
1231-
bool early_pfn_in_nid(unsigned long pfn, int nid);
1232-
bool meminit_pfn_in_nid(unsigned long pfn, int node,
1233-
struct mminit_pfnnid_cache *state);
1234-
#else
1235-
#define early_pfn_in_nid(pfn, nid) (1)
1236-
#define meminit_pfn_in_nid(pfn, nid, state) (1)
1237-
#endif
1238-
12391230
#ifndef early_pfn_valid
12401231
#define early_pfn_valid(pfn) (1)
12411232
#endif

mm/page_alloc.c

Lines changed: 52 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -899,6 +899,58 @@ void __init __free_pages_bootmem(struct page *page, unsigned long pfn,
899899
__free_pages(page, order);
900900
}
901901

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 */
905+
static struct mminit_pfnnid_cache early_pfnnid_cache __meminitdata;
906+
907+
int __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
923+
static 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 */
935+
static 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+
942+
static inline bool __meminit early_pfn_in_nid(unsigned long pfn, int node)
943+
{
944+
return true;
945+
}
946+
static 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+
902954
#ifdef CONFIG_CMA
903955
/* Free whole pageblock and set its migration type to MIGRATE_CMA. */
904956
void __init init_cma_reserved_pageblock(struct page *page)
@@ -4575,43 +4627,6 @@ int __meminit __early_pfn_to_nid(unsigned long pfn,
45754627
}
45764628
#endif /* CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID */
45774629

4578-
static struct mminit_pfnnid_cache early_pfnnid_cache __meminitdata;
4579-
4580-
/* Only safe to use early in boot when initialisation is single-threaded */
4581-
int __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
4596-
bool __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 */
4608-
bool __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-
46154630
/**
46164631
* free_bootmem_with_active_regions - Call memblock_free_early_nid for each active range
46174632
* @nid: The node to free memory on. If MAX_NUMNODES, all nodes are freed.

0 commit comments

Comments
 (0)