網頁

顯示具有 Diary 標籤的文章。 顯示所有文章
顯示具有 Diary 標籤的文章。 顯示所有文章

2006年5月28日 星期日

pf + smp + nogaint network stack = ?

剛剛看到大神這篇「升級到 6.1-RELEASE」裡面喊說因為腳踏車鎖(Giant lock)太多,所以就把 root server 衝到 6.1 了,真的是勇敢的長輩 XD。不過我是看到 GIANT LOCK 才想到我忘了說我遇到的狀況,所以才趕快來紀錄一下。

話說我家美人機到了之後總是會亂 panic 及亂七八糟的事情,在這一篇有稍微提到我後來換 ipnat 之後改善很多,不過偶爾還是會從網路上消失。後來大概在五月中的時候, 看到 mailing list 有人疑似有類似的情形,環境也是 smp ,後來過了不久某篇裡面談到:

This is very similar to the UID/GID filtering problem. What appears to
be happening is on the inbound path, we pickup the pfil lock and attempt
to pickup the inp info lock, while on the outbound path, we hold the inp
info lock across ip_output which will try to pickup the pfil lock.

This problem is the result of a layering violation, in reality the
firewall should not be picking up layer 4 related locks. Myself and a
few others have been discussing this problem for quite some time now,
and hopefully it won't be long before we can come up with a solution
that will make everyone happy.

For now, you should be able to set debug.mpsafenet to 0 which will
re-enable Giant in the network stack, in theory preventing the deadlock.

debug.mpsafenet=0

in your loader.conf

Let me know if this helps


 於是乎,測試了一下,把腳踏車鎖關掉,開機會看到:「WARNING: MPSAFE network stack disabled, expect reduced performance.」
Copyright (c) 1992-2006 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
        The Regents of the University of California. All rights reserved.
FreeBSD 6.1-STABLE #3: Wed May 17 22:41:10 CST 2006
    cookys@ddbeauty.iecs.us:/usr/obj/usr/src/sys/DDBEAUTY
WARNING: MPSAFE network stack disabled, expect reduced performance.
ACPI APIC Table: <GBT    AWRDACPI>
Timecounter "i8254" frequency 1193182 Hz quality 0
CPU: Intel(R) Pentium(R) D  CPU 2.66GHz (3340.93-MHz K8-class CPU)
  Origin = "GenuineIntel"  Id = 0xf47  Stepping = 7

 然後「感覺上」pf 好像反應比 ipnat 好,不過可能是錯覺 XD。雖然說腳踏車鎖一次就會綁一大堆,不過在會亂 dead lock 的狀況下也只能先打開撐著,看什麼時候他們解決 XD。至少跑到現在,兩個禮拜多都沒消失了,除了前一個禮拜被學校裝笑為把她 halt 等停電以外 :p

這時候該高呼,"捷安特鎖"我愛你嗎?(我沒有打廣告喔 @_@) 

2006年4月20日 星期四

mysql5.1 + SK2

離上一篇 post 有很長的一段時間了,這一段時間裡面發生很多故事,只是真的沒空寫。
前一陣子這台機器出了點問題,現在好像恢復了,放著看看還有沒有問題。

由於 File System 的大爆炸於是索性重裝了一台,反正意外發現我買了顆跟之前一模一樣的 HDD 。

ad4: 238474MB <WDC WD2500KS-00MJB0 02.01C03> at ata2-master SATA150
ad6: 238475MB <WDC WD2500KS-00MJB0 02.01C03> at ata3-master SATA150
測試結果似乎是爛了一顆(時好時壞?),管他的。先能動再說。

不過看到這邊被 spam 打的落花流水,只好跑去裝 Spam Karma 2 ,但是裝的時候被唉唉叫 :
Could not create SQL table: wp_sk2_spams.
SQL error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TYPE=MyISAM' at line 11
Could not create SQL table: wp_sk2_logs.
SQL error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TYPE=MyISAM' at line 8

找了一下 google 似乎沒有看到類似的問題,於是我就想到會不會是我手賤裝了 mysql51-server 造成的,於是跑去翻 mysql51的 doc ,翻到這個,看起來很像,於是嘗試性的把 TYPE=MyISM 拿掉,果然就好了。

