Log at the moment of OOM

[  126.809058] sysrq: Manual OOM execution
[  126.809184] kworker/0:2 invoked oom-killer: gfp_mask=0x6000c0(GFP_KERNEL), nodemask=(null), order=-1, oom_score_                               adj=0
[  126.809217] kworker/0:2 cpuset=/ mems_allowed=0
...
[  126.810045] lowmem_reserve[]: 0 0 1204 1204
[  126.810093] HighMem free:1054428kB min:512kB low:7216kB high:13920kB active_anon:22608kB inactive_anon:9220kB ac                               tive_file:61020kB inactive_file:75840kB unevictable:16kB writepending:0kB present:1232896kB managed:1232896kB mlock                               ed:16kB kernel_stack:0kB pagetables:1740kB bounce:0kB free_pcp:3040kB local_pcp:392kB free_cma:0kB
[  126.810152] lowmem_reserve[]: 0 0 0 0
[  126.810187] DMA: 2*4kB (EC) 5*8kB (UEC) 5*16kB (UMEC) 5*32kB (UMEC) 3*64kB (UEC) 4*128kB (UMEC) 0*256kB 3*512kB                                (UEC) 1*1024kB (C) 3*2048kB (UM) 160*4096kB (MC) = 665056kB
[  126.810289] HighMem: 73*4kB (U) 17*8kB (U) 3*16kB (U) 2*32kB (U) 3*64kB (U) 6*128kB (U) 1*256kB (M) 4*512kB (UM)                                4*1024kB (UM) 1*2048kB (U) 255*4096kB (M) = 1054428kB 

Callstack with 'echo f > /proc/sysrq-trigger'

kworker/0:2-1150    [000] ....  3471.541617: <stack trace>
 => show_free_areas+0x8/0x7a8
 => show_mem+0x3c/0xd4
 => dump_header+0x68/0x204
 => oom_kill_process+0x1f8/0x200
 => out_of_memory+0xf0/0x330
 => moom_callback+0x6c/0xb0
 => process_one_work+0x1f4/0x4d8
 => worker_thread+0x50/0x480
 => kthread+0x148/0x158
 => ret_from_fork+0x10/0x30


Message routine; 
 
mm/oom_kill.c
static void dump_header(struct oom_control *oc, struct task_struct *p)
{
pr_warn("%s invoked oom-killer: gfp_mask=%#x(%pGg), order=%d, oom_score_adj=%hd\n",
current->comm, oc->gfp_mask, &oc->gfp_mask, oc->order,
current->signal->oom_score_adj);
if (!IS_ENABLED(CONFIG_COMPACTION) && oc->order)
pr_warn("COMPACTION is disabled!!!\n");

dump_stack();
if (is_memcg_oom(oc))
mem_cgroup_print_oom_meminfo(oc->memcg);
else {
show_mem(SHOW_MEM_FILTER_NODES, oc->nodemask);
if (should_dump_unreclaim_slab())
dump_unreclaimable_slab();
}
if (sysctl_oom_dump_tasks)
dump_tasks(oc);
if (p)
dump_oom_summary(oc, p);
}

'show_free_areas' function

