
From: Guangguan Wang <guangguan.wang@linux.alibaba.com> mainline inclusion from mainline-v6.11-rc1 commit 3ac14b9dfbd345e891d48d89f6c2fa519848f0f4 category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/IC914B Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?i... -------------------------------- SG_MAX_SINGLE_ALLOC is used to limit maximum number of entries that will be allocated in one piece of scatterlist. When the entries of scatterlist exceeds SG_MAX_SINGLE_ALLOC, sg chain will be used. From commit 7c703e54cc71 ("arch: switch the default on ARCH_HAS_SG_CHAIN"), we can know that the macro CONFIG_ARCH_NO_SG_CHAIN is used to identify whether sg chain is supported. So, SMC-R's rmb buffer should be limited by SG_MAX_SINGLE_ALLOC only when the macro CONFIG_ARCH_NO_SG_CHAIN is defined. Fixes: a3fe3d01bd0d ("net/smc: introduce sg-logic for RMBs") Signed-off-by: Guangguan Wang <guangguan.wang@linux.alibaba.com> Co-developed-by: Wen Gu <guwen@linux.alibaba.com> Signed-off-by: Wen Gu <guwen@linux.alibaba.com> Signed-off-by: David S. Miller <davem@davemloft.net> Conflicts: net/smc/smc_core.c [conflicts due to merged euleros 0b7bbc12d17f ("net/smc: Tune the maximum size of virtually contiguous sndbufs or RMBs for SMC-R")] Signed-off-by: Wang Liang <wangliang74@huawei.com> --- net/smc/smc_core.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/net/smc/smc_core.c b/net/smc/smc_core.c index 56b4c3dfec40..a693a5e55aa2 100644 --- a/net/smc/smc_core.c +++ b/net/smc/smc_core.c @@ -2004,8 +2004,10 @@ int smc_conn_create(struct smc_sock *smc, struct smc_init_info *ini) */ static u8 smc_compress_bufsize(struct smc_link_group *lgr, int size, bool is_smcd, bool is_rmb) { - const unsigned int max_scat = SG_MAX_SINGLE_ALLOC * PAGE_SIZE; - u8 compressed, max_phy_compressed; + u8 compressed; +#ifdef CONFIG_ARCH_NO_SG_CHAIN + u8 max_phy_compressed; +#endif if (size <= SMC_BUF_MIN_SIZE) return 0; @@ -2014,8 +2016,9 @@ static u8 smc_compress_bufsize(struct smc_link_group *lgr, int size, bool is_smc compressed = min_t(u8, ilog2(size) + 1, is_smcd ? SMCD_DMBE_SIZES : SMCR_RMBE_SIZES); +#ifdef CONFIG_ARCH_NO_SG_CHAIN if (!is_smcd && is_rmb && lgr->buf_type != SMCR_VIRT_CONT_BUFS) { - max_phy_compressed = ilog2(max_scat >> 14); + max_phy_compressed = ilog2((SG_MAX_SINGLE_ALLOC * PAGE_SIZE) >> 14); switch (lgr->buf_type) { case SMCR_MIXED_BUFS: if (compressed > max_phy_compressed) @@ -2029,6 +2032,7 @@ static u8 smc_compress_bufsize(struct smc_link_group *lgr, int size, bool is_smc break; } } +#endif return compressed; } -- 2.34.1