Home » Computer » Software » OS » Archive by category "Linux" (Page 4)

在 Linux 下引用 Windows 的 DLL 檔

作者為了在 Linux 下進行安全分析而弄出來的計畫:「Porting Windows Dynamic Link Libraries to Linux」。

作者對 Windows 的架構有不少抱怨 XDDD

Distributed, scalable fuzzing on Windows can be challenging and inefficient. This is especially true for endpoint security products, which use complex interconnected components that span across kernel and user space. This often requires spinning up an entire virtualized Windows environment to fuzz them or collect coverage data.

This is less of a problem on Linux, and I've found that porting components of Windows Antivirus products to Linux is often possible. This allows me to run the code I’m testing in minimal containers with very little overhead, and easily scale up testing.

This is just personal opinion, but I also think Linux has better tools. ¯\_(ツ)_/¯

而這個專案跟 WineHQ 完整模擬不一樣,這只是給 Linux 下原生的程式使用 Windows 下 DLL 內的功能:

This project does not replace Wine or Winelib.

Winelib is used to port Windows C++ projects to Linux, and Wine is intended to run full Windows applications. This project is intended to allow native Linux code to load simple Windows DLLs.

The closest analogy would be ndiswrapper but for userspace.

作者拿了 Windows Defender 當範例,示範在 Linux 下呼叫 Windows 的 DLL...

Amazon EC2 上的 Ubuntu 的效能提昇

UbuntuAWS 合作,對 AWS 上 EC2 的 kernel 最佳化:「Ubuntu on AWS gets serious performance boost with AWS-tuned kernel」。

透過各界面拉出來的 Ubuntu 16.04 都將會是對 kernel 最佳化過的版本了:

As of March 29th, Ubuntu Cloud Images for Amazon have been enabled with the AWS-tuned Ubuntu kernel by default. The AWS-tuned Ubuntu kernel will receive the same level of support and security maintenance as all supported Ubuntu kernels for the duration of the Ubuntu 16.04 LTS.


  • Up to 30% faster kernel boot speeds, on a 15% smaller kernel package
  • Full support for Elastic Network Adapter (ENA), including the latest driver version 1.1.2, supporting up to 20 Gbps network speeds for ENA instance types (currently I3, P2, R4, X1, and m4.16xlarge)
  • Improved i3 instance class support with NVMe storage disks under high IO load
  • Increased I/O performance for i3 instances
  • Improved instance initialization with NVMe backed storage disks
  • Disabled CONFIG_NO_HZ_FULL to eliminate deadlocks on some instance types
  • Resolved CPU throttling with AWS t2.micro instances

所以先前打包好的 AMI 都要再重打一次了... @_@

在 ext4 上的 CCFS

在「Application crash consistency and performance with CCFS」這篇看到的東西。

CCFS 目標是拉高 ext4 的 data integrity,並且還是有高效能:

CCFS (the Crash-Consistent File System) is an extension to ext4 that restores ordering and weak atomicity guarantees for applications, while at the same time delivering much improved performance.

如果你需要絕對的 data integrity,你需要用 data=journal 確保資料可以在 system crash 後被 replay,預設的 data=ordered 是無法達到的,而 CCFS 也沒打算達到絕對的 data integrity,而是盡量達到。所以在測試上可以發現 CCFS 大幅改善了 data integrity:

而效能還提昇了 (喂喂):


翻了一下好像沒 open source 出來 (至少現在沒看到),來等看看有沒有人會實做出來...

Ubuntu 12.04 的在 2017 年四月後的後續維護

雖然 Ubuntu 12.04 (Precise Pangolin,一般拿 Precise 當識別代碼) 將會在 2017/04/28 結束五年的維護,而官方也建議大家升級到 14.04 (Trusty Tahr) 或是 16.04 (Xenial Xerus),但總還是會有因為種種因素而升不動的系統...

