Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于ksoftirqd的解释 #5

Open
15915935280 opened this issue Nov 1, 2022 · 5 comments
Open

关于ksoftirqd的解释 #5

15915935280 opened this issue Nov 1, 2022 · 5 comments

Comments

@15915935280
Copy link

想咨询下,我之前理解的ksoftirqd进程不是 为了防止过多软中断导致用户进程处理饥饿状态的一种 策略吗?并非每次收包,都是经过它处理的吧?

@yanfeizhang
Copy link
Owner

历史上不知道是咋样的,反正现在根据源码来看每次收包确实都走了ksoftiqrd了

@shiyiyuedeyu
Copy link

shiyiyuedeyu commented Dec 12, 2023

隔了一年,这块我也看到了。软中断走ksoftirqd线程不是一定的。在触发中断后,是允许软中断的触发点发生在中断上下文,即中断上半部处理完成后可以触发软中断raise_softirq()接着去处理软中断内容。
当然内核做了很多均衡操作,比如软中断处理期间又有中断并塞入了新的软中断到队列里,内核会比如说记录软中断处理时间、当前是否有进程need_sched、软中断处理loop次数超过一定限制等一些判断条件(不同内核版本不一样),决定是否要把软中断推迟到ksoftirqd线程里面去处理。

@shiyiyuedeyu
Copy link

shiyiyuedeyu commented Dec 12, 2023

image
image
linux/v3.10.108

@shiyiyuedeyu
Copy link

还有一点的是,ksoftirqd线程PR是20,NI是0,和普通用户起的进程的等级是一样的,如果每次都在ksoftirqd线程才会处理,网络延迟会很高的。

@yanfeizhang
Copy link
Owner

ksoftirqd我一直以为是走实时调度呢,刚查看了一下,确实如@shiyiyuedeyu所说,竟然是走的完全公平调度器。

chrt -p xxx

pid 10's current scheduling policy: SCHED_OTHER
pid 10's current scheduling priority: 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants