<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>jgsun's blog</title>
    <description>blog address</description>
    <link>https://jgsun.github.io/</link>
    <atom:link href="https://jgsun.github.io/feed.xml" rel="self" type="application/rss+xml"/>
    <pubDate>Thu, 23 Feb 2023 08:03:09 +0000</pubDate>
    <lastBuildDate>Thu, 23 Feb 2023 08:03:09 +0000</lastBuildDate>
    <generator>Jekyll v3.9.3</generator>
    
      <item>
        <title>使用 ftrace 测量 irq disable latency</title>
        <description>&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#overview&quot; id=&quot;markdown-toc-overview&quot;&gt;Overview&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;overview&quot;&gt;Overview&lt;/h1&gt;
某客户使用内核模块实现了一个 1.33ms 的 hrtimer 定时器， 实际测试下来发现定时非常不准，有时候延迟多达 10 多 ms。

根据 hrtimer 的实现原理，怀疑是中断被异常 disable 过长时间所致。

这篇文章记录了调查过程：

首先给出了用于测试的 hrtimer 内核模块；

其次使用  irqsoff tracer 测试 irq disable 的 latency 和 call trace；

然后使用 Event Tracing 进一步验证了 irq disable 的 latency；

最后给出结论：内核 printk 且和 hrtimer 运行在同一个 core 是造成 hrtimer 不准的罪魁祸首。

</description>
        <pubDate>Sun, 19 Feb 2023 00:00:00 +0000</pubDate>
        <link>https://jgsun.github.io/2023/02/19/using-ftrace-to-measure-irq-disable-latency/</link>
        <guid isPermaLink="true">https://jgsun.github.io/2023/02/19/using-ftrace-to-measure-irq-disable-latency/</guid>
        
        <category>ftrace</category>
        
        <category>irqoff</category>
        
        <category>event_tracer</category>
        
        <category>hrtimer</category>
        
        
        <category>debug</category>
        
      </item>
    
      <item>
        <title>Linux arch_timer</title>
        <description>&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#overview&quot; id=&quot;markdown-toc-overview&quot;&gt;Overview&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;overview&quot;&gt;Overview&lt;/h2&gt;
Linux arch_timer 是内核最重要的基础设施之一，内核术语中，timer 带有前缀arch，可见其地位之高！内核之 arch_timer 提供系统运行的节拍，是其他定时任务的基础，相当于人之心脏！

</description>
        <pubDate>Fri, 07 Oct 2022 00:00:00 +0000</pubDate>
        <link>https://jgsun.github.io/2022/10/07/linux-timer/</link>
        <guid isPermaLink="true">https://jgsun.github.io/2022/10/07/linux-timer/</guid>
        
        <category>timer</category>
        
        <category>timer_init</category>
        
        <category>hrtimer</category>
        
        <category>sched_clock</category>
        
        <category>local_clock</category>
        
        
        <category>process</category>
        
      </item>
    
      <item>
        <title>WARNING: CPU: 7 PID: 939 at kernel/trace/trace.c:1635 update_max_tr_single</title>
        <description>&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#overview&quot; id=&quot;markdown-toc-overview&quot;&gt;Overview&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;overview&quot;&gt;Overview&lt;/h2&gt;
The customer reflected the hrtimer has big delay, taking the irqsoff tracer to check the irq disable latency.
&lt;blockquote&gt;
  About irqsoff tracer: &lt;a href=&quot;https://docs.kernel.org/trace/ftrace.html#irqsoff&quot;&gt;irqsoff Tracer — The Linux Kernel documentation&lt;/a&gt;
&lt;/blockquote&gt;

But when echoing irqsoff to current_tracer, the kernel has WARNING as below, at the same time, no call trace from the trace as well.

</description>
        <pubDate>Fri, 07 Oct 2022 00:00:00 +0000</pubDate>
        <link>https://jgsun.github.io/2022/10/07/irqsoff_tracer_issue/</link>
        <guid isPermaLink="true">https://jgsun.github.io/2022/10/07/irqsoff_tracer_issue/</guid>
        
        <category>irqsoff_tracer</category>
        
        <category>update_max_tr_single</category>
        
        <category>buffer_size_kb</category>
        
        
        <category>debug</category>
        
      </item>
    
      <item>
        <title>adb communication based on vsock</title>
        <description>&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#overview&quot; id=&quot;markdown-toc-overview&quot;&gt;Overview&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;overview&quot;&gt;Overview&lt;/h2&gt;