改過的 code 大概像這樣:
    457                         $query = "CREATE TABLE IF NOT EXISTS `" . sk2_kSpamTable . "` (
    458          `id` int(11) NOT NULL auto_increment,
    459          `comment_ID` int(11) NOT NULL default '0',
    460          `karma` float(2) NOT NULL default '0',
    461          `karma_cmts` text NOT NULL,
    462          `last_mod` datetime NOT NULL default '0000-00-00 00:00:00',
    463          `unlock_keys` tinytext NOT NULL,
    464          `remaining_attempts` INT NOT NULL,
    465                 PRIMARY KEY (`id`),
    466                 KEY `comment_ID` (`comment_ID`));";
    467         //) TYPE=MyISAM;";

 很單純的 mark 掉就好了?(希望不要爆炸)。

2005年12月17日 星期六

WDS

這真是個令人討厭的東西。沒有標準化然後害我在那邊搞半天,後來才發現原來除了 SSID 設一樣, Channel 設相同、兩台 AP MAC 要互抄之外,最重要的是「最好」兩台 AP 是同一家廠商的。原本想說 MSI + ASUS 明明就有小通一下下,可是忽然就完全不通了。莫名其妙,就當一頭霧水之際,忽然覺得搞不好 WDS 並沒標準化,於是狠下心再去衝了一台 ASUS 的 WL520G,設完馬上通,而且很快,也不會一頓一頓的。更不會跑一陣子就爛掉。

亙,之前浪費的時間還來啊。

不過呢,現在跟沈大胖之間 AP 用 WDS + WEP 戶連,嘿嘿,這種爽度還是有的 XD。他在他家用網路比我在客廳還快,不過有趣的是 ASUS 的強度設定從 19 -> 84 的話好像超級猛耶 XD。兩台都沒換天線用原廠天線可以跑出 2M 多的成績算不錯了吧 XD。

也正因為這樣這裡多了台 MSI 的 AP ,拿到台中來升級升級 XD。現在無線網路升級成 802.11G + WPA-PSK,應該至少會比較安心一點吧。(不過電磁波.. Orz)。

附帶一題, ASUS 的 WL520G 有放 source code 耶!要不是沒空不然就自己來亂搞 XD。



一樣有圖有真相,上面那張是 AP 疊疊樂。

2005年10月28日 星期五

64 位元好猛啊!

64 位元真的不是蓋的,好大啊。一般對於 32 bits 的系統來講要把 int 玩到 overflow 似乎不是什麼很困難的事,可是對於 64 bits 的系統來說就很難講。以下就來介紹我昨天被嗆的原因以及試圖要幹的蠢事 XD。

2005年10月12日 星期三

昨天幹的蠢事 - ubench

昨天把硬碟清的差不多了(總共清了四天 -_-,因為其中有一顆 WD 80JB 好像存活了三四年,裡面滿滿的是對我來講比較重要的資料。順便藉著這次機會把之前的 Backup 整理歸類,順便備份到 DVD-R 裡面),想說開始大開殺戒。開始把硬碟亂灌作業系統來玩,當然第一個很好奇的就是 ubench 在這台 deaktop 上的 Gentoo 能夠跑這麼高分,那在 FreeBSD 下會是多少?要嗎就是 Linux 分數偏高所以其他台機器的分數顯得比較低,要嗎就是這台機器真的特別神猛,不過我猜應該是因為 Linux 的關係。

於是我在 WD Raptor上的分割區灌了 FreeBSD 5.4 Release。不過開機的時候遇到很奇怪的問題,因為我用 Gentoo 那時候裝的 Grub 來當作開機管理員。一開進 FreeBSD 之後螢幕就花掉然後不給反應了,看起來就像是因為進了 Graphic Mode 搞得鬼, Google 了半天好像找不到該用啥 keyword 查,想說反正只是測一下 ubench ,乾脆裝到另一顆硬碟效果也一樣。忽然間心血來潮,把 KVM 切成 server 然後 ping desktop ,竟然有反應耶。可是 SSH 是爛掉的,想一想可能是因為剛灌完需要產生 RSA KEY Pair,於是胡亂按了一通然後把他重開機。等了好久,果然莫名其妙 ssh 就通了。

於是我就在 FreeBSD 5.4 下測,沒想到測出來只能用「慘不忍睹」來形容阿。

這是之前在 Gentoo 下測的:

rabbit ubench-0.32 # ./ubench
Unix Benchmark Utility v.0.3
Copyright (C) July, 1999 PhysTech, Inc.
Author: Sergei Viznyuk <sv@phystech.com>
http://www.phystech.com/download/ubench.html
Linux 2.6.11-gentoo-r6 #1 SMP Wed May 25 09:31:04 Local time zone must be set--
ee zic  i686
Ubench CPU:   159850
Ubench MEM:   215002
--------------------
Ubench AVG:   187426 (-march=prescott -msse -msse2 -msse3)

 

