Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * mm/percpu-debug.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright (C) 2017		Facebook Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * Copyright (C) 2017		Dennis Zhou <dennis@kernel.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  * Prints statistics about the percpu allocator and backing chunks.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/debugfs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/list.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/percpu.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/seq_file.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/sort.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/vmalloc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include "percpu-internal.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #define P(X, Y) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 	seq_printf(m, "  %-20s: %12lld\n", X, (long long int)Y)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) struct percpu_stats pcpu_stats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) struct pcpu_alloc_info pcpu_stats_ai;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) static int cmpint(const void *a, const void *b)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	return *(int *)a - *(int *)b;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31)  * Iterates over all chunks to find the max nr_alloc entries.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) static int find_max_nr_alloc(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	struct pcpu_chunk *chunk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	int slot, max_nr_alloc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	enum pcpu_chunk_type type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	max_nr_alloc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	for (type = 0; type < PCPU_NR_CHUNK_TYPES; type++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 		for (slot = 0; slot < pcpu_nr_slots; slot++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 			list_for_each_entry(chunk, &pcpu_chunk_list(type)[slot],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 					    list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 				max_nr_alloc = max(max_nr_alloc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 						   chunk->nr_alloc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	return max_nr_alloc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51)  * Prints out chunk state. Fragmentation is considered between
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52)  * the beginning of the chunk to the last allocation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54)  * All statistics are in bytes unless stated otherwise.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) static void chunk_map_stats(struct seq_file *m, struct pcpu_chunk *chunk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 			    int *buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	struct pcpu_block_md *chunk_md = &chunk->chunk_md;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	int i, last_alloc, as_len, start, end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	int *alloc_sizes, *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	/* statistics */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	int sum_frag = 0, max_frag = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	int cur_min_alloc = 0, cur_med_alloc = 0, cur_max_alloc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	alloc_sizes = buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	 * find_last_bit returns the start value if nothing found.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	 * Therefore, we must determine if it is a failure of find_last_bit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	 * and set the appropriate value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	last_alloc = find_last_bit(chunk->alloc_map,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 				   pcpu_chunk_map_bits(chunk) -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 				   chunk->end_offset / PCPU_MIN_ALLOC_SIZE - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	last_alloc = test_bit(last_alloc, chunk->alloc_map) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 		     last_alloc + 1 : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	as_len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	start = chunk->start_offset / PCPU_MIN_ALLOC_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	 * If a bit is set in the allocation map, the bound_map identifies
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	 * where the allocation ends.  If the allocation is not set, the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	 * bound_map does not identify free areas as it is only kept accurate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	 * on allocation, not free.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	 * Positive values are allocations and negative values are free
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	 * fragments.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	while (start < last_alloc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 		if (test_bit(start, chunk->alloc_map)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 			end = find_next_bit(chunk->bound_map, last_alloc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 					    start + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 			alloc_sizes[as_len] = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 			end = find_next_bit(chunk->alloc_map, last_alloc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 					    start + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 			alloc_sizes[as_len] = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 		alloc_sizes[as_len++] *= (end - start) * PCPU_MIN_ALLOC_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 		start = end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	 * The negative values are free fragments and thus sorting gives the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	 * free fragments at the beginning in largest first order.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	if (as_len > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 		sort(alloc_sizes, as_len, sizeof(int), cmpint, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 		/* iterate through the unallocated fragments */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 		for (i = 0, p = alloc_sizes; *p < 0 && i < as_len; i++, p++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 			sum_frag -= *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 			max_frag = max(max_frag, -1 * (*p));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 		cur_min_alloc = alloc_sizes[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 		cur_med_alloc = alloc_sizes[(i + as_len - 1) / 2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 		cur_max_alloc = alloc_sizes[as_len - 1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	P("nr_alloc", chunk->nr_alloc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	P("max_alloc_size", chunk->max_alloc_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	P("empty_pop_pages", chunk->nr_empty_pop_pages);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	P("first_bit", chunk_md->first_free);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	P("free_bytes", chunk->free_bytes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	P("contig_bytes", chunk_md->contig_hint * PCPU_MIN_ALLOC_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	P("sum_frag", sum_frag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	P("max_frag", max_frag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	P("cur_min_alloc", cur_min_alloc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	P("cur_med_alloc", cur_med_alloc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	P("cur_max_alloc", cur_max_alloc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) #ifdef CONFIG_MEMCG_KMEM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	P("memcg_aware", pcpu_is_memcg_chunk(pcpu_chunk_type(chunk)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	seq_putc(m, '\n');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) static int percpu_stats_show(struct seq_file *m, void *v)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	struct pcpu_chunk *chunk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	int slot, max_nr_alloc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	int *buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	enum pcpu_chunk_type type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	int nr_empty_pop_pages;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) alloc_buffer:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	spin_lock_irq(&pcpu_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	max_nr_alloc = find_max_nr_alloc();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	spin_unlock_irq(&pcpu_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	/* there can be at most this many free and allocated fragments */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	buffer = vmalloc(array_size(sizeof(int), (2 * max_nr_alloc + 1)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	if (!buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	spin_lock_irq(&pcpu_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	/* if the buffer allocated earlier is too small */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	if (max_nr_alloc < find_max_nr_alloc()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 		spin_unlock_irq(&pcpu_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 		vfree(buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 		goto alloc_buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	nr_empty_pop_pages = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	for (type = 0; type < PCPU_NR_CHUNK_TYPES; type++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 		nr_empty_pop_pages += pcpu_nr_empty_pop_pages[type];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) #define PL(X)								\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	seq_printf(m, "  %-20s: %12lld\n", #X, (long long int)pcpu_stats_ai.X)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	seq_printf(m,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 			"Percpu Memory Statistics\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 			"Allocation Info:\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 			"----------------------------------------\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	PL(unit_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	PL(static_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	PL(reserved_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	PL(dyn_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	PL(atom_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	PL(alloc_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	seq_putc(m, '\n');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) #undef PL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) #define PU(X) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	seq_printf(m, "  %-20s: %12llu\n", #X, (unsigned long long)pcpu_stats.X)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	seq_printf(m,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 			"Global Stats:\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 			"----------------------------------------\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	PU(nr_alloc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	PU(nr_dealloc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	PU(nr_cur_alloc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	PU(nr_max_alloc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	PU(nr_chunks);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	PU(nr_max_chunks);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	PU(min_alloc_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	PU(max_alloc_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	P("empty_pop_pages", nr_empty_pop_pages);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	seq_putc(m, '\n');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) #undef PU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	seq_printf(m,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 			"Per Chunk Stats:\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 			"----------------------------------------\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	if (pcpu_reserved_chunk) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 		seq_puts(m, "Chunk: <- Reserved Chunk\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 		chunk_map_stats(m, pcpu_reserved_chunk, buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	for (type = 0; type < PCPU_NR_CHUNK_TYPES; type++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 		for (slot = 0; slot < pcpu_nr_slots; slot++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 			list_for_each_entry(chunk, &pcpu_chunk_list(type)[slot],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 					    list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 				if (chunk == pcpu_first_chunk) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 					seq_puts(m, "Chunk: <- First Chunk\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 					chunk_map_stats(m, chunk, buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 				} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 					seq_puts(m, "Chunk:\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 					chunk_map_stats(m, chunk, buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	spin_unlock_irq(&pcpu_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	vfree(buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) DEFINE_SHOW_ATTRIBUTE(percpu_stats);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) static int __init init_percpu_stats_debugfs(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	debugfs_create_file("percpu_stats", 0444, NULL, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 			&percpu_stats_fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) late_initcall(init_percpu_stats_debugfs);