某项目 adb 通讯架构如下，两个系统 Linux 和 Android 运行在某 type-1 hypervisor 上，user 通过 adb 同两个系统通讯。
&lt;ul&gt;
  &lt;li&gt;和 Linux 系统的 adbd 连接简单点，直接和 Linux 系统的 adbd 通讯。&lt;/li&gt;
  &lt;li&gt;和 Android 系统 adb 连接要复杂一些：
    &lt;ul&gt;
      &lt;li&gt;adbd-relay 作为 vsock network 和 usb 之间的桥梁；&lt;/li&gt;
      &lt;li&gt;Android 系统 和 Linux 系统之间采用 vsock 通讯；&lt;/li&gt;
      &lt;li&gt;virtio-vsock backend device 与 vhost-vsock 和 mmio_help 内核模块通过 eventfd 和 irqfd 控制 vsock 报文的收发。&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

</description>
        <pubDate>Fri, 07 Oct 2022 00:00:00 +0000</pubDate>
        <link>https://jgsun.github.io/2022/10/07/adb_vsock/</link>
        <guid isPermaLink="true">https://jgsun.github.io/2022/10/07/adb_vsock/</guid>
        
        <category>timer</category>
        
        <category>timer_init</category>
        
        <category>hrtimer</category>
        
        <category>sched_clock</category>
        
        <category>local_clock</category>
        
        
        <category>I/O</category>
        
      </item>
    
      <item>
        <title>Measure irq_disable latency</title>
        <description>&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#overview&quot; id=&quot;markdown-toc-overview&quot;&gt;Overview&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;overview&quot;&gt;Overview&lt;/h2&gt;
The Linux on top of hypervisor has hrtimer overrun issue, 1.33ms hrtimer may has delay for more than 10ms.
The hypervisor supplier hope us check if there are overruns in native Linux.

&lt;blockquote&gt;
  测试用 patch：&lt;a href=&quot;https://github.com/jgsun/jgsun.github.io/blob/master/doc/patches/0001-meta-qti-base-hrtimer_test.ko_and-enable-irqsoff-tra.patch&quot;&gt;hrtimer_test module and enable irqsoff tracer&lt;/a&gt;
&lt;/blockquote&gt;

</description>
        <pubDate>Thu, 06 Oct 2022 00:00:00 +0000</pubDate>
        <link>https://jgsun.github.io/2022/10/06/measure-rqsoff-latency/</link>
        <guid isPermaLink="true">https://jgsun.github.io/2022/10/06/measure-rqsoff-latency/</guid>
        
        <category>hypervisor</category>
        
        <category>irqsoff</category>
        
        <category>printk</category>
        
        
        <category>irq</category>
        
      </item>
    
      <item>
        <title>Kernel panic flow</title>
        <description>&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#overview&quot; id=&quot;markdown-toc-overview&quot;&gt;Overview&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;overview&quot;&gt;Overview&lt;/h2&gt;
作为一个 Linux 平台软件工程师，时常面对 panic 的世界。每当早晨打开电脑，看到 teams 人影闪动：”Jianguo，刚刚发现系统 crash 了，请有空看下现场吗？” 这时候我的内心充满了 panic， 真似 “衣带渐宽终不悔，为伊消得人憔悴”， 还似 “天不老，情难绝。心似双丝网，中有千千结” 啊！是时候再次了解下内核 panic 的流程了！

</description>
        <pubDate>Thu, 06 Oct 2022 00:00:00 +0000</pubDate>
        <link>https://jgsun.github.io/2022/10/06/kernel-panic-flow/</link>
        <guid isPermaLink="true">https://jgsun.github.io/2022/10/06/kernel-panic-flow/</guid>
        
        <category>panic</category>
        
        <category>smp_send_stop</category>
        
        
        <category>debug</category>
        
      </item>
    
      <item>
        <title>SCSI UFS init view</title>
        <description>&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#overview&quot; id=&quot;markdown-toc-overview&quot;&gt;Overview&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;overview&quot;&gt;Overview&lt;/h2&gt;
本文简要介绍了 Linux SCSI UFS(Universal Flash Storage) 的初始化。契机是解一个 kernel boot 阶段 mount rootfs 失败的的问题： “VFS: Unable to mount root fs on unknown-block(8,6)”。所以，本文最后也介绍了这个问题的原因和解法。

