hv: softirq: refine softirq

1. add register_softirq to register a softirq handler
2. rename exec_softirq to do_softirq; raise_softirq to fire_softirq.
3. in do_softirq call registered softirq handler not call
the device softirq handle function directly
4. enable irq after vm exit and disable irq after the first
call do_softirq before vm enter.
5. call do_softirq again when irq disabled to handle the risk
unhandled softirq.
6. rename SOFTIRQ_DEV_ASSIGN to SOFTIRQ_PTDEV
7. remove SOFTIRQ_ATOMIC

Signed-off-by: Li, Fei1 <fei1.li@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Li, Fei1
2018-07-30 15:58:36 +08:00
committed by lijinxia
parent 073583cc41
commit 457ecd6ef7
8 changed files with 82 additions and 122 deletions

View File

@@ -5,6 +5,7 @@
*/
#include <hypervisor.h>
#include <softirq.h>
static spinlock_t exception_spinlock = { .head = 0U, .tail = 0U, };

View File

@@ -27,7 +27,7 @@ static void run_timer(struct hv_timer *timer)
/* run in interrupt context */
static int tsc_deadline_handler(__unused int irq, __unused void *data)
{
raise_softirq(SOFTIRQ_TIMER);
fire_softirq(SOFTIRQ_TIMER);
return 0;
}
@@ -156,33 +156,7 @@ static void init_tsc_deadline_timer(void)
msr_write(MSR_IA32_TSC_DEADLINE, 0UL);
}
void timer_init(void)
{
char name[32] = {0};
uint16_t pcpu_id = get_cpu_id();
snprintf(name, 32, "timer_tick[%hu]", pcpu_id);
if (request_timer_irq(pcpu_id, tsc_deadline_handler, NULL, name) < 0) {
pr_err("Timer setup failed");
return;
}
init_tsc_deadline_timer();
init_percpu_timer(pcpu_id);
}
void timer_cleanup(void)
{
uint16_t pcpu_id = get_cpu_id();
if (per_cpu(timer_node, pcpu_id) != NULL) {
unregister_handler_common(per_cpu(timer_node, pcpu_id));
}
per_cpu(timer_node, pcpu_id) = NULL;
}
void timer_softirq(uint16_t pcpu_id)
static void timer_softirq(uint16_t pcpu_id)
{
struct per_cpu_timers *cpu_timer;
struct hv_timer *timer;
@@ -222,6 +196,34 @@ void timer_softirq(uint16_t pcpu_id)
update_physical_timer(cpu_timer);
}
void timer_init(void)
{
char name[32] = {0};
uint16_t pcpu_id = get_cpu_id();
init_percpu_timer(pcpu_id);
register_softirq(SOFTIRQ_TIMER, timer_softirq);
snprintf(name, 32, "timer_tick[%hu]", pcpu_id);
if (request_timer_irq(pcpu_id, tsc_deadline_handler, NULL, name) < 0) {
pr_err("Timer setup failed");
return;
}
init_tsc_deadline_timer();
}
void timer_cleanup(void)
{
uint16_t pcpu_id = get_cpu_id();
if (per_cpu(timer_node, pcpu_id) != NULL) {
unregister_handler_common(per_cpu(timer_node, pcpu_id));
}
per_cpu(timer_node, pcpu_id) = NULL;
}
void check_tsc(void)
{
uint64_t temp64;

View File

@@ -216,11 +216,11 @@ int vmexit_handler(struct vcpu *vcpu)
/* Handling external_interrupt
* should disable intr
*/
ret = dispatch->handler(vcpu);
} else {
CPU_IRQ_ENABLE();
ret = dispatch->handler(vcpu);
CPU_IRQ_DISABLE();
ret = dispatch->handler(vcpu);
CPU_IRQ_ENABLE();
} else {
ret = dispatch->handler(vcpu);
}
return ret;