From: Chenghai Huang <huangchenghai2@huawei.com>
To: <herbert@gondor.apana.org.au>, <davem@davemloft.net>
Cc: <linux-kernel@vger.kernel.org>, <linux-crypto@vger.kernel.org>,
<fanghao11@huawei.com>, <liulongfang@huawei.com>,
<qianweili@huawei.com>, <linwenkai6@hisilicon.com>,
<wangzhou1@hisilicon.com>, <lizhi206@huawei.com>,
<taoqi10@huawei.com>
Subject: [PATCH v4 08/11] crypto: hisilicon/qm - optimize device selection priority based on queue ref count and NUMA distance
Date: Thu, 18 Dec 2025 21:44:49 +0800 [thread overview]
Message-ID: <20251218134452.1125469-9-huangchenghai2@huawei.com> (raw)
In-Reply-To: <20251218134452.1125469-1-huangchenghai2@huawei.com>
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>
---
drivers/crypto/hisilicon/qm.c | 35 +++++++++++++++++++++++++----------
1 file changed, 25 insertions(+), 10 deletions(-)
diff --git a/drivers/crypto/hisilicon/qm.c b/drivers/crypto/hisilicon/qm.c
index 3883b6176213..7b9ef40ee5c9 100644
--- a/drivers/crypto/hisilicon/qm.c
+++ b/drivers/crypto/hisilicon/qm.c
@@ -3592,6 +3592,20 @@ void hisi_qm_free_qps(struct hisi_qp **qps, int qp_num)
}
EXPORT_SYMBOL_GPL(hisi_qm_free_qps);
+static void qm_insert_sorted(struct list_head *head, struct hisi_qm_resource *res)
+{
+ struct hisi_qm_resource *tmp;
+ struct list_head *n = head;
+
+ list_for_each_entry(tmp, head, list) {
+ if (res->distance < tmp->distance) {
+ n = &tmp->list;
+ break;
+ }
+ }
+ list_add_tail(&res->list, n);
+}
+
static void free_list(struct list_head *head)
{
struct hisi_qm_resource *res, *tmp;
@@ -3647,11 +3661,12 @@ static int qm_get_and_start_qp(struct hisi_qm *qm, int qp_num, struct hisi_qp **
static int hisi_qm_sort_devices(int node, struct list_head *head,
struct hisi_qm_list *qm_list)
{
- struct hisi_qm_resource *res, *tmp;
+ struct hisi_qm_resource *res;
struct hisi_qm *qm;
- struct list_head *n;
struct device *dev;
int dev_node;
+ LIST_HEAD(non_full_list);
+ LIST_HEAD(full_list);
list_for_each_entry(qm, &qm_list->list, list) {
dev = &qm->pdev->dev;
@@ -3666,16 +3681,16 @@ static int hisi_qm_sort_devices(int node, struct list_head *head,
res->qm = qm;
res->distance = node_distance(dev_node, node);
- n = head;
- list_for_each_entry(tmp, head, list) {
- if (res->distance < tmp->distance) {
- n = &tmp->list;
- break;
- }
- }
- list_add_tail(&res->list, n);
+
+ if (qm->qp_in_used == qm->qp_num)
+ qm_insert_sorted(&full_list, res);
+ else
+ qm_insert_sorted(&non_full_list, res);
}
+ list_splice_tail(&non_full_list, head);
+ list_splice_tail(&full_list, head);
+
return 0;
}
--
2.33.0
next prev parent reply other threads:[~2025-12-18 13:45 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-18 13:44 [PATCH v4 00/11] crypto: hisilicon - add fallback function for hisilicon accelerater driver Chenghai Huang
2025-12-18 13:44 ` [PATCH v4 01/11] crypto: hisilicon/zip - adjust the way to obtain the req in the callback function Chenghai Huang
2025-12-18 13:44 ` [PATCH v4 02/11] crypto: hisilicon/sec - move backlog management to qp and store sqe in qp for callback Chenghai Huang
2025-12-18 13:44 ` [PATCH v4 03/11] crypto: hisilicon/hpre: extend tag field to 64 bits for better performance Chenghai Huang
2025-12-18 13:44 ` [PATCH v4 04/11] crypto: hisilicon/qm - enhance the configuration of req_type in queue attributes Chenghai Huang
2025-12-18 13:44 ` [PATCH v4 05/11] crypto: hisilicon/qm - centralize the sending locks of each module into qm Chenghai Huang
2025-12-18 13:44 ` [PATCH v4 06/11] crypto: hisilicon - consolidate qp creation and start in hisi_qm_alloc_qps_node Chenghai Huang
2025-12-18 13:44 ` [PATCH v4 07/11] crypto: hisilicon/qm - add reference counting to queues for tfm kernel reuse Chenghai Huang
2025-12-18 13:44 ` Chenghai Huang [this message]
2025-12-18 13:44 ` [PATCH v4 09/11] crypto: hisilicon/zip - support fallback for zip Chenghai Huang
2025-12-18 13:44 ` [PATCH v4 10/11] crypto: hisilicon/hpre - support the hpre algorithm fallback Chenghai Huang
2025-12-18 13:44 ` [PATCH v4 11/11] crypto: hisilicon/sec2 - support skcipher/aead fallback for hardware queue unavailable Chenghai Huang
2026-01-16 6:05 ` [PATCH v4 00/11] crypto: hisilicon - add fallback function for hisilicon accelerater driver Herbert Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251218134452.1125469-9-huangchenghai2@huawei.com \
--to=huangchenghai2@huawei.com \
--cc=davem@davemloft.net \
--cc=fanghao11@huawei.com \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linwenkai6@hisilicon.com \
--cc=liulongfang@huawei.com \
--cc=lizhi206@huawei.com \
--cc=qianweili@huawei.com \
--cc=taoqi10@huawei.com \
--cc=wangzhou1@hisilicon.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®