hv: ptirq: refine find_ptirq_entry by hashing

Refine find_ptirq_entry by hashing instead of walk each of the PTIRQ entries one by one.

Tracked-On: #4550
Signed-off-by: Li Fei1 <fei1.li@intel.com>
Acked-by: Eddie Dong<eddie.dong@Intel.com>
This commit is contained in:
Li Fei1
2020-05-14 13:31:21 +08:00
committed by wenlingz
parent 63c019c6d2
commit 53af096726
4 changed files with 100 additions and 34 deletions

View File

@@ -120,6 +120,8 @@ typedef void (*ptirq_arch_release_fn_t)(const struct ptirq_remapping_info *entry
* with interrupt handler and softirq.
*/
struct ptirq_remapping_info {
struct hlist_node phys_link;
struct hlist_node virt_link;
uint16_t ptdev_entry_id;
uint32_t intr_type;
union source_id phys_sid;
@@ -159,6 +161,22 @@ extern spinlock_t ptdev_lock;
*/
/*
* @brief Find a ptdev entry by sid
*
* param[in] intr_type interrupt type of the ptirq entry
* param[in] sid source id of the ptirq entry
* param[in] vm vm pointer of the ptirq entry if find the ptdev entry by virtual sid
*
* @retval NULL when \p when no ptirq entry match the sid
* @retval ptirq entry when \p there is available ptirq entry match the sid
*
* @pre: vm must be NULL when lookup by physical sid, otherwise,
* vm must not be NULL when lookup by virtual sid.
*/
struct ptirq_remapping_info *find_ptirq_entry(uint32_t intr_type,
const union source_id *sid, const struct acrn_vm *vm);
/**
* @brief Handler of softirq for passthrough device.
*

View File

@@ -29,10 +29,20 @@
#ifndef LIST_H_
#define LIST_H_
#include <types.h>
struct list_head {
struct list_head *next, *prev;
};
struct hlist_head {
struct hlist_node *first;
};
struct hlist_node {
struct hlist_node *next, **pprev;
};
#define INIT_LIST_HEAD(ptr) do { (ptr)->next = (ptr); (ptr)->prev = (ptr); } \
while (0)
@@ -121,4 +131,31 @@ static inline void list_splice_init(struct list_head *list,
#define get_first_item(attached, type, member) \
((type *)((char *)((attached)->next)-(uint64_t)(&((type *)0)->member)))
static inline void
hlist_del(struct hlist_node *n)
{
if (n->next != NULL) {
n->next->pprev = n->pprev;
}
*n->pprev = n->next;
}
static inline void
hlist_add_head(struct hlist_node *n, struct hlist_head *h)
{
n->next = h->first;
if (h->first != NULL) {
h->first->pprev = &n->next;
}
h->first = n;
n->pprev = &h->first;
}
#define hlist_entry(ptr, type, member) container_of(ptr,type,member)
#define hlist_for_each(pos, head) \
for (pos = (head)->first; (pos) != NULL; pos = (pos)->next)
#endif /* LIST_H_ */