存档

2006年12月 的存档

how to disable alignment trap from user space in linux

2006年12月23日 hufey 评论已被关闭

I was confused on that how to disable alignment trap from user space in linux. After lots of searching, code/document reading I got the point is, the linux kernel provides a mechanism/interface in procfs let user space application change the unalignment trap action of kernel to
“ignored”,
“warn”,
“fixup”,
“fixup+warn”,
“signal”,
“signal+warn”.
And default mode is 5(signal+warn), that means once unalignment memory access occurs, the kernel will send signal SIGBUS to kill the application.
We can just read all configuration info from /proc/cpu/alignment and just write a number to reset action mode like “echo 2 > /proc/cpu/alignment”.
See linux-2.6.x/Documentation/arm/mem_alignment,
—————————————————————————————-
Too many problems poped up because of unnoticed misaligned memory access in
kernel code lately. Therefore the alignment fixup is now unconditionally
configured in for SA11×0 based targets. According to Alan Cox, this is a
bad idea to configure it out, but Russell King has some good reasons for
doing so on some f***ed up ARM architectures like the EBSA110. However
this is not the case on many design I’m aware of, like all SA11×0 based
ones.
Of course this is a bad idea to rely on the alignment trap to perform
unaligned memory access in general. If those access are predictable, you
are better to use the macros provided by include/asm/unaligned.h. The
alignment trap can fixup misaligned access for the exception cases, but at
a high performance cost. It better be rare.
Now for user space applications, it is possible to configure the alignment
trap to SIGBUS any code performing unaligned access (good for debugging bad
code), or even fixup the access by software like for kernel code. The later
mode isn’t recommended for performance reasons (just think about the
floating point emulation that works about the same way). Fix your code
instead!
Please note that randomly changing the behaviour without good thought is
real bad – it changes the behaviour of all unaligned instructions in user
space, and might cause programs to fail unexpectedly.
To change the alignment trap behavior, simply echo a number into
/proc/sys/debug/alignment. The number is made up from various bits:
bit behavior when set
— —————–
0 A user process performing an unaligned memory access
will cause the kernel to print a message indicating
process name, pid, pc, instruction, address, and the
fault code.
1 The kernel will attempt to fix up the user process
performing the unaligned access. This is of course
slow (think about the floating point emulator) and
not recommended for production use.
2 The kernel will send a SIGBUS signal to the user process
performing the unaligned access.
Note that not all combinations are supported – only values 0 through 5.
(6 and 7 don’t make sense).
For example, the following will turn on the warnings, but without
fixing up or sending SIGBUS signals:
echo 1 > /proc/sys/debug/alignment
You can also read the content of the same file to get statistical
information on unaligned access occurrences plus the current mode of
operation for user space code.
Nicolas Pitre, Mar 13, 2001. Modified Russell King, Nov 30, 2001.
——————————————————————————————–
Note the procfs interface file location was changed. Not sure when it was.

分类: saving 标签:

Window$ CE family

2006年12月20日 hufey 评论已被关闭

分类: saving 标签:

生活流水账(12/16/2006)

2006年12月17日 hufey 评论已被关闭

11点起床
跑了三个银行,招行存钱,中行托收支票,农行交养路费(未遂)
跟LP吵了一架(后背遭到痛击一掌)
违章停车被贴条儿(两百块)
去宜家买俩台灯和一堆不在计划中的东西(LP看中的)
去菜市场买一箱苹果
必胜客吃早中晚合并一餐(比较撑)
去家乐福买鲜奶、酸奶、面条(没买到)和运动饮料
晚上给丈母娘送去半箱苹果
半夜遭到美国同事电话骚扰
开车去公司

分类: listing 标签:

证据保全

2006年12月14日 hufey 评论已被关闭

robin li 是李眼红吗?
提交者 : 方枪枪枪 于 泡网俱乐部 (http://paowang.net/) 北京时间 2006-12-14 14:41:46
From: “peter wang”
Reply-To:
To: “‘Robin LI’” ,’梁冬’
Subject: 新浪专题被收录情况
Date:Wed, 13 Sep 2006 17:08:11 +0800
Dear both;
在过去一段时间新浪科技频道对百度的支持还是有目共睹的,因此中午我约请该频道负责的编辑郭开森吃饭。
其间他提及为什么有时候搜狐的专题比新浪的*前;而搜狐又是对百度那么多负面报道。
我当时没有承诺任何东西,只是让他提供一些数据以便我转给技术部了解。
后来与边疆了解后,知道是因为过去新浪对百度的负面报道而我们降低了其权重。
如今情况有所变化,我们是否可以适当考虑恢复新浪的正常权重而将搜狐的调低?
请两位明示。
谢谢,
Peter
P.S. 季度末频道负责人(如郭)的考核一部分也是以PV为主的,因此恰当时候给郭的
支持,会比一般情况下的作用大。仅供参考。
_____
发件人: guo kaisen [mailto:kaisen@staff.sina.com.cn]
发送时间: 2006年9月13日 15:17
收件人: peter wang
主题: 答复: 请将你提到的专题被收录情况尽快给我,以便转给技术部门,谢谢
我给你一部分数据吧,请千万不要传播。
表格前面是百度数据,后面是google的数据。这大概是8月21日前后的一个监控。
        致
礼!
—–原始邮件—–
发件人: peter wang [mailto:peter.wang@baidu.com]
发送时间: 2006年9月13日 14:17
收件人: kaisen@staff.sina.com.cn
主题: 请将你提到的专题被收录情况尽快给我,以便转给技术部门,谢谢

分类: watching 标签:

QuickCheck

2006年12月11日 hufey 评论已被关闭

删垃圾留言删的我头昏眼花
想着要不要自己写一个extension来快速删除
想了想。。。估计有人写过了
于是找到这个:
QuickCheck

分类: commenting 标签:

推荐本书

2006年12月1日 hufey 评论已被关闭


Advanced Programming in the UNIX Environment
一个新入行的MM程序员让我推荐Linux编程方面的书
我说linux下的编程其实都是标准C和posix api,不用另买书看
她问我什么是posix
我说是一套IEEE定的api标准
她有问有没有哪本书讲posix标准的
我想了半天却想起来大概7年前我做的一个项目,大概就是给一个简陋的RTOS做一个文件系统
我非常希望做到posix-compatible,但是没有讲posix细节的文档,于是上网搜,搜出来的
文档都是要花钱去IEEE买的,而那时的公司又不愿意出这笔钱(好像不是个小数目),最后就不了了之了。当然我还是尽我所能去写了那些代码来贴近我理解的posix。
后来落下了个心病,去书店逛的时候希望能找到一点posix的雪泥鸿爪。
直到在(大概是三联)书店发现了这本UNIX环境高级编程。当时还是第一版,其实我到现在也没完整看完一遍,大概看了2/3内容。多数都是遇到问题时去查。
本来是打算给MM发pdf的,不过在joyo买东西打算凑订单,结果偶然发现了此书的第二版。当即拿下。不过要送人,自己还没打算买。原价99元,即便我以VIP价买也要67块,还是挺贵的。
另外,七百多页的书确实有点太厚,家里书架已经没地方了。。。。。。

分类: commenting 标签: