<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>linux kernel &#8211; richliu&#039;s blog</title>
	<atom:link href="https://blog.richliu.com/tag/linux-kernel/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.richliu.com</link>
	<description>Linux, 工作, 生活, 家人</description>
	<lastBuildDate>Thu, 04 Sep 2025 02:46:02 +0000</lastBuildDate>
	<language>zh-TW</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.6.2</generator>
	<item>
		<title>Build Linux kernel 5.x on CentOS 7</title>
		<link>https://blog.richliu.com/2021/11/15/4515/build-linux-kernel-5-x-on-centos-7/</link>
					<comments>https://blog.richliu.com/2021/11/15/4515/build-linux-kernel-5-x-on-centos-7/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Mon, 15 Nov 2021 04:32:57 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[grub]]></category>
		<category><![CDATA[linux kernel]]></category>
		<guid isPermaLink="false">https://blog.richliu.com/?p=4515</guid>

					<description><![CDATA[<p>This article&#8217;s procedure was tested in Ampere Alt [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2021/11/15/4515/build-linux-kernel-5-x-on-centos-7/">Build Linux kernel 5.x on CentOS 7</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>This article&#8217;s procedure was tested in Ampere Altra CPU platform, but suppose that x86 system also can use this procedure. <br /><br />CentOS 7&#8217;s gcc is too old to compile Linux kernel 5.x, and it can use another package named &#8220;software collections(SCL)&#8221; to install newer gcc to build Linux kernel. </p>



<span id="more-4515"></span>



<h2 class="wp-block-heading">Install CentOS 7 on Ampere Altra CPU</h2>



<p>Earlier CentOS 7 default OS is too old to support ARM64 CPU and SSIF driver, <br />if you have problem to install on Ampre Altra CPU, it needs to block SSIF and change PCI parameter during booting. Add parameters below on Linux kernel booting parameter when install CentOS7. </p>



<pre class="wp-block-code"><code>modprobe.blacklist=ipmi_si pci=nomsi</code></pre>



<h2 class="wp-block-heading">Prepare Build Environment</h2>



<p>Before download and build Linux kernel 5.x, it needs to run those command to prepare build environment </p>



<pre class="wp-block-code"><code>yum install -y centos-release-scl-rh
yum install -y devtoolset-9*
yum groupinstall -y "Development Tools"
yum install -y ncurses-devel
yum install -y hmaccalc zlib-devel binutils-devel elfutils-libelf-devel
yum install -y python3</code></pre>



<h2 class="wp-block-heading">Download Linux kernel</h2>



<p>Ampere LTS kernel can be download from github, here is the command to checkout Ampere LTS kernel and switch version to 5.10</p>



<pre class="wp-block-code"><code>cd /root
git clone https://github.com/AmpereComputing/ampere-lts-kernel.git
cd /ampere-lte-kernel
git checkout -b origin/linux-5.10.y 5.10.y
</code></pre>



<p>On later Linux kernel, it needs to use git switch to switch to 5.10.y</p>



<pre class="wp-block-preformatted">git switch 5.10.y</pre>



<h2 class="wp-block-heading">Build Linux kernel</h2>



<p>It&#8217;s simple to build Linux kernel</p>



<pre class="wp-block-code"><code>scl enable devtoolset-9 bash
cd /root/ampere-lte-kernel
cp arch/arm64/configs/altra_5.10_defconfig .config
make olddefconfig
make -j `nproc` &amp;&amp; make -j `nproc` modules  &amp;&amp; make modules_install &amp;&amp; make install</code></pre>



<h2 class="wp-block-heading">GRUB Setting</h2>



<p>Suggest to change default GRUB timeout to choice right kernel to boot. </p>



<pre class="wp-block-code"><code>sed -i 's/GRUB_TIMEOUT=5/GRUB_TIMEOUT=30/g' /etc/default/grub
grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg</code></pre>



<p>OK, right now it can reboot your system to have try. </p>



<p>Ref: <br />Good mirror site for CentOS7 package.  <br />https://mirrors.bfsu.edu.cn/centos-altarch/7.9.2009/os/aarch64/<br /><br /></p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2021/11/15/4515/build-linux-kernel-5-x-on-centos-7/">Build Linux kernel 5.x on CentOS 7</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.richliu.com/2021/11/15/4515/build-linux-kernel-5-x-on-centos-7/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Ubuntu Build Original Linux Kernel</title>
		<link>https://blog.richliu.com/2018/06/11/2286/ubuntu-build-original-linux-kernel/</link>
					<comments>https://blog.richliu.com/2018/06/11/2286/ubuntu-build-original-linux-kernel/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Mon, 11 Jun 2018 06:55:02 +0000</pubDate>
				<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[ARM]]></category>
		<category><![CDATA[linux kernel]]></category>
		<guid isPermaLink="false">https://blog.richliu.com/?p=2286</guid>

					<description><![CDATA[<p>最好的方式應該是這一篇文章 不要再用什麼 fakeroot 去編了, 失敗率超高, 尤其是在 ARM 平台 h [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2018/06/11/2286/ubuntu-build-original-linux-kernel/">Ubuntu Build Original Linux Kernel</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>最好的方式應該是這一篇文章</p>



<p>不要再用什麼 fakeroot 去編了, 失敗率超高, 尤其是在 ARM 平台</p>



<p><a href="https://wiki.ubuntu.com/KernelTeam/GitKernelBuild" target="_blank" rel="noopener">https://wiki.ubuntu.com/KernelTeam/GitKernelBuild</a></p>



<span id="more-2286"></span>



<p>Install necessary ubuntu packages. </p>



<pre class="wp-block-preformatted">sudo apt-get install git build-essential kernel-package fakeroot libncurses5-dev libssl-dev ccache bison flex libelf-dev dwarves</pre>



<p>24.04</p>



<pre class="wp-block-code"><code>sudo apt-get install git build-essential fakeroot libncurses5-dev libssl-dev ccache bison flex libelf-dev dwarves libdw-dev</code></pre>



<p>來個範例, 在 ARM64 上編了 4.10~4.17 其中幾個版本, 每次都成功</p>



<pre class="wp-block-preformatted">git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
cd linux
git checkout -b 4.17 v4.17
cp /boot/config-`uname -r` .config
scripts/config --disable SYSTEM_REVOCATION_KEYS
make olddefconfig
make -j `getconf _NPROCESSORS_ONLN` deb-pkg LOCALVERSION=-custom
</pre>



<p>不知道為什麼，Ubuntu 22.04 Linux kernel 5.19 上這個方法又不行了，可能是因為取用 vanilla Linux kernel git source  的關係</p>



<p>copy /boot/config-5.19 到 Linux 時要注意要移掉認證的 .pem ，要不然會編不過，命令如下，記得還是要 make olddefconfig 讓新設定生效[<a href="https://blog.csdn.net/m0_47696151/article/details/121574718" target="_blank" rel="noopener">ref</a>]</p>



<pre class="wp-block-preformatted">scripts/config --disable SYSTEM_REVOCATION_KEYS
scripts/config --disable SYSTEM_TRUSTED_KEYS</pre>



<p>接下來下面這一段就可以編了，在我的系統上沒問題</p>



<pre class="wp-block-preformatted">fakeroot debian/rules clean
cp /boot/config-`uname -r` .config
scripts/config --disable SYSTEM_REVOCATION_KEYS
scripts/config --disable SYSTEM_TRUSTED_KEYS
make olddefconfig
make clean
#remove the non git files
git clean -f
rm vmlinux-gdb.py
#make sure there is no linux*.tar too
rm ../linux*.gz

# cherry pick RC6 hack (or necessary command), if don't have it can by pass it.
git cherry-pick 0c6b6fa52c6ad54332eed64acb6aebc59f75e0b2

#
make -j `getconf _NPROCESSORS_ONLN` deb-pkg LOCALVERSION=-custom
cd ..

</pre>



<p>不過這是包成 package ，如果只是單純的要改參數開發時開機用，那就直接 make install 就好了，但是抄 ubutnu 的 kernel configure file 檔案會太大，應該是包了 debug info，這時要 strip modules ，以免 ramdisk 太大</p>



<pre class="wp-block-preformatted">make -j `nproc` &amp;&amp; make INSTALL_MOD_STRIP=1 modules_install &amp;&amp; make install </pre>



<p>ref. <a href="https://askubuntu.com/questions/1190169/ubuntu-build-kernel-from-git-with-a-source-change-how-to-ignore-unrepresentabl" target="_blank" rel="noreferrer noopener">ubuntu build kernel from git with a source change, how to ignore &#8216;unrepresentable changes to source&#8217; error</a><br /><a href="https://unix.stackexchange.com/questions/30345/why-is-my-initial-ramdisk-so-big" target="_blank" rel="noopener">Why is my initial ramdisk so big?</a><br /></p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2018/06/11/2286/ubuntu-build-original-linux-kernel/">Ubuntu Build Original Linux Kernel</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.richliu.com/2018/06/11/2286/ubuntu-build-original-linux-kernel/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Ubuntu 16.04 VMWARE Guest Dual Monitor 問題</title>
		<link>https://blog.richliu.com/2016/11/30/2047/ubuntu-16-04-vmware-guest-dual-monitor-%e5%95%8f%e9%a1%8c/</link>
					<comments>https://blog.richliu.com/2016/11/30/2047/ubuntu-16-04-vmware-guest-dual-monitor-%e5%95%8f%e9%a1%8c/#comments</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Wed, 30 Nov 2016 14:10:33 +0000</pubDate>
				<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[linux kernel]]></category>
		<category><![CDATA[vmware]]></category>
		<guid isPermaLink="false">https://blog.richliu.com/?p=2047</guid>

					<description><![CDATA[<p>Ubuntu 16.04 當 VMWARE Guest OS 時, 如果 Host 有兩個螢幕, Guest  [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2016/11/30/2047/ubuntu-16-04-vmware-guest-dual-monitor-%e5%95%8f%e9%a1%8c/">Ubuntu 16.04 VMWARE Guest Dual Monitor 問題</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Ubuntu 16.04 當 VMWARE Guest OS 時, 如果 Host 有兩個螢幕, Guest 是沒有辦法切二個螢幕的. </p>
<p>看起來是 Ubuntu 16.04 用的 4.4.0 Kernel 有問題, 個人測試是升級到 4.8.11 就可以了. </p>
<p>到 <a href="http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.8.11/" target="_blank" rel="noopener">4.8.11 Mainline Kernel </a> 下載你要的 Kernel 版本<br />
我是用這三個</p>
<pre lang="text">
linux-headers-4.8.11-040811_4.8.11-040811.201611260431_all.deb
linux-headers-4.8.11-040811-generic_4.8.11-040811.201611260431_amd64.deb
linux-image-4.8.11-040811-generic_4.8.11-040811.201611260431_amd64.deb
</pre>
<p>安裝 Kernel </p>
<pre lang="bash">
$ sudo dpkg -i *.deb
</pre>
<p>安裝完畢之後 reboot </p>
<p>如果第二個螢幕有滑鼠對不齊的問題(mouse alignment problem), 要到 VMware Preferences 內的 Input , Optimize mouse for games 選 Always .<br />
這時候要切出 VMware 時就要用 Ctrl + Alt 鍵.<br />
<a href="https://blog.richliu.com/wp-content/uploads/2016/11/vmware-ubuntu-mouse.jpg"><img fetchpriority="high" decoding="async" src="https://blog.richliu.com/wp-content/uploads/2016/11/vmware-ubuntu-mouse-300x249.jpg" alt="vmware-ubuntu-mouse" width="300" height="249" class="aligncenter size-medium wp-image-2051" srcset="https://blog.richliu.com/wp-content/uploads/2016/11/vmware-ubuntu-mouse-300x249.jpg 300w, https://blog.richliu.com/wp-content/uploads/2016/11/vmware-ubuntu-mouse-768x639.jpg 768w, https://blog.richliu.com/wp-content/uploads/2016/11/vmware-ubuntu-mouse.jpg 866w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<p>Ref:<br />
<a href="https://github.com/vmware/open-vm-tools/issues/74" target="_blank" rel="noopener">Linux &#8211; Cycle Multiple Monitors doesn&#8217;t complete correctly. #74</a><br />
<a href="https://ubuntuforums.org/showthread.php?t=1427472" target="_blank" rel="noopener">Mouse Pointer Alignment Problem with Ubuntu on VMWare</a></p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2016/11/30/2047/ubuntu-16-04-vmware-guest-dual-monitor-%e5%95%8f%e9%a1%8c/">Ubuntu 16.04 VMWARE Guest Dual Monitor 問題</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.richliu.com/2016/11/30/2047/ubuntu-16-04-vmware-guest-dual-monitor-%e5%95%8f%e9%a1%8c/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>[跟風] 程式設計師, 你調試過最難的 BUG</title>
		<link>https://blog.richliu.com/2015/01/07/1730/%e8%b7%9f%e9%a2%a8-%e7%a8%8b%e5%bc%8f%e8%a8%ad%e8%a8%88%e5%b8%ab-%e4%bd%a0%e8%aa%bf%e8%a9%a6%e9%81%8e%e6%9c%80%e9%9b%a3%e7%9a%84-bug/</link>
					<comments>https://blog.richliu.com/2015/01/07/1730/%e8%b7%9f%e9%a2%a8-%e7%a8%8b%e5%bc%8f%e8%a8%ad%e8%a8%88%e5%b8%ab-%e4%bd%a0%e8%aa%bf%e8%a9%a6%e9%81%8e%e6%9c%80%e9%9b%a3%e7%9a%84-bug/#comments</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Tue, 06 Jan 2015 16:22:32 +0000</pubDate>
				<category><![CDATA[ARM]]></category>
		<category><![CDATA[Embedded]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[IC Design]]></category>
		<category><![CDATA[工作]]></category>
		<category><![CDATA[arm]]></category>
		<category><![CDATA[Bug]]></category>
		<category><![CDATA[Cache]]></category>
		<category><![CDATA[Hardest Bug]]></category>
		<category><![CDATA[linux kernel]]></category>
		<guid isPermaLink="false">http://blog.richliu.com/?p=1730</guid>

					<description><![CDATA[<p>看到一篇文章 簡體中文翻譯: 程序员，你调试过的最难的 Bug 是？ 原文: What&#8217;s the [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2015/01/07/1730/%e8%b7%9f%e9%a2%a8-%e7%a8%8b%e5%bc%8f%e8%a8%ad%e8%a8%88%e5%b8%ab-%e4%bd%a0%e8%aa%bf%e8%a9%a6%e9%81%8e%e6%9c%80%e9%9b%a3%e7%9a%84-bug/">[跟風] 程式設計師, 你調試過最難的 BUG</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>看到一篇文章<br />
簡體中文翻譯: <a href="http://blog.jobbole.com/50995/" target="_blank" rel="noopener">程序员，你调试过的最难的 Bug 是？</a><br />
原文: <a href="http://www.quora.com/Whats-the-hardest-bug-youve-debugged" target="_blank" rel="noopener">What&#8217;s the hardest bug you&#8217;ve debugged?</a></p>
<p>看原文比翻譯好一點, 從原文大概只可能猜出, 改過 timer 之後, 可能影響到 interrupt 的速度.<br />
但是從最後的描述猜也可能是動到 clock tree 去影響 timer 進而影響到其他的行為.<br />
有碰到這種 BUG 的第一個一定先猜 timing , 純軟體的反而不會這樣想, 所以他覺得最難的 BUG<br />
我們看起來就還好.</p>
<p>這個描述讓我也想寫一下, 我碰過最難的 BUG.<br />
<span id="more-1730"></span></p>
<p>那是新的 SoC 剛回來的時候, 各個 block 都要驗, 我是負責帶領系統驗証部門的,<br />
所以一開始就有一大堆 BUG, 其中有一個 BUG 就是資料存取有問題, 而且要很久才會出現一次的.</p>
<p><strong>最難的 BUG 要件之一就是很久才會出現一次, 這表示會搞很久. </strong></p>
<p>因為當時我是負責 SATA 部份的驗証, 所以這個工作自然就是我去追了.<br />
看倌呀, SOC 就是統統要自己來, 從 hardware CPU/SATA/CLOCK 到 kernel 層都可能有問題.</p>
<p>第一件事情就是, 想辦法找出可以複製的方法. 我們知道資料存取有問題<br />
所以我就寫了一個 sh script 從 A Disk Copy 到 B Disk 再做比對. 然後一直 COPY 下去, 直到找到為止.</p>
<p>這個 sh script 大概可以在 200 次大檔案 COPY, 找到一次錯誤的結果.<br />
大概要花二個小時以上, 一開始的時候, 這個 script 執行下去, 其實並沒有辦法抓出問題.</p>
<p>流程大概是這樣<br />
# dd if=/dev/zero of=test bs=1M count=1024<br />
# md5sum test<br />
這樣就會有一次寫入, 一次讀出, 這樣就可以比對 md5.</p>
<p>有沒有看出什麼問題?</p>
<p>其實這個錯誤可能很少人會意會到, 就是測試 pattern 不能為零, 假設今天 block 寫錯了, 而資料是零, 再怎麼寫入讀出, 資料還是正確的. 所以後來我都改用 AV file 做 test pattern, 工程師的惡趣味就在這邊了.<br />
&#8220;我今天有 update 新的 test pattern 哦&#8230;. &#8221;<br />
大家就知道發生什麼事情了.</p>
<p>修改完 script 之後,  md5 checksum 的結果的確是不一樣. 這時就要猜測是什麼地方在作怪.<br />
首先一定先關心 SATA Hardware 是不是有問題, 所以就拿 PCIe SATA 還有 USB 來驗証比對.<br />
同時間, 看 Linux kernel 追 SATA 這一層在搞什麼飛機.</p>
<p>其實相對於 USB Protocol , AHCI SATA Interface 是很簡單的 interface, 很快的就排除掉這個犯人了. 而且 PCIe SATA 和 USB 的結果顯示也是會複製錯誤.</p>
<p>這下子人就可能是 CPU 和 Kernel 殺的. 還有記憶體.<br />
SoC 守則, 只要資料有錯, 八成是記憶體殺的. 各位可能會問, 那為什麼要先測 SATA? 因為記憶體己經先掃過一輪沒問題了, 所以當然先丟 SATA. 不過這邊的先掃過一輪沒有問題是不是真的沒有問題&#8230;.<br />
這個原因是這樣, 所謂的記憶體沒有問題是用 NON-OS Code 下去掃的, 可能會有切 MMU Mode 和 NonMMU Mode. 總之是這樣測的.</p>
<p>然後我就 mount ramdisk 開 memtest 狂測一天. 果然出問題了. 哼哼, 是你吧.<br />
不過接下來問題才大條. RAM 出問題很麻煩的. 要怎麼定位到到底是什麼出問題呢?</p>
<p>專業的讀者應該就會猜, 那就降速跑.<br />
正解, RAM 出問題就要先降速跑. 所以 DRAM 就跑在 200Mhz (DDR2-800 是 400Mhz, 最低應該是 DDR-400 跑在 200Mhz). 反正都降速, 所以 CPU 也從 600Mhz 降到 400Mhz 跑.<br />
當然老天一定不會這麼容易讓我們破關的, 所以資料錯誤的 BUG 還是可以重現.<br />
同時間 NON-OS 的測試結果仍然是顯示沒有問題.</p>
<p>然後就是猜了. 因為如果 NON-OS 的 memory test 是正確的, 而 Linux 是錯誤的, 那可能問題是出在其他的部份. 這麼複雜的系統一定就是要猜.</p>
<p>猜也是一門學問, 接下來就是先關 L1/L2 Cache .<br />
各位, 為什麼 CACHE 要最後再測, 因為 CACHE 關掉整個系統會變更慢. 所以預期二小時會發生的, 可能測試就要拉到二天, 我還有碰過 Cache 關掉就複製不出來的 BUG.</p>
<p>Disable Cache 有二項, 因為 L2 Enable 一定要 L1 也 Enable.<br />
Disable L1/L2<br />
Disable L2<br />
除了 Disable Cache 以外, 和 CPU 相關的還有 SMP (因為 SoC 有二顆 CPU), 還有 Cache Driver 新舊版的問題.</p>
<p>這幾個測試項測下來, 果然 Disable Cache 就不會出問題了, 而且是 Disable L2 Cache.</p>
<p>走到這邊大概己經測試了三個星期. 快搞死了, SoC 慢就算了, 掉資料是不允許的啊啊啊.<br />
對一個 engineer 來說這根本是不可接受的事.<br />
而且同時間還有一堆 BUG 待解待查. SoC 剛回來天天都是屁股在燒.</p>
<p>為了保險起見. 必需要找到資料錯誤的 Pattern .<br />
所以寫了一個可以 binary compare 並且顯示出那邊不一樣的小程式.<br />
翻了一下當年的痕跡, 原來除了 binary compare, 還有程式內加上 invalidate cache 的相關程式.<br />
我還記得為了這件事翻了整層的 Linux kernel cache 和 memory management 機制.</p>
<p>最後確認到是 cache 的問題是, 使用 binary compare 找出 32bytes, 相當於一條 L2 cache line size.<br />
而且可以重覆這個測試.</p>
<p>到這邊幾乎可以確定是 L2 cache Line 的問題, 而且是硬體的問題, 當然 L2 還有一些測試項目.<br />
像是調整 Cache Latency 之類的. 這個應該都做了, 不過做了以後應該是更久才會再出現一次.</p>
<p>所以我就將我知道的東西整理一下, 寫了一封信問 ARM . (還好當時公司有付錢買 ARM 的服務).</p>
<p>ARM 的回答也很乾脆,<br />
關掉那個 L2 Cache I Prefetch 的功能就可以了. 在 PL310 內, 這個功能只是 1 bit 的改變.<br />
(I Prefetch 是 Instruction Prefetch command , 快要執行到指令時, 先去記憶體先抓回來放在 Cache 內)</p>
<p><strong>然後就一切正常了&#8230;..</strong></p>
<p><strong>然後就一切正常了&#8230;..</strong></p>
<p><strong>然後就一切正常了&#8230;..</strong></p>
<p>1 個 bit, 快要一個月的青春啊~~ 所以這個 BUG 記到現在還在記.</p>
<p>這應該算難嗎? 不知道的 BUG 都很難, 知道之後就不難了.</p>
<p>==</p>
<p>後記1: NON-OS 為什麼沒有測出來, 其實 Cache 那邊的參數也是從 NON-OS 來的, 為什麼 NON-OS 沒有問題呢?<br />
猜想是因為 NON-OS 的 Code Size 很小, 所以 Code 都在 L1 Cache 內, 並不會動用到 I prefetch 的功能. 所以自然也驗不出來了.</p>
<p>後記2: 我覺得很多細節我都忘了, 所以這應該只是大致的情節. 雖然寫起來很輕鬆, 但是當時很慘烈呀~~~~</p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2015/01/07/1730/%e8%b7%9f%e9%a2%a8-%e7%a8%8b%e5%bc%8f%e8%a8%ad%e8%a8%88%e5%b8%ab-%e4%bd%a0%e8%aa%bf%e8%a9%a6%e9%81%8e%e6%9c%80%e9%9b%a3%e7%9a%84-bug/">[跟風] 程式設計師, 你調試過最難的 BUG</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.richliu.com/2015/01/07/1730/%e8%b7%9f%e9%a2%a8-%e7%a8%8b%e5%bc%8f%e8%a8%ad%e8%a8%88%e5%b8%ab-%e4%bd%a0%e8%aa%bf%e8%a9%a6%e9%81%8e%e6%9c%80%e9%9b%a3%e7%9a%84-bug/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>kernel rootwait option</title>
		<link>https://blog.richliu.com/2012/11/09/1347/kermel-rootwait-option/</link>
					<comments>https://blog.richliu.com/2012/11/09/1347/kermel-rootwait-option/#comments</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Thu, 08 Nov 2012 18:40:30 +0000</pubDate>
				<category><![CDATA[Embedded]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[linux kernel]]></category>
		<category><![CDATA[mmc]]></category>
		<category><![CDATA[rootwait]]></category>
		<category><![CDATA[usb]]></category>
		<guid isPermaLink="false">http://blog.richliu.com/?p=1347</guid>

					<description><![CDATA[<p>之前都不知道 Linux kernel 有 rootwait option, 比 rootdelay=? 好用 [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2012/11/09/1347/kermel-rootwait-option/">kernel rootwait option</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>之前都不知道 Linux kernel 有 rootwait option, 比 rootdelay=? 好用多了. </p>
<p>尤其是用 usb or mmc 之類的 device 當作 root, 常用於 embedded system .<br />
(其實我也少用, 都混 IC vendor , rootwait 這種東西就交給系統廠去處理). </p>
<p>Example Command<br />
[TEXT]<br />
CONFIG_CMDLINE=&#8221;root=/dev/mmcblk0p1 rw init=/sbin/init mem=256M console=ttyS0,38400 rootwait&#8221;<br />
[/TEXT]</p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2012/11/09/1347/kermel-rootwait-option/">kernel rootwait option</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.richliu.com/2012/11/09/1347/kermel-rootwait-option/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>Linux Kernel 不支援 Floating Pointer</title>
		<link>https://blog.richliu.com/2010/04/08/909/linux-kernel-%e4%b8%8d%e6%94%af%e6%8f%b4-floating-pointer/</link>
					<comments>https://blog.richliu.com/2010/04/08/909/linux-kernel-%e4%b8%8d%e6%94%af%e6%8f%b4-floating-pointer/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Thu, 08 Apr 2010 10:35:34 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[floating pointer]]></category>
		<category><![CDATA[linux kernel]]></category>
		<guid isPermaLink="false">http://blog.richliu.com/?p=909</guid>

					<description><![CDATA[<p>http://lkml.indiana.edu/hypermail/linux/kernel/0405.3/1 [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2010/04/08/909/linux-kernel-%e4%b8%8d%e6%94%af%e6%8f%b4-floating-pointer/">Linux Kernel 不支援 Floating Pointer</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><a href="http://lkml.indiana.edu/hypermail/linux/kernel/0405.3/1608.html" target="_blank" rel="noopener">http://lkml.indiana.edu/hypermail/linux/kernel/0405.3/1608.html</a></p>
<blockquote><p>Floating point is forbidden in kernel code since the floating point<br />
registers (and other floating point context) is not saved/restored<br />
during system calls, for efficiency. I&#8217;m speculating here, but it<br />
might be possible to manually save the floating point context while<br />
doing some floating point operations. The problem arises if this code<br />
is interrupted midway. Using a preemptive 2.6 kernel would easily<br />
break here.</p></blockquote>
<p>如果是這樣, 那就 Mask IRQ, 做完再 unmask 掉.  不知道可不可行.</p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2010/04/08/909/linux-kernel-%e4%b8%8d%e6%94%af%e6%8f%b4-floating-pointer/">Linux Kernel 不支援 Floating Pointer</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.richliu.com/2010/04/08/909/linux-kernel-%e4%b8%8d%e6%94%af%e6%8f%b4-floating-pointer/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Linux kernel printk 參數.</title>
		<link>https://blog.richliu.com/2010/03/09/874/linux-kernel-printk-%e5%8f%83%e6%95%b8/</link>
					<comments>https://blog.richliu.com/2010/03/09/874/linux-kernel-printk-%e5%8f%83%e6%95%b8/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Tue, 09 Mar 2010 05:56:14 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[linux kernel]]></category>
		<category><![CDATA[printk]]></category>
		<guid isPermaLink="false">http://blog.richliu.com/?p=874</guid>

					<description><![CDATA[<p>Kernek printk 參數預設如下 If variable is of Type, use printk [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2010/03/09/874/linux-kernel-printk-%e5%8f%83%e6%95%b8/">Linux kernel printk 參數.</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Kernek printk 參數預設如下</p>
<p><span id="more-874"></span></p>
<blockquote><p>If variable is of Type,         use printk format specifier:<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
                int                     %d or %x<br />
                unsigned int            %u or %x<br />
                long                    %ld or %lx<br />
                unsigned long           %lu or %lx<br />
                long long               %lld or %llx<br />
                unsigned long long      %llu or %llx<br />
                size_t                  %zu or %zx<br />
                ssize_t                 %zd or %zx<br />
Raw pointer value SHOULD be printed with %p.</p>
<p>u64 SHOULD be printed with %llu/%llx, (unsigned long long):<br />
        printk(&#8220;%llu&#8221;, (unsigned long long)u64_var);<br />
s64 SHOULD be printed with %lld/%llx, (long long):<br />
        printk(&#8220;%lld&#8221;, (long long)s64_var);</p></blockquote>
<p>追了一下 kernel </p>
<p>難道就這樣了嗎?<br />
2.26.29 發現有加一個新參數<br />
%pM : 印出 MAC Address<br />
仔細看了一下, printk 用 %p 做為 extension </p>
<blockquote><p>&#8216;F&#8217; For symbolic function descriptor pointers with offset<br />
&#8216;f&#8217; For simple symbolic function names without offset<br />
&#8216;S&#8217; For symbolic direct pointers with offset<br />
&#8216;s&#8217; For symbolic direct pointers without offset<br />
&#8216;R&#8217; For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]<br />
&#8216;r&#8217; For raw struct resource, e.g., [mem 0x0-0x1f flags 0x201]<br />
&#8216;M&#8217; For a 6-byte MAC address, it prints the address in the<br />
    usual colon-separated hex notation<br />
&#8216;m&#8217; For a 6-byte MAC address, it prints the hex address without colons<br />
&#8216;MF&#8217; For a 6-byte MAC FDDI address, it prints the address<br />
    with a dash-separated hex notation<br />
&#8216;I&#8217; [46] for IPv4/IPv6 addresses printed in the usual way<br />
    IPv4 uses dot-separated decimal without leading 0&#8217;s (1.2.3.4)<br />
    IPv6 uses colon separated network-order 16 bit hex with leading 0&#8217;s<br />
&#8216;i&#8217; [46] for &#8216;raw&#8217; IPv4/IPv6 addresses<br />
    IPv6 omits the colons (01020304&#8230;0f)<br />
    IPv4 uses dot-separated decimal with leading 0&#8217;s (010.123.045.006)<br />
&#8216;[Ii]4[hnbl]&#8217; IPv4 addresses in host, network, big or little endian order<br />
&#8216;I6c&#8217; for IPv6 addresses printed as specified by<br />
    http://tools.ietf.org/html/draft-ietf-6man-text-addr-representation-00<br />
&#8216;U&#8217; For a 16 byte UUID/GUID, it prints the UUID/GUID in the form<br />
    &#8220;xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx&#8221;<br />
    Options for %pU are:<br />
      b big endian lower case hex (default)<br />
      B big endian UPPER case hex<br />
      l little endian lower case hex<br />
      L little endian UPPER case hex<br />
        big endian output byte order is:<br />
          [0][1][2][3]-[4][5]-[6][7]-[8][9]-[10][11][12][13][14][15]<br />
        little endian output byte order is:<br />
          [3][2][1][0]-[5][4]-[7][6]-[8][9]-[10][11][12][13][14][15]<br />
Note: The difference between &#8216;S&#8217; and &#8216;F&#8217; is that on ia64 and ppc64<br />
function pointers are really function descriptors, which contain a<br />
pointer to the real address.
</p></blockquote>
<p>還不錯用. 以後可以直接用了&#8230;..</p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2010/03/09/874/linux-kernel-printk-%e5%8f%83%e6%95%b8/">Linux kernel printk 參數.</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.richliu.com/2010/03/09/874/linux-kernel-printk-%e5%8f%83%e6%95%b8/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Debugfs</title>
		<link>https://blog.richliu.com/2010/01/20/843/debugfs/</link>
					<comments>https://blog.richliu.com/2010/01/20/843/debugfs/#comments</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Wed, 20 Jan 2010 10:22:27 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[debugfs]]></category>
		<category><![CDATA[kernel]]></category>
		<category><![CDATA[linux kernel]]></category>
		<guid isPermaLink="false">http://blog.richliu.com/?p=843</guid>

					<description><![CDATA[<p>以前都習慣用 printk 和 /proc 做輸入輸出的動作, 不過 debugfs 看起來是 User sp [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2010/01/20/843/debugfs/">Debugfs</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>以前都習慣用 printk 和 /proc 做輸入輸出的動作, 不過 debugfs 看起來是 User space 和 kernel space 交流更好的選擇.<br />
<span id="more-843"></span></p>
<p>先確認 Enable Kernel debugfs Function</p>
<blockquote><p>Kernel hacking  &#8212;&gt;<br />
-*- Debug Filesystem</p></blockquote>
<p>先來個簡單的範例,<br />
在你要 debug 的 modules 內, 加入 debugfs 的 include file</p>
<blockquote><p>#include &lt;linux/debugfs.h&gt;</p></blockquote>
<p>要將想要輸出的變數, 假設叫 pcie0_linked 輸出到 debugfs 上, 在 initial code 的地方加上<br />
debugfs_create_u32(&#8220;pcie0_linked&#8221;, 0644, NULL, &amp;pcie0_linked);</p>
<p>接下來就可以重開機了 load 新 kernel 了,</p>
<p>mount debugfs</p>
<blockquote><p>$ mount -t debugfs debug /debugfs</p></blockquote>
<p>或是寫在 /etc/fstab</p>
<blockquote><p>debugfs    /debugfs    debugfs debug</p></blockquote>
<p>這時就可以 ls /debugfs/ , 就會出現 pcie0_linked 的檔案.</p>
<blockquote><p>$ cat /debugfs/pcie0_linked<br />
1<br />
$ echo 0 &gt; /debugfs/pcie0_linked<br />
$ cat /debugfs/pcie0_linked<br />
0</p></blockquote>
<p>像是 procfs 一樣, debugfs 也有 create directory 的 function, 以便讓變數可以在目錄內<br />
我們小小改一下上面的程式, 加上 create_dir 的功能</p>
<blockquote><p>struct dentry *pcie_dir;<br />
pcie_dir = debugfs_create_dir(&#8220;pcie&#8221;,NULL);<br />
if( pcie_dir != NULL ) {<br />
debugfs_create_u32(&#8220;pcie0_linked&#8221;, 0644, pcie_dir, &amp;pcie0_linked);<br />
}</p></blockquote>
<p>改了以上的輸出, 接下來就可以在 /debugfs 下, 看到多了一個 pcie 的目錄, 而 pcie0_linked 就在裡面.</p>
<p>如果想用 hex(16 進位), 可以改用 debugfs_create_x32.</p>
<p>proc file system 最棒的就是可以讀寫檔案了, 可以做更多的控制.<br />
debugfs 也有一個 function 可以讓使用者做檔案讀寫, 這邊寫一個簡單的 sample.</p>
<p>多 include 一個 header</p>
<blockquote><p>#include &lt;linux/seq_file.h&gt;</p>
<p>static int pcie_reg_open(struct seq_file *s, void *data)<br />
{<br />
seq_printf(s, &#8220;pcie0_link status : %s\n&#8221;, pcie0_linked == 1 ? &#8220;Enable&#8221;: &#8220;D<br />
return 0;<br />
}</p>
<p>static int pcie_single_open(struct inode *inode, struct file *file)<br />
{<br />
return single_open(file, pcie_reg_open, inode-&gt;i_private);<br />
}<br />
static ssize_t pcie_debug_write(struct file *file,<br />
const char __user *userbuf,<br />
size_t count, loff_t *ppos)<br />
{<br />
char buf[20];</p>
<p>if (copy_from_user(buf, userbuf, min(count, sizeof(buf))))<br />
return -EFAULT;</p>
<p>printk(&#8220;%s: %s \n&#8221;,__FUNCTION__, buf);</p>
<p>return count;<br />
}</p>
<p>static const struct file_operations pcie_ios_fops = {<br />
.open           = pcie_single_open,<br />
.read           = seq_read,<br />
.write          = pcie_debug_write,<br />
.llseek         = seq_lseek,<br />
.release        = single_release,</p>
<p>};<br />
debugfs_create_file(&#8220;file&#8221;, 0644, pcie_dir, NULL, &amp;pcie_ios_fops);</p></blockquote>
<p>這樣</p>
<blockquote><p>$ cat /debugs/pcie/file 會顯示<br />
pcie0_link status : Enable<br />
而<br />
$ echo &#8220;richliu&#8221; &gt; /debugfs/pcie/file 會顯示<br />
pcie_debug_write: richliu</p>
<p>$</p></blockquote>
<p>最後要介紹的是比較特別的一種格式 blob, 這是可以傳 binary 到 user space 的格式, blob 的 struct 是<br />
struct debugfs_blob_wrapper {<br />
void *data;<br />
unsigned long size;<br />
};</p>
<p>在剛剛的 Code 加上</p>
<blockquote><p>static struct debugfs_blob_wrapper blob; &#8211;&gt; 最好放  global.<br />
char data[100];<br />
sprintf(data, &#8220;Data Pointer is : %08X \n&#8221;, data);<br />
blob.data = data;<br />
blob.size = 100;<br />
debugfs_create_blob(&#8220;blob&#8221;, S_IRUSR, pcie_dir, &amp;blob);</p></blockquote>
<p>在 Linux 下直接用 hexdump 去讀資料出來</p>
<blockquote><p>$ hexdump /debugfs/pcie/blob -c<br />
0000000   D   a   t   a       P   o   i   n   t   e   r       i   s<br />
0000010   :       C   4   0   5   C   1   6   0      \n  \0  \0  \0  \0<br />
0000020  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0<br />
*<br />
0000060</p></blockquote>
<p>請記得 Blob 這個檔案是 Read Only, 只能傳出, 不能傳入&#8230;</p>
<p>參考:<br />
<a href="http://lwn.net/Articles/115405/" target="_blank" rel="noopener">Debugfs</a><br />
<a href="http://www.wretch.cc/blog/shinningball/33089435" target="_blank" rel="noopener">Debugfs 中譯版(好像是從匪區抄過來的?)</a></p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2010/01/20/843/debugfs/">Debugfs</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.richliu.com/2010/01/20/843/debugfs/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>[Linux][Kernel][Memory] smbd: page allocation failure. order:2, mode:0x20</title>
		<link>https://blog.richliu.com/2009/12/11/822/%e8%a8%98%e6%86%b6%e9%ab%94%e5%95%8f%e9%a1%8c-smbd-page-allocation-failure-order2-mode0x20/</link>
					<comments>https://blog.richliu.com/2009/12/11/822/%e8%a8%98%e6%86%b6%e9%ab%94%e5%95%8f%e9%a1%8c-smbd-page-allocation-failure-order2-mode0x20/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Fri, 11 Dec 2009 13:05:31 +0000</pubDate>
				<category><![CDATA[Embedded]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Jumbo Frame]]></category>
		<category><![CDATA[linux kernel]]></category>
		<category><![CDATA[memory]]></category>
		<category><![CDATA[samba]]></category>
		<guid isPermaLink="false">http://blog.richliu.com/?p=822</guid>

					<description><![CDATA[<p>如果啟動了 Jumbo Frame 加上執行 Samba , 有可能會出現類似的訊息(系統抓下來似乎有點不全) [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2009/12/11/822/%e8%a8%98%e6%86%b6%e9%ab%94%e5%95%8f%e9%a1%8c-smbd-page-allocation-failure-order2-mode0x20/">[Linux][Kernel][Memory] smbd: page allocation failure. order:2, mode:0x20</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>如果啟動了 Jumbo Frame 加上執行 Samba , 有可能會出現類似的訊息(系統抓下來似乎有點不全)</p>
<p><span id="more-822"></span></p>
<blockquote><p>smbd: page allocation failure. order:2, mode:0x20<br />
Backtrace:<br />
[&lt;c002fd30&gt;] (dump_backtrace+0x0/0x108) from [&lt;c02ac488&gt;] (dump_stack+0x18/0x1c)<br />
[&lt;c02ac470&gt;] (dump_stack+0x0/0x1c) from [&lt;c0075734&gt;] (__alloc_pages_nodemask+0x3d0/0x55c)<br />
[&lt;c0075364&gt;] (__alloc_pages_nodemask+0x0/0x55c) from [&lt;c008f5d8&gt;] (cache_alloc_refill+0x2b0/0x598)<br />
[&lt;c008f328&gt;] (cache_alloc_refill+0x0/0x598) from [&lt;c008f978&gt;] (__kmalloc+0xb8/0xd8)<br />
[&lt;c008f8c0&gt;] (__kmalloc+0x0/0xd8) from [&lt;c0227a6c&gt;] (__alloc_skb+0x54/0x138)<br />
[&lt;c0227a18&gt;] (__alloc_skb+0x0/0x138) from [&lt;c022879c&gt;] (dev_alloc_skb+0x20/0x44)<br />
[&lt;c022877c&gt;] (dev_alloc_skb+0x0/0x44) from [&lt;c01e643c&gt;] (cns3xxx_receive_packet+0x228/0x3c8)<br />
[&lt;c01e6214&gt;] (cns3xxx_receive_packet+0x0/0x3c8) from [&lt;c01e661c&gt;] (cns3xxx_poll+0x40/0xd4)<br />
[&lt;c01e65dc&gt;] (cns3xxx_poll+0x0/0xd4) from [&lt;c022f264&gt;] (net_rx_action+0xb4/0x184)<br />
[&lt;c022f1b0&gt;] (net_rx_action+0x0/0x184) from [&lt;c0048544&gt;] (__do_softirq+0x90/0x11c)<br />
[&lt;c00484b4&gt;] (__do_softirq+0x0/0x11c) from [&lt;c0048614&gt;] (irq_exit+0x44/0x4c)<br />
[&lt;c00485d0&gt;] (irq_exit+0x0/0x4c) from [&lt;c002b04c&gt;] (_text+0x4c/0x90)<br />
[&lt;c002b000&gt;] (_text+0x0/0x90) from [&lt;c002bab8&gt;] (__irq_svc+0x38/0x80)<br />
Exception stack(0xc7acbcc0 to 0xc7acbd08)<br />
bcc0: c7acbd1c c7829960 c7acbd28 00000000 00000001 c7b53980 c7b539e4 c7acbd1c<br />
bce0: 00000000 00000000 c7acbf08 c7acbd14 c7acbd28 c7acbd08 c0222314 c0057a0c<br />
bd00: 60000013 ffffffff<br />
[&lt;c00579b0&gt;] (finish_wait+0x0/0x6c) from [&lt;c0222314&gt;] (sk_wait_data+0xcc/0xec)<br />
[&lt;c0222248&gt;] (sk_wait_data+0x0/0xec) from [&lt;c0255fc0&gt;] (tcp_recvmsg+0x600/0x8a8)<br />
[&lt;c02559c0&gt;] (tcp_recvmsg+0x0/0x8a8) from [&lt;c0221208&gt;] (sock_common_recvmsg+0x48/0x5c)<br />
[&lt;c02211c0&gt;] (sock_common_recvmsg+0x0/0x5c) from [&lt;c021e7d8&gt;] (sock_aio_read+0x138/0x144)<br />
[&lt;c021e6a0&gt;] (sock_aio_read+0x0/0x144) from [&lt;c0092918&gt;] (do_sync_read+0xc4/0x110)<br />
[&lt;c0092854&gt;] (do_sync_read+0x0/0x110) from [&lt;c00936ac&gt;] (vfs_read+0x164/0x16c)<br />
[&lt;c0093548&gt;] (vfs_read+0x0/0x16c) from [&lt;c0093790&gt;] (sys_read+0x44/0x74)<br />
[&lt;c009374c&gt;] (sys_read+0x0/0x74) from [&lt;c002be40&gt;] (ret_fast_syscall+0x0/0x2c)<br />
Mem-info:<br />
Normal per-cpu:<br />
CPU    0: hi:   42, btch:   7 usd:  32<br />
Active_anon:570 active_file:9598 inactive_anon:576<br />
inactive_file:17657 unevictable:0 dirty:3503 writeback:0 unstable:0<br />
free:419 slab:2389 mapped:1587 pagetables:87 bounce:0<br />
Normal free:1676kB min:1440kB low:1800kB high:2160kB active_anon:2280kB inactive_anon:2304kB active_file:38392kB inactive_file:70628kB unevictable:0kB present:130048kB pages_scanned:0 all_unreclaimable? no<br />
lowmem_reserve[]: 0 0<br />
Normal: 345*4kB 25*8kB 6*16kB 0*32kB 0*64kB 0*128kB 0*256kB 0*512kB 0*1024kB 0*2048kB 0*4096kB = 1676kB<br />
27277 total pagecache pages<br />
32768 pages of RAM<br />
543 free pages<br />
1251 reserved pages<br />
2389 slab pages<br />
29382 pages shared<br />
0 pages swap cached</p></blockquote>
<p>可以加大 kernel 預留的 Buffer, 我系統上原來是 1117, 可以用指令</p>
<p><strong>echo 8192 &gt; /proc/sys/vm/min_free_kbytes</strong><strong><br />
</strong></p>
<p>加大到 8Mbytes, 這樣可以減少 page allocation 失敗的機率, 在我們的測試內, 某些時候 8MByte 仍會出現, 可以考慮加大到 16Mbytes.</p>
<p>原因是因為在 interrupt 中, 向系統一次要求大塊的記憶體. 這時可以透過增加 min_free_kbytes 參數去避過這個問題.<br />
調整 slab 的參數或許也有用  ( echo x y z &gt; /proc/slab)</p>
<p>Ref.<br />
http://lime-technology.com/forum/index.php?topic=3999.0<br />
http://linux.derkeiler.com/Mailing-Lists/Kernel/2004-01/0059.html</p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2009/12/11/822/%e8%a8%98%e6%86%b6%e9%ab%94%e5%95%8f%e9%a1%8c-smbd-page-allocation-failure-order2-mode0x20/">[Linux][Kernel][Memory] smbd: page allocation failure. order:2, mode:0x20</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.richliu.com/2009/12/11/822/%e8%a8%98%e6%86%b6%e9%ab%94%e5%95%8f%e9%a1%8c-smbd-page-allocation-failure-order2-mode0x20/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
