Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

crypto: hisilicon/qm - optimize device selection priority based on queue ref count and NUMA distance

Add device sorting criteria to prioritize devices with fewer
references and closer NUMA distances. Devices that are fully
occupied will not be prioritized for use.

Signed-off-by: Chenghai Huang <huangchenghai2@huawei.com>
Signed-off-by: Weili Qian <qianweili@huawei.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Chenghai Huang and committed by
Herbert Xu
2a75dece 47054897

+25 -10
+25 -10
drivers/crypto/hisilicon/qm.c
··· 3617 3617 } 3618 3618 EXPORT_SYMBOL_GPL(hisi_qm_free_qps); 3619 3619 3620 + static void qm_insert_sorted(struct list_head *head, struct hisi_qm_resource *res) 3621 + { 3622 + struct hisi_qm_resource *tmp; 3623 + struct list_head *n = head; 3624 + 3625 + list_for_each_entry(tmp, head, list) { 3626 + if (res->distance < tmp->distance) { 3627 + n = &tmp->list; 3628 + break; 3629 + } 3630 + } 3631 + list_add_tail(&res->list, n); 3632 + } 3633 + 3620 3634 static void free_list(struct list_head *head) 3621 3635 { 3622 3636 struct hisi_qm_resource *res, *tmp; ··· 3686 3672 static int hisi_qm_sort_devices(int node, struct list_head *head, 3687 3673 struct hisi_qm_list *qm_list) 3688 3674 { 3689 - struct hisi_qm_resource *res, *tmp; 3675 + struct hisi_qm_resource *res; 3690 3676 struct hisi_qm *qm; 3691 - struct list_head *n; 3692 3677 struct device *dev; 3693 3678 int dev_node; 3679 + LIST_HEAD(non_full_list); 3680 + LIST_HEAD(full_list); 3694 3681 3695 3682 list_for_each_entry(qm, &qm_list->list, list) { 3696 3683 dev = &qm->pdev->dev; ··· 3706 3691 3707 3692 res->qm = qm; 3708 3693 res->distance = node_distance(dev_node, node); 3709 - n = head; 3710 - list_for_each_entry(tmp, head, list) { 3711 - if (res->distance < tmp->distance) { 3712 - n = &tmp->list; 3713 - break; 3714 - } 3715 - } 3716 - list_add_tail(&res->list, n); 3694 + 3695 + if (qm->qp_in_used == qm->qp_num) 3696 + qm_insert_sorted(&full_list, res); 3697 + else 3698 + qm_insert_sorted(&non_full_list, res); 3717 3699 } 3700 + 3701 + list_splice_tail(&non_full_list, head); 3702 + list_splice_tail(&full_list, head); 3718 3703 3719 3704 return 0; 3720 3705 }