Linux kernel 软中断机制之触发软中断执行

在前面介绍中,我们知道如何对软中断的简单初始化,软中断需要触发,然后软中断处理函数才能被执行:
 
内核提供__raise_softirq_irqoff()类函数对指定的软中设置标志位。与此相关的函数还有:
 
raise_softirq_irqoff()local中断已经关闭,对软中设置标识位,并且在非中断上下文,唤醒软中处理的内核线程softirqd。
raise_softirq() 在此函数中关闭local中断,之后对软中断标识位设置。
__raise_softirq_irqoff() local中断已经关闭,对指定软中断设置标志位。
 
这里需要关注一下对标识位的存储,从当前内核实现来看,这个是与体系结构相关,如果体系没有实现,则采用一个默认的实现
即在前面的irq_stat中定义成员,即使用__softirq_pending来跟踪设置的softirq标识。
 
通用定义如下:
include/asm-generic/hardirq.h
typedef struct {
 unsigned int __softirq_pending;
} ____cacheline_aligned irq_cpustat_t;
 
 
arch/x86/include/asm/hardirq.h

typedef struct {  unsigned int __softirq_pending;  unsigned int __nmi_count; /* arch dependent */ #ifdef CONFIG_X86_LOCAL_APIC  unsigned int apic_timer_irqs; /* arch dependent */  unsigned int irq_spurious_count;  unsigned int icr_read_retry_count; #endif #ifdef CONFIG_HAVE_KVM  unsigned int kvm_posted_intr_ipis;  unsigned int kvm_posted_intr_wakeup_ipis; #endif  unsigned int x86_platform_ipis; /* arch dependent */  unsigned int apic_perf_irqs;  unsigned int apic_irq_work_irqs; #ifdef CONFIG_SMP  unsigned int irq_resched_count;  unsigned int irq_call_count;  unsigned int irq_tlb_count; #endif #ifdef CONFIG_X86_THERMAL_VECTOR  unsigned int irq_thermal_count; #endif #ifdef CONFIG_X86_MCE_THRESHOLD  unsigned int irq_threshold_count; #endif #ifdef CONFIG_X86_MCE_AMD  unsigned int irq_deferred_error_count; #endif #if IS_ENABLED(CONFIG_HYPERV) || defined(CONFIG_XEN)  unsigned int irq_hv_callback_count; #endif }irq_cpustat_t;

DECLARE_PER_CPU_SHARED_ALIGNED(irq_cpustat_t, irq_stat);

arch/arm/include/asm/hardirq.h

typedef struct {  unsigned int __softirq_pending; #ifdef CONFIG_SMP  unsigned int ipi_irqs[NR_IPI]; #endif } irq_cpustat_t;

 

arch/arm64/include/asm/hardirq.h

typedef struct {  unsigned int __softirq_pending;  unsigned int ipi_irqs[NR_IPI]; } irq_cpustat_t;

 
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值