因為升級有困難而還在使用 12.04 的使用者,Ubuntu 則是提供了商業的維護合約 Ubuntu Advantage:「Introducing Ubuntu 12.04 ESM (Extended Security Maintenance)」。

Desktop 版是 $125/year (最少 50 套),VM 是 $250/year (最少 10 套),Server 是 $750/year (可單買)。


Amazon EC2 上的 gettimeofday 與 clock_gettime 的效能

看到「Two frequently used system calls are ~77% slower on AWS EC2」這篇在講 gettimeofdayclock_gettime 的效能,另外搜資料時發現應該也是作者提問的「gettimeofday() not using vDSO?」這篇。

EC2 比較新的機器上用 tsc 應該是沒問題的 (在 2015 的時候官方就這樣建議了):

it seems tsc support in Xen has improved with version 4.0 and with improved CPU support in Sandy Bridge+ platforms. Modern EC2 machines should be okay with tsc. Check Xen version using dmesg | grep "Xen version". Amazon recommended the tsc clocksource already in re:Invent 2015 (https://www.slideshare.net/AmazonWebServices/cmp402-amazon-ec2-instances-deep-dive). I'm not yet running to production with this, but the situation doesn't seem as bad as implied by packagecloud.

開了一台 t2.micro 看 /sys/devices/system/clocksource/clocksource0/current_clocksource 看起來目前是設成 xen

ubuntu@ip-172-31-22-165:~$ cat /sys/devices/system/clocksource/clocksource0/current_clocksource

在「(CMP402) Amazon EC2 Instances Deep Dive」這邊也可以看到一些資料 (page 24 與 page 25):

/usr/bin 下的工具介紹

Adventures in /usr/bin and the likes」這篇介紹了 /usr/bin 的各種工具。即使是在 FreeBSDLinux 下面混了許多年,還是看到了不少好用的工具,值得慶幸的是,至少有一個章節 (Misc) 還算熟悉...

OS 的 chrttaskset 看起來再壓榨效能的時候應該可以拿出來用。用
peekfd 不如記 strace 比較萬用...

Debugging 的 addr2line 則是學到了一招,對於還是 segfault 看起來應該會很有用...

後面 Data Manipulation 的部份其實都很值得再拿出來看,尤其是這一章的東西,沒在用常常會忘記...

把 rTorrent 跑到 Docker 裡

花了些時間研究如何把 rTorrent 丟進 Docker 裡跑,對應的設定都放在 GitHub 上的「gslin/rtorrent-docker」這邊。

使用的方式是傳入使用者的 uid 與 gid (-e USER_GID-e USER_UID),以及預期的 port (有兩個地方,一個是 -e PORT,另外一個是 -p 開 port forwarding,不然外面沒辦法直接連進來),然後把 TERM 變數丟進確保 console 的操作。剩下來把對應的目錄掛進 container 讓他可以寫入 (-v 的部份):

docker run \
    -e PORT=6991 -e TERM=${TERM} \
    -e USER_GID=`id -g` -e USER_UID=`id -u` \
    -i -p 6991:6991 -t -v "`pwd`:/srv/rtorrent" \

自己用這樣應該是夠用了... 把這串命令放到 shell 的 alias 裡面用就好了。

vm.swappiness 設成 1 或是 0 的差異

在「MongoDB System Tuning Best Practices」這份投影片裡面看到:

To avoid disk-based swap: 1 (not zero!)


‘0’ can cause unpredicted behaviour

在 kernel 的說明文件是這樣描述,設成 0 時表示只有在避免 oom 時才會 swap:

This control is used to define how aggressive the kernel will swap memory pages. Higher values will increase agressiveness, lower values decrease the amount of swap. A value of 0 instructs the kernel not to initiate swap until the amount of free and file-backed pages is less than the high water mark in a zone.

設成 1 的想法頗有趣的,來看看在 MySQL 上是不是也有同樣的情況要注意...