這是昨天在 FreeBSD 下測的:

> ubench
Unix Benchmark Utility v.0.3
Copyright (C) July, 1999 PhysTech, Inc.
Author: Sergei Viznyuk <sv@phystech.com>
http://www.phystech.com/download/ubench.html
FreeBSD 5.4-RELEASE FreeBSD 5.4-RELEASE #0: Sun May  8 10:21:06 UTC 2005     roo
t@harlow.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC i386
Ubench CPU:   109562
Ubench MEM:   117601
--------------------
Ubench AVG:   113581 (Tue Oct 11 06:44:21 CST 2005) (NO_HTT)

然後我忽然想到,那時 Linux 的 Kernel 是有 SMP 下去跑的 Kernel ,天曉得會不會有影響。反正就試看看。於是就很高興的去重新編 kernel 。到後來 make installkernel KERNCONF=SMP 打完的時候,看他 installation finished 之後很習慣性的就按了 alt-ctrl-del ,過了兩秒才想到「幹!!」。我現在是用 server ssh 到桌機上啊,這樣等於是我把 server 給重開了阿 -_-。果不其然,開了 37 天多的 server 就被我 alt-ctrl-del 了。 XD 真是超白痴的。後來編完之後測的結果其實還是很糟糕:

> ubench
Unix Benchmark Utility v.0.3
Copyright (C) July, 1999 PhysTech, Inc.
Author: Sergei Viznyuk <sv@phystech.com>
http://www.phystech.com/download/ubench.html
FreeBSD 5.4-RELEASE-p7 FreeBSD 5.4-RELEASE-p7 #0: Tue Oct 11 07:01:27 CST 2005
   cookys@fleebsd.iecs.us:/usr/obj/usr/src/sys/SMP i386
Ubench CPU:   109382
Ubench MEM:   113730
--------------------
Ubench AVG:   111556 (Tue Oct 11 07:30:57 CST 2005) HTT


於是我又本著好奇的心態想說,會不會是 FreeBSD 5.x 系列寫爛了,搞不好 DragonFlyBSD 從 4.xx 上來的會好一點,於是又去抓他的 LiveCD 來測,測了之後反而比 FreeBSD 還慘,不過因為那版是 1.1 ,聽說 1.2 拿掉很多 lock ..於是又抱著一線希望去抓 1.3-DEVELOPMENT。還是差不多:

 

> ubench
Unix Benchmark Utility v.0.3
Copyright (C) July, 1999 PhysTech, Inc.
Author: Sergei Viznyuk <sv@phystech.com>
http://www.phystech.com/download/ubench.html
DragonFly 1.1-CURRENT DragonFly 1.1-CURRENT #10: Mon i386
Ubench CPU:     98245   99820    107728          108276
Ubench MEM:   107367  112979    135429          134525
-------------------- --------   ------          ------
Ubench AVG:   102806  106399    121578          121400
                     (GCC 2.95) (GCC 3.4 -O2)   (GCC -O3)
                        (1.3-DEVELOPMENT ,April 20)
(Tue Oct 11 17:42:25 CST 2005) (GCC 2.95)


後來又很好奇為什麼 FreeBSD 在編 Kernel 的時候都會把特殊指令集給關掉,於是 Google 了一下發現這篇和這篇:

 

For speed reasons, we restrict the kernel to using integer instructions
only.  This means we can avoid the considerable expense of
saving/restoring floating point context unnecessarily for syscalls,
interrupts, etc.

...

Note that we *could* concievably set aside a few xmm registers for
faster data copies inside the kernel, but we don't do it yet.  I
believe linux makes %xmm0 and %xmm1 available in the kernel and saves
them with every trap into kernel mode.


 

Whether or not the kernel is compiled with instructions that use these
registers has absolutely no bearing on whether userland code can use
them.  It's purely about trading one optimization (using optimized
opcodes in the kernel) for another (not having to save and restore
dozens of registers to the stack on each syscall).  It might be
interesting to experiment with allowing a certain class of instructions
in the kernel and saving and restoring the associated registers, and
seeing if GCC will actually generate code that is better and overcomes
the save/restore expense.  Any takers?

Scott

反正就是其實用了的話在 save/restore 的時候會有比較大的 overhead ,所以先關掉。然後其實還有方訪能夠去增加他的效率,那就是跟 Linux 一樣用 %xmm0 and %xmm1 來搞。不過這似乎跟上面的測試沒什麼太大關係就是了,測試數據參考就好。 Linux 在 ubench 的分數上勝出很多是事實 XD。

