
Exploring *BSDs: A Journey Beyond GNU/Linux Dominance
Join a research engineer as they share their experience transitioning from GNU/Linux to *BSDs like FreeBSD and OpenBSD. Discover their motivations, contributions to the *BSD community, and implementation of lscpu for *BSD environments.
Uploaded on | 0 Views
Download Presentation

Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.
E N D
Presentation Transcript
lscpu for *BSDs Xiao, Nan
Who AM I? A research engineer working in DSI. like researching techs related to computer infrastructure, such as Operating System kernel, concurrent programming, debugging, etc. Non-native English speaker, so please bear my poor oral English and grammar errors in both talk&slides.
Agenda Why *BSDs? lscpu for GNU/Linux. Implement lscpu for *BSDs. Takeaway
GNU/Linux dominates the world! Examples: The top 500 supercomputers all run GNU/Linux (please refer here): Although my previous employer (HPE) has its own Unix Operating System (HP-UX), it puts main focus on GNU/Linux. The same situation as Oracle/Solaris.
Why did I begin to use *BSDs? No special reasons, just tired of GNU/Linux is everywhere! It run on all servers in the laboratory, so I want to try different things!
FreeBSD The first *BSDs flavor which I began to get my hands dirty on is FreeBSD (since January, 2016). I wrote a simple manual (FreeBSD 101 Hacks) during that year.
OpenBSD I dived into OpenBSD last year (2017). Actually, I first learnt about OpenBSD is in 2014 (lack of money for the electricity bill, and this news sparked some discussion on Internet forums). I knew OpenBSD is famous for its security at that time.
Contribute to *BSDs Do some interesting stuff for *BSDs. Find *BSDs lack a neat command like lscpu on GNU/Linux to display CPU information (please refer stackoverflow). Implement it myself!
Physical CPU VS Logical CPU Physical CPU number = socket (1) Logical CPU number = Threads * cores * socket (1 * 2 * 1)
How does lscpu work on GNU/Linux? The source code is here. No rocket science, just read info from /proc and /sys:
Shocking news! Unfortunately, the procfs (/proc) is removed from *BSDs (At least on FreeBSD and OpenBSD. Please refer wikipedia).
sysctl(3) sysctl(3) is a library function which can get or set system information:
Example of using sysctl(3) The following is an example of getting CPU count by sysctl(3):
Get CPU info from sysctl(3) The sysctl(3) can only get limited information, and not all *BSD flavors support same options:
Get CPU info from CPUID (x86) The x86 CPU provides CPUID instruction to get CPU information. The compilers (gcc & clang) provide a __cpuid macro (the gcc s source code is here): The tedious work was reading the Intel&AMD documents to parse the returned value.
Example of using __cpuid Below is an example of getting CPU vendor from CPUID instruction:
Test Install OpenBSD/FreeBSD in virtual machines (host is GNU/Linux), and compare the result with lscpu output in host. Thanks for other developers testing on AMD CPUs (I only have Intel at hand) and other *BSDs distributions: DragonflyBSD, NetBSD, etc.
Current status The source code of lscpu for *BSDs is https://github.com/NanXiao/lscpu. Thanks for developers creating ports for FreeBSD, OpenBSD, MidnightBSD, and so on. Mainly support x86 families, not display enough info on other architectures.
A rewarding process What I have learnt: How to develop a *BSD program. The CPU knowledge, especially x86. Free/Open Source software change the world! Everyone can contribute to it: coding, testing, donating, and so forth.