-
Notifications
You must be signed in to change notification settings - Fork 279
/
memory.c
20434 lines (17524 loc) · 556 KB
/
memory.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* memory.c - core analysis suite
*
* Copyright (C) 1999, 2000, 2001, 2002 Mission Critical Linux, Inc.
* Copyright (C) 2002-2019 David Anderson
* Copyright (C) 2002-2019 Red Hat, Inc. All rights reserved.
* Copyright (C) 2002 Silicon Graphics, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "defs.h"
#include <sys/mman.h>
#include <ctype.h>
#include <netinet/in.h>
#include <byteswap.h>
#include "maple_tree.h"
struct meminfo { /* general purpose memory information structure */
ulong cache; /* used by the various memory searching/dumping */
ulong slab; /* routines. Only one of these is used per cmd */
ulong c_flags; /* so stuff whatever's helpful in here... */
ulong c_offset;
ulong c_num;
ulong s_mem;
void *s_freep;
ulong *s_index;
ulong s_inuse;
ulong cpucached_cache;
ulong cpucached_slab;
ulong inuse;
ulong order;
ulong slabsize;
ulong num_slabs;
ulong objects;
ulonglong spec_addr;
ulong flags;
ulong size;
ulong objsize;
int memtype;
int free;
int slab_offset;
char *reqname;
char *curname;
ulong *spec_cpumask;
ulong *addrlist;
int *kmem_bufctl;
ulong *cpudata[NR_CPUS];
ulong *shared_array_cache;
int current_cache_index;
ulong found;
ulong retval;
struct struct_member_data *page_member_cache;
ulong nr_members;
char *ignore;
int errors;
int calls;
int cpu;
int cache_count;
ulong get_shared;
ulong get_totalram;
ulong get_buffers;
ulong get_slabs;
char *slab_buf;
char *cache_buf;
ulong *cache_list;
struct vmlist {
ulong addr;
ulong size;
} *vmlist;
ulong container;
int *freelist;
int freelist_index_size;
ulong random;
ulong list_offset;
};
/*
* Search modes
*/
#define SEARCH_ULONG (0)
#define SEARCH_UINT (1)
#define SEARCH_USHORT (2)
#define SEARCH_CHARS (3)
#define SEARCH_DEFAULT (SEARCH_ULONG)
/* search mode information */
struct searchinfo {
int mode;
int vcnt;
int val;
int context;
int memtype;
int do_task_header;
int tasks_found;
struct task_context *task_context;
ulong vaddr_start;
ulong vaddr_end;
ulonglong paddr_start;
ulonglong paddr_end;
union {
/* default ulong search */
struct {
ulong value[MAXARGS];
char *opt_string[MAXARGS];
ulong mask;
} s_ulong;
/* uint search */
struct {
uint value[MAXARGS];
char *opt_string[MAXARGS];
uint mask;
} s_uint;
/* ushort search */
struct {
ushort value[MAXARGS];
char *opt_string[MAXARGS];
ushort mask;
} s_ushort;
/* string (chars) search */
struct {
char *value[MAXARGS];
int len[MAXARGS];
int started_flag; /* string search needs history */
} s_chars;
} s_parms;
char buf[BUFSIZE];
};
struct handle_each_vm_area_args {
ulong task;
ulong flag;
ulong vaddr;
struct reference *ref;
char *vma_header;
char *buf1;
char *buf2;
char *buf3;
char *buf4;
char *buf5;
ulong vma;
char **vma_buf;
struct task_mem_usage *tm;
int *found;
int *single_vma_found;
unsigned int radix;
struct task_context *tc;
ulong *single_vma;
};
static char *memtype_string(int, int);
static char *error_handle_string(ulong);
static void collect_page_member_data(char *, struct meminfo *);
struct integer_data {
ulong value;
ulong bitfield_value;
struct struct_member_data *pmd;
};
static int get_bitfield_data(struct integer_data *);
static int show_page_member_data(char *, ulong, struct meminfo *, char *);
static void dump_mem_map(struct meminfo *);
static void dump_mem_map_SPARSEMEM(struct meminfo *);
static void fill_mem_map_cache(ulong, ulong, char *);
static void page_flags_init(void);
static int page_flags_init_from_pageflag_names(void);
static int page_flags_init_from_pageflags_enum(void);
static int translate_page_flags(char *, ulong);
static void dump_free_pages(struct meminfo *);
static int dump_zone_page_usage(void);
static void dump_multidimensional_free_pages(struct meminfo *);
static void dump_free_pages_zones_v1(struct meminfo *);
static void dump_free_pages_zones_v2(struct meminfo *);
struct free_page_callback_data;
static int dump_zone_free_area(ulong, int, ulong, struct free_page_callback_data *);
static void dump_page_hash_table(struct meminfo *);
static void kmem_search(struct meminfo *);
static void kmem_cache_init(void);
static void kmem_cache_init_slub(void);
static ulong max_cpudata_limit(ulong, ulong *);
static int kmem_cache_downsize(void);
static int ignore_cache(struct meminfo *, char *);
static char *is_kmem_cache_addr(ulong, char *);
static char *is_kmem_cache_addr_common(ulong, char *);
static void kmem_cache_list(struct meminfo *);
static void dump_kmem_cache(struct meminfo *);
static void dump_kmem_cache_percpu_v1(struct meminfo *);
static void dump_kmem_cache_percpu_v2(struct meminfo *);
static void dump_kmem_cache_slub(struct meminfo *);
static void kmem_cache_list_common(struct meminfo *);
static ulong get_cpu_slab_ptr(struct meminfo *, int, ulong *);
static unsigned int oo_order(ulong);
static unsigned int oo_objects(ulong);
static char *vaddr_to_kmem_cache(ulong, char *, int);
static char *is_slab_overload_page(ulong, ulong *, char *);
static ulong vaddr_to_slab(ulong);
static void do_slab_chain(int, struct meminfo *);
static void do_slab_chain_percpu_v1(long, struct meminfo *);
static void do_slab_chain_percpu_v2(long, struct meminfo *);
static void do_slab_chain_percpu_v2_nodes(long, struct meminfo *);
static void do_slab_chain_slab_overload_page(long, struct meminfo *);
static int slab_freelist_index_size(void);
static int do_slab_slub(struct meminfo *, int);
static void do_kmem_cache_slub(struct meminfo *);
static void save_slab_data(struct meminfo *);
static int slab_data_saved(struct meminfo *);
static void dump_saved_slab_data(void);
static void dump_slab(struct meminfo *);
static void dump_slab_percpu_v1(struct meminfo *);
static void dump_slab_percpu_v2(struct meminfo *);
static void dump_slab_overload_page(struct meminfo *);
static int verify_slab_v1(struct meminfo *, ulong, int);
static int verify_slab_v2(struct meminfo *, ulong, int);
static int verify_slab_overload_page(struct meminfo *, ulong, int);
static void gather_slab_free_list(struct meminfo *);
static void gather_slab_free_list_percpu(struct meminfo *);
static void gather_slab_free_list_slab_overload_page(struct meminfo *);
static void gather_cpudata_list_v1(struct meminfo *);
static void gather_cpudata_list_v2(struct meminfo *);
static void gather_cpudata_list_v2_nodes(struct meminfo *, int);
static int check_cpudata_list(struct meminfo *, ulong);
static int check_shared_list(struct meminfo *, ulong);
static void gather_slab_cached_count(struct meminfo *);
static void dump_slab_objects(struct meminfo *);
static void dump_slab_objects_percpu(struct meminfo *);
static void dump_vmlist(struct meminfo *);
static void dump_vmap_area(struct meminfo *);
static int get_vmap_area_list_from_nodes(ulong **);
static int dump_page_lists(struct meminfo *);
static void dump_kmeminfo(void);
static int page_to_phys(ulong, physaddr_t *);
static void display_memory(ulonglong, long, ulong, int, void *);
static char *show_opt_string(struct searchinfo *);
static void display_with_pre_and_post(void *, ulonglong, struct searchinfo *);
static ulong search_ulong(ulong *, ulong, int, struct searchinfo *);
static ulong search_uint(ulong *, ulong, int, struct searchinfo *);
static ulong search_ushort(ulong *, ulong, int, struct searchinfo *);
static ulong search_chars(ulong *, ulong, int, struct searchinfo *);
static ulonglong search_ulong_p(ulong *, ulonglong, int, struct searchinfo *);
static ulonglong search_uint_p(ulong *, ulonglong, int, struct searchinfo *);
static ulonglong search_ushort_p(ulong *, ulonglong, int, struct searchinfo *);
static ulonglong search_chars_p(ulong *, ulonglong, int, struct searchinfo *);
static void search_virtual(struct searchinfo *);
static void search_physical(struct searchinfo *);
static int next_upage(struct task_context *, ulong, ulong *);
static int next_kpage(ulong, ulong *);
static int next_physpage(ulonglong, ulonglong *);
static int next_vmlist_vaddr(ulong, ulong *);
static int next_module_vaddr(ulong, ulong *);
static int next_identity_mapping(ulong, ulong *);
static int vm_area_page_dump(ulong, ulong, ulong, ulong, ulong,
struct reference *);
static void rss_page_types_init(void);
static int dump_swap_info(ulong, ulong *, ulong *);
static int get_hugetlb_total_pages(ulong *, ulong *);
static char *get_swapdev(ulong, char *);
static void fill_swap_info(ulong);
static char *vma_file_offset(ulong, ulong, char *);
static ssize_t read_dev_kmem(ulong, char *, long);
static void dump_memory_nodes(int);
static void dump_zone_stats(void);
#define MEMORY_NODES_DUMP (0)
#define MEMORY_NODES_INITIALIZE (1)
static void node_table_init(void);
static int compare_node_data(const void *, const void *);
static void do_vm_flags(ulonglong);
static ulonglong get_vm_flags(char *);
static void PG_reserved_flag_init(void);
static void PG_slab_flag_init(void);
static ulong nr_blockdev_pages(void);
static ulong nr_blockdev_pages_v2(void);
void sparse_mem_init(void);
void dump_mem_sections(int);
void dump_memory_blocks(int);
void list_mem_sections(void);
ulong sparse_decode_mem_map(ulong, ulong);
char *read_mem_section(ulong);
ulong nr_to_section(ulong);
int valid_section(ulong);
int section_has_mem_map(ulong);
ulong section_mem_map_addr(ulong, int);
ulong valid_section_nr(ulong);
ulong pfn_to_map(ulong);
static int get_nodes_online(void);
static int next_online_node(int);
static ulong next_online_pgdat(int);
static int vm_stat_init(void);
static int vm_event_state_init(void);
static int dump_vm_stat(char *, long *, ulong);
static int dump_vm_event_state(void);
static int dump_page_states(void);
static int generic_read_dumpfile(ulonglong, void *, long, char *, ulong);
static int generic_write_dumpfile(ulonglong, void *, long, char *, ulong);
static int page_to_nid(ulong);
static int get_kmem_cache_list(ulong **);
static int get_kmem_cache_root_list(ulong **);
static int get_kmem_cache_child_list(ulong **, ulong);
static int get_kmem_cache_slub_data(long, struct meminfo *);
static ulong compound_head(ulong);
static long count_partial(ulong, struct meminfo *, ulong *);
static short count_cpu_partial(struct meminfo *, int);
static ulong get_freepointer(struct meminfo *, void *);
static int count_free_objects(struct meminfo *, ulong);
char *is_slab_page(struct meminfo *, char *);
static void do_cpu_partial_slub(struct meminfo *, int);
static void do_node_lists_slub(struct meminfo *, ulong, int);
static int devmem_is_restricted(void);
static int switch_to_proc_kcore(void);
static int verify_pfn(ulong);
static void dump_per_cpu_offsets(void);
static void dump_page_flags(ulonglong);
static ulong kmem_cache_nodelists(ulong);
static void dump_hstates(void);
static ulong freelist_ptr(struct meminfo *, ulong, ulong);
static ulong handle_each_vm_area(struct handle_each_vm_area_args *);
/*
* Memory display modes specific to this file.
*/
#define DISPLAY_8 (0x2)
#define DISPLAY_16 (0x4)
#define DISPLAY_32 (0x8)
#define DISPLAY_64 (0x10)
#define SHOW_OFFSET (0x20)
#define SYMBOLIC (0x40)
#define HEXADECIMAL (0x80)
#define DECIMAL (0x100)
#define UDECIMAL (0x200)
#define ASCII_ENDLINE (0x400)
#define NO_ASCII (0x800)
#define SLAB_CACHE (0x1000)
#define DISPLAY_ASCII (0x2000)
#define NET_ENDIAN (0x4000)
#define DISPLAY_RAW (0x8000)
#define NO_ERROR (0x10000)
#define SLAB_CACHE2 (0x20000)
#define DISPLAY_TYPES (DISPLAY_RAW|DISPLAY_ASCII|DISPLAY_8|\
DISPLAY_16|DISPLAY_32|DISPLAY_64)
#define ASCII_UNLIMITED ((ulong)(-1) >> 1)
static ulong DISPLAY_DEFAULT;
/*
* Before kernel commit ff202303c398e, the value is defined as a macro, so copy it here;
* After this commit, the value is defined as an enum, which can be evaluated at runtime.
*/
#define PAGE_TYPE_BASE 0xf0000000
#define PageType(page_type, flag) \
((page_type & (vt->page_type_base | flag)) == vt->page_type_base)
static void page_type_init(void)
{
if (!enumerator_value("PAGE_TYPE_BASE", (long *)&vt->page_type_base))
vt->page_type_base = PAGE_TYPE_BASE;
}
/*
* The PG_slab's type has changed from a page flag to a page type
* since kernel commit 46df8e73a4a3.
*/
static bool page_slab(ulong page, ulong flags)
{
if (vt->flags & SLAB_PAGEFLAGS) {
if ((flags >> vt->PG_slab) & 1)
return TRUE;
}
if (VALID_MEMBER(page_page_type)) {
uint page_type;
readmem(page+OFFSET(page_page_type), KVADDR, &page_type,
sizeof(page_type), "page_type", FAULT_ON_ERROR);
if (PageType(page_type, (uint)vt->PG_slab))
return TRUE;
}
return FALSE;
}
/*
* Verify that the sizeof the primitive types are reasonable.
*/
void
mem_init(void)
{
if (sizeof(char) != SIZEOF_8BIT)
error(FATAL, "unsupported sizeof(char): %d\n", sizeof(char));
if (sizeof(short) != SIZEOF_16BIT)
error(FATAL, "unsupported sizeof(short): %d\n", sizeof(short));
if ((sizeof(int) != SIZEOF_32BIT) && (sizeof(int) != SIZEOF_64BIT))
error(FATAL, "unsupported sizeof(int): %d\n", sizeof(int));
if ((sizeof(long) != SIZEOF_32BIT) && (sizeof(long) != SIZEOF_64BIT))
error(FATAL, "unsupported sizeof(long): %d\n", sizeof(long));
if (sizeof(void *) != sizeof(long))
error(FATAL, "pointer size: %d is not sizeof(long): %d\n", sizeof(void *), sizeof(long));
DISPLAY_DEFAULT = (sizeof(long) == 8) ? DISPLAY_64 : DISPLAY_32;
}
/*
* Stash a few popular offsets and some basic kernel virtual memory
* items used by routines in this file.
*/
void
vm_init(void)
{
char buf[BUFSIZE];
int i, len, dimension, nr_node_ids;
struct syment *sp_array[2];
ulong value1, value2;
char *kmem_cache_node_struct, *nodelists_field;
MEMBER_OFFSET_INIT(task_struct_mm, "task_struct", "mm");
MEMBER_OFFSET_INIT(mm_struct_mmap, "mm_struct", "mmap");
MEMBER_OFFSET_INIT(mm_struct_mm_mt, "mm_struct", "mm_mt");
if (VALID_MEMBER(mm_struct_mm_mt)) {
maple_init();
}
MEMBER_OFFSET_INIT(mm_struct_pgd, "mm_struct", "pgd");
MEMBER_OFFSET_INIT(mm_struct_rss, "mm_struct", "rss");
if (!VALID_MEMBER(mm_struct_rss))
MEMBER_OFFSET_INIT(mm_struct_rss, "mm_struct", "_rss");
MEMBER_OFFSET_INIT(mm_struct_anon_rss, "mm_struct", "_anon_rss");
MEMBER_OFFSET_INIT(mm_struct_file_rss, "mm_struct", "_file_rss");
if (!VALID_MEMBER(mm_struct_anon_rss)) {
MEMBER_OFFSET_INIT(mm_struct_rss_stat, "mm_struct", "rss_stat");
MEMBER_OFFSET_INIT(mm_rss_stat_count, "mm_rss_stat", "count");
}
MEMBER_OFFSET_INIT(mm_struct_total_vm, "mm_struct", "total_vm");
MEMBER_OFFSET_INIT(mm_struct_start_code, "mm_struct", "start_code");
MEMBER_OFFSET_INIT(mm_struct_mm_count, "mm_struct", "mm_count");
MEMBER_OFFSET_INIT(vm_area_struct_vm_mm, "vm_area_struct", "vm_mm");
MEMBER_OFFSET_INIT(vm_area_struct_vm_next, "vm_area_struct", "vm_next");
MEMBER_OFFSET_INIT(vm_area_struct_vm_end, "vm_area_struct", "vm_end");
MEMBER_OFFSET_INIT(vm_area_struct_vm_start,
"vm_area_struct", "vm_start");
MEMBER_OFFSET_INIT(vm_area_struct_vm_flags,
"vm_area_struct", "vm_flags");
MEMBER_OFFSET_INIT(vm_area_struct_vm_file, "vm_area_struct", "vm_file");
MEMBER_OFFSET_INIT(vm_area_struct_vm_offset,
"vm_area_struct", "vm_offset");
MEMBER_OFFSET_INIT(vm_area_struct_vm_pgoff,
"vm_area_struct", "vm_pgoff");
MEMBER_SIZE_INIT(vm_area_struct_vm_flags, "vm_area_struct", "vm_flags");
MEMBER_OFFSET_INIT(vm_struct_addr, "vm_struct", "addr");
MEMBER_OFFSET_INIT(vm_struct_size, "vm_struct", "size");
MEMBER_OFFSET_INIT(vm_struct_next, "vm_struct", "next");
MEMBER_OFFSET_INIT(vmap_area_va_start, "vmap_area", "va_start");
MEMBER_OFFSET_INIT(vmap_area_va_end, "vmap_area", "va_end");
MEMBER_OFFSET_INIT(vmap_area_list, "vmap_area", "list");
MEMBER_OFFSET_INIT(vmap_area_flags, "vmap_area", "flags");
MEMBER_OFFSET_INIT(vmap_area_vm, "vmap_area", "vm");
if (INVALID_MEMBER(vmap_area_vm))
MEMBER_OFFSET_INIT(vmap_area_vm, "vmap_area", "private");
MEMBER_OFFSET_INIT(vmap_area_purge_list, "vmap_area", "purge_list");
STRUCT_SIZE_INIT(vmap_area, "vmap_area");
if (VALID_MEMBER(vmap_area_va_start) &&
VALID_MEMBER(vmap_area_va_end) &&
VALID_MEMBER(vmap_area_list) &&
VALID_MEMBER(vmap_area_vm)) {
if (kernel_symbol_exists("vmap_nodes")) {
STRUCT_SIZE_INIT(vmap_node, "vmap_node");
MEMBER_OFFSET_INIT(vmap_node_busy, "vmap_node", "busy");
MEMBER_OFFSET_INIT(rb_list_head, "rb_list", "head");
vt->flags |= USE_VMAP_NODES;
} else if (kernel_symbol_exists("vmap_area_list"))
vt->flags |= USE_VMAP_AREA;
}
if (kernel_symbol_exists("hstates")) {
STRUCT_SIZE_INIT(hstate, "hstate");
MEMBER_OFFSET_INIT(hstate_order, "hstate", "order");
MEMBER_OFFSET_INIT(hstate_nr_huge_pages, "hstate", "nr_huge_pages");
MEMBER_OFFSET_INIT(hstate_free_huge_pages, "hstate", "free_huge_pages");
MEMBER_OFFSET_INIT(hstate_name, "hstate", "name");
}
MEMBER_OFFSET_INIT(page_next, "page", "next");
if (VALID_MEMBER(page_next))
MEMBER_OFFSET_INIT(page_prev, "page", "prev");
if (INVALID_MEMBER(page_next))
ANON_MEMBER_OFFSET_INIT(page_next, "page", "next");
if (INVALID_MEMBER(page_next))
MEMBER_OFFSET_INIT(page_next, "slab", "next");
MEMBER_OFFSET_INIT(page_list, "page", "list");
if (VALID_MEMBER(page_list)) {
ASSIGN_OFFSET(page_list_next) = OFFSET(page_list) +
OFFSET(list_head_next);
ASSIGN_OFFSET(page_list_prev) = OFFSET(page_list) +
OFFSET(list_head_prev);
}
MEMBER_OFFSET_INIT(page_next_hash, "page", "next_hash");
MEMBER_OFFSET_INIT(page_inode, "page", "inode");
MEMBER_OFFSET_INIT(page_offset, "page", "offset");
MEMBER_OFFSET_INIT(page_count, "page", "count");
if (INVALID_MEMBER(page_count)) {
MEMBER_OFFSET_INIT(page_count, "page", "_count");
if (INVALID_MEMBER(page_count))
ANON_MEMBER_OFFSET_INIT(page_count, "page", "_count");
if (INVALID_MEMBER(page_count))
MEMBER_OFFSET_INIT(page_count, "page", "_refcount");
if (INVALID_MEMBER(page_count))
ANON_MEMBER_OFFSET_INIT(page_count, "page", "_refcount");
}
MEMBER_OFFSET_INIT(page_flags, "page", "flags");
MEMBER_SIZE_INIT(page_flags, "page", "flags");
MEMBER_OFFSET_INIT(page_mapping, "page", "mapping");
if (INVALID_MEMBER(page_mapping))
ANON_MEMBER_OFFSET_INIT(page_mapping, "page", "mapping");
if (INVALID_MEMBER(page_mapping) &&
(THIS_KERNEL_VERSION < LINUX(2,6,17)) &&
MEMBER_EXISTS("page", "_mapcount"))
ASSIGN_OFFSET(page_mapping) = MEMBER_OFFSET("page", "_mapcount") +
STRUCT_SIZE("atomic_t") + sizeof(ulong);
MEMBER_OFFSET_INIT(page_index, "page", "index");
if (INVALID_MEMBER(page_index))
ANON_MEMBER_OFFSET_INIT(page_index, "page", "index");
MEMBER_OFFSET_INIT(page_buffers, "page", "buffers");
MEMBER_OFFSET_INIT(page_lru, "page", "lru");
if (INVALID_MEMBER(page_lru))
ANON_MEMBER_OFFSET_INIT(page_lru, "page", "lru");
MEMBER_OFFSET_INIT(page_pte, "page", "pte");
MEMBER_OFFSET_INIT(page_compound_head, "page", "compound_head");
if (INVALID_MEMBER(page_compound_head))
ANON_MEMBER_OFFSET_INIT(page_compound_head, "page", "compound_head");
MEMBER_OFFSET_INIT(page_private, "page", "private");
MEMBER_OFFSET_INIT(page_freelist, "page", "freelist");
MEMBER_OFFSET_INIT(page_page_type, "page", "page_type");
MEMBER_OFFSET_INIT(mm_struct_pgd, "mm_struct", "pgd");
MEMBER_OFFSET_INIT(swap_info_struct_swap_file,
"swap_info_struct", "swap_file");
MEMBER_OFFSET_INIT(swap_info_struct_swap_vfsmnt,
"swap_info_struct", "swap_vfsmnt");
MEMBER_OFFSET_INIT(swap_info_struct_flags,
"swap_info_struct", "flags");
MEMBER_OFFSET_INIT(swap_info_struct_swap_map,
"swap_info_struct", "swap_map");
MEMBER_OFFSET_INIT(swap_info_struct_swap_device,
"swap_info_struct", "swap_device");
MEMBER_OFFSET_INIT(swap_info_struct_prio, "swap_info_struct", "prio");
MEMBER_OFFSET_INIT(swap_info_struct_max, "swap_info_struct", "max");
MEMBER_OFFSET_INIT(swap_info_struct_pages, "swap_info_struct", "pages");
MEMBER_OFFSET_INIT(swap_info_struct_inuse_pages, "swap_info_struct",
"inuse_pages");
MEMBER_OFFSET_INIT(swap_info_struct_old_block_size,
"swap_info_struct", "old_block_size");
MEMBER_OFFSET_INIT(swap_info_struct_bdev, "swap_info_struct", "bdev");
MEMBER_OFFSET_INIT(zs_pool_size_class, "zs_pool", "size_class");
MEMBER_OFFSET_INIT(size_class_size, "size_class", "size");
MEMBER_OFFSET_INIT(block_device_bd_inode, "block_device", "bd_inode");
MEMBER_OFFSET_INIT(block_device_bd_list, "block_device", "bd_list");
MEMBER_OFFSET_INIT(block_device_bd_disk, "block_device", "bd_disk");
MEMBER_OFFSET_INIT(inode_i_mapping, "inode", "i_mapping");
MEMBER_OFFSET_INIT(address_space_page_tree, "address_space", "page_tree");
if (INVALID_MEMBER(address_space_page_tree))
MEMBER_OFFSET_INIT(address_space_page_tree, "address_space", "i_pages");
MEMBER_OFFSET_INIT(address_space_nrpages, "address_space", "nrpages");
if (INVALID_MEMBER(address_space_nrpages))
MEMBER_OFFSET_INIT(address_space_nrpages, "address_space", "__nrpages");
MEMBER_OFFSET_INIT(super_block_s_inodes, "super_block", "s_inodes");
MEMBER_OFFSET_INIT(inode_i_sb_list, "inode", "i_sb_list");
MEMBER_OFFSET_INIT(gendisk_major, "gendisk", "major");
MEMBER_OFFSET_INIT(gendisk_fops, "gendisk", "fops");
MEMBER_OFFSET_INIT(gendisk_disk_name, "gendisk", "disk_name");
MEMBER_OFFSET_INIT(gendisk_private_data, "gendisk", "private_data");
STRUCT_SIZE_INIT(block_device, "block_device");
STRUCT_SIZE_INIT(address_space, "address_space");
STRUCT_SIZE_INIT(gendisk, "gendisk");
STRUCT_SIZE_INIT(blk_major_name, "blk_major_name");
if (VALID_STRUCT(blk_major_name)) {
MEMBER_OFFSET_INIT(blk_major_name_next, "blk_major_name",
"next");
MEMBER_OFFSET_INIT(blk_major_name_name, "blk_major_name",
"name");
MEMBER_OFFSET_INIT(blk_major_name_major, "blk_major_name",
"major");
}
STRUCT_SIZE_INIT(kmem_slab_s, "kmem_slab_s");
STRUCT_SIZE_INIT(slab_s, "slab_s");
STRUCT_SIZE_INIT(slab, "slab");
STRUCT_SIZE_INIT(kmem_cache_s, "kmem_cache_s");
STRUCT_SIZE_INIT(pgd_t, "pgd_t");
/*
* slab: overload struct slab over struct page
* https://lkml.org/lkml/2013/10/16/155
*
* commit e36ce448a08d removed kmem_cache.freelist_cache in 6.1,
* so use freelist_size instead.
*/
if (MEMBER_EXISTS("kmem_cache", "freelist_size")) {
vt->flags |= SLAB_OVERLOAD_PAGE;
ANON_MEMBER_OFFSET_INIT(page_s_mem, "page", "s_mem");
ANON_MEMBER_OFFSET_INIT(page_freelist, "page", "freelist");
ANON_MEMBER_OFFSET_INIT(page_active, "page", "active");
/*
* Moved to struct slab in Linux 5.17
*/
if (INVALID_MEMBER(page_s_mem))
MEMBER_OFFSET_INIT(page_s_mem, "slab", "s_mem");
if (INVALID_MEMBER(page_freelist))
MEMBER_OFFSET_INIT(page_freelist, "slab", "freelist");
if (INVALID_MEMBER(page_active))
MEMBER_OFFSET_INIT(page_active, "slab", "active");
MEMBER_OFFSET_INIT(slab_slab_list, "slab", "slab_list");
}
if (!VALID_STRUCT(kmem_slab_s) && VALID_STRUCT(slab_s)) {
vt->flags |= PERCPU_KMALLOC_V1;
MEMBER_OFFSET_INIT(kmem_cache_s_num, "kmem_cache_s", "num");
MEMBER_OFFSET_INIT(kmem_cache_s_next, "kmem_cache_s", "next");
MEMBER_OFFSET_INIT(kmem_cache_s_name, "kmem_cache_s", "name");
MEMBER_OFFSET_INIT(kmem_cache_s_objsize,
"kmem_cache_s", "objsize");
MEMBER_OFFSET_INIT(kmem_cache_s_flags, "kmem_cache_s", "flags");
MEMBER_OFFSET_INIT(kmem_cache_s_gfporder,
"kmem_cache_s", "gfporder");
MEMBER_OFFSET_INIT(kmem_cache_s_slabs,
"kmem_cache_s", "slabs");
MEMBER_OFFSET_INIT(kmem_cache_s_slabs_full,
"kmem_cache_s", "slabs_full");
MEMBER_OFFSET_INIT(kmem_cache_s_slabs_partial,
"kmem_cache_s", "slabs_partial");
MEMBER_OFFSET_INIT(kmem_cache_s_slabs_free,
"kmem_cache_s", "slabs_free");
MEMBER_OFFSET_INIT(kmem_cache_s_cpudata,
"kmem_cache_s", "cpudata");
ARRAY_LENGTH_INIT(len, NULL, "kmem_cache_s.cpudata", NULL, 0);
MEMBER_OFFSET_INIT(kmem_cache_s_colour_off,
"kmem_cache_s", "colour_off");
MEMBER_OFFSET_INIT(slab_s_list, "slab_s", "list");
MEMBER_OFFSET_INIT(slab_s_s_mem, "slab_s", "s_mem");
MEMBER_OFFSET_INIT(slab_s_inuse, "slab_s", "inuse");
MEMBER_OFFSET_INIT(slab_s_free, "slab_s", "free");
MEMBER_OFFSET_INIT(cpucache_s_avail, "cpucache_s", "avail");
MEMBER_OFFSET_INIT(cpucache_s_limit, "cpucache_s", "limit");
STRUCT_SIZE_INIT(cpucache_s, "cpucache_s");
} else if (!VALID_STRUCT(kmem_slab_s) &&
!VALID_STRUCT(slab_s) &&
!MEMBER_EXISTS("kmem_cache", "cpu_slab") &&
(VALID_STRUCT(slab) || (vt->flags & SLAB_OVERLOAD_PAGE))) {
vt->flags |= PERCPU_KMALLOC_V2;
if (VALID_STRUCT(kmem_cache_s)) {
MEMBER_OFFSET_INIT(kmem_cache_s_num, "kmem_cache_s", "num");
MEMBER_OFFSET_INIT(kmem_cache_s_next, "kmem_cache_s", "next");
MEMBER_OFFSET_INIT(kmem_cache_s_name, "kmem_cache_s", "name");
MEMBER_OFFSET_INIT(kmem_cache_s_colour_off, "kmem_cache_s",
"colour_off");
MEMBER_OFFSET_INIT(kmem_cache_s_objsize, "kmem_cache_s",
"objsize");
MEMBER_OFFSET_INIT(kmem_cache_s_flags, "kmem_cache_s", "flags");
MEMBER_OFFSET_INIT(kmem_cache_s_gfporder,
"kmem_cache_s", "gfporder");
MEMBER_OFFSET_INIT(kmem_cache_s_lists, "kmem_cache_s", "lists");
MEMBER_OFFSET_INIT(kmem_cache_s_array, "kmem_cache_s", "array");
ARRAY_LENGTH_INIT(len, NULL, "kmem_cache_s.array", NULL, 0);
} else {
STRUCT_SIZE_INIT(kmem_cache_s, "kmem_cache");
MEMBER_OFFSET_INIT(kmem_cache_s_num, "kmem_cache", "num");
MEMBER_OFFSET_INIT(kmem_cache_s_next, "kmem_cache", "next");
if (INVALID_MEMBER(kmem_cache_s_next)) {
/*
* slab/slub unification starting in Linux 3.6.
*/
MEMBER_OFFSET_INIT(kmem_cache_s_next, "kmem_cache", "list");
MEMBER_OFFSET_INIT(kmem_cache_list, "kmem_cache", "list");
MEMBER_OFFSET_INIT(kmem_cache_name, "kmem_cache", "name");
MEMBER_OFFSET_INIT(kmem_cache_size, "kmem_cache", "size");
STRUCT_SIZE_INIT(kmem_cache, "kmem_cache");
}
MEMBER_OFFSET_INIT(kmem_cache_s_name, "kmem_cache", "name");
MEMBER_OFFSET_INIT(kmem_cache_s_colour_off, "kmem_cache",
"colour_off");
if (MEMBER_EXISTS("kmem_cache", "objsize"))
MEMBER_OFFSET_INIT(kmem_cache_s_objsize, "kmem_cache",
"objsize");
else if (MEMBER_EXISTS("kmem_cache", "buffer_size"))
MEMBER_OFFSET_INIT(kmem_cache_s_objsize, "kmem_cache",
"buffer_size");
else if (MEMBER_EXISTS("kmem_cache", "size"))
MEMBER_OFFSET_INIT(kmem_cache_s_objsize, "kmem_cache",
"size");
MEMBER_OFFSET_INIT(kmem_cache_s_flags, "kmem_cache", "flags");
MEMBER_OFFSET_INIT(kmem_cache_s_gfporder,
"kmem_cache", "gfporder");
MEMBER_OFFSET_INIT(kmem_cache_cpu_cache, "kmem_cache", "cpu_cache");
if (MEMBER_EXISTS("kmem_cache", "lists"))
MEMBER_OFFSET_INIT(kmem_cache_s_lists, "kmem_cache", "lists");
else if (MEMBER_EXISTS("kmem_cache", "nodelists") ||
MEMBER_EXISTS("kmem_cache", "node")) {
nodelists_field = MEMBER_EXISTS("kmem_cache", "node") ?
"node" : "nodelists";
vt->flags |= PERCPU_KMALLOC_V2_NODES;
MEMBER_OFFSET_INIT(kmem_cache_s_lists, "kmem_cache", nodelists_field);
if (MEMBER_TYPE("kmem_cache", nodelists_field) == TYPE_CODE_PTR) {
/*
* nodelists now a pointer to an outside array
*/
vt->flags |= NODELISTS_IS_PTR;
if (kernel_symbol_exists("nr_node_ids")) {
get_symbol_data("nr_node_ids", sizeof(int),
&nr_node_ids);
vt->kmem_cache_len_nodes = nr_node_ids;
} else
vt->kmem_cache_len_nodes = 1;
} else if (VALID_MEMBER(kmem_cache_cpu_cache)) {
/*
* commit bf0dea23a9c094ae869a88bb694fbe966671bf6d
* mm/slab: use percpu allocator for cpu cache
*/
vt->flags |= SLAB_CPU_CACHE;
MEMBER_OFFSET_INIT(kmem_cache_node, "kmem_cache", "node");
if (kernel_symbol_exists("nr_node_ids")) {
get_symbol_data("nr_node_ids", sizeof(int),
&nr_node_ids);
vt->kmem_cache_len_nodes = nr_node_ids;
} else
vt->kmem_cache_len_nodes = 1;
} else {
/*
* This should never happen with kmem_cache.node,
* only with kmem_cache.nodelists
*/
ARRAY_LENGTH_INIT(vt->kmem_cache_len_nodes, NULL,
"kmem_cache.nodelists", NULL, 0);
}
}
MEMBER_OFFSET_INIT(kmem_cache_s_array, "kmem_cache", "array");
ARRAY_LENGTH_INIT(len, NULL, "kmem_cache.array", NULL, 0);
}
if (VALID_STRUCT(slab)) {
MEMBER_OFFSET_INIT(slab_list, "slab", "list");
MEMBER_OFFSET_INIT(slab_s_mem, "slab", "s_mem");
MEMBER_OFFSET_INIT(slab_inuse, "slab", "inuse");
MEMBER_OFFSET_INIT(slab_free, "slab", "free");
/*
* slab members were moved to an anonymous union in 2.6.39.
*/
if (INVALID_MEMBER(slab_list))
ANON_MEMBER_OFFSET_INIT(slab_list, "slab", "list");
if (INVALID_MEMBER(slab_s_mem))
ANON_MEMBER_OFFSET_INIT(slab_s_mem, "slab", "s_mem");
if (INVALID_MEMBER(slab_inuse))
ANON_MEMBER_OFFSET_INIT(slab_inuse, "slab", "inuse");
if (INVALID_MEMBER(slab_free))
ANON_MEMBER_OFFSET_INIT(slab_free, "slab", "free");
}
MEMBER_OFFSET_INIT(array_cache_avail, "array_cache", "avail");
MEMBER_OFFSET_INIT(array_cache_limit, "array_cache", "limit");
STRUCT_SIZE_INIT(array_cache, "array_cache");
/*
* kmem_list3 renamed to kmem_cache_node in kernel 3.11-rc1
*/
kmem_cache_node_struct = STRUCT_EXISTS("kmem_cache_node") ?
"kmem_cache_node" : "kmem_list3";
MEMBER_OFFSET_INIT(kmem_list3_slabs_partial,
kmem_cache_node_struct, "slabs_partial");
MEMBER_OFFSET_INIT(kmem_list3_slabs_full,
kmem_cache_node_struct, "slabs_full");
MEMBER_OFFSET_INIT(kmem_list3_slabs_free,
kmem_cache_node_struct, "slabs_free");
MEMBER_OFFSET_INIT(kmem_list3_free_objects,
kmem_cache_node_struct, "free_objects");
MEMBER_OFFSET_INIT(kmem_list3_shared, kmem_cache_node_struct, "shared");
/*
* Common to slab/slub
*/
MEMBER_OFFSET_INIT(page_slab, "page", "slab_cache");
if (INVALID_MEMBER(page_slab))
ANON_MEMBER_OFFSET_INIT(page_slab, "page", "slab_cache");
MEMBER_OFFSET_INIT(page_slab_page, "page", "slab_page");
if (INVALID_MEMBER(page_slab_page))
ANON_MEMBER_OFFSET_INIT(page_slab_page, "page", "slab_page");
MEMBER_OFFSET_INIT(page_first_page, "page", "first_page");
if (INVALID_MEMBER(page_first_page))
ANON_MEMBER_OFFSET_INIT(page_first_page, "page", "first_page");
} else if (MEMBER_EXISTS("kmem_cache", "cpu_slab") &&
STRUCT_EXISTS("kmem_cache_node")) {
vt->flags |= KMALLOC_SLUB;
STRUCT_SIZE_INIT(kmem_cache, "kmem_cache");
MEMBER_OFFSET_INIT(kmem_cache_size, "kmem_cache", "size");
MEMBER_OFFSET_INIT(kmem_cache_objsize, "kmem_cache", "objsize");
if (INVALID_MEMBER(kmem_cache_objsize))
MEMBER_OFFSET_INIT(kmem_cache_objsize, "kmem_cache",
"object_size");
MEMBER_OFFSET_INIT(kmem_cache_offset, "kmem_cache", "offset");
MEMBER_OFFSET_INIT(kmem_cache_order, "kmem_cache", "order");
MEMBER_OFFSET_INIT(kmem_cache_local_node, "kmem_cache", "local_node");
MEMBER_OFFSET_INIT(kmem_cache_objects, "kmem_cache", "objects");
MEMBER_OFFSET_INIT(kmem_cache_inuse, "kmem_cache", "inuse");
MEMBER_OFFSET_INIT(kmem_cache_align, "kmem_cache", "align");
MEMBER_OFFSET_INIT(kmem_cache_node, "kmem_cache", "node");
MEMBER_OFFSET_INIT(kmem_cache_cpu_slab, "kmem_cache", "cpu_slab");
MEMBER_OFFSET_INIT(kmem_cache_list, "kmem_cache", "list");
MEMBER_OFFSET_INIT(kmem_cache_red_left_pad, "kmem_cache", "red_left_pad");
MEMBER_OFFSET_INIT(kmem_cache_name, "kmem_cache", "name");
MEMBER_OFFSET_INIT(kmem_cache_flags, "kmem_cache", "flags");
MEMBER_OFFSET_INIT(kmem_cache_random, "kmem_cache", "random");
MEMBER_OFFSET_INIT(kmem_cache_cpu_freelist, "kmem_cache_cpu", "freelist");
MEMBER_OFFSET_INIT(kmem_cache_cpu_page, "kmem_cache_cpu", "page");
if (INVALID_MEMBER(kmem_cache_cpu_page))
MEMBER_OFFSET_INIT(kmem_cache_cpu_page, "kmem_cache_cpu", "slab");
MEMBER_OFFSET_INIT(kmem_cache_cpu_node, "kmem_cache_cpu", "node");
MEMBER_OFFSET_INIT(kmem_cache_cpu_partial, "kmem_cache_cpu", "partial");
MEMBER_OFFSET_INIT(page_inuse, "page", "inuse");
if (INVALID_MEMBER(page_inuse))
ANON_MEMBER_OFFSET_INIT(page_inuse, "page", "inuse");
if (INVALID_MEMBER(page_inuse))
MEMBER_OFFSET_INIT(page_inuse, "slab", "inuse");
MEMBER_OFFSET_INIT(page_offset, "page", "offset");
if (INVALID_MEMBER(page_offset))
ANON_MEMBER_OFFSET_INIT(page_offset, "page", "offset");
MEMBER_OFFSET_INIT(page_slab, "page", "slab");
if (INVALID_MEMBER(page_slab))
ANON_MEMBER_OFFSET_INIT(page_slab, "page", "slab");
if (INVALID_MEMBER(page_slab)) {
MEMBER_OFFSET_INIT(page_slab, "page", "slab_cache");
if (INVALID_MEMBER(page_slab))
ANON_MEMBER_OFFSET_INIT(page_slab, "page", "slab_cache");
}
if (INVALID_MEMBER(page_slab))
MEMBER_OFFSET_INIT(page_slab, "slab", "slab_cache");
MEMBER_OFFSET_INIT(slab_slab_list, "slab", "slab_list");
MEMBER_OFFSET_INIT(page_slab_page, "page", "slab_page");
if (INVALID_MEMBER(page_slab_page))
ANON_MEMBER_OFFSET_INIT(page_slab_page, "page", "slab_page");
MEMBER_OFFSET_INIT(page_first_page, "page", "first_page");
if (INVALID_MEMBER(page_first_page))
ANON_MEMBER_OFFSET_INIT(page_first_page, "page", "first_page");
MEMBER_OFFSET_INIT(page_freelist, "page", "freelist");
if (INVALID_MEMBER(page_freelist))
ANON_MEMBER_OFFSET_INIT(page_freelist, "page", "freelist");
if (INVALID_MEMBER(page_freelist))
MEMBER_OFFSET_INIT(page_freelist, "slab", "freelist");
if (INVALID_MEMBER(kmem_cache_objects)) {
MEMBER_OFFSET_INIT(kmem_cache_oo, "kmem_cache", "oo");
/* NOTE: returns offset of containing bitfield */
ANON_MEMBER_OFFSET_INIT(page_objects, "page", "objects");
if (INVALID_MEMBER(page_objects))
ANON_MEMBER_OFFSET_INIT(page_objects, "slab", "objects");
}
if (VALID_MEMBER(kmem_cache_node)) {
ARRAY_LENGTH_INIT(len, NULL, "kmem_cache.node", NULL, 0);
vt->flags |= CONFIG_NUMA;
}
ARRAY_LENGTH_INIT(len, NULL, "kmem_cache.cpu_slab", NULL, 0);
STRUCT_SIZE_INIT(kmem_cache_node, "kmem_cache_node");
STRUCT_SIZE_INIT(kmem_cache_cpu, "kmem_cache_cpu");
MEMBER_OFFSET_INIT(kmem_cache_node_nr_partial,
"kmem_cache_node", "nr_partial");
MEMBER_OFFSET_INIT(kmem_cache_node_nr_slabs,
"kmem_cache_node", "nr_slabs");
MEMBER_OFFSET_INIT(kmem_cache_node_total_objects,
"kmem_cache_node", "total_objects");
MEMBER_OFFSET_INIT(kmem_cache_node_partial,
"kmem_cache_node", "partial");
MEMBER_OFFSET_INIT(kmem_cache_node_full,
"kmem_cache_node", "full");
} else {
MEMBER_OFFSET_INIT(kmem_cache_s_c_nextp,
"kmem_cache_s", "c_nextp");
MEMBER_OFFSET_INIT(kmem_cache_s_c_name,
"kmem_cache_s", "c_name");
MEMBER_OFFSET_INIT(kmem_cache_s_c_num,
"kmem_cache_s", "c_num");
MEMBER_OFFSET_INIT(kmem_cache_s_c_org_size,
"kmem_cache_s", "c_org_size");
MEMBER_OFFSET_INIT(kmem_cache_s_c_flags,
"kmem_cache_s", "c_flags");
MEMBER_OFFSET_INIT(kmem_cache_s_c_offset,
"kmem_cache_s", "c_offset");
MEMBER_OFFSET_INIT(kmem_cache_s_c_firstp,
"kmem_cache_s", "c_firstp");
MEMBER_OFFSET_INIT(kmem_cache_s_c_gfporder,
"kmem_cache_s", "c_gfporder");
MEMBER_OFFSET_INIT(kmem_cache_s_c_magic,
"kmem_cache_s", "c_magic");
MEMBER_OFFSET_INIT(kmem_cache_s_c_align,
"kmem_cache_s", "c_align");
MEMBER_OFFSET_INIT(kmem_slab_s_s_nextp,
"kmem_slab_s", "s_nextp");
MEMBER_OFFSET_INIT(kmem_slab_s_s_freep,
"kmem_slab_s", "s_freep");
MEMBER_OFFSET_INIT(kmem_slab_s_s_inuse,
"kmem_slab_s", "s_inuse");
MEMBER_OFFSET_INIT(kmem_slab_s_s_mem,
"kmem_slab_s", "s_mem");
MEMBER_OFFSET_INIT(kmem_slab_s_s_index,
"kmem_slab_s", "s_index");
MEMBER_OFFSET_INIT(kmem_slab_s_s_offset,
"kmem_slab_s", "s_offset");
MEMBER_OFFSET_INIT(kmem_slab_s_s_magic,
"kmem_slab_s", "s_magic");
}
if (kernel_symbol_exists("slab_root_caches")) {
MEMBER_OFFSET_INIT(kmem_cache_memcg_params,
"kmem_cache", "memcg_params");
MEMBER_OFFSET_INIT(memcg_cache_params___root_caches_node,
"memcg_cache_params", "__root_caches_node");
MEMBER_OFFSET_INIT(memcg_cache_params_children,
"memcg_cache_params", "children");
MEMBER_OFFSET_INIT(memcg_cache_params_children_node,
"memcg_cache_params", "children_node");
if (VALID_MEMBER(kmem_cache_memcg_params)
&& VALID_MEMBER(memcg_cache_params___root_caches_node)
&& VALID_MEMBER(memcg_cache_params_children)
&& VALID_MEMBER(memcg_cache_params_children_node))
vt->flags |= SLAB_ROOT_CACHES;
}
if (!kt->kernel_NR_CPUS) {
if (enumerator_value("WORK_CPU_UNBOUND", (long *)&value1))
kt->kernel_NR_CPUS = (int)value1;
else if ((i = get_array_length("__per_cpu_offset", NULL, 0)))
kt->kernel_NR_CPUS = i;
else if (ARRAY_LENGTH(kmem_cache_s_cpudata))
kt->kernel_NR_CPUS = ARRAY_LENGTH(kmem_cache_s_cpudata);
else if (ARRAY_LENGTH(kmem_cache_s_array))
kt->kernel_NR_CPUS = ARRAY_LENGTH(kmem_cache_s_array);
else if (ARRAY_LENGTH(kmem_cache_cpu_slab))
kt->kernel_NR_CPUS = ARRAY_LENGTH(kmem_cache_cpu_slab);
}
if (CRASHDEBUG(1))
fprintf(fp, "kernel NR_CPUS: %d %s\n", kt->kernel_NR_CPUS,
kt->kernel_NR_CPUS ? "" : "(unknown)");
if (kt->kernel_NR_CPUS > NR_CPUS) {
error(WARNING,
"kernel-configured NR_CPUS (%d) greater than compiled-in NR_CPUS (%d)\n",
kt->kernel_NR_CPUS, NR_CPUS);
error(FATAL, "recompile crash with larger NR_CPUS\n");
}
if (machdep->init_kernel_pgd)
machdep->init_kernel_pgd();
else if (symbol_exists("swapper_pg_dir")) {
value1 = symbol_value("swapper_pg_dir");
for (i = 0; i < NR_CPUS; i++)
vt->kernel_pgd[i] = value1;
} else if (symbol_exists("cpu_pgd")) {
len = get_array_length("cpu_pgd", &dimension, 0);
if ((len == NR_CPUS) && (dimension == machdep->ptrs_per_pgd)) {
value1 = symbol_value("cpu_pgd");
for (i = 0; i < NR_CPUS; i++) {
value2 = i *
(SIZE(pgd_t) * machdep->ptrs_per_pgd);
vt->kernel_pgd[i] = value1 + value2;
}
error(WARNING,
"no swapper_pg_dir: using first entry of cpu_pgd[%d][%d]\n\n",
dimension, len);
} else {
error(WARNING,
"unrecognized dimensions: cpu_pgd[%d][%d]\n",