关中刀客偶得轩

奶粉抽检结果暴露出"潜规则"令人恶心

刀客谝闲传

央视新闻联播由邢质斌主播的国家质检总局关于奶粉质量检查结果的通报。22家奶粉厂家产品含有三聚氰胺,著名国产品牌几乎一网打尽。报道里这样几条信息耐人寻味:

How likely should likely() be?

Linux系统知识

http://lwn.net/Articles/70473/
这篇文章讲内核代码中likely和unlikely的用法。这个两个宏在以前的内核里面是没有的,应该是在2.5以后的代码中引进的。
比较新的CPU,一般都会有指令预取的功能,也就是在执行当前指令的时候,可能把当前指令后的很多指令都取到了指令cache里面了,而且由于指令流水的 并行执行,很可能在执行当前指令时,把后面的很多指令都执行了。所以,如果当前指令是一个条件指令,那么,最后它后面的指令是条件为真时执行的指令,这样 可以提高执行的性能。

Linux用户进程是如何申请和释放内存的?

Linux系统知识

UTF-8

http://lixiang.cn/glibc_mem/glibc_mem.html

mmap释疑

Linux系统知识

MAP_PRIVATE 是创建一个写时拷贝映射(copy-on-write),也就是说如果有多个进程同时映射到一个文件上,映射建立时只是共享同样的存储页面,但是某进程企图修改页面内容,则复制一个副本给该进程私用,它的任何修改对其它进程都不可见。而MAP_SHARED则无论修改与否都使用同一副本,任何进程对页面的修改对其它进程都是可见的。所以它们占有的内存大小当然差别比较大了^_^

When Linux Runs Out of Memory

Linux系统知识

Perhaps you rarely face it, but once you do, you surely know what's wrong: lack of free memory, or Out of Memory (OOM). The results are typical: you can no longer allocate more memory and the kernel kills a task (usually the current running one). Heavy swapping usually accompanies this situation, so both screen and disk activity reflect this.

how to use one compiled kernel of bsd in a new server

on 147.182 , cp /boot/kernel.tar.gz to new server
on new server: tar xvfz kernel.tar.gz /newkernel
cp -R /boot/kernel  /boot/kernel.orig
mv /newkernel /boot/kernel

reboo

create your own customed boot disc

技巧&手册

1. Put the contents of the boot.iso image into a temporary directory
   # mkdir /tmp/iso
   # mount -o loop boot.iso /mnt
   # cd /mnt
   # cp -a . /tmp/iso

2. Put additional files (e.g. kickstart files) into the same directory.

3. Edit isolinux/isolinux.cfg to modify/add boot entries.

4. You can also modify isolinux/boot.msg to privide a custom boot message.

5. Create a new bootable image with the following commands:

   # cd /tmp/iso
   # mkisofs -o ../bootcd.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -Jr .

ks=hd:<device>:/<file>

安​装​程​序​把​文​件​系​统​挂​载​在 <device>(必​须​是 vfat 或 ext2),而​且​在​该​文​件​系​统​里​以 <file> 来​寻​找 kickstart 文​件​(例​如​,ks=hd:sda3:/mydir/ks.cfg)。

Linux Memory Management or 'Why is there no free RAM?'

Linux系统知识

Linux Memory Management or 'Why is there no free RAM?'
Revision 2.3
Copyright 2004 sapphirecat. The text of this post is licensed under a Creative Commons License.

for loop

技巧&手册

for i in `seq 1 10` ; do mount -o loop rhn-$i.iso /mnt; cp -dR  /mnt/* /rhntmp; umount /mnt; done

Linux 的 Virtual Memory Areas(VMA):基本概念介紹

由 user process 角度來說明的話,VMA 是 user process 裡一段 virtual address space 區塊;virtual address space 是連續的記憶體空間,當然 VMA 也會是連續的空間。VMA 對 Linux 的主要好處是,可以記憶體的使用更有效率,並且更容易管理 user process address space。