From e2c1a983f972709ec67e1de294ce6c485fbe2397 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 13 Jun 2024 13:28:05 +0200 Subject: [PATCH] 5.10-stable patches added patches: f2fs-compress-fix-compression-chksum.patch rdma-hns-fix-cq-and-qp-cache-affinity.patch rdma-hns-use-mutex-instead-of-spinlock-for-ida-allocation.patch --- ...f2fs-compress-fix-compression-chksum.patch | 41 +++++++ ...dma-hns-fix-cq-and-qp-cache-affinity.patch | 100 ++++++++++++++++++ ...stead-of-spinlock-for-ida-allocation.patch | 84 +++++++++++++++ queue-5.10/series | 3 + 4 files changed, 228 insertions(+) create mode 100644 queue-5.10/f2fs-compress-fix-compression-chksum.patch create mode 100644 queue-5.10/rdma-hns-fix-cq-and-qp-cache-affinity.patch create mode 100644 queue-5.10/rdma-hns-use-mutex-instead-of-spinlock-for-ida-allocation.patch diff --git a/queue-5.10/f2fs-compress-fix-compression-chksum.patch b/queue-5.10/f2fs-compress-fix-compression-chksum.patch new file mode 100644 index 00000000000..672c69c7675 --- /dev/null +++ b/queue-5.10/f2fs-compress-fix-compression-chksum.patch @@ -0,0 +1,41 @@ +From 75e91c888989cf2df5c78b251b07de1f5052e30e Mon Sep 17 00:00:00 2001 +From: Chao Yu +Date: Wed, 9 Dec 2020 16:42:14 +0800 +Subject: f2fs: compress: fix compression chksum + +From: Chao Yu + +commit 75e91c888989cf2df5c78b251b07de1f5052e30e upstream. + +This patch addresses minor issues in compression chksum. + +Fixes: b28f047b28c5 ("f2fs: compress: support chksum") +Signed-off-by: Chao Yu +Signed-off-by: Jaegeuk Kim +Signed-off-by: Greg Kroah-Hartman +--- + fs/f2fs/compress.c | 3 +-- + fs/f2fs/compress.h | 0 + fs/f2fs/compress.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + create mode 100644 fs/f2fs/compress.h + +--- a/fs/f2fs/compress.c ++++ b/fs/f2fs/compress.c +@@ -783,7 +783,7 @@ void f2fs_decompress_pages(struct bio *b + + ret = cops->decompress_pages(dic); + +- if (!ret && fi->i_compress_flag & 1 << COMPRESS_CHKSUM) { ++ if (!ret && (fi->i_compress_flag & 1 << COMPRESS_CHKSUM)) { + u32 provided = le32_to_cpu(dic->cbuf->chksum); + u32 calculated = f2fs_crc32(sbi, dic->cbuf->cdata, dic->clen); + +@@ -796,7 +796,6 @@ void f2fs_decompress_pages(struct bio *b + provided, calculated); + } + set_sbi_flag(sbi, SBI_NEED_FSCK); +- WARN_ON_ONCE(1); + } + } + diff --git a/queue-5.10/rdma-hns-fix-cq-and-qp-cache-affinity.patch b/queue-5.10/rdma-hns-fix-cq-and-qp-cache-affinity.patch new file mode 100644 index 00000000000..ecd950dda9b --- /dev/null +++ b/queue-5.10/rdma-hns-fix-cq-and-qp-cache-affinity.patch @@ -0,0 +1,100 @@ +From 9e03dbea2b0634b21a45946b4f8097e0dc86ebe1 Mon Sep 17 00:00:00 2001 +From: Chengchang Tang +Date: Fri, 4 Aug 2023 09:27:11 +0800 +Subject: RDMA/hns: Fix CQ and QP cache affinity + +From: Chengchang Tang + +commit 9e03dbea2b0634b21a45946b4f8097e0dc86ebe1 upstream. + +Currently, the affinity between QP cache and CQ cache is not +considered when assigning QPN, it will affect the message rate of HW. + +Allocate QPN from QP cache with better CQ affinity to get better +performance. + +Fixes: 71586dd20010 ("RDMA/hns: Create QP with selected QPN for bank load balance") +Signed-off-by: Chengchang Tang +Signed-off-by: Junxian Huang +Link: https://lore.kernel.org/r/20230804012711.808069-5-huangjunxian6@hisilicon.com +Signed-off-by: Leon Romanovsky +Signed-off-by: Greg Kroah-Hartman +--- + drivers/infiniband/hw/hns/hns_roce_device.h | 2 ++ + drivers/infiniband/hw/hns/hns_roce_qp.c | 28 ++++++++++++++++++++++------ + 2 files changed, 24 insertions(+), 6 deletions(-) + +--- a/drivers/infiniband/hw/hns/hns_roce_device.h ++++ b/drivers/infiniband/hw/hns/hns_roce_device.h +@@ -122,6 +122,8 @@ + */ + #define EQ_DEPTH_COEFF 2 + ++#define CQ_BANKID_MASK GENMASK(1, 0) ++ + enum { + SERV_TYPE_RC, + SERV_TYPE_UC, +--- a/drivers/infiniband/hw/hns/hns_roce_qp.c ++++ b/drivers/infiniband/hw/hns/hns_roce_qp.c +@@ -154,14 +154,29 @@ static void hns_roce_ib_qp_event(struct + } + } + +-static u8 get_least_load_bankid_for_qp(struct hns_roce_bank *bank) ++static u8 get_affinity_cq_bank(u8 qp_bank) + { +- u32 least_load = bank[0].inuse; ++ return (qp_bank >> 1) & CQ_BANKID_MASK; ++} ++ ++static u8 get_least_load_bankid_for_qp(struct ib_qp_init_attr *init_attr, ++ struct hns_roce_bank *bank) ++{ ++#define INVALID_LOAD_QPNUM 0xFFFFFFFF ++ struct ib_cq *scq = init_attr->send_cq; ++ u32 least_load = INVALID_LOAD_QPNUM; ++ unsigned long cqn = 0; + u8 bankid = 0; + u32 bankcnt; + u8 i; + +- for (i = 1; i < HNS_ROCE_QP_BANK_NUM; i++) { ++ if (scq) ++ cqn = to_hr_cq(scq)->cqn; ++ ++ for (i = 0; i < HNS_ROCE_QP_BANK_NUM; i++) { ++ if (scq && (get_affinity_cq_bank(i) != (cqn & CQ_BANKID_MASK))) ++ continue; ++ + bankcnt = bank[i].inuse; + if (bankcnt < least_load) { + least_load = bankcnt; +@@ -193,7 +208,8 @@ static int alloc_qpn_with_bankid(struct + + return 0; + } +-static int alloc_qpn(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp) ++static int alloc_qpn(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp, ++ struct ib_qp_init_attr *init_attr) + { + struct hns_roce_qp_table *qp_table = &hr_dev->qp_table; + unsigned long num = 0; +@@ -211,7 +227,7 @@ static int alloc_qpn(struct hns_roce_dev + hr_qp->doorbell_qpn = 1; + } else { + mutex_lock(&qp_table->bank_mutex); +- bankid = get_least_load_bankid_for_qp(qp_table->bank); ++ bankid = get_least_load_bankid_for_qp(init_attr, qp_table->bank); + + ret = alloc_qpn_with_bankid(&qp_table->bank[bankid], bankid, + &num); +@@ -1005,7 +1021,7 @@ static int hns_roce_create_qp_common(str + goto err_db; + } + +- ret = alloc_qpn(hr_dev, hr_qp); ++ ret = alloc_qpn(hr_dev, hr_qp, init_attr); + if (ret) { + ibdev_err(ibdev, "failed to alloc QPN, ret = %d.\n", ret); + goto err_buf; diff --git a/queue-5.10/rdma-hns-use-mutex-instead-of-spinlock-for-ida-allocation.patch b/queue-5.10/rdma-hns-use-mutex-instead-of-spinlock-for-ida-allocation.patch new file mode 100644 index 00000000000..b08425eb9bd --- /dev/null +++ b/queue-5.10/rdma-hns-use-mutex-instead-of-spinlock-for-ida-allocation.patch @@ -0,0 +1,84 @@ +From 9293d3fcb70583f2c786f04ca788af026b7c4c5c Mon Sep 17 00:00:00 2001 +From: Yangyang Li +Date: Tue, 19 Jan 2021 17:28:33 +0800 +Subject: RDMA/hns: Use mutex instead of spinlock for ida allocation + +From: Yangyang Li + +commit 9293d3fcb70583f2c786f04ca788af026b7c4c5c upstream. + +GFP_KERNEL may cause ida_alloc_range() to sleep, but the spinlock covering +this function is not allowed to sleep, so the spinlock needs to be changed +to mutex. + +As there is a certain chance of memory allocation failure, GFP_ATOMIC is +not suitable for QP allocation scenarios. + +Fixes: 71586dd20010 ("RDMA/hns: Create QP with selected QPN for bank load balance") +Link: https://lore.kernel.org/r/1611048513-28663-1-git-send-email-liweihang@huawei.com +Signed-off-by: Yangyang Li +Signed-off-by: Weihang Li +Signed-off-by: Jason Gunthorpe +Signed-off-by: Greg Kroah-Hartman +--- + drivers/infiniband/hw/hns/hns_roce_device.h | 2 +- + drivers/infiniband/hw/hns/hns_roce_qp.c | 11 ++++++----- + 2 files changed, 7 insertions(+), 6 deletions(-) + +--- a/drivers/infiniband/hw/hns/hns_roce_device.h ++++ b/drivers/infiniband/hw/hns/hns_roce_device.h +@@ -537,7 +537,7 @@ struct hns_roce_qp_table { + struct hns_roce_hem_table sccc_table; + struct mutex scc_mutex; + struct hns_roce_bank bank[HNS_ROCE_QP_BANK_NUM]; +- spinlock_t bank_lock; ++ struct mutex bank_mutex; + }; + + struct hns_roce_cq_table { +--- a/drivers/infiniband/hw/hns/hns_roce_qp.c ++++ b/drivers/infiniband/hw/hns/hns_roce_qp.c +@@ -210,7 +210,7 @@ static int alloc_qpn(struct hns_roce_dev + + hr_qp->doorbell_qpn = 1; + } else { +- spin_lock(&qp_table->bank_lock); ++ mutex_lock(&qp_table->bank_mutex); + bankid = get_least_load_bankid_for_qp(qp_table->bank); + + ret = alloc_qpn_with_bankid(&qp_table->bank[bankid], bankid, +@@ -218,12 +218,12 @@ static int alloc_qpn(struct hns_roce_dev + if (ret) { + ibdev_err(&hr_dev->ib_dev, + "failed to alloc QPN, ret = %d\n", ret); +- spin_unlock(&qp_table->bank_lock); ++ mutex_unlock(&qp_table->bank_mutex); + return ret; + } + + qp_table->bank[bankid].inuse++; +- spin_unlock(&qp_table->bank_lock); ++ mutex_unlock(&qp_table->bank_mutex); + + hr_qp->doorbell_qpn = (u32)num; + } +@@ -409,9 +409,9 @@ static void free_qpn(struct hns_roce_dev + + ida_free(&hr_dev->qp_table.bank[bankid].ida, hr_qp->qpn >> 3); + +- spin_lock(&hr_dev->qp_table.bank_lock); ++ mutex_lock(&hr_dev->qp_table.bank_mutex); + hr_dev->qp_table.bank[bankid].inuse--; +- spin_unlock(&hr_dev->qp_table.bank_lock); ++ mutex_unlock(&hr_dev->qp_table.bank_mutex); + } + + static int set_rq_size(struct hns_roce_dev *hr_dev, struct ib_qp_cap *cap, +@@ -1358,6 +1358,7 @@ int hns_roce_init_qp_table(struct hns_ro + unsigned int i; + + mutex_init(&qp_table->scc_mutex); ++ mutex_init(&qp_table->bank_mutex); + xa_init(&hr_dev->qp_table_xa); + + reserved_from_bot = hr_dev->caps.reserved_qps; diff --git a/queue-5.10/series b/queue-5.10/series index db667f53ba1..2f71c4ef652 100644 --- a/queue-5.10/series +++ b/queue-5.10/series @@ -312,3 +312,6 @@ s390-ap-fix-crash-in-ap-internal-function-modify_bitmap.patch nfs-fix-undefined-behavior-in-nfs_block_bits.patch nfs-fix-read_plus-when-server-doesn-t-support-op_read_plus.patch scsi-ufs-ufs-qcom-clear-qunipro_g4_sel-for-hw-major-version-5.patch +f2fs-compress-fix-compression-chksum.patch +rdma-hns-use-mutex-instead-of-spinlock-for-ida-allocation.patch +rdma-hns-fix-cq-and-qp-cache-affinity.patch -- 2.47.3