OK6410A development board (eight) 11 linux-5.11 OK6410A start_kernel print angle first stage mem

Publisher:耿高良Latest update time:2022-09-16 Source: csdnKeywords:OK6410A Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

This phase is complete

1. Reserve the page table that does not need to be filled according to the reserved member of memblock // reserve_bootmem_region


2. By complementing the reserved memblock in the full physical memory, unused physical memory is obtained and the page table that needs to be filled is filled // __free_memory_core


3. At this point, buddy initialization is complete


4. Fill kmalloc_caches[type([0-1])][idx([6-d])] with (memory address, memory size, requested block size)


5. At this point, slab initialization is complete


6. Register the used virtual memory address A (mainly io devices) in the vmalloc interval to vmap_area_root


7. By complementing A in the full virtual memory (non-vmalloc interval), the virtual address space is obtained and registered to free_vmap_area_root


8. At this point, vmalloc initialization is complete


// Virtual memory layout is no longer printed 

// Please check 1c31d4e96b8c205fe3aa8e73e930a0ccbf4b9a2b


In fact, there is also a section about mem in setup_arch


The mem-related part of setup_arch


2. Match board-level mdesc and parse atags (including core cmdline mem)

5. Initialize various types of descriptor tables

6. Add various (kernel/initrd/device tree/atags/reserved in device tree/) reserved memory to memblock

7. Clear the address where the page table will be stored to 0

8. Fill page tables for multiple contents (lowmem/device tree/vectors/various devices)

10. Apply for memory to store many struct pages 

11. Initialize all struct pages



It can be said that setup_arch completes

1. Creation of virtual page table (lowmem/device tree/vectors/various devices)

2. Initialization of memblock // At the end of setup_arch, memory can be allocated through memblock_alloc

3. The first part of buddy initialization // All low-end memory struct pages are ready


In this article, we focus on the following functions

page_address_init

// null

setup_arch

// This has been discussed before

build_all_zonelists

// Print information

// Built 1 zonelists, mobility grouping on.  Total pages: 65024

mm_init

// Print information

// mem auto-init: stack:off, heap alloc:off, heap free:off

// Memory: 243936K/262144K available (5120K kernel code, 6569K rwdata, 732K rodata, 1024K init, 2134K bss, 18208K reserved, 0K cma-reserved)

// SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1


build_all_zonelists

build_all_zonelists

build_all_zonelists_init

__build_all_zonelists

for_each_online_node(nid) build_zonelists(pgdat);

zonerefs = pgdat->node_zonelists[ZONELIST_FALLBACK]._zonerefs;

nr_zones = build_zonerefs_node(pgdat, zonerefs);

zone = pgdat->node_zones + zone_type;

zoneref_set_zone(zone, &zonerefs[nr_zones++]);

zoneref->zone = zone;

zoneref->zone_idx = zone_idx(zone);

zonerefs += nr_zones;

for_each_possible_cpu(cpu) pageset_init(&per_cpu(boot_pageset, cpu));

mminit_verify_zonelist

cpuset_init_current_mems_allowed

vm_total_pages = nr_free_zone_pages(gfp_zone(GFP_HIGHUSER_MOVABLE)); // fe00

page_group_by_mobility_disabled = 0;


mm_init

mm_init

page_ext_init_flatmem

// null

init_mem_debugging_and_hardening

// ALL

report_remembers

// pr_info

mem_init

set_max_mapnr(pfn_to_page(max_pfn) - mem_map);

max_mapnr = pfn_to_page(max_pfn) - mem_map;

/* this will put all unused low memory onto the freelists */

memblock_free_all

free_unused_memmap // Sparse memory related, release non-existent addresses

free_memmap

reset_all_zones_managed_pages

pages = free_low_memory_core_early

// reserve all the struct page

for_each_reserved_mem_range(i, &start, &end) reserve_bootmem_region(start, end); // reserve_bootmem_region executed 16 times

for (; start_pfn < end_pfn; start_pfn++) 

init_reserved_page(start_pfn);

INIT_LIST_HEAD(&page->lru);

__SetPageReserved(page);

