sysprog
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invitee
      • No invitee
    • Publish Note

      Publish Note

      Everyone on the web can find and read all notes of this public team.
      Once published, notes can be searched and viewed by anyone online.
      See published notes
      Please check the box to agree to the Community Guidelines.
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Sharing URL Help
Menu
Options
Versions and GitHub Sync Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
Invitee
No invitee
Publish Note

Publish Note

Everyone on the web can find and read all notes of this public team.
Once published, notes can be searched and viewed by anyone online.
See published notes
Please check the box to agree to the Community Guidelines.
Engagement control
Commenting
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Suggest edit
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
Emoji Reply
Enable
Import from Dropbox Google Drive Gist Clipboard
   owned this note    owned this note      
Published Linked with GitHub
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
# 2024-04-30, 05-02 討論簡記 :::success ![image](https://hackmd.io/_uploads/S10cDraZ0.png) "**You never fail until you stop trying.**" ― Albert Einstein (當你停下嘗試的腳步,就意味著失敗) ::: ## fns 的改進 > [[PATCH] bitops: Optimize fns() for improved performance](https://lore.kernel.org/mm-commits/20240426190857.BB28FC2BD10@smtp.kernel.org/) [第 2 週測驗題](https://hackmd.io/@sysprog/linux2024-quiz2)的測驗 3:「考慮 `find_nth_bit` 可在指定的記憶體空間找出第 N 個設定的位元」,取自 Linux 核心的 `fns` 函式,引導學員提出改進。 [FNS 比較](https://hackmd.io/@david96514/HJoPc_YeR) > 延伸閱讀: [Refining Data Structure Implementations in the Linux Kernel for Improved Performance](https://youtu.be/3Wk8fZVdbZo) ## zack-404 > [Homework5](https://hackmd.io/@zack-404/2023q1Homewotk5) 第三週 - 浮點數 ``` $ python >>> 0.1 + 0.2 == 0.3 False >>> 0.1 + 0.2 0.30000000000000004 >>> 0.3 0.29999999999999999 ``` 如何讓 0.1 + 0.2 == 0.3 成立 不同語言會有不同的 $\epsilon$ 去界定相等 python: `float_info.epsilon = 2.2e-16` c++: `std::numeric_limits<float>::max_digits10 = 6` ## jimmy01240397 > [Homework1](https://hackmd.io/@Jimmy01240397/linuxkernal2024-homework1) https://github.com/torvalds/linux/blob/master/lib/list-test.c 以計算機結構來講為何會比較快: 1. 降低分支 2. cache ``` commit c0d15cc7ee8c0d1970197d9eb1727503bcdd2471 Author: Dave Jones <davej@redhat.com> Date: Tue Jul 16 22:44:08 2013 -0400 linked-list: Remove __list_for_each ``` ``` commit 75d65a425c0163d3ec476ddc12b51087217a070c Author: Linus Torvalds <torvalds@linux-foundation.org> Date: Thu May 19 13:50:07 2011 -0700 hlist: remove software prefetching in hlist iterators ``` ## 164253 ### 如何有效的測試 sort #### 背景狀況 現有的 kernel 在 lib 下有 test_sort.c 和 test_list_sort.c 兩筆測試,但觀察可以發現實作上十分簡陋,是否穩定、原地排序、最差狀況等都沒有測試,同樣的 rbtree_test.c 也沒有測試速 這點和我原先的預期差距極大,這麼大一個 linux kernel 居然連基本的時間複雜度都沒測。 #### 過於複雜的測試方法 由於考慮到潮汐現象(此處特指測試程式常因外部干擾,造成時間浮動極大),我原本提出測多種不同的資料總數,並微分且計算增長率,推斷是 $n^2$ 或 $n\log_2n$ 。 但老師指出潮汐現象在 kernel 中容易解決,只需要在測試時禁止搶占、並關掉或暫停終端等,因此不是嚴重的問題。 且對於 kernel 來說,需要的是較簡易且大致的測試,需要考慮每次測試不能有太大的時間成本,先提供較主要的測試內容,細節交由開發者處理即可。 #### 改進的方法 意料之外的,就和各類競賽一樣,由於一秒可以估算為能跑 $10^8\sim10^9$ 個運算,帶入 $n=5\times10^5$ 和 $n=10^6$ 就可大致排除 $n^2$ 的作法,且每次測試僅需一秒。 而我原先也提出可能會卡常數等問題,但可以用 linux kernel 中現有的實作估算常數。 #### kernel 中其他類似的不足 顯然的, lib 中 test 系列之程式碼都有些簡陋,例如 rbtree, hashtable 和其他常見的資料結構。 尤其 hashtable 甚至沒有對多個相同 key 的複雜度做測試。 rbtree 也仍是教科書上常見的實作方式,而不是競賽中數年前一致認定程式碼極短又簡潔、速度更快、且支援所有 treap 和 splay tree 操作的范浩強無旋 treap 。 (註:范浩強 treap 其中一個重要部分就是根據馬可夫鍊,以保證樹的平衡,也因此保證比起旋轉這種高成本的操作,用切割替代是不會造成錯誤的方法) > 先前有人提過相同的改進,但最後未獲收錄,待寫出完整測試並確認速度 #### 額外發現的效益 長期以來潮汐效應對競賽圈是非常嚴重的困擾,記憶體限制也常是用 page fault 等方式偵測,而使用者塞入惡意程式碼,更改答案或偷看測資,或者試圖癱瘓系統等問題更沒有有效的解決方法,現有處理是開一個沙箱,然後賭大家打不穿他。 lab0 中對記憶體的處理方式,以及上述的潮汐解決方法,對競賽都是有重大效益的東西。 > 額外的待解決問題:如何解決拿到 pid 後,被 kernel 回收而程式卻不知道的現象。 ## vax-r > [Homework6](https://hackmd.io/@vax-r/linux2024-homework6) `getcpu()`, `putcpu()` 如何實作? --- :::info :information_source: 若你想在課堂討論,請標示 GitHub 帳號名稱,伴隨著第五次或第六次作業的超連結。 ::: > [2024 年開放原始碼專案協作](https://hackmd.io/@sysprog/ByLJ8DUFT) ## SHChang-Anderson ## LULser0204 https://hackmd.io/@LULser/linux2024-homework5 lvalue C99 6.3.2.1 p.46 >The name ‘‘lvalue’’ comes originally from the assignment expression E1 = E2, in which the left operand E1 is required to be a (modifiable) lvalue. It is perhaps better considered as representing an object ‘‘locator value’’. What is sometimes called ‘‘rvalue’’ is in this International Standard described as the ‘‘value of an expression’’. >An obvious example of an lvalue is an identifier of an object. As a further example, if E is a unary expression that is a pointer to an object, *E is an lvalue that designates the object to which E points. ## marvin0102 ## HenryChaing 我 kernel module 無法 rmmod.