https://elixir.bootlin.com/linux/v5.15.100/source/mm/page_alloc.c
void show_free_areas(unsigned int filter, nodemask_t *nodemask)
{
unsigned long free_pcp = 0;
int cpu;
struct zone *zone;
pg_data_t *pgdat;

for_each_populated_zone(zone) {
if (show_mem_node_skip(filter, zone_to_nid(zone), nodemask))
continue;

for_each_online_cpu(cpu)
free_pcp += per_cpu_ptr(zone->per_cpu_pageset, cpu)->count;
}

printk("active_anon:%lu inactive_anon:%lu isolated_anon:%lu\n"
" active_file:%lu inactive_file:%lu isolated_file:%lu\n"
" unevictable:%lu dirty:%lu writeback:%lu\n"
" slab_reclaimable:%lu slab_unreclaimable:%lu\n"
" mapped:%lu shmem:%lu pagetables:%lu bounce:%lu\n"
" kernel_misc_reclaimable:%lu\n"
" free:%lu free_pcp:%lu free_cma:%lu\n",
global_node_page_state(NR_ACTIVE_ANON),
global_node_page_state(NR_INACTIVE_ANON),
global_node_page_state(NR_ISOLATED_ANON),
global_node_page_state(NR_ACTIVE_FILE),
global_node_page_state(NR_INACTIVE_FILE),
global_node_page_state(NR_ISOLATED_FILE),
global_node_page_state(NR_UNEVICTABLE),
global_node_page_state(NR_FILE_DIRTY),
global_node_page_state(NR_WRITEBACK),
global_node_page_state_pages(NR_SLAB_RECLAIMABLE_B),
global_node_page_state_pages(NR_SLAB_UNRECLAIMABLE_B),
global_node_page_state(NR_FILE_MAPPED),
global_node_page_state(NR_SHMEM),
global_node_page_state(NR_PAGETABLE),
global_zone_page_state(NR_BOUNCE),
global_node_page_state(NR_KERNEL_MISC_RECLAIMABLE),
global_zone_page_state(NR_FREE_PAGES),
free_pcp,
global_zone_page_state(NR_FREE_CMA_PAGES));

'global_node_page_state' function

include/linux/vmstat.h#L200
static inline unsigned long global_node_page_state(enum node_stat_item item)
{
VM_WARN_ON_ONCE(vmstat_item_in_bytes(item));

return global_node_page_state_pages(item);
}

'global_node_page_state_pages' function

include/linux/vmstat.h#L190
static inline
unsigned long global_node_page_state_pages(enum node_stat_item item)
{
long x = atomic_long_read(&vm_node_stat[item]);
#ifdef CONFIG_SMP
if (x < 0)
x = 0;
#endif
return x;
}

'enum node_stat_item'
include/linux/mmzone.h 
enum node_stat_item {
NR_LRU_BASE,
NR_INACTIVE_ANON = NR_LRU_BASE, /* must match order of LRU_[IN]ACTIVE */
NR_ACTIVE_ANON, /*  "     "     "   "       "         */
NR_INACTIVE_FILE, /*  "     "     "   "       "         */
NR_ACTIVE_FILE, /*  "     "     "   "       "         */
NR_UNEVICTABLE, /*  "     "     "   "       "         */
NR_SLAB_RECLAIMABLE_B,
NR_SLAB_UNRECLAIMABLE_B,
NR_ISOLATED_ANON, /* Temporary isolated pages from anon lru */
NR_ISOLATED_FILE, /* Temporary isolated pages from file lru */
WORKINGSET_NODES,
WORKINGSET_REFAULT_BASE,
WORKINGSET_REFAULT_ANON = WORKINGSET_REFAULT_BASE,
WORKINGSET_REFAULT_FILE,
WORKINGSET_ACTIVATE_BASE,
WORKINGSET_ACTIVATE_ANON = WORKINGSET_ACTIVATE_BASE,
WORKINGSET_ACTIVATE_FILE,
WORKINGSET_RESTORE_BASE,
WORKINGSET_RESTORE_ANON = WORKINGSET_RESTORE_BASE,
WORKINGSET_RESTORE_FILE,
WORKINGSET_NODERECLAIM,
NR_ANON_MAPPED, /* Mapped anonymous pages */
NR_FILE_MAPPED, /* pagecache pages mapped into pagetables.
   only modified from process context */
NR_FILE_PAGES,
NR_FILE_DIRTY,
NR_WRITEBACK,
NR_WRITEBACK_TEMP, /* Writeback using temporary buffers */
NR_SHMEM, /* shmem pages (included tmpfs/GEM pages) */
NR_SHMEM_THPS,
NR_SHMEM_PMDMAPPED,
NR_FILE_THPS,
NR_FILE_PMDMAPPED,
NR_ANON_THPS,
NR_VMSCAN_WRITE,
NR_VMSCAN_IMMEDIATE, /* Prioritise for reclaim when writeback ends */
NR_DIRTIED, /* page dirtyings since bootup */
NR_WRITTEN, /* page writings since bootup */
NR_KERNEL_MISC_RECLAIMABLE, /* reclaimable non-slab kernel pages */
NR_FOLL_PIN_ACQUIRED, /* via: pin_user_page(), gup flag: FOLL_PIN */
NR_FOLL_PIN_RELEASED, /* pages returned via unpin_user_page() */
NR_KERNEL_STACK_KB, /* measured in KiB */
#if IS_ENABLED(CONFIG_SHADOW_CALL_STACK)
NR_KERNEL_SCS_KB, /* measured in KiB */
#endif
NR_PAGETABLE, /* used for pagetables */
#ifdef CONFIG_SWAP
NR_SWAPCACHE,
#endif
NR_VM_NODE_STAT_ITEMS
};

'vm_node_stat' with TRACE32

  vm_node_stat = (
    [0] = (counter = 52435),  // NR_INACTIVE_ANON
    [1] = (counter = 266), // NR_ACTIVE_ANON
    [2] = (counter = 115288),
    [3] = (counter = 27257),
    [4] = (counter = 17555),
    [5] = (counter = 7484),
    [6] = (counter = 7500),
    [7] = (counter = 0),
    [8] = (counter = 0),
    [9] = (counter = 0),
    [10] = (counter = 0),
    [11] = (counter = 0),
    [12] = (counter = 0),
    [13] = (counter = 0),
    [14] = (counter = 0),
    [15] = (counter = 0),
    [16] = (counter = 0),
    [17] = (counter = 49938),
    [18] = (counter = 42295),
    [19] = (counter = 162865),
    [20] = (counter = 81),
    [21] = (counter = 0),
    [22] = (counter = 0),
    [23] = (counter = 20320),
    [24] = (counter = 0),
    [25] = (counter = 0),
    [26] = (counter = 0),
    [27] = (counter = 0),
    [28] = (counter = 0),
    [29] = (counter = 0),
    [30] = (counter = 0),
    [31] = (counter = 32378),
    [32] = (counter = 31663),
    [33] = (counter = 0),
    [34] = (counter = 0),
    [35] = (counter = 0),
    [36] = (counter = 3920),
    [37] = (counter = 1400),

'vm_flags' is important field in the 'struct vm_area_struct'.

struct vm_area_struct {
/* The first cache line has the info for VMA tree walking. */

unsigned long vm_start; /* Our start address within vm_mm. */
unsigned long vm_end; /* The first byte after our end address
   within vm_mm. */

/* linked list of VM areas per task, sorted by address */
struct vm_area_struct *vm_next, *vm_prev;

...
unsigned long vm_flags; /* Flags, see mm.h. */

'vm_flags' can be seen when using crash utility program as below.

crash64 > vm 5533
PID: 5533  TASK: ffffffc4da6d4340 CPU: 5  COMMAND: "sh"
    MM        PGD     RSS  TOTAL_VM
ffffffc50cdbbc40 ffffffc4e2efc000 3036k  33588k
   VMA      START    END   FLAGS FILE
ffffffc4dde36528 55686d3000 55686de000  871 /system/bin/sh 
ffffffc4dde36f78 55686de000 556871b000  874 /system/bin/sh //<<-
ffffffc4e42f6948 556871b000 556871c000 100873 /system/bin/sh
ffffffc4dde377b8 556871c000 556871e000 100871 /system/bin/sh

We can refer to the corresponding attribute of 'vm_flags' in 'include/linux/mm.h' 

include/linux/mm.h
/*
 * vm_flags in vm_area_struct, see mm_types.h.
 * When changing, update also include/trace/events/mmflags.h
 */
#define VM_NONE 0x00000000

#define VM_READ 0x00000001 /* currently active flags */
#define VM_WRITE 0x00000002
#define VM_EXEC 0x00000004
#define VM_SHARED 0x00000008

/* mprotect() hardcodes VM_MAYREAD >> 4 == VM_READ, and so for r/w/x bits. */
#define VM_MAYREAD 0x00000010 /* limits for mprotect() etc */
#define VM_MAYWRITE 0x00000020
#define VM_MAYEXEC 0x00000040
#define VM_MAYSHARE 0x00000080

#define VM_GROWSDOWN 0x00000100 /* general info on the segment */
#define VM_UFFD_MISSING 0x00000200 /* missing pages tracking */
#define VM_PFNMAP 0x00000400 /* Page-ranges managed without "struct page", just pure PFN */
#define VM_UFFD_WP 0x00001000 /* wrprotect pages tracking */

#define VM_LOCKED 0x00002000
#define VM_IO           0x00004000 /* Memory mapped I/O or similar */

crash64> bt 
...
#20 [ffffffc00932be70] do_el0_svc at ffffffd174227f30
#21 [ffffffc00932be80] el0_svc at ffffffd174d4d328
#22 [ffffffc00932bea0] el0t_64_sync_handler at ffffffd174d4da20
#23 [ffffffc00932bfe0] el0t_64_sync at ffffffd17421160c
     PC: 0000007fa528cb20   LR: 0000007fa5237f94   SP: 0000007fc3fc7ad0
    X29: 0000007fc3fc7ad0  X28: 000000557d72f000  X27: 0000000000000000
    X26: 000000557d6f5000  X25: 0000007fa5339668  X24: 000000000000000a
    X23: 00000055b19f3330  X22: 0000007fa53cb740  X21: 0000007fa5339580
    X20: 00000055b19f3330  X19: 0000000000000001  X18: 0000000000000000
    X17: 0000007fa5234800  X16: 0000007fa52393a0  X15: 0000000000000000
    X14: 0000000000000002  X13: 0000000000000001  X12: 0000000000000000
    X11: 0000000000000000  X10: 0000000000000007   X9: 000000000004804c
     X8: 0000000000000040   X7: 0000000000001030   X6: 0000000000000009
     X5: 0001555100045400   X4: 0000000040100401   X3: 0000007fa53cb040
     X2: 000000000000000a   X1: 00000055b19f3330   X0: 0000000000000001
    ORIG_X0: 0000000000000001  SYSCALLNO: 40  PSTATE: 20000000

crash64> vtop 0000007fc3fc7ad0
7fc3fc7ad0: 7fc3fc7
crash64> vtop 0000007fc3fc7ad0
VIRTUAL     PHYSICAL
7fc3fc7ad0  4aafead0

PAGE DIRECTORY: ffffff806cf0b000
   PGD: ffffff806cf0bff8 => 80000006cf0c003
   PMD: ffffff806cf0c0f8 => 8000000711c9003
   PTE: ffffff80711c9e38 => e800004aafef43
  PAGE: 4aafe000

     PTE        PHYSICAL  FLAGS
e800004aafef43  4aafe000  (VALID|USER|SHARED|AF|NG|PXN|UXN|DIRTY)

      VMA           START       END     FLAGS FILE
ffffff80685fb730 7fc3fa8000 7fc3fc9000 200100173

      PAGE       PHYSICAL      MAPPING       INDEX CNT FLAGS
fffffffe012abf80 4aafe000 ffffff8069edc2d9  7fffffe  1 4000000000080014 uptodate,lru,swapbacked

crash64> kmem ffffff8069edc2d9
CACHE             OBJSIZE  ALLOCATED     TOTAL  SLABS  SSIZE  NAME
ffffff804002a600       96       3535      5148    132     4k  anon_vma
  SLAB              MEMORY            NODE  TOTAL  ALLOCATED  FREE
  fffffffe01a7b700  ffffff8069edc000     0     39         19    20
  FREE / [ALLOCATED]
  [ffffff8069edc2d8]

      PAGE       PHYSICAL      MAPPING       INDEX CNT FLAGS
fffffffe01a7b700 69edc000 ffffff804002a600        0  1 4000000000000200 slab

crash64> kmem ffffff8069edc2e0
CACHE             OBJSIZE  ALLOCATED     TOTAL  SLABS  SSIZE  NAME
ffffff804002a600       96       3535      5148    132     4k  anon_vma
  SLAB              MEMORY            NODE  TOTAL  ALLOCATED  FREE
  fffffffe01a7b700  ffffff8069edc000     0     39         19    20
  FREE / [ALLOCATED]
  [ffffff8069edc2d8]

      PAGE       PHYSICAL      MAPPING       INDEX CNT FLAGS
fffffffe01a7b700 69edc000 ffffff804002a600        0  1 4000000000000200 slab


  (struct anon_vma *) (struct anon_vma*)0xffffff8069edc2d8 = 0xFFFFFF8069EDC2D8 -> (
    (struct anon_vma *) root = 0xFFFFFF8069EDC2D8,
    (struct rw_semaphore) rwsem = ((atomic_long_t) count = ((s64) counter = 0x0), (atomic
    (atomic_t) refcount = ((int) counter = 0x1),
    (long unsigned int) num_children = 0x1,
    (long unsigned int) num_active_vmas = 0x1,
    (struct anon_vma *) parent = 0xFFFFFF8069EDC2D8,
    (struct rb_root_cached) rb_root = ((struct rb_root) rb_root = ((struct rb_node *) rb_

In case of anon page, struct page->mapping is pointing to ( &(struct anon_vma) + 1 )

log 

[  747.358161] 81920 pages cma reserved
[  747.358164] Tasks state (memory values in pages):
[  747.358167] [  pid  ]   uid  tgid total_vm      rss pgtables_bytes swapents oom_score_adj name
[  747.358186] [    142]     0   142    12270       43    94208      236          -250 systemd-journal
...
[  747.358591] [   1468]     0  1468     1740      131    45056        0             0 bash
[  747.358597] [   1502]  1000  1502    39991       99    65536        0             0 gvfsd-metadata
[  747.358607] [   1604]     0  1604  2570484   224052 20631552     1271             0 invoke_memleak
[  747.358612] oom-kill:constraint=CONSTRAINT_NONE,nodemask=(null),cpuset=/,mems_allowed=0,global_oom,task_memcg=/,task=invoke_memleak,pid=1604,uid=0
[  747.358652] Out of memory: Killed process 1604 (invoke_memleak) total-vm:10281936kB, anon-rss:896204kB, file-rss:4kB, shmem-rss:0kB, UID:0 pgtables:20148kB oom_score_adj:0

__oom_kill_process() function

https://elixir.bootlin.com/linux/v5.15.30/source/mm/oom_kill.c
static void __oom_kill_process(struct task_struct *victim, const char *message)
{
struct task_struct *p;
..
pr_err("%s: Killed process %d (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB, shmem-rss:%lukB, UID:%u pgtables:%lukB oom_score_adj:%hd\n",
message, task_pid_nr(victim), victim->comm, K(mm->total_vm),
K(get_mm_counter(mm, MM_ANONPAGES)),
K(get_mm_counter(mm, MM_FILEPAGES)),
K(get_mm_counter(mm, MM_SHMEMPAGES)),
from_kuid(&init_user_ns, task_uid(victim)),
mm_pgtables_bytes(mm) >> 10, victim->signal->oom_score_adj);
task_unlock(victim);

(where)
#define K(x) ((x) << (PAGE_SHIFT-10))

Access 'K(mm->total_vm)' using TRACE32

v.v %t  (struct task_struct*)0xffffff8040238000

  (struct task_struct *) (struct task_struct*)0xffffff8040238000 = 0xFFFFFF8040238000 -> (
    (struct thread_info) thread_info = ((long unsigned int) flags = 0, (u64) preempt_count = 4294967
    (unsigned int) __state = 1,
    (void *) stack = 0xFFFFFFC008028000,
...
    (struct mm_struct *) mm = 0xFFFFFF8041A08000 -> (
      (struct vm_area_struct *) mmap = 0xFFFFFF8040F2D0B8,
      (struct rb_root) mm_rb = ((struct rb_node *) rb_node = 0xFFFFFF8040F2DDC8),
      (u64) vmacache_seqnum = 55,
      (long unsigned int (*)()) get_unmapped_area = 0xFFFFFFD1744A5194,
      (long unsigned int) mmap_base = 548384292864,
      (long unsigned int) mmap_legacy_base = 0,
      (long unsigned int) task_size = 549755813888,
      (long unsigned int) highest_vm_end = 548951498752,
      (pgd_t *) pgd = 0xFFFFFF8040F2C000,
      (atomic_t) membarrier_state = ((int) counter = 0),
      (atomic_t) mm_users = ((int) counter = 1),
      (atomic_t) mm_count = ((int) counter = 1),
      (atomic_long_t) pgtables_bytes = ((s64) counter = 86016),
      (int) map_count = 130,
      (spinlock_t) page_table_lock = ((struct raw_spinlock) rlock = ((arch_spinlock_t) raw_lock = ((
      (struct rw_semaphore) mmap_lock = ((atomic_long_t) count = ((s64) counter = 0), (atomic_long_t
      (struct list_head) mmlist = ((struct list_head *) next = 0xFFFFFF8041A08090, (struct list_head
      (long unsigned int) hiwater_rss = 7782,
      (long unsigned int) hiwater_vm = 58098,
      (long unsigned int) total_vm = 41714,  // <<-- K(mm->total_vm)
      (long unsigned int) locked_vm = 0,

https://elixir.bootlin.com/linux/v5.15.30/source/arch/arm64/include/asm/pgtable-hwdef.h#L151

#define PTE_VALID (_AT(pteval_t, 1) << 0)
#define PTE_TYPE_MASK (_AT(pteval_t, 3) << 0)
#define PTE_TYPE_PAGE (_AT(pteval_t, 3) << 0)
#define PTE_TABLE_BIT (_AT(pteval_t, 1) << 1)
#define PTE_USER (_AT(pteval_t, 1) << 6) /* AP[1] */
#define PTE_RDONLY (_AT(pteval_t, 1) << 7) /* AP[2] */
#define PTE_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
#define PTE_AF (_AT(pteval_t, 1) << 10) /* Access Flag */
#define PTE_NG (_AT(pteval_t, 1) << 11) /* nG */
#define PTE_GP (_AT(pteval_t, 1) << 50) /* BTI guarded */
#define PTE_DBM (_AT(pteval_t, 1) << 51) /* Dirty Bit Management */
#define PTE_CONT (_AT(pteval_t, 1) << 52) /* Contiguous range */
#define PTE_PXN (_AT(pteval_t, 1) << 53) /* Privileged XN */
#define PTE_UXN (_AT(pteval_t, 1) << 54) /* User XN */

  68 void trace_pte_value(void)
  69 {
  70         printk("PTE: %lx \n", PTE_VALID);
  71         printk("PTE: %lx \n", PTE_TYPE_MASK);
  72         printk("PTE: %lx \n", PTE_TYPE_PAGE);
  73         printk("PTE: %lx \n", PTE_TABLE_BIT);
  74         printk("PTE: %lx \n", PTE_USER);
  75         printk("PTE: %lx \n", PTE_RDONLY);
  76         printk("PTE: %lx \n", PTE_SHARED);
  77         printk("PTE: %lx \n", PTE_AF);
  78         printk("PTE: %lx \n", PTE_NG);
  79         printk("PTE: %lx \n", PTE_GP);
  80         printk("PTE: %lx \n", PTE_DBM);
  81         printk("PTE: %lx \n", PTE_CONT);
  82         printk("PTE: %lx \n", PTE_PXN);
  83         printk("PTE: %lx \n", PTE_UXN);
  84 }
  85
  86
  87

ffffffc0080370f0 <trace_pte_value>:
ffffffc0080370f0: stp     x29, x30, [sp, #-32]!
ffffffc0080370f4: mov     x29, sp
ffffffc0080370f8: str     x19, [sp, #16]
ffffffc0080370fc: adrp    x19, ffffffc008e04000 <kallsyms_token_index+0x6e70>
ffffffc008037100: mov     x0, x30
ffffffc008037104: add     x19, x19, #0x718
ffffffc008037108: bl      ffffffc00802c674 <_mcount>
ffffffc00803710c: mov     x1, #0x1  // PTE_VALID ; 0b01
ffffffc008037110: mov     x0, x19
ffffffc008037114: bl      ffffffc008b41ea0 <_printk>
ffffffc008037118: mov     x1, #0x3  // PTE_TYPE_MASK ; 0b11
ffffffc00803711c: mov     x0, x19
ffffffc008037120: bl      ffffffc008b41ea0 <_printk>
ffffffc008037124: mov     x1, #0x3   // PTE_TYPE_MASK ; 0b11
ffffffc008037128: mov     x0, x19
ffffffc00803712c: bl      ffffffc008b41ea0 <_printk>
ffffffc008037130: mov     x1, #0x2   // PTE_TABLE_BIT ; 0b10 
ffffffc008037134: mov     x0, x19
ffffffc008037138: bl      ffffffc008b41ea0 <_printk>
ffffffc00803713c: mov     x1, #0x40  // PTE_USER ;  0b1000000 // 6th bit 
ffffffc008037140: mov     x0, x19
ffffffc008037144: bl      ffffffc008b41ea0 <_printk>
ffffffc008037148: mov     x1, #0x80  // PTE_RDONLY ;  0b10000000 // 7th bit 
ffffffc00803714c: mov     x0, x19
ffffffc008037150: bl      ffffffc008b41ea0 <_printk>
ffffffc008037154: mov     x1, #0x300  // PTE_SHARED ; 11|0000|0000 // (8+9)th bit
ffffffc008037158: mov     x0, x19
ffffffc00803715c: bl      ffffffc008b41ea0 <_printk>
ffffffc008037160: mov     x1, #0x400  // PTE_AF ;     100|0000|0000 // (10)th bit
ffffffc008037164: mov     x0, x19
ffffffc008037168: bl      ffffffc008b41ea0 <_printk>
ffffffc00803716c: mov     x1, #0x800  // PTE_NG ;     1000|0000|0000 // (11)th bit
ffffffc008037170: mov     x0, x19
ffffffc008037174: bl      ffffffc008b41ea0 <_printk>
ffffffc008037178: mov     x1, #0x4000000000000 // PTE_GP ;  // (50)th bit
ffffffc00803717c: mov     x0, x19
ffffffc008037180: bl      ffffffc008b41ea0 <_printk>
ffffffc008037184: mov     x1, #0x8000000000000 // PTE_DBM ;  // (51)th bit
ffffffc008037188: mov     x0, x19
ffffffc00803718c: bl      ffffffc008b41ea0 <_printk>
ffffffc008037190: mov     x1, #0x10000000000000  // PTE_CONT ;  // (52)th bit
ffffffc008037194: mov     x0, x19
ffffffc008037198: bl      ffffffc008b41ea0 <_printk>
ffffffc00803719c: mov     x1, #0x20000000000000 // PTE_PXN ;  // (53)th bit
ffffffc0080371a0: mov     x0, x19
ffffffc0080371a4: bl      ffffffc008b41ea0 <_printk>
ffffffc0080371a8: mov     x1, #0x40000000000000  // PTE_UXN ;  // (54)th bit
ffffffc0080371ac: mov     x0, x19
ffffffc0080371b0: bl      ffffffc008b41ea0 <_printk>
ffffffc0080371b4: ldr     x19, [sp, #16]
ffffffc0080371b8: ldp     x29, x30, [sp], #32
ffffffc0080371bc: ret

 

< '시스템 소프트웨어 개발을 위한 Arm 아키텍처의 구조와 원리' 저자>

 
 

memory layout is traced at boot in the previous kernel version where the current 
version cannot show the memory map. 

https://elixir.bootlin.com/linux/v4.14.30/source/arch/arm64/mm/init.c#L583
void __init mem_init(void)
{
if (swiotlb_force == SWIOTLB_FORCE ||
    max_pfn > (arm64_dma_phys_limit >> PAGE_SHIFT))
swiotlb_init(1);
else
swiotlb_force = SWIOTLB_NO_FORCE;

set_max_mapnr(pfn_to_page(max_pfn) - mem_map);

#ifndef CONFIG_SPARSEMEM_VMEMMAP
free_unused_memmap();
#endif
/* this will put all unused low memory onto the freelists */
free_all_bootmem();

kexec_reserve_crashkres_pages();

mem_init_print_info(NULL);

#define MLK(b, t) b, t, ((t) - (b)) >> 10
#define MLM(b, t) b, t, ((t) - (b)) >> 20
#define MLG(b, t) b, t, ((t) - (b)) >> 30
#define MLK_ROUNDUP(b, t) b, t, DIV_ROUND_UP(((t) - (b)), SZ_1K)

pr_notice("Virtual kernel memory layout:\n");
#ifdef CONFIG_KASAN
pr_notice("    kasan   : 0x%16lx - 0x%16lx   (%6ld GB)\n",
MLG(KASAN_SHADOW_START, KASAN_SHADOW_END));
#endif
pr_notice("    modules : 0x%16lx - 0x%16lx   (%6ld MB)\n",
MLM(MODULES_VADDR, MODULES_END));
pr_notice("    vmalloc : 0x%16lx - 0x%16lx   (%6ld GB)\n",
MLG(VMALLOC_START, VMALLOC_END));
pr_notice("      .text : 0x%p" " - 0x%p" "   (%6ld KB)\n",
MLK_ROUNDUP(_text, _etext));
pr_notice("    .rodata : 0x%p" " - 0x%p" "   (%6ld KB)\n",
MLK_ROUNDUP(__start_rodata, __init_begin));
pr_notice("      .init : 0x%p" " - 0x%p" "   (%6ld KB)\n",
MLK_ROUNDUP(__init_begin, __init_end));
pr_notice("      .data : 0x%p" " - 0x%p" "   (%6ld KB)\n",
MLK_ROUNDUP(_sdata, _edata));
pr_notice("       .bss : 0x%p" " - 0x%p" "   (%6ld KB)\n",
MLK_ROUNDUP(__bss_start, __bss_stop));
pr_notice("    fixed   : 0x%16lx - 0x%16lx   (%6ld KB)\n",
MLK(FIXADDR_START, FIXADDR_TOP));
pr_notice("    PCI I/O : 0x%16lx - 0x%16lx   (%6ld MB)\n",
MLM(PCI_IO_START, PCI_IO_END));
#ifdef CONFIG_SPARSEMEM_VMEMMAP
pr_notice("    vmemmap : 0x%16lx - 0x%16lx   (%6ld GB maximum)\n",
MLG(VMEMMAP_START, VMEMMAP_START + VMEMMAP_SIZE));
pr_notice("              0x%16lx - 0x%16lx   (%6ld MB actual)\n",
MLM((unsigned long)phys_to_page(memblock_start_of_DRAM()),
    (unsigned long)virt_to_page(high_memory)));
#endif
pr_notice("    memory  : 0x%16lx - 0x%16lx   (%6ld MB)\n",
MLM(__phys_to_virt(memblock_start_of_DRAM()),
    (unsigned long)high_memory));

+ Recent posts