/*

// These 16 are reserved members in memblock

Reserved for kernel/page table/struct page/vectors

There is also memory requested during io map/request_standard_resources

reserve_bootmem_region // 16 times, the reason is 16 times, because memblock_alloc was called 16 times before

start_pfn:50004,end_pfn:50008 // Mark this address as being used, used as a page table

page:cfdf5080

page:cfdf50a0

page:cfdf50c0

page:cfdf50e0

start_pfn:50100,end_pfn:51081 // Mark this address as being used, used in the kernel (__pa(KERNEL_START), KERNEL_END - KERNEL_START)

page:cfdf7000

...

page:cfe16000

start_pfn:5fdbc,end_pfn:5fdf4

page:cfff0780

...

page:cfff0e60

start_pfn:5fdf5,end_pfn:5fffc // Mark this address as being used, used as struct page

page:cfff0ea0

...

page:cfff4f60

start_pfn:5fffc,end_pfn:5fffd

page:cfff4f80

start_pfn:5fffc,end_pfn:5fffd

page:cfff4f80

start_pfn:5fffc,end_pfn:5fffd

page:cfff4f80

start_pfn:5fffc,end_pfn:5fffd

page:cfff4f80

start_pfn:5fffc,end_pfn:5fffd

page:cfff4f80

start_pfn:5fffc,end_pfn:5fffd

page:cfff4f80

start_pfn:5fffc,end_pfn:5fffd

page:cfff4f80

start_pfn:5fffc,end_pfn:5fffd

page:cfff4f80

start_pfn:5fffc,end_pfn:5fffd

page:cfff4f80

start_pfn:5fffc,end_pfn:5fffd

page:cfff4f80

start_pfn:5fffc,end_pfn:5fffd

page:cfff4f80

start_pfn:5fffc,end_pfn:60000 // Mark this section as occupied by vectors and others

page:cfff4f80

...

page:cfff4fe0

*/

// free mem

for_each_free_mem_range __free_memory_core(start, end);

__free_pages_memory(start_pfn, end_pfn); // __free_pages_memory executed 4 times

memblock_free_pages(pfn_to_page(start), start, order);

__free_pages_core

__free_pages_ok

free_one_page

__free_one_page

add_to_free_list(page, zone, order, migratetype);