2005年6月15日 星期三

鴨子的怒吼

拼了一個早上的演算法作業,被老師說看不出來在做什麼。
然後明明都是自己寫的,都被說太陽春。 demo 網路找來的程式的人卻被說 "你們這組比較認真喔"

於是鴨子就暴走了。其實我已經懶的計較了,但是鴨子要暴走我也不會阻止他,反而會加點油下去,反正有人要翻 XD
結果全都出籠了... haha...全部都找到喔 XD
鴨把拔暴走果然強 (Y)

http://www.cs.oswego.edu/~mohammad/classes/csc241/samples/sort/Sort2-E.html

http://www.unf.edu/~wkloster/foundations/
http://www.unf.edu/~wkloster/foundations/KruskalApplet/KruskalApplet.htm

http://www.guides.sk/suuri/maxflow/mfex1.html
http://www.guides.sk/suuri/dijex4.html

http://www-cg-hci.informatik.uni-oldenburg.de/~da/peters/Kalvin/Doku-BN.htm

http://www.cut-the-knot.org/ctk/Mazes.shtml

http://carbon.cudenver.edu/~hgreenbe/sessions/dijkstra/DijkstraApplet.html

http://www.princeton.edu/~rvdb/JAVA/CIV201/shortpaths/shortpaths.html

http://olli.informatik.uni-oldenburg.de/fpsort/Animation.html


http://www2.hig.no/~algmet/animate.html (超多)
http://www2.cs.pitt.edu/~kirk/cs1501/animations/Sort2.html

http://www.dat.ruc.dk/~keld/algoritmik_e99/Applets/Chap08/ShellSort/ShellSort.html
http://www.akira.ruc.dk/~keld/algoritmik_e99/Applets/Chap08/Bubble/BubbleSort.html

http://www.akira.ruc.dk/~keld/algoritmik_e99/Applets/Chap31/GraphW/GraphW.html

2005年4月9日 星期六

postfix/spamassassin

整天都在做著很沒有意義的事。

早上把 postfix 重新整理了一下,順便升級了。下午再跟阿滑討論的情況下把 openwebmail 裡面的那個 SA 設定值弄成能動了。
大致上的問題有幾個,postfix 的 master.cf 裡邊,對於 postfixfilter 的原來設定:

postfixfilter unix - n n - - pipe flags=Rq user=nobody
argv=/usr/local/bin/spamc -d 127.0.0.1 -f -p 783 -t 30 -e /usr/local/sbin/sendmail -i -f ${sender} -- ${recipient}

要改成

postfixfilter unix - n n - - pipe flags=Rq user=nobody
argv=/usr/local/bin/spamc -d 127.0.0.1 -f -p 783 -t 30 -u ${user} -e /usr/local/sbin/sendmail -i -f ${sender} -- ${recipient}

這邊要傳入 uid ,然後在 spamd 的部分,問題是出在啟動的 flag 上:
原本是:
#spamd_flags="-d -L -m 32 -r /var/run/spamd.pid -u nobody -V /usr/local/etc/spamassassin --user-config"

我猜可能是之前升級 perl 的時候用 portupgrade -f 'p5*' 有自動升到 spamassassin ,不然不應該會有問題。升上新版後的 flag 必須弄成:
root     85135  0.0  3.1 21476 20344  ??  Is    6:46下午   0:02.09 /usr/local/bin/spamd -c -d -r /var/run/spamd.pid (suidperl)

不能夠加 -x or --user-config ,跟文件不太一樣...不過兩份文件前後寫的不太一致,應該後面的比較新, -x == --no-user-config 。所以

Apr 8 23:40:58 soul spamd[85136]: Creating default_prefs [/home/scout/55th/alin6345/.spamassassin/user_prefs]
Apr 8 23:40:58 soul spamd[85136]: Cannot write to /home/scout/55th/alin6345/.spamassassin/user_prefs: No such file or directory
Apr 8 23:40:58 soul spamd[85136]: Couldn't create readable default_prefs for [/home/scout/55th/alin6345/.spamassassin/user_prefs]
Apr 8 23:40:58 soul spamd[85136]: processing message for alin6345:1033.
Apr 8 23:41:06 soul spamd[85136]: clean message (6.9/7.5) for alin6345:1033 in 8.2 seconds, 49482 bytes.


他就會正常動作了, openwebmail 裡面設的 spamassassin rule 也能正確的使用。不過有個問題比較大的一點,能不能讓沒有 user_prefs 的傢伙自動去吃 default setting 啊?