</description>
        <pubDate>Thu, 06 Oct 2022 00:00:00 +0000</pubDate>
        <link>https://jgsun.github.io/2022/10/06/SCSI-UFS-init/</link>
        <guid isPermaLink="true">https://jgsun.github.io/2022/10/06/SCSI-UFS-init/</guid>
        
        <category>SCSI</category>
        
        <category>UFS</category>
        
        <category>sd_probe</category>
        
        
        <category>storage</category>
        
      </item>
    
      <item>
        <title>Linux soft lockup</title>
        <description>&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#overview&quot; id=&quot;markdown-toc-overview&quot;&gt;Overview&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;overview&quot;&gt;Overview&lt;/h2&gt;
The Linux kernel can act as a watchdog to detect both soft and hard lockups.

建议首先阅读内核文档来了解学习 Linux soft lockup，上面这句话就来自这篇文档，该文档是 soft lockup 的第一手资料。记得著名程序员左耳朵耗子有个访谈，说到学习看第一手资料的重要性！

我这篇文章纯属记录下学习的过程，供以后查询。
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.kernel.org/doc/html/latest/admin-guide/lockup-watchdogs.html&quot;&gt;Softlockup detector and hardlockup detector (aka nmi_watchdog) — The Linux Kernel documentation&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
        <pubDate>Thu, 06 Oct 2022 00:00:00 +0000</pubDate>
        <link>https://jgsun.github.io/2022/10/06/Linux-soft-lockup/</link>
        <guid isPermaLink="true">https://jgsun.github.io/2022/10/06/Linux-soft-lockup/</guid>
        
        <category>panic</category>
        
        <category>soft_lockup</category>
        
        
        <category>debug</category>
        
      </item>
    
      <item>
        <title>tmux</title>
        <description>&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#overview&quot; id=&quot;markdown-toc-overview&quot;&gt;Overview&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;overview&quot;&gt;Overview&lt;/h1&gt;
本文为 “工欲善其事，必先利其器！” 系列之 tmux。

地球人都知道，tmux 是终端神器，面对网上巨量的使用指南有点懵。

在 github 上面找到 tmux 项目的主页，发现其还在不停的开发迭代。
&lt;blockquote&gt;
  tmux is part of the OpenBSD base system, tmux currently sees a new release approximately every six months - the same schedule as OpenBSD, around May and October.
  &lt;ul&gt;
    &lt;li&gt;&lt;a href=&quot;https://github.com/tmux&quot;&gt;https://github.com/tmux&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;https://github.com/tmux/tmux/wiki&quot;&gt;https://github.com/tmux/tmux/wiki&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
&lt;/blockquote&gt;

&lt;img src=&quot;/images/posts/build/tmux/tmux_logo.png&quot; alt=&quot;image&quot; /&gt;

</description>
        <pubDate>Tue, 05 Apr 2022 00:00:00 +0000</pubDate>
        <link>https://jgsun.github.io/2022/04/05/tmux/</link>
        <guid isPermaLink="true">https://jgsun.github.io/2022/04/05/tmux/</guid>
        
        <category>tmux</category>
        
        <category>tabby</category>
        
        <category>.tmux.conf</category>
        
        
        <category>build</category>
        
      </item>
    
      <item>
        <title>EDK2 DebbugLib PrintLevel 配置实例</title>
        <description>&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#overview&quot; id=&quot;markdown-toc-overview&quot;&gt;Overview&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;overview&quot;&gt;Overview&lt;/h1&gt;
By default, three printlevel of DEBUG function in edk2\QcomModulePkg\Library\avb\VerifiedBoot.c get printed, they are EFI_D_WARN, DEBUG_INFO and EFI_D_ERROR, this picece of paper will tell us how to let EFI_D_VERBOSE get printed too at startup.
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  AVBVersion = GetAVBVersion ();
  DEBUG ((EFI_D_VERBOSE, &quot;[EFI_D_VERBOSE]:AVB version %d\n&quot;, AVBVersion));
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;img src=&quot;/images/posts/boot/whats_edk2.png&quot; alt=&quot;image&quot; /&gt;

&lt;blockquote&gt;
  about EDK2 https://www.tianocore.org/
&lt;/blockquote&gt;

</description>
        <pubDate>Sun, 27 Feb 2022 00:00:00 +0000</pubDate>
        <link>https://jgsun.github.io/2022/02/27/EDK2-print/</link>
        <guid isPermaLink="true">https://jgsun.github.io/2022/02/27/EDK2-print/</guid>
        
        <category>EDK2</category>
        
        <category>EFI_D_VERBOSE</category>
        
        <category>DEBUG_VERBOSE</category>
        
        <category>PcdDebugPrintErrorLevel</category>
        
        
        <category>boot</category>
        
      </item>
    
  </channel>
</rss>
