hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/mm/percpu-stats.c
....@@ -1,10 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * mm/percpu-debug.c
34 *
45 * Copyright (C) 2017 Facebook Inc.
5
- * Copyright (C) 2017 Dennis Zhou <dennisz@fb.com>
6
- *
7
- * This file is released under the GPLv2.
6
+ * Copyright (C) 2017 Dennis Zhou <dennis@kernel.org>
87 *
98 * Prints statistics about the percpu allocator and backing chunks.
109 */
....@@ -35,11 +34,15 @@
3534 {
3635 struct pcpu_chunk *chunk;
3736 int slot, max_nr_alloc;
37
+ enum pcpu_chunk_type type;
3838
3939 max_nr_alloc = 0;
40
- for (slot = 0; slot < pcpu_nr_slots; slot++)
41
- list_for_each_entry(chunk, &pcpu_slot[slot], list)
42
- max_nr_alloc = max(max_nr_alloc, chunk->nr_alloc);
40
+ for (type = 0; type < PCPU_NR_CHUNK_TYPES; type++)
41
+ for (slot = 0; slot < pcpu_nr_slots; slot++)
42
+ list_for_each_entry(chunk, &pcpu_chunk_list(type)[slot],
43
+ list)
44
+ max_nr_alloc = max(max_nr_alloc,
45
+ chunk->nr_alloc);
4346
4447 return max_nr_alloc;
4548 }
....@@ -53,6 +56,7 @@
5356 static void chunk_map_stats(struct seq_file *m, struct pcpu_chunk *chunk,
5457 int *buffer)
5558 {
59
+ struct pcpu_block_md *chunk_md = &chunk->chunk_md;
5660 int i, last_alloc, as_len, start, end;
5761 int *alloc_sizes, *p;
5862 /* statistics */
....@@ -121,14 +125,17 @@
121125 P("nr_alloc", chunk->nr_alloc);
122126 P("max_alloc_size", chunk->max_alloc_size);
123127 P("empty_pop_pages", chunk->nr_empty_pop_pages);
124
- P("first_bit", chunk->first_bit);
128
+ P("first_bit", chunk_md->first_free);
125129 P("free_bytes", chunk->free_bytes);
126
- P("contig_bytes", chunk->contig_bits * PCPU_MIN_ALLOC_SIZE);
130
+ P("contig_bytes", chunk_md->contig_hint * PCPU_MIN_ALLOC_SIZE);
127131 P("sum_frag", sum_frag);
128132 P("max_frag", max_frag);
129133 P("cur_min_alloc", cur_min_alloc);
130134 P("cur_med_alloc", cur_med_alloc);
131135 P("cur_max_alloc", cur_max_alloc);
136
+#ifdef CONFIG_MEMCG_KMEM
137
+ P("memcg_aware", pcpu_is_memcg_chunk(pcpu_chunk_type(chunk)));
138
+#endif
132139 seq_putc(m, '\n');
133140 }
134141
....@@ -137,6 +144,8 @@
137144 struct pcpu_chunk *chunk;
138145 int slot, max_nr_alloc;
139146 int *buffer;
147
+ enum pcpu_chunk_type type;
148
+ int nr_empty_pop_pages;
140149
141150 alloc_buffer:
142151 spin_lock_irq(&pcpu_lock);
....@@ -157,7 +166,11 @@
157166 goto alloc_buffer;
158167 }
159168
160
-#define PL(X) \
169
+ nr_empty_pop_pages = 0;
170
+ for (type = 0; type < PCPU_NR_CHUNK_TYPES; type++)
171
+ nr_empty_pop_pages += pcpu_nr_empty_pop_pages[type];
172
+
173
+#define PL(X) \
161174 seq_printf(m, " %-20s: %12lld\n", #X, (long long int)pcpu_stats_ai.X)
162175
163176 seq_printf(m,
....@@ -188,7 +201,7 @@
188201 PU(nr_max_chunks);
189202 PU(min_alloc_size);
190203 PU(max_alloc_size);
191
- P("empty_pop_pages", pcpu_nr_empty_pop_pages);
204
+ P("empty_pop_pages", nr_empty_pop_pages);
192205 seq_putc(m, '\n');
193206
194207 #undef PU
....@@ -202,18 +215,18 @@
202215 chunk_map_stats(m, pcpu_reserved_chunk, buffer);
203216 }
204217
205
- for (slot = 0; slot < pcpu_nr_slots; slot++) {
206
- list_for_each_entry(chunk, &pcpu_slot[slot], list) {
207
- if (chunk == pcpu_first_chunk) {
208
- seq_puts(m, "Chunk: <- First Chunk\n");
209
- chunk_map_stats(m, chunk, buffer);
210
-
211
-
212
- } else {
213
- seq_puts(m, "Chunk:\n");
214
- chunk_map_stats(m, chunk, buffer);
218
+ for (type = 0; type < PCPU_NR_CHUNK_TYPES; type++) {
219
+ for (slot = 0; slot < pcpu_nr_slots; slot++) {
220
+ list_for_each_entry(chunk, &pcpu_chunk_list(type)[slot],
221
+ list) {
222
+ if (chunk == pcpu_first_chunk) {
223
+ seq_puts(m, "Chunk: <- First Chunk\n");
224
+ chunk_map_stats(m, chunk, buffer);
225
+ } else {
226
+ seq_puts(m, "Chunk:\n");
227
+ chunk_map_stats(m, chunk, buffer);
228
+ }
215229 }
216
-
217230 }
218231 }
219232