config.c
0.17MB
ftrace_log.c
1.00MB
vmlinux.zip
3.55MB

command

$ git clone --branch rpi-4.19.y-rt https://github.com/raspberrypi/linux

.config

  79 CONFIG_PREEMPT=y
  80 CONFIG_PREEMPT_RT_BASE=y
  81 CONFIG_HAVE_PREEMPT_LAZY=y
  82 CONFIG_PREEMPT_LAZY=y
  83 # CONFIG_PREEMPT_NONE is not set
  84 # CONFIG_PREEMPT_VOLUNTARY is not set
  85 # CONFIG_PREEMPT__LL is not set
  86 # CONFIG_PREEMPT_RTB is not set
  87 CONFIG_PREEMPT_RT_FULL=y
  88 CONFIG_PREEMPT_COUNT=y

Ftrace message

1. preemption at rt_spin_lock()

kworker/u8:0-7     [002] d...2..   765.163489: sched_switch: prev_comm=kworker/u8:0 prev_pid=7 prev_prio=120 prev_state=D ==> next_comm=swapper/2 next_pid=0 next_prio=120
     kworker/0:1-48    [000] d...211   765.163502: <stack trace>
 => __schedule+0x65c/0x7d8
 => preempt_schedule_common+0x40/0xa8
 => preempt_schedule+0x58/0x5c
 => migrate_disable+0x180/0x278
 => rt_spin_lock+0x3c/0x80
 => worker_thread+0x10c/0x5b8
 => kthread+0x16c/0x174
 => ret_from_fork+0x14/0x20
 => 0

Assembly instruction around worker_thread+0x10c address

