mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-08-03 17:31:42 +00:00
HV: modify code for intr storm detect & handling
This patch is to enhance the feature of "interrupt storm mitigation"; when interrupt storm happens on one UOS it should keep as smaller effect to SOS as possible. Add variables in PTdev entry & VM, used to record one UOS's pass-thru devices' interrupt data; add a function to collect the data. Also add a timer used to delay UOS pass-thru devices' interrupt injection if an "interrupt storm" detected by SOS. Tracked-On: #866 Signed-off-by: Minggui Cao <minggui.cao@intel.com> Reviewed-by: Li Fei1 <fei1.li@intel.com> Acked-by: Anthony Xu <anthony.xu@intel.com>
This commit is contained in:
parent
de68ee7a09
commit
918403f925
@ -187,6 +187,7 @@ int create_vm(struct vm_description *vm_desc, struct vm **rtn_vm)
|
|||||||
|
|
||||||
INIT_LIST_HEAD(&vm->softirq_dev_entry_list);
|
INIT_LIST_HEAD(&vm->softirq_dev_entry_list);
|
||||||
spinlock_init(&vm->softirq_dev_lock);
|
spinlock_init(&vm->softirq_dev_lock);
|
||||||
|
vm->intr_inject_delay_delta = 0UL;
|
||||||
|
|
||||||
/* Set up IO bit-mask such that VM exit occurs on
|
/* Set up IO bit-mask such that VM exit occurs on
|
||||||
* selected IO ranges
|
* selected IO ranges
|
||||||
|
@ -36,6 +36,14 @@ static void ptdev_enqueue_softirq(struct ptdev_remapping_info *entry)
|
|||||||
fire_softirq(SOFTIRQ_PTDEV);
|
fire_softirq(SOFTIRQ_PTDEV);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void ptdev_intr_delay_callback(void *data)
|
||||||
|
{
|
||||||
|
struct ptdev_remapping_info *entry =
|
||||||
|
(struct ptdev_remapping_info *) data;
|
||||||
|
|
||||||
|
ptdev_enqueue_softirq(entry);
|
||||||
|
}
|
||||||
|
|
||||||
struct ptdev_remapping_info*
|
struct ptdev_remapping_info*
|
||||||
ptdev_dequeue_softirq(struct vm *vm)
|
ptdev_dequeue_softirq(struct vm *vm)
|
||||||
{
|
{
|
||||||
@ -44,10 +52,20 @@ ptdev_dequeue_softirq(struct vm *vm)
|
|||||||
|
|
||||||
spinlock_irqsave_obtain(&vm->softirq_dev_lock, &rflags);
|
spinlock_irqsave_obtain(&vm->softirq_dev_lock, &rflags);
|
||||||
|
|
||||||
if (!list_empty(&vm->softirq_dev_entry_list)) {
|
while (!list_empty(&vm->softirq_dev_entry_list)) {
|
||||||
entry = get_first_item(&vm->softirq_dev_entry_list,
|
entry = get_first_item(&vm->softirq_dev_entry_list,
|
||||||
struct ptdev_remapping_info, softirq_node);
|
struct ptdev_remapping_info, softirq_node);
|
||||||
|
|
||||||
list_del_init(&entry->softirq_node);
|
list_del_init(&entry->softirq_node);
|
||||||
|
|
||||||
|
/* if vm0, just dequeue, if uos, check delay timer */
|
||||||
|
if (is_vm0(entry->vm) ||
|
||||||
|
timer_expired(&entry->intr_delay_timer)) {
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
/* add it into timer list; dequeue next one */
|
||||||
|
(void)add_timer(&entry->intr_delay_timer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
spinlock_irqrestore_release(&vm->softirq_dev_lock, rflags);
|
spinlock_irqrestore_release(&vm->softirq_dev_lock, rflags);
|
||||||
@ -69,6 +87,10 @@ alloc_entry(struct vm *vm, uint32_t intr_type)
|
|||||||
INIT_LIST_HEAD(&entry->softirq_node);
|
INIT_LIST_HEAD(&entry->softirq_node);
|
||||||
INIT_LIST_HEAD(&entry->entry_node);
|
INIT_LIST_HEAD(&entry->entry_node);
|
||||||
|
|
||||||
|
entry->intr_count = 0UL;
|
||||||
|
initialize_timer(&entry->intr_delay_timer, ptdev_intr_delay_callback,
|
||||||
|
entry, 0UL, 0, 0UL);
|
||||||
|
|
||||||
atomic_clear32(&entry->active, ACTIVE_FLAG);
|
atomic_clear32(&entry->active, ACTIVE_FLAG);
|
||||||
list_add(&entry->entry_node, &ptdev_list);
|
list_add(&entry->entry_node, &ptdev_list);
|
||||||
|
|
||||||
@ -116,6 +138,22 @@ static void ptdev_interrupt_handler(__unused uint32_t irq, void *data)
|
|||||||
struct ptdev_remapping_info *entry =
|
struct ptdev_remapping_info *entry =
|
||||||
(struct ptdev_remapping_info *) data;
|
(struct ptdev_remapping_info *) data;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* "interrupt storm" detection & delay intr injection just for UOS
|
||||||
|
* pass-thru devices, collect its data and delay injection if needed
|
||||||
|
*/
|
||||||
|
if (!is_vm0(entry->vm)) {
|
||||||
|
entry->intr_count++;
|
||||||
|
|
||||||
|
/* if delta > 0, set the delay TSC, dequeue to handle */
|
||||||
|
if (entry->vm->intr_inject_delay_delta > 0UL) {
|
||||||
|
entry->intr_delay_timer.fire_tsc = rdtsc() +
|
||||||
|
entry->vm->intr_inject_delay_delta;
|
||||||
|
} else {
|
||||||
|
entry->intr_delay_timer.fire_tsc = 0UL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ptdev_enqueue_softirq(entry);
|
ptdev_enqueue_softirq(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,3 +207,27 @@ void ptdev_release_all_entries(struct vm *vm)
|
|||||||
release_all_entries(vm);
|
release_all_entries(vm);
|
||||||
spinlock_release(&ptdev_lock);
|
spinlock_release(&ptdev_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t get_vm_ptdev_intr_data(const struct vm *target_vm, uint64_t *buffer,
|
||||||
|
uint32_t buffer_cnt)
|
||||||
|
{
|
||||||
|
uint32_t index = 0U;
|
||||||
|
struct ptdev_remapping_info *entry;
|
||||||
|
struct list_head *pos, *tmp;
|
||||||
|
|
||||||
|
list_for_each_safe(pos, tmp, &ptdev_list) {
|
||||||
|
entry = list_entry(pos, struct ptdev_remapping_info,
|
||||||
|
entry_node);
|
||||||
|
if (entry->vm == target_vm) {
|
||||||
|
buffer[index] = entry->allocated_pirq;
|
||||||
|
buffer[index + 1U] = entry->intr_count;
|
||||||
|
|
||||||
|
index += 2U;
|
||||||
|
if (index >= buffer_cnt) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
@ -173,6 +173,7 @@ struct vm {
|
|||||||
|
|
||||||
spinlock_t softirq_dev_lock;
|
spinlock_t softirq_dev_lock;
|
||||||
struct list_head softirq_dev_entry_list;
|
struct list_head softirq_dev_entry_list;
|
||||||
|
uint64_t intr_inject_delay_delta; /* delay of intr injection */
|
||||||
} __aligned(CPU_PAGE_SIZE);
|
} __aligned(CPU_PAGE_SIZE);
|
||||||
|
|
||||||
#ifdef CONFIG_PARTITION_MODE
|
#ifdef CONFIG_PARTITION_MODE
|
||||||
|
@ -48,6 +48,11 @@ static inline void initialize_timer(struct hv_timer *timer,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline bool timer_expired(const struct hv_timer *timer)
|
||||||
|
{
|
||||||
|
return ((timer->fire_tsc == 0UL) || (rdtsc() >= timer->fire_tsc));
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Don't call add_timer/del_timer in the timer callback function.
|
* Don't call add_timer/del_timer in the timer callback function.
|
||||||
*/
|
*/
|
||||||
|
@ -61,6 +61,9 @@ struct ptdev_remapping_info {
|
|||||||
struct list_head softirq_node;
|
struct list_head softirq_node;
|
||||||
struct list_head entry_node;
|
struct list_head entry_node;
|
||||||
struct ptdev_msi_info msi;
|
struct ptdev_msi_info msi;
|
||||||
|
|
||||||
|
uint64_t intr_count;
|
||||||
|
struct hv_timer intr_delay_timer; /* used for delay intr injection */
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct list_head ptdev_list;
|
extern struct list_head ptdev_list;
|
||||||
@ -83,4 +86,7 @@ void ptdev_deactivate_entry(struct ptdev_remapping_info *entry);
|
|||||||
void get_ptdev_info(char *str_arg, int str_max);
|
void get_ptdev_info(char *str_arg, int str_max);
|
||||||
#endif /* HV_DEBUG */
|
#endif /* HV_DEBUG */
|
||||||
|
|
||||||
|
uint32_t get_vm_ptdev_intr_data(const struct vm *target_vm, uint64_t *buffer,
|
||||||
|
uint32_t buffer_cnt);
|
||||||
|
|
||||||
#endif /* PTDEV_H */
|
#endif /* PTDEV_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user