/*

__free_pages_memory executed 4 times

// The reason why it is 4 times is that the total memory minus the memory of memblock_alloc leaves only 4 consecutive free memory blocks

start_pfn:50000,end_pfn:50004 //Mark this memory as not in use

pfn_to_page(start):cfdf5000, start:50000, order:2

start_pfn:50008,end_pfn:50100 // Mark this memory as not in use. Although this memory belongs to the kernel, it does not belong to the kernel (__pa(KERNEL_START), KERNEL_END - KERNEL_START)

pfn_to_page(start):cfdf5100, start:50008, order:3

pfn_to_page(start):cfdf5200, start:50010, order:4

pfn_to_page(start):cfdf5400, start:50020, order:5

pfn_to_page(start):cfdf5800, start:50040, order:6

pfn_to_page(start):cfdf6000, start:50080, order:7

start_pfn:51081,end_pfn:5fdbc

pfn_to_page(start):cfe16020, start:51081, order:0

pfn_to_page(start):cfe16040, start:51082, order:1

pfn_to_page(start):cfe16080, start:51084, order:2

pfn_to_page(start):cfe16100, start:51088, order:3

pfn_to_page(start):cfe16200, start:51090, order:4

pfn_to_page(start):cfe16400, start:510a0, order:5

pfn_to_page(start):cfe16800, start:510c0, order:6

pfn_to_page(start):cfe17000, start:51100, order:8

pfn_to_page(start):cfe19000, start:51200, order:9

pfn_to_page(start):cfe1d000, start:51400, order:a

pfn_to_page(start):cfe25000, start:51800, order:a

pfn_to_page(start):cfe2d000, start:51c00, order:a

pfn_to_page(start):cfe35000, start:52000, order:a

pfn_to_page(start):cfe3d000, start:52400, order:a

pfn_to_page(start):cfe45000, start:52800, order:a

pfn_to_page(start):cfe4d000, start:52c00, order:a

pfn_to_page(start):cfe55000, start:53000, order:a

pfn_to_page(start):cfe5d000, start:53400, order:a

pfn_to_page(start):cfe65000, start:53800, order:a

pfn_to_page(start):cfe6d000, start:53c00, order:a

pfn_to_page(start):cfe75000, start:54000, order:a

pfn_to_page(start):cfe7d000, start:54400, order:a

pfn_to_page(start):cfe85000, start:54800, order:a

pfn_to_page(start):cfe8d000, start:54c00, order:a

pfn_to_page(start):cfe95000, start:55000, order:a

pfn_to_page(start):cfe9d000, start:55400, order:a

pfn_to_page(start):cfea5000, start:55800, order:a

pfn_to_page(start):cfead000, start:55c00, order:a

pfn_to_page(start):cfeb5000, start:56000, order:a

pfn_to_page(start):cfebd000, start:56400, order:a

pfn_to_page(start):cfec5000, start:56800, order:a

pfn_to_page(start):cfecd000, start:56c00, order:a

pfn_to_page(start):cfed5000, start:57000, order:a

pfn_to_page(start):cfedd000, start:57400, order:a

pfn_to_page(start):cfee5000, start:57800, order:a

pfn_to_page(start):cfeed000, start:57c00, order:a

pfn_to_page(start):cfef5000, start:58000, order:a

pfn_to_page(start):cfefd000, start:58400, order:a

pfn_to_page(start):cff05000, start:58800, order:a

pfn_to_page(start):cff0d000, start:58c00, order:a

pfn_to_page(start):cff15000, start:59000, order:a

pfn_to_page(start):cff1d000, start:59400, order:a

pfn_to_page(start):cff25000, start:59800, order:a

pfn_to_page(start):cff2d000, start:59c00, order:a

pfn_to_page(start):cff35000, start:5a000, order:a

pfn_to_page(start):cff3d000, start:5a400, order:a

pfn_to_page(start):cff45000, start:5a800, order:a

pfn_to_page(start):cff4d000, start:5ac00, order:a

pfn_to_page(start):cff55000, start:5b000, order:a

pfn_to_page(start):cff5d000, start:5b400, order:a

pfn_to_page(start):cff65000, start:5b800, order:a

pfn_to_page(start):cff6d000, start:5bc00, order:a

pfn_to_page(start):cff75000, start:5c000, order:a

pfn_to_page(start):cff7d000, start:5c400, order:a

pfn_to_page(start):cff85000, start:5c800, order:a

pfn_to_page(start):cff8d000, start:5cc00, order:a

pfn_to_page(start):cff95000, start:5d000, order:a

pfn_to_page(start):cff9d000, start:5d400, order:a

pfn_to_page(start):cffa5000, start:5d800, order:a

pfn_to_page(start):cffad000, start:5dc00, order:a

pfn_to_page(start):cffb5000, start:5e000, order:a

pfn_to_page(start):cffbd000, start:5e400, order:a

pfn_to_page(start):cffc5000, start:5e800, order:a

pfn_to_page(start):cffcd000, start:5ec00, order:a

pfn_to_page(start):cffd5000, start:5f000, order:a

pfn_to_page(start):cffdd000, start:5f400, order:a

pfn_to_page(start):cffe5000, start:5f800, order:a

pfn_to_page(start):cffed000, start:5fc00, order:8

pfn_to_page(start):cffef000, start:5fd00, order:7

pfn_to_page(start):cfff0000, start:5fd80, order:5

pfn_to_page(start):cfff0400, start:5fda0, order:4

pfn_to_page(start):cfff0600, start:5fdb0, order:3

pfn_to_page(start):cfff0700, start:5fdb8, order:2

start_pfn:5fdf4,end_pfn:5fdf5 // Mark this memory as not in use

pfn_to_page(start):cfff0e80, start:5fdf4, order:0

*/



/*

So far, 50000000 - 60000000 has been recorded by struct page

[1] [2]
Keywords:OK6410A Reference address:OK6410A development board (eight) 11 linux-5.11 OK6410A start_kernel print angle first stage mem

Previous article:OK6410A development board (eight) 12 linux-5.11 OK6410A start_kernel print angle first stage irq
Next article:OK6410A development board (eight) 10 linux-5.11 OK6410A start_kernel print angle first stage setup_arch

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号