______addr/line|label_______|mnemonic________________|comment
   NSR:C023FD1C|             bl      0xC09B8E40       ; schedule
   NSR:C023FD20|woke_up:     cpy     r0,r6            ; r0,pool
   NSR:C023FD24|             bl      0xC09BD4AC       ; rt_spin_lock
   NSR:C023FD28|             ldr     r3,[r4,#0x30]
   NSR:C023FD2C|             tst     r3,#0x2          ; r3,#2
   NSR:C023FD30|             bne     0xC023FF38
   NSR:C023FD34|             tst     r3,#0x4          ; r3,#4
   NSR:C023FD38|             ldr     r5,[r4,#0x20]    ; pool,[r4,#32]
   NSR:C023FD3C|             beq     0xC024008C
 
2. preemption at rt_spin_lock()

irq/39-s-mmc1-98    [000] d...2..   763.500866: sched_switch: prev_comm=irq/39-s-mmc1 prev_pid=98 prev_prio=50 prev_state=R+ ==> next_comm=irq/39-mmc1 next_pid=97 next_prio=49
   irq/39-s-mmc1-98    [000] d...2..   763.500895: <stack trace>
 => __schedule+0x65c/0x7d8
 => preempt_schedule_common+0x40/0xa8
 => preempt_schedule+0x58/0x5c
 => migrate_enable+0x1d8/0x4b0
 => rt_spin_unlock+0x68/0x90
 => bcm2835_mmc_request+0x64/0xb8
 => __mmc_start_request+0x98/0x1dc
 => mmc_start_request+0x94/0xb8
 => mmc_wait_for_req+0x74/0xe0
 => mmc_io_rw_extended+0x258/0x314
 => sdio_io_rw_ext_helper+0x144/0x1c0
 => sdio_writel+0x3c/0x4c
 => brcmf_sdiod_writel+0x60/0x88 [brcmfmac]
 => brcmf_sdio_intr_rstatus+0xa8/0xdc [brcmfmac]
 => brcmf_sdio_isr+0x9c/0xe4 [brcmfmac]
 => brcmf_sdiod_ib_irqhandler+0x3c/0x40 [brcmfmac]
 => process_sdio_pending_irqs+0xdc/0x198
 => sdio_run_irqs+0x4c/0x68
 => bcm2835_mmc_thread_irq+0x50/0x8c
 => irq_thread_fn+0x2c/0x88
 => irq_thread+0x148/0x234
 => kthread+0x16c/0x174
 => ret_from_fork+0x14/0x20

Assembly instruction around bcm2835_mmc_request+0x64 address

______addr/line|label_|mnemonic________________|comment
   NSR:C0828D74|       ldr     r1,[r5]
   NSR:C0828D78|       cmp     r1,#0x0          ; r1,#0
   NSR:C0828D7C|       beq     0xC0828D8C
   NSR:C0828D80|       ldr     r3,[r4,#0x4D4]
   NSR:C0828D84|       tst     r3,#0x80         ; r3,#128
   NSR:C0828D88|       beq     0xC0828D90
   NSR:C0828D8C|       ldr     r1,[r5,#0x4]
   NSR:C0828D90|       cpy     r0,r6
   NSR:C0828D94|       bl      0xC082852C       ; bcm2835_mmc_send_command
   NSR:C0828D98|       cpy     r0,r6
   NSR:C0828D9C|       bl      0xC09BD67C       ; rt_spin_unlock
   NSR:C0828DA0|       ldr     r3,[r5]
   NSR:C0828DA4|       cmp     r3,#0x0          ; r3,#0
   NSR:C0828DA8|       beq     0xC0828DB8
   NSR:C0828DAC|       ldr     r3,[r4,#0x4D4]
   NSR:C0828DB0|       tst     r3,#0x80         ; r3,#128

RT App 개발 관련 발표자료 

* A Checklist for Writing Linux Real-Time Applications (ELC 2020 발표자료 및 유튜브 동영상)
https://ogness.net/ese2020/ese2020_johnogness_rtchecklist.pdf
 https://www.youtube.com/watch?v=NrjXEaTSyrw 

* Real-time programming with Linux (2022)  - good!

https://shuhaowu.com/blogseries.html#rt-linux-programming

* Raspberry Pi Realtime Linux 개발 관련 link

https://lemariva.com/blog/2019/09/raspberry-pi-4b-preempt-rt-kernel-419y-performance-test

구글 검색해보시면 엄청 나옵니다. 

https://m.blog.naver.com/alice_k106/221170259817

* Raspberry Pi 는 rt patched kernel 을 4.19 와 4.14 기반으로 제공 

https://github.com/raspberrypi/linux/tree/rpi-4.19.y-rt
https://github.com/raspberrypi/linux/tree/rpi-4.14.y-rt

아래 명령어 입력

$ git clone https://kernel.googlesource.com/pub/scm/linux/kernel/git/next/linux-next


$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
$ git clone https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
$ git clone https://kernel.googlesource.com/pub/scm/linux/kernel/git/next/linux-next.git

<Updated, 09/12/2023>

 

Linux v5.19

https://kernelnewbies.org/Linux_5.19

More secure virtualization with AMD's SEV-SNP and Intel's TDX
Jumbograms: IPv6 packets bigger than 64 KB
New architecture: LoongArch
Larger per-inode attribute limits in XFS
ID mapping in overlayfs
Proactive reclaim in memory control groups
BPF improvements: dynamic pointers, typed pointers, libbpf USDT
NFS Courteous Server
ZSTD compressed firmware files

Linux v6.0

https://kernelnewbies.org/Linux_6.0

io_uring features
Runtime verification system
Btrfs send v2 and other improvements
XFS scalability improvements
New perf tools: lock contention and kwork
BPF improvements
Task scheduler improvements
Better LRU list quality with DAMON
dma-buf: Add API for exporting and importing sync files
Support for Intel SGX2

Linux v6.1

https://kernelnewbies.org/Linux_6.1

Initial support for the Rust programming language
Multi-generational LRU for better memory management
KMSAN, a kernel memory sanitizer
Support for KCFI, a forward-edge control-flow integrity scheme
Memory tiering improvements
BPF features: panic helper, PKCS#7 signature verification, memory allocator
Maple trees, a more efficient tree data structure
Allow a process to induce collapsing of memory into transparent hugepages
PSI improvements: per-cgroup PSI, IRQ/SoftIRQ PSI, optimizations
Btrfs performance improvements

Linux v6.2

https://kernelnewbies.org/Linux_6.2

Faster mitigation of the Retbleed CPU vulnerability, and FineIBT
Btrfs RAID5/6 and performance improvements
Better control of block device writeback
Add support for TCP Protective Load Balancing
BPF features: User defined objects
The runtime verification tool
Improved Rust support
Some optional power savings due to improved RCU locking

Linux v6.3

https://kernelnewbies.org/Linux_6.3

Btrfs performance and fragmentation improvements
eBPF support for HID devices, and other BPF enhancements
Non-executable memfds
Support IPv4 big TCP (TSO frames larger than 64kB)
Add new ids to the rseq system call for faster and more efficient memory allocators
Support AMD QoS new features
Netlink protocol specifications
More secure NFS encryption
Multi-actuator support in the BFQ I/O scheduler

Linux v6.4

https://kernelnewbies.org/Linux_6.4

Enable Intel's Linear Address Masking
Unprivileged Pressure Stall Information
New API for User-space trace events
Safer Kernel Samepage Merging with a new process/cgroup API
More scalable memory management with per-VMA locks
More scalable context switching between user and kernel threads
New BPF features
Removal of the SELinux runtime disable capability

Linux v5.19

https://kernelnewbies.org/Linux_5.19
https://lwn.net/Articles/896140/
https://lwn.net/Articles/896410/

Linux v6.0

https://kernelnewbies.org/Linux_6.0
https://lwn.net/Articles/903487/
https://lwn.net/Articles/904032/

Linux v6.1

https://kernelnewbies.org/Linux_6.1
https://lwn.net/Articles/910312/
https://lwn.net/Articles/910608/

Linux v6.2

https://kernelnewbies.org/Linux_6.2
https://lwn.net/Articles/917733/
https://lwn.net/Articles/918146/

Linux v6.3

https://kernelnewbies.org/Linux_6.3
https://lwn.net/Articles/923846/
https://lwn.net/Articles/924384/

.

https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=e046eb0c9bf26d94be9e4592c00c7a78b0fa9bfd 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=376133b7edc20f237a42e4c72415cc9e8c0a9704 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=7655abb953860485940d4de74fb45a8192149bb6 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=85d13c001497b481b4a8cc5d7db243cc44ac2bd8 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=158d495899ce55db453f682a8ac8390d5a426578 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=27a921e75711d924617269e0ba4adb8bae9fd0d1 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=0c8ea531b7740754cf374ca8b7510655f569c5e3 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=fc0e1299da548b32440051f58f08e0c1eb7edd0b 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=9b0de864b5bc298ea53005ad812f3386f81aee9c 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=c7b9adaf85f818d747eeff5145eb4095ccd587fb 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=51a0048beb449682d632d0af52a515adb9f9882e 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=d1777e686ad10ba7c594304429c6045fb79255a1 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=bb48711800e6d7aedbf4dfd3367e0ab1270a6bea 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=18011eac28c7cb31c87b86b7d0e5b01894405c7f 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=ea1e3de85e94d711f63437c04624aa0e8de5c8b3 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=6c27c4082f4f70b9f41df4d0adf51128b40351df 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=be04a6d1126b02c6a28741155b899d648739fc5b 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=084eb77cd3a81134d02500977dc0ecc9277dc97d 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=0617052ddde355ee663b2f048e67dd381e5ebd6a 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=179a56f6f9fbda28f6ca07db1fc3dfad6bc7343c 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=67948af41f2e6818edeeba5182811c704d484949 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=b519538dfefc2f8478a1bcb458459c861d431784 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=6b88a32c7af68895134872cdec3b6bfdb532d94e 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=0d90718871fe80f019b7295ec9d2b23121e396fb 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=0ba2e29c7fc1d58a90fab614d41bf487e28e3840 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=41acec624087b1268a15f414cf7d573deebafeec 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=4e602056559633303d7e5bb2ff624778ca248f68 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=753e8abc36b2c966caea075db0c845563c8a19bf 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=f992b4dfd58be07e31a42bc940a53b3e4b282616 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v5.4.13&id=6dc52b15c4a48052ade2529d639eee401d76e469 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v5.4.13&id=fa0465fc07c2f9f47bd1198ab368d341bd7c7e4e 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=f167211a93ac41a65b7a0ab79d4479d0fb58c4f1 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=439e70e27a51fe374806f460848066b237b0c10b 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=7a4a0c1555b824e0d3dd72942481b1190abea604 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=b89d82ef01b33bc50cbaa8ff05607879b40d0704 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=2f97967503df8e45bc256a348b6f050abd2a38ed 
 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=79e9aa59dc29a995921fb01e64cd36b73cf5abe0 

.

.

Sometime I noticed that system does not crash when the call to BUG() is made in the kernel driver. I just observed the stack trace from the kernel log and then find that target is running rather than entering crash mode.
 
To make the target crash when BUG() is called, the following config should be present;
 
CONFIG_PANIC_ON_OOPS=y
CONFIG_PANIC_ON_OOPS_VALUE=1
 
Let's look at kernel die() function which is called from BUG() function.
 
void die(const char *str, struct pt_regs *regs, int err)
{
...
 
if (in_interrupt())
panic("%s: Fatal exception in interrupt", str);
if (panic_on_oops)
panic("%s: Fatal exception", str);
 
If panic_on_oops is true, the panic() is called with "Fatal exception message". How panic_on_oops is specified? Is it configured during run-time?
 
Let's take a look at below statement;
 
int panic_on_oops = CONFIG_PANIC_ON_OOPS_VALUE;
 
panic_on_oops depends on CONFIG_PANIC_ON_OOPS_VALUE.
Now is time to check the definition of CONFIG_PANIC_ON_OOPS_VALUE.
 
config PANIC_ON_OOPS_VALUE
int
range 0 1
default 0 if !PANIC_ON_OOPS
default 1 if PANIC_ON_OOPS
 
CONFIG_PANIC_ON_OOPS_VALUE can be configured by PANIC_ON_OOPS.
 
Conclusion
 
PANIC_ON_OOPS should be enabled to make the target crash when BUG() is called.

아래 사이트에 유익한 리눅스 커널 드라이버 샘플 코드가 있다.

 
 
<From: Mr. Paran Lee>
---
1. Arm64 Linux kernel 에서 수정 후 테스트해본 리눅스 커널 모듈 드라이버 코드입니다.
 
Tasklet
 
Workqueue
 
2. int generic_handle_irq(unsigned int irq) 관련 루틴
 
Invoke the handler for a particular irq
 
---
 
slub debug enable 하려면 부트 커멘드 라인 추가 요망
 
set bootopts slub_debug=FZPUAO,kmalloc-128
 
https://www.kernel.org/doc/html/v5.4/vm/slub.html>
...
F.e. in order to boot just with sanity checks and red zoning one would specify:
 
slub_debug=FZ
Trying to find an issue in the dentry cache? Try:
 
slub_debug=,dentry
to only enable debugging on the dentry cache. You may use an asterisk at the end of the slab name, in order to cover all slabs with the same prefix. For example, here’s how you can poison the dentry cache as well as all kmalloc slabs:
 
slub_debug=P,kmalloc-*,dentry
Red zoning and tracking may realign the slab. We can just apply sanity checks to the dentry cache with:
 
slub_debug=F,dentry
static int __init setup_slub_debug(char *str)
{
slab_flags_t flags;
char *saved_str;
char *slab_list;
bool global_slub_debug_changed = false;
bool slab_list_specified = false;
 
slub_debug = DEBUG_DEFAULT_FLAGS;
if (*str++ != '=' || !*str)
/*
 * No options specified. Switch on full debugging.
 */
goto out;
 
saved_str = str; // 커멘드 라인 저장
while (str) {
str = parse_slub_debug_flags(str, &flags, &slab_list, true);
 
if (!slab_list) {
slub_debug = flags;
global_slub_debug_changed = true;
} else {
slab_list_specified = true;  // 커멘드 라인에서 슬랩 캐시의 종류를 지정한 경우, slub_debug=P,kmalloc-*,dentry
}
}
 
if (slab_list_specified) {
if (!global_slub_debug_changed)
slub_debug = 0;
slub_debug_string = saved_str;
}
out:
if (slub_debug != 0 || slub_debug_string)
static_branch_enable(&slub_debug_enabled);
if ((static_branch_unlikely(&init_on_alloc) ||
     static_branch_unlikely(&init_on_free)) &&
    (slub_debug & SLAB_POISON))
pr_info("mem auto-init: SLAB_POISON will take precedence over init_on_alloc/init_on_free\n");
return 1;
}
__setup("slub_debug", setup_slub_debug);
 
  (static struct kmem_cache * [14]) kmalloc_caches = (
    [0] = 0x0 =  -> NULL,
    [1] = 0x0 =  -> NULL,
    [2] = 0x0 =  -> NULL,
    [3] = 0x0 =  -> NULL,
    [4] = 0x0 =  -> NULL,
    [5] = 0x0 =  -> NULL,
    [6] = 0x0 =  -> NULL,
    [7] = 0xFFFFFFD33FC20400 // "kmalloc-64"
    [8] = 0xFFFFFFD33FC27780 // "kmalloc-128"
    [9] = 0xFFFFFFD33FC20780 // "kmalloc-256"
    [10] = 0xFFFFFFD33FC27400 
    [11] = 0xFFFFFFD33FC20B00 
    [12] = 0xFFFFFFD33FC27080 
    [13] = 0xFFFFFFD33FC20E80 // "kmalloc-8192"
<version: ES1>
 
Overview
 
이번 포스트에서는 커널 v5.10에 반영된 boottime-trace를 소개합니다. 관련 문서는 아래 링크에서 확인할 수 있습니다.
 
 
강의 동영상 링크는 다음과 같습니다.
 
 
boottime-trace는 커멘드 라인을 통해 ftrace 설정을 해서 부팅 과정에서 ftrace의 주요 기능을 enable하는 기능입니다. 위 링크에서 소개된 패치는 initrd가 존재해야 효과가 있어(ex: 우분투), 배포판마다 활성화가 하기는 어렵습니다. 안드로이드나 크로뮴 OS에서는 initrd을 사용하지 않습니다.
 
소스 분석 
 
v5.15 버전의 리눅스 커널 소스에서 확인한 디렉토리에서 커맨드 라인을 읽는 ftrace 옵션과 콜백 함수 리스트는 아래와 같습니다. ('kernel/trace'에서 서칭 )
 
$ egrep -nr __setup  *
ftrace.c:5526:__setup("ftrace_notrace=", set_ftrace_notrace);
ftrace.c:5534:__setup("ftrace_filter=", set_ftrace_filter);
ftrace.c:5546:__setup("ftrace_graph_filter=", set_graph_function);
ftrace.c:5553:__setup("ftrace_graph_notrace=", set_graph_notrace_function);
ftrace.c:5562:__setup("ftrace_graph_max_depth=", set_graph_max_depth_function);
trace.c:197:__setup("ftrace=", set_cmdline_ftrace);
trace.c:213:__setup("ftrace_dump_on_oops", set_ftrace_dump_on_oops);
trace.c:221:__setup("traceoff_on_warning", stop_trace_on_warning);
trace.c:230:__setup("alloc_snapshot", boot_alloc_snapshot);
trace.c:240:__setup("trace_options=", set_trace_boot_options);
trace.c:251:__setup("trace_clock=", set_trace_boot_clock);
trace.c:263:__setup("tp_printk", set_tracepoint_printk);
trace.c:270:__setup("tp_printk_stop_on_boot", set_tracepoint_printk_stop);
trace.c:1507:__setup("trace_buf_size=", set_buf_size);
trace.c:1522:__setup("tracing_thresh=", set_tracing_thresh);
trace_events.c:3438:__setup("trace_event=", setup_trace_event);
trace_kprobe.c:36:__setup("kprobe_event=", set_kprobe_boot_events);
trace_stack.c:552:__setup("stacktrace", enable_stacktrace);
 
커맨드 라인에 boottime-trace 설정하기
 
크로뮴 OS
 
먼저 크로뮴 OS에서 아래 패치를 적용하면 커멘드 라인이 업데이트됩니다.
 
diff --git a/chromeos/config/x86_64/chromiumos-x86_64.flavour.config b/chromeos/config/x86_64/chromiumos-x86_64.flavour.config
index 084c67d005dd..ad8f8bddc233 100644
— a/chromeos/config/x86_64/chromiumos-x86_64.flavour.config
+++ b/chromeos/config/x86_64/chromiumos-x86_64.flavour.config
 
+CONFIG_CMDLINE="crashkernel=512M ftrace=function ftrace_filter=*_probe*
+CONFIG_CMDLINE_BOOL=y
 
'ftrace=function ftrace_filter=*_probe*'이 핵심 구문입니다.
 
라즈비안
 
이번에는 라즈비안에서 boottime-trace 커맨드 라인을 추가하는 방법을 소개합니다. 라즈비안은 디바이스 트리에서 부트 커멘트 라인을 업데이트할 수 있습니다. 아래는 arm32 기반 라즈비안에서 커멘드 라인을 수정하는 패치입니다. (소스 베이스: v5.15.33)
 
diff --git a/arch/arm/boot/dts/bcm2711-rpi-4-b.dts b/arch/arm/boot/dts/bcm2711-rpi-4-b.dts
index 8c0ab39..47e552e 100644
--- a/arch/arm/boot/dts/bcm2711-rpi-4-b.dts
+++ b/arch/arm/boot/dts/bcm2711-rpi-4-b.dts
@@ -282,7 +282,7 @@
 
 / {
        chosen {
-               bootargs = "coherent_pool=1M 8250.nr_uarts=1 snd_bcm2835.enable_compat_alsa=0 snd_bcm2835.enable_hdmi=1";
+               bootargs = "coherent_pool=1M 8250.nr_uarts=1 snd_bcm2835.enable_compat_alsa=0 snd_bcm2835.enable_hdmi=1 ftrace=function ftrace_filter=*_probe*";
        };
 
        aliases {
 
위 패치는 Arm64 기반 라즈비안에 적용됩니다. bcm2711-rpi-4-b.dts 파일을 열면 "arm/boot/dts/bcm2711-rpi-4-b.dts"을 include하기 때문입니다. 
 
arch/arm64/boot/dts/broadcom/bcm2711-rpi-4-b.dts
#include "../../../../arm/boot/dts/bcm2711-rpi-4-b.dts"
 
(리서치 1)
검색 과정에서 사용한 명령어는 다음과 같습니다. 
 
rpi_5_15_src/linux/arch/arm/boot/dts$ find . -name "bcm271*.*" -type f | xargs grep bootargs
./bcm2711-rpi-cm4.dts:          bootargs = "coherent_pool=1M 8250.nr_uarts=1 snd_bcm2835.enable_compat_alsa=0 snd_bcm2835.enable_hdmi=1";
./bcm2711-rpi-4-b.dts:          bootargs = "coherent_pool=1M 8250.nr_uarts=1 snd_bcm2835.enable_compat_alsa=0 snd_bcm2835.enable_hdmi=1 ftrace=function ftrace_filter=*_probe*";
./bcm2711-rpi-400.dts:          bootargs = "coherent_pool=1M 8250.nr_uarts=1 snd_bcm2835.enable_compat_alsa=0 snd_bcm2835.enable_hdmi=1";
./bcm2710-rpi-3-b.dts:          bootargs = "coherent_pool=1M 8250.nr_uarts=1 snd_bcm2835.enable_compat_alsa=0 snd_bcm2835.enable_hdmi=1";
./bcm2710-rpi-zero-2-w.dts:             bootargs = "coherent_pool=1M 8250.nr_uarts=1 snd_bcm2835.enable_compat_alsa=0 snd_bcm2835.enable_hdmi=1";
./bcm2710-rpi-3-b-plus.dts:             bootargs = "coherent_pool=1M 8250.nr_uarts=1 snd_bcm2835.enable_compat_alsa=0 snd_bcm2835.enable_hdmi=1";
./bcm2711-rpi-cm4s.dts:         bootargs = "coherent_pool=1M 8250.nr_uarts=1 snd_bcm2835.enable_compat_alsa=0 snd_bcm2835.enable_hdmi=1";
 
각각 서로 다른 라즈베리 파이에 대해 다음 파일이 적용됩니다. 
 
modified: arch/arm/boot/dts/bcm2711-rpi-4-b.dts
modified: arch/arm/boot/dts/bcm2711-rpi-400.dts
modified: arch/arm/boot/dts/bcm2711-rpi-cm4s.dts
 
(리서치 2)
 
CONFIG_ARCH_BCM_2835가 bcm2711_defconfig에 enable돼 있습니다.
 
out64/.config
...
 293 # CONFIG_ARCH_APPLE is not set
 294 CONFIG_ARCH_BCM2835=y
 295 # CONFIG_ARCH_BCM4908 is not set
 296 # CONFIG_ARCH_BCM_IPROC is not set
 
ARCH_BCM_2835를 Makefile에서 검색해 bcm27* dtb 파일이 빌드에 포함됨을 확인했습니다. 
 
arch/arm64/boot/dts/broadcom/Makefile 
# SPDX-License-Identifier: GPL-2.0
dtb-$(CONFIG_ARCH_BCM2835) += bcm2711-rpi-400.dtb \
                  bcm2711-rpi-4-b.dtb \
                  bcm2837-rpi-3-a-plus.dtb \
                  bcm2837-rpi-3-b.dtb \
                  bcm2837-rpi-3-b-plus.dtb \
                  bcm2837-rpi-cm3-io3.dtb
dtb-$(CONFIG_ARCH_BCM2835) += bcm2710-rpi-zero-2.dtb
dtb-$(CONFIG_ARCH_BCM2835) += bcm2710-rpi-2-b.dtb
dtb-$(CONFIG_ARCH_BCM2835) += bcm2710-rpi-3-b.dtb
dtb-$(CONFIG_ARCH_BCM2835) += bcm2710-rpi-3-b-plus.dtb
dtb-$(CONFIG_ARCH_BCM2835) += bcm2711-rpi-4-b.dtb
dtb-$(CONFIG_ARCH_BCM2835) += bcm2711-rpi-400.dtb
dtb-$(CONFIG_ARCH_BCM2835) += bcm2710-rpi-cm3.dtb
dtb-$(CONFIG_ARCH_BCM2835) += bcm2711-rpi-cm4.dtb
 
subdir-y    += bcm4908
subdir-y    += northstar2
subdir-y    += stingray
 
# Enable fixups to support overlays on BCM2835 platforms
ifeq ($(CONFIG_ARCH_BCM2835),y)
    DTC_FLAGS += -@
endif
 
샘플 ftrace 메시지 
 
부트 커멘드 라인으로 "ftrace=function ftrace_filter=*initcall*"을 적용한 후 
받은 ftrace 메시지는 다음과 같습니다.
 
# tracer: function
#
# entries-in-buffer/entries-written: 6800/6800   #P:4
#
#                                _-----=> irqs-off
#                               / _----=> need-resched
#                              | / _---=> hardirq/softirq
#                              || / _--=> preempt-depth
#                              ||| /     delay
#           TASK-PID     CPU#  ||||   TIMESTAMP  FUNCTION
#              | |         |   ||||      |         |
          <idle>-0       [000] d..1     0.250968: arch_probe_nr_irqs <-early_irq_init
          <idle>-0       [000] ...1     0.252607: physflat_probe <-default_setup_apic_routing
          <idle>-0       [000] ...1     0.252608: flat_probe <-default_setup_apic_routing
            init-1       [000] ....     0.270282: watchdog_nmi_probe <-lockup_detector_init
            init-1       [000] ....     0.281332: bus_probe_device <-device_add
            init-1       [000] ....     0.281348: add_probe_files <-bus_register 
...
            init-1       [002] d..2     0.641288: sched_switch: prev_comm=swapper/0 prev_pid=1 prev_prio=120 prev_state=D ==> next_comm=swapper/2 next_pid=0 next_prio=120
          <idle>-0       [003] d..2     0.641309: sched_switch: prev_comm=swapper/3 prev_pid=0 prev_prio=120 prev_state=R ==> next_comm=kworker/u8:1 next_pid=76 next_prio=120
    kworker/u8:1-76      [003] d..2     0.641337: sched_switch: prev_comm=kworker/u8:1 prev_pid=76 prev_prio=120 prev_state=R+ ==> next_comm=irq/42-mmc1 next_pid=107 next_prio=49
     irq/42-mmc1-107     [003] d..2     0.641396: sched_switch: prev_comm=irq/42-mmc1 prev_pid=107 prev_prio=49 prev_state=S ==> next_comm=kworker/u8:1 next_pid=76 next_prio=120
    kworker/u8:1-76      [003] d..2     0.641407: sched_switch: prev_comm=kworker/u8:1 prev_pid=76 prev_prio=120 prev_state=S ==> next_comm=swapper/3 next_pid=0 next_prio=120
          <idle>-0       [002] d..2     0.641408: sched_switch: prev_comm=swapper/2 prev_pid=0 prev_prio=120 prev_state=R ==> next_comm=kworker/u8:1 next_pid=125 next_prio=120
          <idle>-0       [001] d..2     0.641414: sched_switch: prev_comm=swapper/1 prev_pid=0 prev_prio=120 prev_state=R ==> next_comm=kworker/1:0 next_pid=20 next_prio=120
     kworker/1:0-20      [001] d..2     0.641458: sched_switch: prev_comm=kworker/1:0 prev_pid=20 prev_prio=120 prev_state=D ==> next_comm=swapper/1 next_pid=0 next_prio=120
    kworker/u8:1-125     [002] d..2     0.641476: signal_generate: sig=17 errno=0 code=1 comm=kworker/u8:1 pid=76 grp=1 res=1
    kworker/u8:1-125     [002] d..2     0.641482: sched_switch: prev_comm=kworker/u8:1 prev_pid=125 prev_prio=120 prev_state=Z ==> next_comm=swapper/2 next_pid=0 next_prio=120
          <idle>-0       [003] d..2     0.641483: sched_switch: prev_comm=swapper/3 prev_pid=0 prev_prio=120 prev_state=R ==> next_comm=kworker/u8:1 next_pid=76 next_prio=120
    kworker/u8:1-76      [003] d..2     0.641492: sched_switch: prev_comm=kworker/u8:1 prev_pid=76 prev_prio=120 prev_state=I ==> next_comm=swapper/3 next_pid=0 next_prio=120
          <idle>-0       [002] d..2     0.641494: sched_switch: prev_comm=swapper/2 prev_pid=0 prev_prio=120 prev_state=R ==> next_comm=swapper/0 next_pid=1 next_prio=120
            init-1       [002] d..2     0.641502: sched_switch: prev_comm=swapper/0 prev_pid=1 prev_prio=120 prev_state=D ==> next_comm=swapper/2 next_pid=0 next_prio=120
          <idle>-0       [003] d..2     0.641504: sched_switch: prev_comm=swapper/3 prev_pid=0 prev_prio=120 prev_state=R ==> next_comm=kworker/u8:1 next_pid=76 next_prio=120
    kworker/u8:1-76      [003] d..2     0.641520: sched_switch: prev_comm=kworker/u8:1 prev_pid=76 prev_prio=120 prev_state=S ==> next_comm=swapper/3 next_pid=0 next_prio=120
          <idle>-0       [002] d..2     0.641521: sched_switch: prev_comm=swapper/2 prev_pid=0 prev_prio=120 prev_state=R ==> next_comm=kworker/u8:1 next_pid=126 next_prio=120
    kworker/u8:1-126     [002] d..2     0.641543: signal_generate: sig=17 errno=0 code=1 comm=kworker/u8:1 pid=76 grp=1 res=1
    kworker/u8:1-126     [002] d..2     0.641548: sched_switch: prev_comm=kworker/u8:1 prev_pid=126 prev_prio=120 prev_state=Z ==> next_comm=swapper/2 next_pid=0 next_prio=120
          <idle>-0       [003] d..2     0.641549: sched_switch: prev_comm=swapper/3 prev_pid=0 prev_prio=120 prev_state=R ==> next_comm=kworker/u8:1 next_pid=76 next_prio=120
    kworker/u8:1-76      [003] d..2     0.641555: sched_switch: prev_comm=kworker/u8:1 prev_pid=76 prev_prio=120 prev_state=I ==> next_comm=swapper/3 next_pid=0 next_prio=120
          <idle>-0       [002] d..2     0.641557: sched_switch: prev_comm=swapper/2 prev_pid=0 prev_prio=120 prev_state=R ==> next_comm=swapper/0 next_pid=1 next_prio=120
            init-1       [002] d..2     0.641565: sched_switch: prev_comm=swapper/0 prev_pid=1 prev_prio=120 prev_state=D ==> next_comm=swapper/2 next_pid=0 next_prio=120
          <idle>-0       [001] d..2     0.641586: sched_switch: prev_comm=swapper/1 prev_pid=0 prev_prio=120 prev_state=R ==> next_comm=kthreadd next_pid=2 next_prio=120
        kthreadd-2       [001] d..2     0.641612: sched_switch: prev_comm=kthreadd prev_pid=2 prev_prio=120 prev_state=S ==> next_comm=swapper/1 next_pid=0 next_prio=120
          <idle>-0       [002] d..2     0.641613: sched_switch: prev_comm=swapper/2 prev_pid=0 prev_prio=120 prev_state=R ==> next_comm=kthreadd next_pid=127 next_prio=120
 cryptomgr_probe-127     [002] d..2     0.641619: sched_switch: prev_comm=kthreadd prev_pid=127 prev_prio=120 prev_state=D ==> next_comm=swapper/2 next_pid=0 next_prio=120
          <idle>-0       [003] d..2     0.641620: sched_switch: prev_comm=swapper/3 prev_pid=0 prev_prio=120 prev_state=R ==> next_comm=swapper/0 next_pid=1 next_prio=120
            init-1       [003] d..2     0.641628: sched_switch: prev_comm=swapper/0 prev_pid=1 prev_prio=120 prev_state=D ==> next_comm=swapper/3 next_pid=0 next_prio=120
          <idle>-0       [002] d..2     0.641629: sched_switch: prev_comm=swapper/2 prev_pid=0 prev_prio=120 prev_state=R ==> next_comm=cryptomgr_probe next_pid=127 next_prio=120
 cryptomgr_probe-127     [002] ....     0.641630: cryptomgr_probe <-kthread
...
            init-1       [001] ....     0.642319: driver_deferred_probe_trigger <-deferred_probe_initcall
            init-1       [001] d..2     0.642321: sched_switch: prev_comm=swapper/0 prev_pid=1 prev_prio=120 prev_state=D ==> next_comm=kworker/1:4 next_pid=109 next_prio=120
     kworker/1:4-109     [001] ....     0.642321: deferred_probe_work_func <-process_one_work
     kworker/1:4-109     [001] d..2     0.642323: sched_switch: prev_comm=kworker/1:4 prev_pid=109 prev_prio=120 prev_state=R+ ==> next_comm=swapper/0 next_pid=1 next_prio=120
            init-1       [001] d..1     0.642327: console: [    0.640227] PM:   Magic number: 10:467:470
          <idle>-0       [002] d.h3     0.642461: console: [    0.640361] atkbd serio0: Unknown key released (translated set 2, code 0x7c on isa0060/serio0).
          <idle>-0       [002] d.h3     0.642464: console: [    0.640365] atkbd serio0: Use 'setkeycodes 7c <keycode>' to make it known.
            init-1       [001] d..1     0.642535: console: [    0.640435] ALSA device list:
            init-1       [001] d..1     0.642539: console: [    0.640440]   No soundcards found.
            init-1       [001] d..1     0.642558: console: [    0.640459] Warning: unable to open an initial console. Fallback to ttynull.
            init-1       [001] d..1     0.642563: console: [    0.640464] printk: console [ttynull0] enabled
            init-1       [001] d..2     0.642587: sched_switch: prev_comm=swapper/0 prev_pid=1 prev_prio=120 prev_state=D ==> next_comm=kworker/1:4 next_pid=109 next_prio=120
     kworker/1:4-109     [001] d..2     0.642590: sched_switch: prev_comm=kworker/1:4 prev_pid=109 prev_prio=120 prev_state=I ==> next_comm=swapper/1 next_pid=0 next_prio=120
          <idle>-0       [002] d..2     0.642630: sched_switch: prev_comm=swapper/2 prev_pid=0 prev_prio=120 prev_state=R ==> next_comm=irq/39-mmc0 next_pid=105 next_prio=49
          <idle>-0       [001] d..2     0.642670: sched_switch: prev_comm=swapper/1 prev_pid=0 prev_prio=120 prev_state=R ==> next_comm=kworker/1:0 next_pid=20 next_prio=120

+ Recent posts