Import from clipboard

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lose their connection.

Create a note from template

Create a note from template

Oops...
This template is not available.
Upgrade
All
  • All
  • Team
No template found.

Create custom template

Upgrade

Delete template

Do you really want to delete this template?
Turn this template into a regular note and keep its content, versions, and comments.

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

By clicking below, you agree to our terms of service.

Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
Wallet ( )
Connect another wallet

New to HackMD? Sign up

Help

  • English
  • 中文
  • Français
  • Deutsch
  • 日本語
  • Español
  • Català
  • Ελληνικά
  • Português
  • italiano
  • Türkçe
  • Русский
  • Nederlands
  • hrvatski jezik
  • język polski
  • Українська
  • हिन्दी
  • svenska
  • Esperanto
  • dansk

Documents

Help & Tutorial

How to use Book mode

How to use Slide mode

API Docs

Edit in VSCode

Install browser extension

Get in Touch

Feedback

Discord

Send us email

Resources

Releases

Pricing

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions and GitHub Sync
Upgrade to Prime Plan

  • Edit version name
  • Delete

revision author avatar     named on  

More Less

No updates to save
Compare
    Choose a version
    No search result
    Version not found
Sign in to link this note to GitHub
Learn more
This note is not linked with GitHub
 

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub
      • Please sign in to GitHub and install the HackMD app on your GitHub repo.
      • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
      Learn more  Sign in to GitHub

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Include title and tags
      Available push count

      Upgrade

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Upgrade

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully