Repository navigation
Conversation
硬中断处理函数只屏蔽网卡中断并调度 NAPI,并不会立即恢复中断;恢复中断发生在软中断 poll 调用 napi_complete 之后。原文把“恢复中断”归到硬中断处理函数有误。 Closes xiaolincoder#362
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
修正 Linux 协议栈收包章节中关于「硬件中断处理函数恢复中断」的时机描述。
Why
Closes #362 —— 原文在「硬件中断处理函数会做如下的事情」下列了:
这与现代 Linux 的 NAPI(中断+轮询)机制不符。NAPI 下,硬件中断处理函数只做两件事:屏蔽该网卡中断 + 通过
napi_schedule()调度软中断(NET_RX_SOFTIRQ),并不会立即恢复中断就返回。网卡的硬件中断会一直保持屏蔽,直到软中断上下文里的 NAPI poll 函数把 Ring Buffer 中的网络包轮询处理完、调用napi_complete()收尾后,才重新开启中断。若硬中断一退出就恢复中断,软中断(下半部)可能还没被调度执行,下一个包就在几微秒内再次触发硬中断,打断正在排队/执行的软中断,CPU 退化为纯中断模式,甚至可能中断风暴、Ring Buffer 爆满。
权威佐证(多来源一致):
napi_schedule()+my_nic_mask_irq()(屏蔽中断)后返回;poll 函数末尾napi_complete_done()才 re-enable 中断。disable_device_interrupts()+napi_schedule();Poll 函数末尾napi_complete()+enable_device_interrupts()。How
将
network/1_base/how_os_deal_network_package.md中该 bullet 改为:硬中断处理函数不会立刻恢复中断,恢复动作发生在软中断 poll 完成(napi_complete)之后。仅改这一句,未改动其他内容、未触及图片或结构。Verification
search/issues?q=repo:xiaolincoder/CS-Base+type:pr+362无伴生 PR(issue 0 评论、无 assignee、长期无人认领,现补修)。