hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/include/linux/vmstat.h
....@@ -8,6 +8,7 @@
88 #include <linux/vm_event_item.h>
99 #include <linux/atomic.h>
1010 #include <linux/static_key.h>
11
+#include <linux/mmdebug.h>
1112
1213 extern int sysctl_stat_interval;
1314
....@@ -16,8 +17,8 @@
1617 #define DISABLE_NUMA_STAT 0
1718 extern int sysctl_vm_numa_stat;
1819 DECLARE_STATIC_KEY_TRUE(vm_numa_stat_key);
19
-extern int sysctl_vm_numa_stat_handler(struct ctl_table *table,
20
- int write, void __user *buffer, size_t *length, loff_t *ppos);
20
+int sysctl_vm_numa_stat_handler(struct ctl_table *table, int write,
21
+ void *buffer, size_t *length, loff_t *ppos);
2122 #endif
2223
2324 struct reclaim_stat {
....@@ -26,9 +27,17 @@
2627 unsigned nr_congested;
2728 unsigned nr_writeback;
2829 unsigned nr_immediate;
29
- unsigned nr_activate;
30
+ unsigned nr_pageout;
31
+ unsigned nr_activate[ANON_AND_FILE];
3032 unsigned nr_ref_keep;
3133 unsigned nr_unmap_fail;
34
+ unsigned nr_lazyfree_fail;
35
+};
36
+
37
+enum writeback_stat_item {
38
+ NR_DIRTY_THRESHOLD,
39
+ NR_DIRTY_BG_THRESHOLD,
40
+ NR_VM_WRITEBACK_STAT_ITEMS,
3241 };
3342
3443 #ifdef CONFIG_VM_EVENT_COUNTERS
....@@ -188,7 +197,8 @@
188197 return x;
189198 }
190199
191
-static inline unsigned long global_node_page_state(enum node_stat_item item)
200
+static inline
201
+unsigned long global_node_page_state_pages(enum node_stat_item item)
192202 {
193203 long x = atomic_long_read(&vm_node_stat[item]);
194204 #ifdef CONFIG_SMP
....@@ -196,6 +206,13 @@
196206 x = 0;
197207 #endif
198208 return x;
209
+}
210
+
211
+static inline unsigned long global_node_page_state(enum node_stat_item item)
212
+{
213
+ VM_WARN_ON_ONCE(vmstat_item_in_bytes(item));
214
+
215
+ return global_node_page_state_pages(item);
199216 }
200217
201218 static inline unsigned long zone_page_state(struct zone *zone,
....@@ -238,15 +255,13 @@
238255 extern unsigned long sum_zone_numa_state(int node, enum numa_stat_item item);
239256 extern unsigned long node_page_state(struct pglist_data *pgdat,
240257 enum node_stat_item item);
258
+extern unsigned long node_page_state_pages(struct pglist_data *pgdat,
259
+ enum node_stat_item item);
241260 #else
242261 #define sum_zone_node_page_state(node, item) global_zone_page_state(item)
243262 #define node_page_state(node, item) global_node_page_state(item)
263
+#define node_page_state_pages(node, item) global_node_page_state_pages(item)
244264 #endif /* CONFIG_NUMA */
245
-
246
-#define add_zone_page_state(__z, __i, __d) mod_zone_page_state(__z, __i, __d)
247
-#define sub_zone_page_state(__z, __i, __d) mod_zone_page_state(__z, __i, -(__d))
248
-#define add_node_page_state(__p, __i, __d) mod_node_page_state(__p, __i, __d)
249
-#define sub_node_page_state(__p, __i, __d) mod_node_page_state(__p, __i, -(__d))
250265
251266 #ifdef CONFIG_SMP
252267 void __mod_zone_page_state(struct zone *, enum zone_stat_item item, long);
....@@ -277,8 +292,8 @@
277292 void refresh_zone_stat_thresholds(void);
278293
279294 struct ctl_table;
280
-int vmstat_refresh(struct ctl_table *, int write,
281
- void __user *buffer, size_t *lenp, loff_t *ppos);
295
+int vmstat_refresh(struct ctl_table *, int write, void *buffer, size_t *lenp,
296
+ loff_t *ppos);
282297
283298 void drain_zonestat(struct zone *zone, struct per_cpu_pageset *);
284299
....@@ -301,6 +316,11 @@
301316 static inline void __mod_node_page_state(struct pglist_data *pgdat,
302317 enum node_stat_item item, int delta)
303318 {
319
+ if (vmstat_item_in_bytes(item)) {
320
+ VM_WARN_ON_ONCE(delta & (PAGE_SIZE - 1));
321
+ delta >>= PAGE_SHIFT;
322
+ }
323
+
304324 node_page_state_add(delta, pgdat, item);
305325 }
306326
....@@ -390,4 +410,48 @@
390410
391411 extern const char * const vmstat_text[];
392412
413
+static inline const char *zone_stat_name(enum zone_stat_item item)
414
+{
415
+ return vmstat_text[item];
416
+}
417
+
418
+#ifdef CONFIG_NUMA
419
+static inline const char *numa_stat_name(enum numa_stat_item item)
420
+{
421
+ return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
422
+ item];
423
+}
424
+#endif /* CONFIG_NUMA */
425
+
426
+static inline const char *node_stat_name(enum node_stat_item item)
427
+{
428
+ return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
429
+ NR_VM_NUMA_STAT_ITEMS +
430
+ item];
431
+}
432
+
433
+static inline const char *lru_list_name(enum lru_list lru)
434
+{
435
+ return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
436
+}
437
+
438
+static inline const char *writeback_stat_name(enum writeback_stat_item item)
439
+{
440
+ return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
441
+ NR_VM_NUMA_STAT_ITEMS +
442
+ NR_VM_NODE_STAT_ITEMS +
443
+ item];
444
+}
445
+
446
+#if defined(CONFIG_VM_EVENT_COUNTERS) || defined(CONFIG_MEMCG)
447
+static inline const char *vm_event_name(enum vm_event_item item)
448
+{
449
+ return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
450
+ NR_VM_NUMA_STAT_ITEMS +
451
+ NR_VM_NODE_STAT_ITEMS +
452
+ NR_VM_WRITEBACK_STAT_ITEMS +
453
+ item];
454
+}
455
+#endif /* CONFIG_VM_EVENT_COUNTERS || CONFIG_MEMCG */
456
+
393457 #endif /* _LINUX_VMSTAT_H */