Skip to content

Commit

Permalink
mm: make show_free_areas() static
Browse files Browse the repository at this point in the history
All callers of show_free_areas() pass 0 and NULL, so we can directly use
show_mem() instead of show_free_areas(0, NULL), which could make
show_free_areas() a static function.

Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Kefeng Wang <[email protected]>
Cc: Christophe Leroy <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Matthew Wilcox <[email protected]>
Cc: Michael Ellerman <[email protected]>
Cc: Nicholas Piggin <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
  • Loading branch information
Kefeng Wang authored and akpm00 committed Aug 18, 2023
1 parent 527ed4f commit 1279aa0
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 19 deletions.
2 changes: 1 addition & 1 deletion arch/sparc/kernel/setup_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ static void prom_sync_me(void)
"nop\n\t" : : "r" (&trapbase));

prom_printf("PROM SYNC COMMAND...\n");
show_free_areas(0, NULL);
show_mem();
if (!is_idle_task(current)) {
local_irq_enable();
ksys_sync();
Expand Down
12 changes: 0 additions & 12 deletions include/linux/mm.h
Original file line number Diff line number Diff line change
Expand Up @@ -2236,18 +2236,6 @@ extern void pagefault_out_of_memory(void);
#define offset_in_thp(page, p) ((unsigned long)(p) & (thp_size(page) - 1))
#define offset_in_folio(folio, p) ((unsigned long)(p) & (folio_size(folio) - 1))

/*
* Flags passed to show_mem() and show_free_areas() to suppress output in
* various contexts.
*/
#define SHOW_MEM_FILTER_NODES (0x0001u) /* disallowed nodes */

extern void __show_free_areas(unsigned int flags, nodemask_t *nodemask, int max_zone_idx);
static void __maybe_unused show_free_areas(unsigned int flags, nodemask_t *nodemask)
{
__show_free_areas(flags, nodemask, MAX_NR_ZONES - 1);
}

/*
* Parameter block passed down to zap_pte_range in exceptional cases.
*/
Expand Down
6 changes: 6 additions & 0 deletions mm/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ void page_writeback_init(void);
#define COMPOUND_MAPPED 0x800000
#define FOLIO_PAGES_MAPPED (COMPOUND_MAPPED - 1)

/*
* Flags passed to __show_mem() and show_free_areas() to suppress output in
* various contexts.
*/
#define SHOW_MEM_FILTER_NODES (0x0001u) /* disallowed nodes */

/*
* How many individual pages have an elevated _mapcount. Excludes
* the folio's entire_mapcount.
Expand Down
8 changes: 4 additions & 4 deletions mm/nommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,7 @@ static int do_mmap_private(struct vm_area_struct *vma,
enomem:
pr_err("Allocation of length %lu from process %d (%s) failed\n",
len, current->pid, current->comm);
show_free_areas(0, NULL);
show_mem();
return -ENOMEM;
}

Expand Down Expand Up @@ -1236,20 +1236,20 @@ unsigned long do_mmap(struct file *file,
kmem_cache_free(vm_region_jar, region);
pr_warn("Allocation of vma for %lu byte allocation from process %d failed\n",
len, current->pid);
show_free_areas(0, NULL);
show_mem();
return -ENOMEM;

error_getting_region:
pr_warn("Allocation of vm region for %lu byte allocation from process %d failed\n",
len, current->pid);
show_free_areas(0, NULL);
show_mem();
return -ENOMEM;

error_vma_iter_prealloc:
kmem_cache_free(vm_region_jar, region);
vm_area_free(vma);
pr_warn("Allocation of vma tree for process %d failed\n", current->pid);
show_free_areas(0, NULL);
show_mem();
return -ENOMEM;

}
Expand Down
4 changes: 2 additions & 2 deletions mm/show_mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ static bool node_has_managed_zones(pg_data_t *pgdat, int max_zone_idx)
* SHOW_MEM_FILTER_NODES: suppress nodes that are not allowed by current's
* cpuset.
*/
void __show_free_areas(unsigned int filter, nodemask_t *nodemask, int max_zone_idx)
static void show_free_areas(unsigned int filter, nodemask_t *nodemask, int max_zone_idx)
{
unsigned long free_pcp = 0;
int cpu, nid;
Expand Down Expand Up @@ -406,7 +406,7 @@ void __show_mem(unsigned int filter, nodemask_t *nodemask, int max_zone_idx)
struct zone *zone;

printk("Mem-Info:\n");
__show_free_areas(filter, nodemask, max_zone_idx);
show_free_areas(filter, nodemask, max_zone_idx);

for_each_populated_zone(zone) {

Expand Down

0 comments on commit 1279aa0

Please sign in to comment.