<?xml version="1.0" encoding="ISO-8859-1"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:ref="http://purl.org/rss/1.0/modules/reference/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns="http://purl.org/rss/1.0/">
	<channel rdf:about="http://bl0g.blogdns.com/rss.rdf">
		<title>Ming c Li Blog</title>
		<link>http://bl0g.blogdns.com/index.php</link>
		<description><![CDATA[No Footer]]></description>
		<items>
			<rdf:Seq>
				<rdf:li resource="http://bl0g.blogdns.com/index.php?entry=entry090618-100109" />
				<rdf:li resource="http://bl0g.blogdns.com/index.php?entry=entry090611-160632" />
				<rdf:li resource="http://bl0g.blogdns.com/index.php?entry=entry090528-085316" />
				<rdf:li resource="http://bl0g.blogdns.com/index.php?entry=entry090403-140553" />
				<rdf:li resource="http://bl0g.blogdns.com/index.php?entry=entry090401-112319" />
				<rdf:li resource="http://bl0g.blogdns.com/index.php?entry=entry090225-192813" />
				<rdf:li resource="http://bl0g.blogdns.com/index.php?entry=entry090129-133042" />
				<rdf:li resource="http://bl0g.blogdns.com/index.php?entry=entry080604-150944" />
				<rdf:li resource="http://bl0g.blogdns.com/index.php?entry=entry080602-111714" />
				<rdf:li resource="http://bl0g.blogdns.com/index.php?entry=entry080530-100315" />
			</rdf:Seq>
		</items>
	</channel>
	<item rdf:about="http://bl0g.blogdns.com/index.php?entry=entry090618-100109">
		<title>Return page_count(page) - !!page_has_private(page) == 2 discussion</title>
		<link>http://bl0g.blogdns.com/index.php?entry=entry090618-100109</link>
		<description><![CDATA[(15:34:44) vincentinsz:  287 static inline int is_page_cache_freeable(struct page *page)<br /> 288 {<br /> 289         return page_count(page) - !!page_has_private(page) == 2;<br /> 290 }<br /><br />(15:35:21) vincentinsz: this function eventually returns 0 or 1, right?<br />(15:36:35) qunying: not understand it fully, looks strange to me<br />(15:38:20) qunying: as !!page_has_private(page) should return 0 or 1, and  !!page_has_private(page) == 2 should always fail, then that is the result of page_count(page)<br />(15:40:02) vincentinsz: I thought  it is like return 3 - 1 == 2? 1 : 0 ?<br />(15:40:45) qunying: ah right, forgot the &#039;-&#039;<br />(15:41:11) qunying: it is always return 0 or 1<br />(15:42:52) vincentinsz: not sure why number 2 is special in this case ==2<br />(15:43:13) vincentinsz: why not == 1, or == 3 ?<br />(15:44:00) qunying: that is beyond my understanding, you make dig into how page_count is working<br />(15:53:00) vincentinsz: what the !! is for, like !!func(a), always get the oposite of function retuning value?<br />(15:53:47) qunying: not, it normalize the return code to 0 or 1<br />(15:54:02) qunying: some func(a0 may return &gt; 1 or &lt; 0 values<br />(15:54:53) vincentinsz: &gt; 1 to make it 1, &lt; 0 to make it 0, right<br />(15:55:34) qunying: no. &lt; 0 make it to 1 also<br />(15:55:52) qunying: in C, any none 0 value is true<br />(15:56:37) vincentinsz: oh, forgot that part, so &lt; or &gt; 1 to make it 1, 0 to make it 0<br />(15:57:25) qunying: ya<br />(15:57:35) vincentinsz: f**k :-) so &lt; or &gt; 0 to make it 1<br />(16:58:12) qunying logged out.<br /><br /><br />---<br /><br /><br />(09:31:33) vincentinsz: Hi, still to the strange !!((page)-&gt;flags &amp; ((1 &lt;&lt; PG_private) | (1 &lt;&lt; PG_private_2))) statement<br />(09:34:25) vincentinsz: (page)-&gt;flags &amp; ((1 &lt;&lt; PG_private) | (1 &lt;&lt; PG_private_2)) is to mask (page)-&gt;flags to something like 00010000, assuming the 1 bit value represents the PG_private, am I right?<br />(09:34:46) qunying: yes<br />(09:35:33) vincentinsz: then !!(0000100000) make it to vaule 1, right?<br />(09:35:59) qunying: yes<br />(09:38:03) vincentinsz: someone else had this explaintion: <a href="http://zh-kernel.org/pipermail/linux-kernel/2009-June/011228.html" target="_blank" >http://zh-kernel.org/pipermail/linux-ke ... 11228.html</a><br />(09:38:32) vincentinsz: is that the same thing as you said?<br />(09:39:27) qunying: ya<br />(09:40:13) vincentinsz: is that to say that !! will always get 1?<br />(09:40:36) qunying: no, it says none 0 value to 1<br />(09:40:49) qunying: 0 will always get 0<br />(09:51:05) vincentinsz: ok. Oh and the page_count(page) -  !!((page)-&gt;flags &amp; ((1 &lt;&lt; PG_private) | (1 &lt;&lt; PG_private_2))) == 2 meaning that if (page)-&gt;flag PG_private is set, then there should be another two  bit set to 1 in (page)-&gt;flags so that this page can be freeable<br />(09:51:53) qunying: i see<br />(09:53:06) vincentinsz: the other two bit could mean a page is in user mapped address space and LRU (Least recently used) list which are most likely for page reclaim candidate<br /><br />(10:03:46) vincentinsz: There are many details, I could be wrong :-), the devil is the detail <br />(10:04:19) qunying: ^_6<br />(10:48:29) vincentinsz: ok, more, page_count(page) count the reference count of page, if page flag PG_private bit flag is set, the page is  pagecache page backed by inode or swap , so the pagecache itself would have 1 reference to the page, that is at least 2 ref count. Then the page has to be referenced in LRU list so it can be freed, that is 3.<br />(10:51:11) qunying: hmm, that is why it minors the 1 reference from private bit reference<br />(10:51:16) qunying: minus<br /><br />]]></description>
	</item>
	<item rdf:about="http://bl0g.blogdns.com/index.php?entry=entry090611-160632">
		<title>kernel virtual address to size caculation chat log</title>
		<link>http://bl0g.blogdns.com/index.php?entry=entry090611-160632</link>
		<description><![CDATA[I had an interesting chat with my friend qunying about how to caculate the hex presentation of address to a size:<br /><br />(14:29:56) vincentinsz: on x86 32bit the kernel image located at physical address 1MiB, which translate to 0x00100000, but how 0x00100000 equals 1M, how to caculate it?<br />(14:32:00) qunying: 1024*1024 = 0x100000<br />(14:32:11) qunying: that is 1MiB<br />(14:33:56) vincentinsz: is there easy way to see 0x100000 as 1024 * 1024?<br />(14:34:18) qunying: just count the zeros<br />(14:34:36) qunying: one 0 in hex is 2^^2<br />(14:34:49) qunying: there is 5 zero, that is 2^^10<br />(14:35:00) qunying: that is 1M<br />(14:35:54) qunying: one 0 is 2^^4<br />(14:35:58) qunying: not 2,<br />(14:36:09) qunying: 5 zero is 2^^20<br />(14:37:59) vincentinsz: how do you get one 0 is 2^^4?<br />(14:38:27) qunying: for one number in hex represents 4 bits in binary<br />(14:38:55) qunying: 0x10 = 2^4, 0x100 = 2^8, etc<br />(14:40:01) vincentinsz: 0x10 = 1000 0000<br />(14:40:13) qunying: ya<br />(14:40:23) qunying: no<br />(14:40:29) qunying: 001 000<br />(14:40:34) qunying: 0001 0000<br />(14:40:47) vincentinsz: i see<br />(14:42:20) vincentinsz: what about some other hex address like 0xC0000000 which is about 3G, How to caculate<br />(14:45:10) vincentinsz: so there is 7 0s which is 2^^28?<br />(14:45:24) qunying: ya<br />(14:45:35) qunying: C is 1100<br />(14:46:00) qunying: so times 2^12<br />(14:46:35) vincentinsz: ah, so 2^^30 * 3?<br />(14:48:33) qunying: ya<br /><br /><br />---<br />]]></description>
	</item>
	<item rdf:about="http://bl0g.blogdns.com/index.php?entry=entry090528-085316">
		<title>Learning Linux Kernel  series 1 - Buffer Head</title>
		<link>http://bl0g.blogdns.com/index.php?entry=entry090528-085316</link>
		<description><![CDATA[First I read:<br /><br />A nasty file corruption bug - fixed<br /><a href="http://lwn.net/Articles/215868/" target="_blank" >http://lwn.net/Articles/215868/</a><br /><br />The header for buffer head is include/linux/buffer_head.h<br /><br /><br />defines maxmum disk sectores/blocks as 8 per page, PAGE_CACHE_SIZE normally is the same size of PAGE_SIZE as 4k<br /><br />#define MAX_BUF_PER_PAGE (PAGE_CACHE_SIZE / 512)<br /><br />The function definition for buffer head is fs/buffer.c]]></description>
	</item>
	<item rdf:about="http://bl0g.blogdns.com/index.php?entry=entry090403-140553">
		<title>Asterisk app_mp3 patch to play m3u playlist  file</title>
		<link>http://bl0g.blogdns.com/index.php?entry=entry090403-140553</link>
		<description><![CDATA[Asterisk app_mp3.c could only play one local single mp3 file, I patched it to play m3u playlist file randomly.<br /> <br /><a href="http://bl0g.blogdns.com/asterisk/app_mp3.patch" target="_blank" >http://bl0g.blogdns.com/asterisk/app_mp3.patch</a>]]></description>
	</item>
	<item rdf:about="http://bl0g.blogdns.com/index.php?entry=entry090401-112319">
		<title>Linux file system ext4 debate</title>
		<link>http://bl0g.blogdns.com/index.php?entry=entry090401-112319</link>
		<description><![CDATA[<br /><a href="http://lwn.net/Articles/322913/" target="_blank" >http://lwn.net/Articles/322913/</a><br /><a href="http://lwn.net/Articles/322043/" target="_blank" >http://lwn.net/Articles/322043/</a>]]></description>
	</item>
	<item rdf:about="http://bl0g.blogdns.com/index.php?entry=entry090225-192813">
		<title>Use vim and cscope to read large C source code project</title>
		<link>http://bl0g.blogdns.com/index.php?entry=entry090225-192813</link>
		<description><![CDATA[Vim is my favourite editor, I often use vim to read open source C code, Later, I found cscope is quite good tool to jump back and forth between different C source files to better understand how those C sources connect together in a large open source C code project. <br /><br />cscopes_maps.vim can be downloaded from <a href="http://cscope.sourceforge.net/cscope_maps.vim" target="_blank" >http://cscope.sourceforge.net/cscope_maps.vim</a>, put this file under ~/.vim/plugin and run cscope -b -R -k under the folder of open source project, for example cd /usr/src/linux-2.28.x;cscope -b -R -k. then open a C source file,  move cursor under a function name, press ctrl + ] will jump to the function declaration/definition of .c/.h file. use ctrl + t, ctrl + ^, etc to jump back and forth.<br /><br />type :help cscope to get more help info about cscope at vim command mode, also vim folding can be helpful to get a broad picture of C source file, type :help folding to get more info about vim folding.]]></description>
	</item>
	<item rdf:about="http://bl0g.blogdns.com/index.php?entry=entry090129-133042">
		<title>Asterisk App DISA usage and programing control</title>
		<link>http://bl0g.blogdns.com/index.php?entry=entry090129-133042</link>
		<description><![CDATA[DISA: Direct Inward System Access, application allows someone from outside the telephone switch (PBX) to obtain an &lt;emphasis&gt;internal&lt;/emphasis&gt; system dialtone and to place calls from it as if they were placing a call from within the switch. <br />Sampel Extension Usage:<br /><br />exten =&gt; 123,1,DISA(111,disa-context,,123@default,np)<br />or<br />exten =&gt; 123,1,DISA(/etc/asterisk/passcode.txt)<br /><br />passcode.txt is like this:<br /><br />111,disa-context,,123@default<br />222,disa-context,,123@default<br /><br />In the for loop, when k is either 00, or 10, the loop would be in password state,  entered digit saved in f-&gt;subclass and assigned to j, later saved in array exten[i++]=j. when password end with #, k would be set to k|=1 to 3(11), i reset to 0, the password state test k&amp;1 would be all false,so skips all the password state instruction, and do the exten[i++]=j to save entered extension number to array exten, when # entered, break the loop and go to check if k==3. ]]></description>
	</item>
	<item rdf:about="http://bl0g.blogdns.com/index.php?entry=entry080604-150944">
		<title>Tip to turn on vim syntax highlighting on os x 10.5</title>
		<link>http://bl0g.blogdns.com/index.php?entry=entry080604-150944</link>
		<description><![CDATA[ $HOME/.vimrc, put &quot;syntax enable&quot;]]></description>
	</item>
	<item rdf:about="http://bl0g.blogdns.com/index.php?entry=entry080602-111714">
		<title>mp3 to audio cd converter on Linux</title>
		<link>http://bl0g.blogdns.com/index.php?entry=entry080602-111714</link>
		<description><![CDATA[I bought a cheap FM/AM and CD player for my little baby, the CD part could not play mp3 format music. Since I have a lot of MP3 music files, I need to convert them to audio CD so that my baby could enjoy the music, I found that mp3cd (written in Perl) is quite intuitive to automatically convert mp3 to CD.<br /><br /><a href="http://outflux.net/unix/software/mp3cd/" target="_blank" >http://outflux.net/unix/software/mp3cd/</a>]]></description>
	</item>
	<item rdf:about="http://bl0g.blogdns.com/index.php?entry=entry080530-100315">
		<title>Linux filesystem events API</title>
		<link>http://bl0g.blogdns.com/index.php?entry=entry080530-100315</link>
		<description><![CDATA[Here is Linux file sytem events API you could use to monitor Linux folder/files changes.<br /><br /><a href="http://tomoyo.sourceforge.jp/cgi-bin/lxr/source/Documentation/filesystems/inotify.txt" target="_blank" >inotify</a>]]></description>
	</item>
</rdf:RDF>
