general protection fault in lookup_object_or_alloc
Hi Kernel Maintainers, we found a crash "general protection fault in lookup_object_or_alloc" in upstream, and reproduced it successfully, this bug is a KASAN. HEAD Commit: 88fac17500f4ea49c7bac136cf1b27e7b9980075(Merge tag 'fuse-fixes-6.11-rc7') kernel config: https://raw.githubusercontent.com/androidAppGuard/KernelBugs/main/6.11.config console output: https://raw.githubusercontent.com/androidAppGuard/KernelBugs/main/88fac17500f4ea49c7bac136cf1b27e7b9980075/1b5c18c216e3fa6127f8a798b4c2d1ca1a8ff56e/repro.log repro report: https://raw.githubusercontent.com/androidAppGuard/KernelBugs/main/88fac17500f4ea49c7bac136cf1b27e7b9980075/1b5c18c216e3fa6127f8a798b4c2d1ca1a8ff56e/repro.report syz reproducer: https://raw.githubusercontent.com/androidAppGuard/KernelBugs/main/88fac17500f4ea49c7bac136cf1b27e7b9980075/1b5c18c216e3fa6127f8a798b4c2d1ca1a8ff56e/repro.prog Please let me know if there is anything I can help. Best, Hui Guo This is the crash log I got by reproducing the bug based on the above environment, I have piped this log through decode_stacktrace.sh for better understand the cause of the bug. [ 895.266222][ T84] Bluetooth: hci1: unexpected cc 0x0c03 length: 249 > 1 [ 895.267926][ T84] Bluetooth: hci1: unexpected cc 0x1003 length: 249 > 9 [ 895.269300][ T84] Bluetooth: hci1: unexpected cc 0x1001 length: 249 > 9 [ 895.270998][ T84] Bluetooth: hci1: unexpected cc 0x0c23 length: 249 > 4 [ 895.272912][ T84] Bluetooth: hci1: unexpected cc 0x0c25 length: 249 > 3 [ 895.274413][ T84] Bluetooth: hci1: unexpected cc 0x0c38 length: 249 > 2 [ 895.410150][T20127] chnl_net:caif_netlink_parms(): no params data found [ 895.494391][T20127] bridge0: port 1(bridge_slave_0) entered blocking state [ 895.495435][T20127] bridge0: port 1(bridge_slave_0) entered disabled state [ 895.496415][T20127] bridge_slave_0: entered allmulticast mode [ 895.498601][T20127] bridge_slave_0: entered promiscuous mode [ 895.501009][T20127] bridge0: port 2(bridge_slave_1) entered blocking state [ 895.501821][T20127] bridge0: port 2(bridge_slave_1) entered disabled state [ 895.502674][T20127] bridge_slave_1: entered allmulticast mode [ 895.503989][T20127] bridge_slave_1: entered promiscuous mode [ 895.551919][T20127] bond0: (slave bond_slave_0): Enslaving as an active interface with an up link [ 895.556437][T20127] bond0: (slave bond_slave_1): Enslaving as an active interface with an up link [ 895.607375][T20127] team0: Port device team_slave_0 added [ 895.609904][T20127] team0: Port device team_slave_1 added [ 895.646804][T20127] batman_adv: batadv0: Adding interface: batadv_slave_0 [ 895.647620][T20127] batman_adv: batadv0: The MTU of interface batadv_slave_0 is too small (1500) to handle the transport of batman-adv packets. Packets going over this interface will be fragmented on layer2 which could impact the performance. Setting the MTU to 1560 would solve the problem. [ 895.650389][T20127] batman_adv: batadv0: Not using interface batadv_slave_0 (retrying later): interface not active [ 895.653411][T20127] batman_adv: batadv0: Adding interface: batadv_slave_1 [ 895.654150][T20127] batman_adv: batadv0: The MTU of interface batadv_slave_1 is too small (1500) to handle the transport of batman-adv packets. Packets going over this interface will be fragmented on layer2 which could impact the performance. Setting the MTU to 1560 would solve the problem. [ 895.654516][ T84] Bluetooth: hci0: command tx timeout [ 895.659120][T20127] batman_adv: batadv0: Not using interface batadv_slave_1 (retrying later): interface not active [ 895.716645][T20127] hsr_slave_0: entered promiscuous mode [ 895.718562][T20127] hsr_slave_1: entered promiscuous mode [ 895.719871][T20127] debugfs: Directory 'hsr0' with parent 'hsr' already present! [ 895.720876][T20127] Cannot create hsr debugfs directory [ 896.281656][T20127] netdevsim netdevsim0 netdevsim0: renamed from eth0 [ 896.286970][T20127] netdevsim netdevsim0 netdevsim1: renamed from eth1 [ 896.291120][T20127] netdevsim netdevsim0 netdevsim2: renamed from eth2 [ 896.295245][T20127] netdevsim netdevsim0 netdevsim3: renamed from eth3 [ 896.346467][T20127] 8021q: adding VLAN 0 to HW filter on device bond0 [ 896.356632][T20127] 8021q: adding VLAN 0 to HW filter on device team0 [ 896.362049][T13908] bridge0: port 1(bridge_slave_0) entered blocking state [ 896.364148][T13908] bridge0: port 1(bridge_slave_0) entered forwarding state [ 896.378645][ T94] bridge0: port 2(bridge_slave_1) entered blocking state [ 896.379672][ T94] bridge0: port 2(bridge_slave_1) entered forwarding state [ 896.529186][T20127] 8021q: adding VLAN 0 to HW filter on device batadv0 [ 896.562218][T20127] veth0_vlan: entered promiscuous mode [ 896.568608][T20127] veth1_vlan: entered promiscuous mode [ 896.590615][T20127] veth0_macvtap: entered promiscuous mode [ 896.594647][T20127] veth1_macvtap: entered promiscu
Re: [PATCH] crypto: hisilicon/hpre - fix unmapping invalid dma address
On 2021/4/16 19:26, Herbert Xu wrote: On Sat, Apr 10, 2021 at 05:49:17PM +0800, Hui Tang wrote: Currently, an invalid dma address may be unmapped when calling 'xx_data_clr_all' in error path, so check dma address of sqe in/out whether it has been mapped before calling 'dma_free_coherent' or 'dma_unmap_single'. An abnormal case is as follows: hpre_curve25519_compute_value -> hpre_curve25519_src_init -> hpre_curve25519_hw_data_clr_all Fixes: a9214b0b6ed2(crypto: hisilicon - fix the check on dma address) Signed-off-by: Hui Tang --- drivers/crypto/hisilicon/hpre/hpre_crypto.c | 18 ++ 1 file changed, 18 insertions(+) This triggers new sparse warnings. Thanks, I will fix it in 5.13 rc1.
[PATCH for vm-scalability] usemem: Output a message after punch holes done
From: Hui Zhu When I use punch holes to setup a test page fragmentation environment, I didn't know when the punch holes done. I can only get this information through top or something else. This commit add code to output a message after punch holes done to handle this issue. Signed-off-by: Hui Zhu --- usemem.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/usemem.c b/usemem.c index 5b90aae..0c76d17 100644 --- a/usemem.c +++ b/usemem.c @@ -791,6 +791,8 @@ long do_units(void) for (i = 0; i < nptr; i++) do_punch_holes(ptrs[i], lens[i]); } + printf("punch holes done\n"); + fflush(stdout); } while (sleep_secs) -- 1.8.3.1
[PATCH] sched: remove the redundant comments
Since the commit 55627e3cd22c ("sched/core: Remove rq->cpu_load[]"), we don't need this any more. Signed-off-by: Hui Su --- kernel/sched/sched.h | 5 - 1 file changed, 5 deletions(-) diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 10a1522b1e30..2232022d8561 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -897,11 +897,6 @@ DECLARE_STATIC_KEY_FALSE(sched_uclamp_used); struct rq { /* runqueue lock: */ raw_spinlock_t lock; - - /* -* nr_running and cpu_load should be in the same cacheline because -* remote CPUs use both these fields when doing load calculation. -*/ unsigned intnr_running; #ifdef CONFIG_NUMA_BALANCING unsigned intnr_numa_running; -- 2.25.1
[PATCH v3] crypto: hisilicon/hpre - delete redundant log and return in advance
'hpre_cfg_by_dsm' has checked and printed error path internally. It is not necessary to do it here, so remove it. It should return error immediately when return value of 'hpre_cfg_by_dsm' is non-zero, and no need to execute the remaining sentences. Signed-off-by: Hui Tang --- v1 -> v2: - Return immediately when return value of 'hpre_cfg_by_dsm' is non-zero. v2 -> v3: - Add description for return if function fails. --- drivers/crypto/hisilicon/hpre/hpre_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/crypto/hisilicon/hpre/hpre_main.c b/drivers/crypto/hisilicon/hpre/hpre_main.c index a8c7921..264684a 100644 --- a/drivers/crypto/hisilicon/hpre/hpre_main.c +++ b/drivers/crypto/hisilicon/hpre/hpre_main.c @@ -384,7 +384,7 @@ static int hpre_set_user_domain_and_cache(struct hisi_qm *qm) if (qm->ver == QM_HW_V2) { ret = hpre_cfg_by_dsm(qm); if (ret) - dev_err(dev, "acpi_evaluate_dsm err.\n"); + return ret; disable_flr_of_bme(qm); } -- 2.8.1
[PATCH] crypto: hisilicon/hpre - fix unmapping invalid dma address
Currently, an invalid dma address may be unmapped when calling 'xx_data_clr_all' in error path, so check dma address of sqe in/out whether it has been mapped before calling 'dma_free_coherent' or 'dma_unmap_single'. An abnormal case is as follows: hpre_curve25519_compute_value -> hpre_curve25519_src_init -> hpre_curve25519_hw_data_clr_all Fixes: a9214b0b6ed2(crypto: hisilicon - fix the check on dma address) Signed-off-by: Hui Tang --- drivers/crypto/hisilicon/hpre/hpre_crypto.c | 18 ++ 1 file changed, 18 insertions(+) diff --git a/drivers/crypto/hisilicon/hpre/hpre_crypto.c b/drivers/crypto/hisilicon/hpre/hpre_crypto.c index f363653..d23893a 100644 --- a/drivers/crypto/hisilicon/hpre/hpre_crypto.c +++ b/drivers/crypto/hisilicon/hpre/hpre_crypto.c @@ -298,6 +298,8 @@ static void hpre_hw_data_clr_all(struct hpre_ctx *ctx, dma_addr_t tmp; tmp = le64_to_cpu(sqe->in); + if (unlikely(dma_mapping_error(dev, tmp))) + return; if (src) { if (req->src) @@ -307,6 +309,8 @@ static void hpre_hw_data_clr_all(struct hpre_ctx *ctx, } tmp = le64_to_cpu(sqe->out); + if (unlikely(dma_mapping_error(dev, tmp))) + return; if (req->dst) { if (dst) @@ -517,6 +521,8 @@ static int hpre_msg_request_set(struct hpre_ctx *ctx, void *req, bool is_rsa) msg->key = cpu_to_le64(ctx->dh.dma_xa_p); } + msg->in = DMA_MAPPING_ERROR; + msg->out = DMA_MAPPING_ERROR; msg->dw0 |= cpu_to_le32(0x1 << HPRE_SQE_DONE_SHIFT); msg->task_len1 = (ctx->key_sz >> HPRE_BITS_2_BYTES_SHIFT) - 1; h_req->ctx = ctx; @@ -1365,11 +1371,15 @@ static void hpre_ecdh_hw_data_clr_all(struct hpre_ctx *ctx, dma_addr_t dma; dma = le64_to_cpu(sqe->in); + if (unlikely(dma_mapping_error(dev, dma))) + return; if (src && req->src) dma_free_coherent(dev, ctx->key_sz << 2, req->src, dma); dma = le64_to_cpu(sqe->out); + if (unlikely(dma_mapping_error(dev, dma))) + return; if (req->dst) dma_free_coherent(dev, ctx->key_sz << 1, req->dst, dma); @@ -1424,6 +1434,8 @@ static int hpre_ecdh_msg_request_set(struct hpre_ctx *ctx, h_req->areq.ecdh = req; msg = &h_req->req; memset(msg, 0, sizeof(*msg)); + msg->in = DMA_MAPPING_ERROR; + msg->out = DMA_MAPPING_ERROR; msg->key = cpu_to_le64(ctx->ecdh.dma_p); msg->dw0 |= cpu_to_le32(0x1U << HPRE_SQE_DONE_SHIFT); @@ -1660,11 +1672,15 @@ static void hpre_curve25519_hw_data_clr_all(struct hpre_ctx *ctx, dma_addr_t dma; dma = le64_to_cpu(sqe->in); + if (unlikely(dma_mapping_error(dev, dma))) + return; if (src && req->src) dma_free_coherent(dev, ctx->key_sz, req->src, dma); dma = le64_to_cpu(sqe->out); + if (unlikely(dma_mapping_error(dev, dma))) + return; if (req->dst) dma_free_coherent(dev, ctx->key_sz, req->dst, dma); @@ -1715,6 +1731,8 @@ static int hpre_curve25519_msg_request_set(struct hpre_ctx *ctx, h_req->areq.curve25519 = req; msg = &h_req->req; memset(msg, 0, sizeof(*msg)); + msg->in = DMA_MAPPING_ERROR; + msg->out = DMA_MAPPING_ERROR; msg->key = cpu_to_le64(ctx->curve25519.dma_p); msg->dw0 |= cpu_to_le32(0x1U << HPRE_SQE_DONE_SHIFT); -- 2.8.1
[PATCH 3/3] crypto: hisilicon/hpre - add debug log
When the received sqe is abnormal, the error message in the sqe written back by the hardware is printed to help to analyze the abnormal causes. Signed-off-by: Hui Tang --- drivers/crypto/hisilicon/hpre/hpre_crypto.c | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/hisilicon/hpre/hpre_crypto.c b/drivers/crypto/hisilicon/hpre/hpre_crypto.c index 0adaf92..c8531c0 100644 --- a/drivers/crypto/hisilicon/hpre/hpre_crypto.c +++ b/drivers/crypto/hisilicon/hpre/hpre_crypto.c @@ -325,14 +325,16 @@ static void hpre_hw_data_clr_all(struct hpre_ctx *ctx, static int hpre_alg_res_post_hf(struct hpre_ctx *ctx, struct hpre_sqe *sqe, void **kreq) { + struct device *dev = HPRE_DEV(ctx); struct hpre_asym_request *req; - unsigned int err, done; + unsigned int err, done, alg; int id; #define HPRE_NO_HW_ERR 0 #define HPRE_HW_TASK_DONE 3 #define HREE_HW_ERR_MASK 0x7ff #define HREE_SQE_DONE_MASK 0x3 +#define HREE_ALG_TYPE_MASK 0x1f id = (int)le16_to_cpu(sqe->tag); req = ctx->req_list[id]; hpre_rm_req_from_ctx(req); @@ -347,6 +349,10 @@ static int hpre_alg_res_post_hf(struct hpre_ctx *ctx, struct hpre_sqe *sqe, if (likely(err == HPRE_NO_HW_ERR && done == HPRE_HW_TASK_DONE)) return 0; + alg = le32_to_cpu(sqe->dw0) & HREE_ALG_TYPE_MASK; + dev_err_ratelimited(dev, "alg[0x%x] error: done[0x%x], etype[0x%x]\n", + alg, done, err); + return -EINVAL; } -- 2.8.1
[PATCH 2/3] crypto: hisilicon/hpre - use the correct variable type
The return value of 'le32_to_cpu' is unsigned, so change the variable type from 'int' to 'unsigned int'. Signed-off-by: Hui Tang --- drivers/crypto/hisilicon/hpre/hpre_crypto.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/hisilicon/hpre/hpre_crypto.c b/drivers/crypto/hisilicon/hpre/hpre_crypto.c index b312a38..0adaf92 100644 --- a/drivers/crypto/hisilicon/hpre/hpre_crypto.c +++ b/drivers/crypto/hisilicon/hpre/hpre_crypto.c @@ -326,7 +326,8 @@ static int hpre_alg_res_post_hf(struct hpre_ctx *ctx, struct hpre_sqe *sqe, void **kreq) { struct hpre_asym_request *req; - int err, id, done; + unsigned int err, done; + int id; #define HPRE_NO_HW_ERR 0 #define HPRE_HW_TASK_DONE 3 -- 2.8.1
[PATCH 0/3] crypto: hisilicon/hpre - add debug log
This patchset adds the debug log and cleanup code style. Hui Tang (3): crypto: hisilicon/hpre - delete the rudundant space after return crypto: hisilicon/hpre - use the correct variable type crypto: hisilicon/hpre - add debug log drivers/crypto/hisilicon/hpre/hpre_crypto.c | 11 +-- drivers/crypto/hisilicon/hpre/hpre_main.c | 4 ++-- 2 files changed, 11 insertions(+), 4 deletions(-) -- 2.8.1
[PATCH 1/3] crypto: hisilicon/hpre - delete the rudundant space after return
There are two spaces after return, just keep one. Signed-off-by: Hui Tang --- drivers/crypto/hisilicon/hpre/hpre_crypto.c | 2 +- drivers/crypto/hisilicon/hpre/hpre_main.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/crypto/hisilicon/hpre/hpre_crypto.c b/drivers/crypto/hisilicon/hpre/hpre_crypto.c index d23893a..b312a38 100644 --- a/drivers/crypto/hisilicon/hpre/hpre_crypto.c +++ b/drivers/crypto/hisilicon/hpre/hpre_crypto.c @@ -344,7 +344,7 @@ static int hpre_alg_res_post_hf(struct hpre_ctx *ctx, struct hpre_sqe *sqe, HREE_SQE_DONE_MASK; if (likely(err == HPRE_NO_HW_ERR && done == HPRE_HW_TASK_DONE)) - return 0; + return 0; return -EINVAL; } diff --git a/drivers/crypto/hisilicon/hpre/hpre_main.c b/drivers/crypto/hisilicon/hpre/hpre_main.c index 264684a..916af3f 100644 --- a/drivers/crypto/hisilicon/hpre/hpre_main.c +++ b/drivers/crypto/hisilicon/hpre/hpre_main.c @@ -472,7 +472,7 @@ static int hpre_clear_enable_write(struct hpre_debugfs_file *file, u32 val) ~HPRE_CTRL_CNT_CLR_CE_BIT) | val; writel(tmp, qm->io_base + HPRE_CTRL_CNT_CLR_CE); - return 0; + return 0; } static u32 hpre_cluster_inqry_read(struct hpre_debugfs_file *file) @@ -494,7 +494,7 @@ static int hpre_cluster_inqry_write(struct hpre_debugfs_file *file, u32 val) writel(val, qm->io_base + offset + HPRE_CLUSTER_INQURY); - return 0; + return 0; } static ssize_t hpre_ctrl_debug_read(struct file *filp, char __user *buf, -- 2.8.1
Re: [PATCH v2] crypto: hisilicon/hpre - delete redundant log
On 2021/4/9 15:33, Herbert Xu wrote: On Fri, Apr 02, 2021 at 07:24:29PM +0800, Hui Tang wrote: 'hpre_cfg_by_dsm' has checked and printed error path internally. It is not necessary to do it here, so remove it. Signed-off-by: Hui Tang v1 -> v2: - Return immediately when return value of 'hpre_cfg_by_dsm' is non-zero. --- drivers/crypto/hisilicon/hpre/hpre_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Your patch description is misleading as the patch does moe than just remove the redundant printk. Please rephrase so that it is clear that the patch is in fact changing behaviour. Okay, I will fix it in next version.
[PATCH v2 -next 3/3] clk: qcom: apss-ipq-pll: Add missing MODULE_DEVICE_TABLE
CONFIG_IPQ_APSS_PLL is tristate option and therefore this driver can be compiled as a module. This patch adds missing MODULE_DEVICE_TABLE definition which generates correct modalias for automatic loading of this driver when it is built as an external module. Fixes: ecd2bacfbbc4 ("clk: qcom: Add ipq apss pll driver") Signed-off-by: Chen Hui Reviewed-by: Manivannan Sadhasivam --- drivers/clk/qcom/apss-ipq-pll.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/clk/qcom/apss-ipq-pll.c b/drivers/clk/qcom/apss-ipq-pll.c index 30be87fb222a..bef7899ad0d6 100644 --- a/drivers/clk/qcom/apss-ipq-pll.c +++ b/drivers/clk/qcom/apss-ipq-pll.c @@ -81,6 +81,7 @@ static const struct of_device_id apss_ipq_pll_match_table[] = { { .compatible = "qcom,ipq6018-a53pll" }, { } }; +MODULE_DEVICE_TABLE(of, apss_ipq_pll_match_table); static struct platform_driver apss_ipq_pll_driver = { .probe = apss_ipq_pll_probe, -- 2.17.1
[PATCH v2 -next 1/3] clk: qcom: a7-pll: Add missing MODULE_DEVICE_TABLE
CONFIG_QCOM_A7PLL is tristate option and therefore this driver can be compiled as a module. This patch adds missing MODULE_DEVICE_TABLE definition which generates correct modalias for automatic loading of this driver when it is built as an external module. Fixes: 5a5223ffd7ef ("clk: qcom: Add A7 PLL support") Signed-off-by: Chen Hui Reviewed-by: Manivannan Sadhasivam --- drivers/clk/qcom/a7-pll.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/clk/qcom/a7-pll.c b/drivers/clk/qcom/a7-pll.c index e171d3caf2cf..c4a53e5db229 100644 --- a/drivers/clk/qcom/a7-pll.c +++ b/drivers/clk/qcom/a7-pll.c @@ -86,6 +86,7 @@ static const struct of_device_id qcom_a7pll_match_table[] = { { .compatible = "qcom,sdx55-a7pll" }, { } }; +MODULE_DEVICE_TABLE(of, qcom_a7pll_match_table); static struct platform_driver qcom_a7pll_driver = { .probe = qcom_a7pll_probe, -- 2.17.1
[PATCH v2 -next 2/3] clk: qcom: a53-pll: Add missing MODULE_DEVICE_TABLE
CONFIG_QCOM_A53PLL is tristate option and therefore this driver can be compiled as a module. This patch adds missing MODULE_DEVICE_TABLE definition which generates correct modalias for automatic loading of this driver when it is built as an external module. Fixes: 0c6ab1b8f894 ("clk: qcom: Add A53 PLL support") Signed-off-by: Chen Hui Reviewed-by: Manivannan Sadhasivam --- drivers/clk/qcom/a53-pll.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/clk/qcom/a53-pll.c b/drivers/clk/qcom/a53-pll.c index 45cfc57bff92..af6ac17c7dae 100644 --- a/drivers/clk/qcom/a53-pll.c +++ b/drivers/clk/qcom/a53-pll.c @@ -93,6 +93,7 @@ static const struct of_device_id qcom_a53pll_match_table[] = { { .compatible = "qcom,msm8916-a53pll" }, { } }; +MODULE_DEVICE_TABLE(of, qcom_a53pll_match_table); static struct platform_driver qcom_a53pll_driver = { .probe = qcom_a53pll_probe, -- 2.17.1
[PATCH v2 -next 0/3] Add missing MODULE_DEVICE_TABLE
v2: - separate from one patch into three patches - add fixes tags Chen Hui (3): clk: qcom: a7-pll: Add missing MODULE_DEVICE_TABLE clk: qcom: a53-pll: Add missing MODULE_DEVICE_TABLE clk: qcom: apss-ipq-pll: Add missing MODULE_DEVICE_TABLE drivers/clk/qcom/a53-pll.c | 1 + drivers/clk/qcom/a7-pll.c | 1 + drivers/clk/qcom/apss-ipq-pll.c | 1 + 3 files changed, 3 insertions(+) -- 2.17.1
[PATCH -next] PCI: altera-msi: Remove redundant dev_err call in altera_msi_probe()
There is a error message within devm_ioremap_resource already, so remove the dev_err call to avoid redundant error message. Signed-off-by: Chen Hui --- drivers/pci/controller/pcie-altera-msi.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/pci/controller/pcie-altera-msi.c b/drivers/pci/controller/pcie-altera-msi.c index 42691dd8ebef..98aa1dccc6e6 100644 --- a/drivers/pci/controller/pcie-altera-msi.c +++ b/drivers/pci/controller/pcie-altera-msi.c @@ -236,10 +236,8 @@ static int altera_msi_probe(struct platform_device *pdev) res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "vector_slave"); msi->vector_base = devm_ioremap_resource(&pdev->dev, res); - if (IS_ERR(msi->vector_base)) { - dev_err(&pdev->dev, "failed to map vector_slave memory\n"); + if (IS_ERR(msi->vector_base)) return PTR_ERR(msi->vector_base); - } msi->vector_phy = res->start; -- 2.17.1
[PATCH -next] drm/hisilicon/kirin: Remove redundant DRM_ERROR call in dsi_parse_dt()
There is a error message within devm_ioremap_resource already, so remove the DRM_ERROR call to avoid redundant error message. Signed-off-by: Chen Hui --- drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c b/drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c index 00e87c290796..bc19ce318c62 100644 --- a/drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c +++ b/drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c @@ -836,10 +836,8 @@ static int dsi_parse_dt(struct platform_device *pdev, struct dw_dsi *dsi) res = platform_get_resource(pdev, IORESOURCE_MEM, 0); ctx->base = devm_ioremap_resource(&pdev->dev, res); - if (IS_ERR(ctx->base)) { - DRM_ERROR("failed to remap dsi io region\n"); + if (IS_ERR(ctx->base)) return PTR_ERR(ctx->base); - } return 0; } -- 2.17.1
[PATCH -next] clk: qcom: Add missing MODULE_DEVICE_TABLE
Add missing MODULE_DEVICE_TABLE entries to support module autoloading, as these drivers can be compiled as external modules. Signed-off-by: Chen Hui --- drivers/clk/qcom/a53-pll.c | 1 + drivers/clk/qcom/a7-pll.c | 1 + drivers/clk/qcom/apss-ipq-pll.c | 1 + 3 files changed, 3 insertions(+) diff --git a/drivers/clk/qcom/a53-pll.c b/drivers/clk/qcom/a53-pll.c index 45cfc57bff92..af6ac17c7dae 100644 --- a/drivers/clk/qcom/a53-pll.c +++ b/drivers/clk/qcom/a53-pll.c @@ -93,6 +93,7 @@ static const struct of_device_id qcom_a53pll_match_table[] = { { .compatible = "qcom,msm8916-a53pll" }, { } }; +MODULE_DEVICE_TABLE(of, qcom_a53pll_match_table); static struct platform_driver qcom_a53pll_driver = { .probe = qcom_a53pll_probe, diff --git a/drivers/clk/qcom/a7-pll.c b/drivers/clk/qcom/a7-pll.c index e171d3caf2cf..c4a53e5db229 100644 --- a/drivers/clk/qcom/a7-pll.c +++ b/drivers/clk/qcom/a7-pll.c @@ -86,6 +86,7 @@ static const struct of_device_id qcom_a7pll_match_table[] = { { .compatible = "qcom,sdx55-a7pll" }, { } }; +MODULE_DEVICE_TABLE(of, qcom_a7pll_match_table); static struct platform_driver qcom_a7pll_driver = { .probe = qcom_a7pll_probe, diff --git a/drivers/clk/qcom/apss-ipq-pll.c b/drivers/clk/qcom/apss-ipq-pll.c index 30be87fb222a..bef7899ad0d6 100644 --- a/drivers/clk/qcom/apss-ipq-pll.c +++ b/drivers/clk/qcom/apss-ipq-pll.c @@ -81,6 +81,7 @@ static const struct of_device_id apss_ipq_pll_match_table[] = { { .compatible = "qcom,ipq6018-a53pll" }, { } }; +MODULE_DEVICE_TABLE(of, apss_ipq_pll_match_table); static struct platform_driver apss_ipq_pll_driver = { .probe = apss_ipq_pll_probe, -- 2.17.1
[PATCH -next] clk: samsung: Remove redundant dev_err calls
There is error message within devm_ioremap_resource already, so remove the dev_err calls to avoid redundant error messages. Signed-off-by: Chen Hui --- drivers/clk/samsung/clk-exynos4412-isp.c | 4 +--- drivers/clk/samsung/clk-s5pv210-audss.c | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/clk/samsung/clk-exynos4412-isp.c b/drivers/clk/samsung/clk-exynos4412-isp.c index 4b9e73608c21..b69e381b8c0c 100644 --- a/drivers/clk/samsung/clk-exynos4412-isp.c +++ b/drivers/clk/samsung/clk-exynos4412-isp.c @@ -115,10 +115,8 @@ static int __init exynos4x12_isp_clk_probe(struct platform_device *pdev) res = platform_get_resource(pdev, IORESOURCE_MEM, 0); reg_base = devm_ioremap_resource(dev, res); - if (IS_ERR(reg_base)) { - dev_err(dev, "failed to map registers\n"); + if (IS_ERR(reg_base)) return PTR_ERR(reg_base); - } exynos4x12_save_isp = samsung_clk_alloc_reg_dump(exynos4x12_clk_isp_save, ARRAY_SIZE(exynos4x12_clk_isp_save)); diff --git a/drivers/clk/samsung/clk-s5pv210-audss.c b/drivers/clk/samsung/clk-s5pv210-audss.c index 14985ebd043b..a7827a120695 100644 --- a/drivers/clk/samsung/clk-s5pv210-audss.c +++ b/drivers/clk/samsung/clk-s5pv210-audss.c @@ -72,10 +72,8 @@ static int s5pv210_audss_clk_probe(struct platform_device *pdev) res = platform_get_resource(pdev, IORESOURCE_MEM, 0); reg_base = devm_ioremap_resource(&pdev->dev, res); - if (IS_ERR(reg_base)) { - dev_err(&pdev->dev, "failed to map audss registers\n"); + if (IS_ERR(reg_base)) return PTR_ERR(reg_base); - } clk_data = devm_kzalloc(&pdev->dev, struct_size(clk_data, hws, AUDSS_MAX_CLKS), -- 2.17.1
[PATCH for vm-scalability] usemem: Add code for touch-alloc
Add code for touch-alloc. And Change read memory to write memory to avoid use the zero-page for reads in do_anonymous_page. Signed-off-by: Hui Zhu --- usemem.c | 34 ++ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/usemem.c b/usemem.c index e2c46ec..5b90aae 100644 --- a/usemem.c +++ b/usemem.c @@ -329,6 +329,18 @@ void detach(void) } } +unsigned long do_access(unsigned long *p, unsigned long idx, int read) +{ + volatile unsigned long *vp = p; + + if (read) + return vp[idx]; /* read data */ + else { + vp[idx] = idx; /* write data */ + return 0; + } +} + unsigned long * allocate(unsigned long bytes) { unsigned long *p; @@ -355,6 +367,14 @@ unsigned long * allocate(unsigned long bytes) p = (unsigned long *)ALIGN((unsigned long)p, pagesize - 1); } + if (opt_touch_alloc) { + unsigned long i; + unsigned long m = bytes / sizeof(*p); + + for (i = 0; i < m; i += 1) + do_access(p, i, 0); + } + return p; } @@ -436,18 +456,6 @@ void shm_unlock(int seg_id) shmctl(seg_id, SHM_UNLOCK, NULL); } -unsigned long do_access(unsigned long *p, unsigned long idx, int read) -{ - volatile unsigned long *vp = p; - - if (read) - return vp[idx]; /* read data */ - else { - vp[idx] = idx; /* write data */ - return 0; - } -} - #define NSEC_PER_SEC (1UL * 1000 * 1000 * 1000) long nsec_sub(long nsec1, long nsec2) @@ -953,6 +961,8 @@ int main(int argc, char *argv[]) opt_punch_holes = 1; } else if (strcmp(opts[opt_index].name, "init-time") == 0) { opt_init_time = 1; + } else if (strcmp(opts[opt_index].name, "touch-alloc") == 0) { + opt_touch_alloc = 1; } else usage(1); break; -- 2.17.1
[PATCH -next] drm/mediatek: Remove redundant dev_err calls
There is a error message within devm_ioremap_resource already, so remove the dev_err calls to avoid redundant error messages. Signed-off-by: Chen Hui --- drivers/gpu/drm/mediatek/mtk_disp_color.c | 4 +--- drivers/gpu/drm/mediatek/mtk_disp_gamma.c | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_disp_color.c b/drivers/gpu/drm/mediatek/mtk_disp_color.c index 63f411ab393b..d9b6f3b100dc 100644 --- a/drivers/gpu/drm/mediatek/mtk_disp_color.c +++ b/drivers/gpu/drm/mediatek/mtk_disp_color.c @@ -112,10 +112,8 @@ static int mtk_disp_color_probe(struct platform_device *pdev) res = platform_get_resource(pdev, IORESOURCE_MEM, 0); priv->regs = devm_ioremap_resource(dev, res); - if (IS_ERR(priv->regs)) { - dev_err(dev, "failed to ioremap color\n"); + if (IS_ERR(priv->regs)) return PTR_ERR(priv->regs); - } #if IS_REACHABLE(CONFIG_MTK_CMDQ) ret = cmdq_dev_get_client_reg(dev, &priv->cmdq_reg, 0); if (ret) diff --git a/drivers/gpu/drm/mediatek/mtk_disp_gamma.c b/drivers/gpu/drm/mediatek/mtk_disp_gamma.c index 3ebf91e0ab41..ad5df3f9d477 100644 --- a/drivers/gpu/drm/mediatek/mtk_disp_gamma.c +++ b/drivers/gpu/drm/mediatek/mtk_disp_gamma.c @@ -146,10 +146,8 @@ static int mtk_disp_gamma_probe(struct platform_device *pdev) res = platform_get_resource(pdev, IORESOURCE_MEM, 0); priv->regs = devm_ioremap_resource(dev, res); - if (IS_ERR(priv->regs)) { - dev_err(dev, "failed to ioremap gamma\n"); + if (IS_ERR(priv->regs)) return PTR_ERR(priv->regs); - } #if IS_REACHABLE(CONFIG_MTK_CMDQ) ret = cmdq_dev_get_client_reg(dev, &priv->cmdq_reg, 0); -- 2.17.1
[PATCH v2] crypto: hisilicon/hpre - delete redundant log
'hpre_cfg_by_dsm' has checked and printed error path internally. It is not necessary to do it here, so remove it. Signed-off-by: Hui Tang v1 -> v2: - Return immediately when return value of 'hpre_cfg_by_dsm' is non-zero. --- drivers/crypto/hisilicon/hpre/hpre_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/crypto/hisilicon/hpre/hpre_main.c b/drivers/crypto/hisilicon/hpre/hpre_main.c index c7ab06d..fa40835 100644 --- a/drivers/crypto/hisilicon/hpre/hpre_main.c +++ b/drivers/crypto/hisilicon/hpre/hpre_main.c @@ -386,7 +386,7 @@ static int hpre_set_user_domain_and_cache(struct hisi_qm *qm) if (qm->ver == QM_HW_V2) { ret = hpre_cfg_by_dsm(qm); if (ret) - dev_err(dev, "acpi_evaluate_dsm err.\n"); + return ret; disable_flr_of_bme(qm); } -- 2.8.1
[PATCH] crypto: hisilicon - check if debugfs opened
'xx_debugfs_init' check if debugfs opened. Signed-off-by: Hui Tang --- drivers/crypto/hisilicon/hpre/hpre_main.c | 5 - drivers/crypto/hisilicon/qm.c | 3 +++ drivers/crypto/hisilicon/sec2/sec_main.c | 5 - drivers/crypto/hisilicon/zip/zip_main.c | 3 +++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/crypto/hisilicon/hpre/hpre_main.c b/drivers/crypto/hisilicon/hpre/hpre_main.c index c7ab06d..f2605c4 100644 --- a/drivers/crypto/hisilicon/hpre/hpre_main.c +++ b/drivers/crypto/hisilicon/hpre/hpre_main.c @@ -779,6 +779,9 @@ static int hpre_debugfs_init(struct hisi_qm *qm) struct device *dev = &qm->pdev->dev; int ret; + if (!debugfs_initialized()) + return -ENOENT; + qm->debug.debug_root = debugfs_create_dir(dev_name(dev), hpre_debugfs_root); @@ -949,7 +952,7 @@ static int hpre_probe(struct pci_dev *pdev, const struct pci_device_id *id) ret = hpre_debugfs_init(qm); if (ret) - dev_warn(&pdev->dev, "init debugfs fail!\n"); + dev_warn(&pdev->dev, "init debugfs fail (%d)!\n", ret); ret = hisi_qm_alg_register(qm, &hpre_devices); if (ret < 0) { diff --git a/drivers/crypto/hisilicon/qm.c b/drivers/crypto/hisilicon/qm.c index bc23174..14f2656 100644 --- a/drivers/crypto/hisilicon/qm.c +++ b/drivers/crypto/hisilicon/qm.c @@ -2926,6 +2926,9 @@ void hisi_qm_debug_init(struct hisi_qm *qm) void *data; int i; + if (!debugfs_initialized()) + return; + qm_d = debugfs_create_dir("qm", qm->debug.debug_root); qm->debug.qm_d = qm_d; diff --git a/drivers/crypto/hisilicon/sec2/sec_main.c b/drivers/crypto/hisilicon/sec2/sec_main.c index 78a6043..226475d 100644 --- a/drivers/crypto/hisilicon/sec2/sec_main.c +++ b/drivers/crypto/hisilicon/sec2/sec_main.c @@ -695,6 +695,9 @@ static int sec_debugfs_init(struct hisi_qm *qm) struct device *dev = &qm->pdev->dev; int ret; + if (!debugfs_initialized()) + return -ENOENT; + qm->debug.debug_root = debugfs_create_dir(dev_name(dev), sec_debugfs_root); qm->debug.sqe_mask_offset = SEC_SQE_MASK_OFFSET; @@ -928,7 +931,7 @@ static int sec_probe(struct pci_dev *pdev, const struct pci_device_id *id) ret = sec_debugfs_init(qm); if (ret) - pci_warn(pdev, "Failed to init debugfs!\n"); + pci_warn(pdev, "Failed to init debugfs (%d)!\n", ret); ret = hisi_qm_alg_register(qm, &sec_devices); if (ret < 0) { diff --git a/drivers/crypto/hisilicon/zip/zip_main.c b/drivers/crypto/hisilicon/zip/zip_main.c index 02c44572..4b111c0 100644 --- a/drivers/crypto/hisilicon/zip/zip_main.c +++ b/drivers/crypto/hisilicon/zip/zip_main.c @@ -600,6 +600,9 @@ static int hisi_zip_debugfs_init(struct hisi_qm *qm) struct dentry *dev_d; int ret; + if (!debugfs_initialized()) + return -ENOENT; + dev_d = debugfs_create_dir(dev_name(dev), hzip_debugfs_root); qm->debug.sqe_mask_offset = HZIP_SQE_MASK_OFFSET; -- 2.8.1
[PATCH] crypto: hisilicon/hpre - delete redundant log
'hpre_cfg_by_dsm' has checked and printed error path, so it is not necessary at all. Signed-off-by: Hui Tang --- drivers/crypto/hisilicon/hpre/hpre_main.c | 5 + 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/crypto/hisilicon/hpre/hpre_main.c b/drivers/crypto/hisilicon/hpre/hpre_main.c index 8aae921..73ee997 100644 --- a/drivers/crypto/hisilicon/hpre/hpre_main.c +++ b/drivers/crypto/hisilicon/hpre/hpre_main.c @@ -384,10 +384,7 @@ static int hpre_set_user_domain_and_cache(struct hisi_qm *qm) /* This setting is only needed by Kunpeng 920. */ if (qm->ver == QM_HW_V2) { - ret = hpre_cfg_by_dsm(qm); - if (ret) - dev_err(dev, "acpi_evaluate_dsm err.\n"); - + hpre_cfg_by_dsm(qm); disable_flr_of_bme(qm); } -- 2.8.1
[PATCH] crypto: hisilicon - delete redundant '\n'
It has newline already by sysfs, so delete redundant '\n' Signed-off-by: Hui Tang --- drivers/crypto/hisilicon/hpre/hpre_main.c | 4 ++-- drivers/crypto/hisilicon/sec2/sec_main.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/crypto/hisilicon/hpre/hpre_main.c b/drivers/crypto/hisilicon/hpre/hpre_main.c index 73ee997..3c56d33 100644 --- a/drivers/crypto/hisilicon/hpre/hpre_main.c +++ b/drivers/crypto/hisilicon/hpre/hpre_main.c @@ -814,9 +814,9 @@ static int hpre_qm_init(struct hisi_qm *qm, struct pci_dev *pdev) } if (pdev->revision >= QM_HW_V3) - qm->algs = "rsa\ndh\necdh\nx25519\nx448\necdsa\nsm2\n"; + qm->algs = "rsa\ndh\necdh\nx25519\nx448\necdsa\nsm2"; else - qm->algs = "rsa\ndh\n"; + qm->algs = "rsa\ndh"; qm->mode = uacce_mode; qm->pdev = pdev; qm->ver = pdev->revision; diff --git a/drivers/crypto/hisilicon/sec2/sec_main.c b/drivers/crypto/hisilicon/sec2/sec_main.c index 226475d..b7c62a1 100644 --- a/drivers/crypto/hisilicon/sec2/sec_main.c +++ b/drivers/crypto/hisilicon/sec2/sec_main.c @@ -810,7 +810,7 @@ static int sec_qm_init(struct hisi_qm *qm, struct pci_dev *pdev) qm->pdev = pdev; qm->ver = pdev->revision; - qm->algs = "cipher\ndigest\naead\n"; + qm->algs = "cipher\ndigest\naead"; qm->mode = uacce_mode; qm->sqe_size = SEC_SQE_SIZE; qm->dev_name = sec_name; -- 2.8.1
[PATCH] crypto: hisilicon/hpre - fix a typo and delete redundant blank line
s/shoul/should/ Signed-off-by: Hui Tang --- drivers/crypto/hisilicon/hpre/hpre_main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/crypto/hisilicon/hpre/hpre_main.c b/drivers/crypto/hisilicon/hpre/hpre_main.c index f2605c4..8aae921 100644 --- a/drivers/crypto/hisilicon/hpre/hpre_main.c +++ b/drivers/crypto/hisilicon/hpre/hpre_main.c @@ -323,7 +323,7 @@ static int hpre_set_cluster(struct hisi_qm *qm) } /* - * For Kunpeng 920, we shoul disable FLR triggered by hardware (BME/PM/SRIOV). + * For Kunpeng 920, we should disable FLR triggered by hardware (BME/PM/SRIOV). * Or it may stay in D3 state when we bind and unbind hpre quickly, * as it does FLR triggered by hardware. */ @@ -1019,7 +1019,6 @@ static void hpre_remove(struct pci_dev *pdev) hisi_qm_uninit(qm); } - static const struct pci_error_handlers hpre_err_handler = { .error_detected = hisi_qm_dev_err_detected, .slot_reset = hisi_qm_dev_slot_reset, -- 2.8.1
[PATCH] crypto: hisilicon/hpre - fix PASID setting on kunpeng 920
We must confirm the PASID is disabled before using no-sva mode. Signed-off-by: Hui Tang --- drivers/crypto/hisilicon/hpre/hpre_main.c | 43 +-- 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/drivers/crypto/hisilicon/hpre/hpre_main.c b/drivers/crypto/hisilicon/hpre/hpre_main.c index 87e8f4d..c7ab06d 100644 --- a/drivers/crypto/hisilicon/hpre/hpre_main.c +++ b/drivers/crypto/hisilicon/hpre/hpre_main.c @@ -246,28 +246,24 @@ struct hisi_qp *hpre_create_qp(u8 type) return NULL; } -static void hpre_pasid_enable(struct hisi_qm *qm) +static void hpre_config_pasid(struct hisi_qm *qm) { - u32 val; - - val = readl_relaxed(qm->io_base + HPRE_DATA_RUSER_CFG); - val |= BIT(HPRE_PASID_EN_BIT); - writel_relaxed(val, qm->io_base + HPRE_DATA_RUSER_CFG); - val = readl_relaxed(qm->io_base + HPRE_DATA_WUSER_CFG); - val |= BIT(HPRE_PASID_EN_BIT); - writel_relaxed(val, qm->io_base + HPRE_DATA_WUSER_CFG); -} + u32 val1, val2; -static void hpre_pasid_disable(struct hisi_qm *qm) -{ - u32 val; + if (qm->ver >= QM_HW_V3) + return; - val = readl_relaxed(qm->io_base + HPRE_DATA_RUSER_CFG); - val &= ~BIT(HPRE_PASID_EN_BIT); - writel_relaxed(val, qm->io_base + HPRE_DATA_RUSER_CFG); - val = readl_relaxed(qm->io_base + HPRE_DATA_WUSER_CFG); - val &= ~BIT(HPRE_PASID_EN_BIT); - writel_relaxed(val, qm->io_base + HPRE_DATA_WUSER_CFG); + val1 = readl_relaxed(qm->io_base + HPRE_DATA_RUSER_CFG); + val2 = readl_relaxed(qm->io_base + HPRE_DATA_WUSER_CFG); + if (qm->use_sva) { + val1 |= BIT(HPRE_PASID_EN_BIT); + val2 |= BIT(HPRE_PASID_EN_BIT); + } else { + val1 &= ~BIT(HPRE_PASID_EN_BIT); + val2 &= ~BIT(HPRE_PASID_EN_BIT); + } + writel_relaxed(val1, qm->io_base + HPRE_DATA_RUSER_CFG); + writel_relaxed(val2, qm->io_base + HPRE_DATA_WUSER_CFG); } static int hpre_cfg_by_dsm(struct hisi_qm *qm) @@ -393,12 +389,11 @@ static int hpre_set_user_domain_and_cache(struct hisi_qm *qm) dev_err(dev, "acpi_evaluate_dsm err.\n"); disable_flr_of_bme(qm); - - /* Enable data buffer pasid */ - if (qm->use_sva) - hpre_pasid_enable(qm); } + /* Config data buffer pasid needed by Kunpeng 920 */ + hpre_config_pasid(qm); + return ret; } @@ -1013,8 +1008,6 @@ static void hpre_remove(struct pci_dev *pdev) hisi_qm_stop(qm, QM_NORMAL); if (qm->fun_type == QM_HW_PF) { - if (qm->use_sva && qm->ver == QM_HW_V2) - hpre_pasid_disable(qm); hpre_cnt_regs_clear(qm); qm->debug.curr_qm_qp_num = 0; hisi_qm_dev_err_uninit(qm); -- 2.8.1
[PATCH] crypto: hisilicon/hpre - fix Kconfig
hpre select 'CRYPTO_ECDH' and 'CRYPTO_CURVE25519'. Signed-off-by: Hui Tang --- drivers/crypto/hisilicon/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/hisilicon/Kconfig b/drivers/crypto/hisilicon/Kconfig index c45adb1..e572f99 100644 --- a/drivers/crypto/hisilicon/Kconfig +++ b/drivers/crypto/hisilicon/Kconfig @@ -65,10 +65,11 @@ config CRYPTO_DEV_HISI_HPRE depends on UACCE || UACCE=n depends on ARM64 || (COMPILE_TEST && 64BIT) depends on ACPI - select CRYPTO_LIB_CURVE25519_GENERIC select CRYPTO_DEV_HISI_QM select CRYPTO_DH select CRYPTO_RSA + select CRYPTO_CURVE25519 + select CRYPTO_ECDH help Support for HiSilicon HPRE(High Performance RSA Engine) accelerator, which can accelerate RSA and DH algorithms. -- 2.8.1
[PATCH] crypto: hisilicon/hpre - fix "hpre_ctx_init" resource leak
When calling "hpre_ctx_set" fails, stop and put qp, otherwise will leak qp resource. Signed-off-by: Hui Tang --- drivers/crypto/hisilicon/hpre/hpre_crypto.c | 13 - 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/hisilicon/hpre/hpre_crypto.c b/drivers/crypto/hisilicon/hpre/hpre_crypto.c index b77473b..d7a4adf 100644 --- a/drivers/crypto/hisilicon/hpre/hpre_crypto.c +++ b/drivers/crypto/hisilicon/hpre/hpre_crypto.c @@ -458,9 +458,16 @@ static void hpre_alg_cb(struct hisi_qp *qp, void *resp) req->cb(ctx, resp); } +static void hpre_stop_qp_and_put(struct hisi_qp *qp) +{ + hisi_qm_stop_qp(qp); + hisi_qm_free_qps(&qp, 1); +} + static int hpre_ctx_init(struct hpre_ctx *ctx, u8 type) { struct hisi_qp *qp; + int ret; qp = hpre_get_qp_and_start(type); if (IS_ERR(qp)) @@ -469,7 +476,11 @@ static int hpre_ctx_init(struct hpre_ctx *ctx, u8 type) qp->qp_ctx = ctx; qp->req_cb = hpre_alg_cb; - return hpre_ctx_set(ctx, qp, QM_Q_DEPTH); + ret = hpre_ctx_set(ctx, qp, QM_Q_DEPTH); + if (ret) + hpre_stop_qp_and_put(qp); + + return ret; } static int hpre_msg_request_set(struct hpre_ctx *ctx, void *req, bool is_rsa) -- 2.8.1
[PATCH] crypto: hisilicon - fix the check on dma address
System may be able to get physical address of zero if not reserved by firmware. The dma address obtained by 'dma_alloc_coherent' is valid, since already checking cpu va before, so do not check again. Signed-off-by: Hui Tang --- drivers/crypto/hisilicon/hpre/hpre_crypto.c | 12 drivers/crypto/hisilicon/qm.c | 2 +- drivers/crypto/hisilicon/sec2/sec_crypto.c | 6 -- 3 files changed, 1 insertion(+), 19 deletions(-) diff --git a/drivers/crypto/hisilicon/hpre/hpre_crypto.c b/drivers/crypto/hisilicon/hpre/hpre_crypto.c index d7a4adf..d743c54 100644 --- a/drivers/crypto/hisilicon/hpre/hpre_crypto.c +++ b/drivers/crypto/hisilicon/hpre/hpre_crypto.c @@ -298,8 +298,6 @@ static void hpre_hw_data_clr_all(struct hpre_ctx *ctx, dma_addr_t tmp; tmp = le64_to_cpu(sqe->in); - if (unlikely(!tmp)) - return; if (src) { if (req->src) @@ -309,8 +307,6 @@ static void hpre_hw_data_clr_all(struct hpre_ctx *ctx, } tmp = le64_to_cpu(sqe->out); - if (unlikely(!tmp)) - return; if (req->dst) { if (dst) @@ -1369,15 +1365,11 @@ static void hpre_ecdh_hw_data_clr_all(struct hpre_ctx *ctx, dma_addr_t dma; dma = le64_to_cpu(sqe->in); - if (unlikely(!dma)) - return; if (src && req->src) dma_free_coherent(dev, ctx->key_sz << 2, req->src, dma); dma = le64_to_cpu(sqe->out); - if (unlikely(!dma)) - return; if (req->dst) dma_free_coherent(dev, ctx->key_sz << 1, req->dst, dma); @@ -1668,15 +1660,11 @@ static void hpre_curve25519_hw_data_clr_all(struct hpre_ctx *ctx, dma_addr_t dma; dma = le64_to_cpu(sqe->in); - if (unlikely(!dma)) - return; if (src && req->src) dma_free_coherent(dev, ctx->key_sz, req->src, dma); dma = le64_to_cpu(sqe->out); - if (unlikely(!dma)) - return; if (req->dst) dma_free_coherent(dev, ctx->key_sz, req->dst, dma); diff --git a/drivers/crypto/hisilicon/qm.c b/drivers/crypto/hisilicon/qm.c index bc23174..e3688bf 100644 --- a/drivers/crypto/hisilicon/qm.c +++ b/drivers/crypto/hisilicon/qm.c @@ -2681,7 +2681,7 @@ static int __hisi_qm_start(struct hisi_qm *qm) { int ret; - WARN_ON(!qm->qdma.dma); + WARN_ON(!qm->qdma.va); if (qm->fun_type == QM_HW_PF) { ret = qm_dev_mem_reset(qm); diff --git a/drivers/crypto/hisilicon/sec2/sec_crypto.c b/drivers/crypto/hisilicon/sec2/sec_crypto.c index f835514..6c91c90 100644 --- a/drivers/crypto/hisilicon/sec2/sec_crypto.c +++ b/drivers/crypto/hisilicon/sec2/sec_crypto.c @@ -710,12 +710,6 @@ static int sec_cipher_pbuf_map(struct sec_ctx *ctx, struct sec_req *req, } c_req->c_in_dma = qp_ctx->res[req_id].pbuf_dma; - - if (!c_req->c_in_dma) { - dev_err(dev, "fail to set pbuffer address!\n"); - return -ENOMEM; - } - c_req->c_out_dma = c_req->c_in_dma; return 0; -- 2.8.1
[PATCH 0/2] crypto: hisilicon/hpre - remove 'CONFIG_CRYPTO_DH'
Remove 'CONFIG_CRYPTO_DH' and optimise 'hpre_algs_register' error path. Hui Tang (2): crypto: hisilicon/hpre - delete wrap of 'CONFIG_CRYPTO_DH' crypto: hisilicon/hpre - optimise 'hpre_algs_register' error path drivers/crypto/hisilicon/hpre/hpre_crypto.c | 30 ++--- 1 file changed, 10 insertions(+), 20 deletions(-) -- 2.8.1
[PATCH 2/2] crypto: hisilicon/hpre - optimise 'hpre_algs_register' error path
There is redundant code especially when registing new algorithms in the future. Signed-off-by: Hui Tang --- drivers/crypto/hisilicon/hpre/hpre_crypto.c | 19 +-- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/crypto/hisilicon/hpre/hpre_crypto.c b/drivers/crypto/hisilicon/hpre/hpre_crypto.c index 50ccd10..b77473b 100644 --- a/drivers/crypto/hisilicon/hpre/hpre_crypto.c +++ b/drivers/crypto/hisilicon/hpre/hpre_crypto.c @@ -1993,25 +1993,24 @@ int hpre_algs_register(struct hisi_qm *qm) return ret; ret = crypto_register_kpp(&dh); - if (ret) { - crypto_unregister_akcipher(&rsa); - return ret; - } + if (ret) + goto unreg_rsa; if (qm->ver >= QM_HW_V3) { ret = hpre_register_ecdh(); if (ret) - goto reg_err; + goto unreg_dh; ret = crypto_register_kpp(&curve25519_alg); - if (ret) { - hpre_unregister_ecdh(); - goto reg_err; - } + if (ret) + goto unreg_ecdh; } return 0; -reg_err: +unreg_ecdh: + hpre_unregister_ecdh(); +unreg_dh: crypto_unregister_kpp(&dh); +unreg_rsa: crypto_unregister_akcipher(&rsa); return ret; } -- 2.8.1
[PATCH 1/2] crypto: hisilicon/hpre - delete wrap of 'CONFIG_CRYPTO_DH'
'CRYPTO_DH' has selected in 'Kconfig', so delete 'CONFIG_CRYPTO_DH'. Signed-off-by: Hui Tang --- drivers/crypto/hisilicon/hpre/hpre_crypto.c | 11 +-- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/drivers/crypto/hisilicon/hpre/hpre_crypto.c b/drivers/crypto/hisilicon/hpre/hpre_crypto.c index 53068d2..50ccd10 100644 --- a/drivers/crypto/hisilicon/hpre/hpre_crypto.c +++ b/drivers/crypto/hisilicon/hpre/hpre_crypto.c @@ -546,7 +546,6 @@ static int hpre_send(struct hpre_ctx *ctx, struct hpre_sqe *msg) return ret; } -#ifdef CONFIG_CRYPTO_DH static int hpre_dh_compute_value(struct kpp_request *req) { struct crypto_kpp *tfm = crypto_kpp_reqtfm(req); @@ -719,7 +718,6 @@ static void hpre_dh_exit_tfm(struct crypto_kpp *tfm) hpre_dh_clear_ctx(ctx, true); } -#endif static void hpre_rsa_drop_leading_zeros(const char **ptr, size_t *len) { @@ -1893,7 +1891,6 @@ static struct akcipher_alg rsa = { }, }; -#ifdef CONFIG_CRYPTO_DH static struct kpp_alg dh = { .set_secret = hpre_dh_set_secret, .generate_public_key = hpre_dh_compute_value, @@ -1910,7 +1907,6 @@ static struct kpp_alg dh = { .cra_module = THIS_MODULE, }, }; -#endif static struct kpp_alg ecdh_nist_p192 = { .set_secret = hpre_ecdh_set_secret, @@ -1995,13 +1991,12 @@ int hpre_algs_register(struct hisi_qm *qm) ret = crypto_register_akcipher(&rsa); if (ret) return ret; -#ifdef CONFIG_CRYPTO_DH + ret = crypto_register_kpp(&dh); if (ret) { crypto_unregister_akcipher(&rsa); return ret; } -#endif if (qm->ver >= QM_HW_V3) { ret = hpre_register_ecdh(); @@ -2016,9 +2011,7 @@ int hpre_algs_register(struct hisi_qm *qm) return 0; reg_err: -#ifdef CONFIG_CRYPTO_DH crypto_unregister_kpp(&dh); -#endif crypto_unregister_akcipher(&rsa); return ret; } @@ -2030,8 +2023,6 @@ void hpre_algs_unregister(struct hisi_qm *qm) hpre_unregister_ecdh(); } -#ifdef CONFIG_CRYPTO_DH crypto_unregister_kpp(&dh); -#endif crypto_unregister_akcipher(&rsa); } -- 2.8.1
Re: [PATCH] scsi: ses: Fix crash caused by kfree an invalid pointer
On 2020/11/29 7:27, James Bottomley wrote: ---8>8>8><8<8<8 From: James Bottomley Subject: [PATCH] scsi: ses: don't attach if enclosure has no components An enclosure with no components can't usefully be operated by the driver (since effectively it has nothing to manage), so report the problem and don't attach. Not attaching also fixes an oops which could occur if the driver tries to manage a zero component enclosure. Reported-by: Ding Hui Cc: sta...@vger.kernel.org Signed-off-by: James Bottomley --- drivers/scsi/ses.c | 5 + 1 file changed, 5 insertions(+) diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c index c2afba2a5414..9624298b9c89 100644 --- a/drivers/scsi/ses.c +++ b/drivers/scsi/ses.c @@ -690,6 +690,11 @@ static int ses_intf_add(struct device *cdev, type_ptr[0] == ENCLOSURE_COMPONENT_ARRAY_DEVICE) components += type_ptr[1]; } + if (components == 0) { + sdev_printk(KERN_ERR, sdev, "enclosure has no enumerated components\n"); + goto err_free; + } + ses_dev->page1 = buf; ses_dev->page1_len = len; buf = NULL; Can I ask you to resubmit your patch ("scsi: ses: don't attach if enclosure has no components") to kernel, thanks -- Thanks, - Ding Hui
[PATCH v2 0/2] crypto: qat - fixes related to 'dma_map_single'
This patchset fix bugs related to 'dma_map_single' use: Hui Tang (2): crypto: qat - fix 'dma_unmap_single' invalid address crypto: qat - fix use of 'dma_map_single' v1 -> v2: 1.fix build warning reported by kernel test rebot 2.add patch #1 drivers/crypto/qat/qat_common/qat_algs.c | 32 1 file changed, 20 insertions(+), 12 deletions(-) -- 2.8.1
[PATCH v2 2/2] crypto: qat - fix use of 'dma_map_single'
DMA_TO_DEVICE synchronisation must be done after the last modification of the memory region by the software and before it is handed off to the device. Signed-off-by: Hui Tang Reported-by: kernel test robot Reported-by: Dan Carpenter --- drivers/crypto/qat/qat_common/qat_algs.c | 27 ++- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/drivers/crypto/qat/qat_common/qat_algs.c b/drivers/crypto/qat/qat_common/qat_algs.c index ea1c689..f998ed5 100644 --- a/drivers/crypto/qat/qat_common/qat_algs.c +++ b/drivers/crypto/qat/qat_common/qat_algs.c @@ -718,8 +718,8 @@ static int qat_alg_sgl_to_bufl(struct qat_crypto_instance *inst, int n = sg_nents(sgl); struct qat_alg_buf_list *bufl; struct qat_alg_buf_list *buflout = NULL; - dma_addr_t blp; - dma_addr_t bloutp; + dma_addr_t blp = DMA_MAPPING_ERROR; + dma_addr_t bloutp = DMA_MAPPING_ERROR; struct scatterlist *sg; size_t sz_out, sz = struct_size(bufl, bufers, n + 1); @@ -734,10 +734,6 @@ static int qat_alg_sgl_to_bufl(struct qat_crypto_instance *inst, for_each_sg(sgl, sg, n, i) bufl->bufers[i].addr = DMA_MAPPING_ERROR; - blp = dma_map_single(dev, bufl, sz, DMA_TO_DEVICE); - if (unlikely(dma_mapping_error(dev, blp))) - goto err_in; - for_each_sg(sgl, sg, n, i) { int y = sg_nctr; @@ -753,6 +749,9 @@ static int qat_alg_sgl_to_bufl(struct qat_crypto_instance *inst, sg_nctr++; } bufl->num_bufs = sg_nctr; + blp = dma_map_single(dev, bufl, sz, DMA_TO_DEVICE); + if (unlikely(dma_mapping_error(dev, blp))) + goto err_in; qat_req->buf.bl = bufl; qat_req->buf.blp = blp; qat_req->buf.sz = sz; @@ -772,9 +771,6 @@ static int qat_alg_sgl_to_bufl(struct qat_crypto_instance *inst, for_each_sg(sglout, sg, n, i) bufers[i].addr = DMA_MAPPING_ERROR; - bloutp = dma_map_single(dev, buflout, sz_out, DMA_TO_DEVICE); - if (unlikely(dma_mapping_error(dev, bloutp))) - goto err_out; for_each_sg(sglout, sg, n, i) { int y = sg_nctr; @@ -791,6 +787,9 @@ static int qat_alg_sgl_to_bufl(struct qat_crypto_instance *inst, } buflout->num_bufs = sg_nctr; buflout->num_mapped_bufs = sg_nctr; + bloutp = dma_map_single(dev, buflout, sz_out, DMA_TO_DEVICE); + if (unlikely(dma_mapping_error(dev, bloutp))) + goto err_out; qat_req->buf.blout = buflout; qat_req->buf.bloutp = bloutp; qat_req->buf.sz_out = sz_out; @@ -802,17 +801,21 @@ static int qat_alg_sgl_to_bufl(struct qat_crypto_instance *inst, return 0; err_out: + if (!dma_mapping_error(dev, bloutp)) + dma_unmap_single(dev, bloutp, sz_out, DMA_TO_DEVICE); + n = sg_nents(sglout); for (i = 0; i < n; i++) if (!dma_mapping_error(dev, buflout->bufers[i].addr)) dma_unmap_single(dev, buflout->bufers[i].addr, buflout->bufers[i].len, DMA_BIDIRECTIONAL); - if (!dma_mapping_error(dev, bloutp)) - dma_unmap_single(dev, bloutp, sz_out, DMA_TO_DEVICE); kfree(buflout); err_in: + if (!dma_mapping_error(dev, blp)) + dma_unmap_single(dev, blp, sz, DMA_TO_DEVICE); + n = sg_nents(sgl); for (i = 0; i < n; i++) if (!dma_mapping_error(dev, bufl->bufers[i].addr)) @@ -820,8 +823,6 @@ static int qat_alg_sgl_to_bufl(struct qat_crypto_instance *inst, bufl->bufers[i].len, DMA_BIDIRECTIONAL); - if (!dma_mapping_error(dev, blp)) - dma_unmap_single(dev, blp, sz, DMA_TO_DEVICE); kfree(bufl); dev_err(dev, "Failed to map buf for dma\n"); -- 2.8.1
[PATCH v2 1/2] crypto: qat - fix unmap invalid dma address
'dma_mapping_error' return a negative value if 'dma_addr' is equal to 'DMA_MAPPING_ERROR' not zero, so fix initialization of 'dma_addr'. Signed-off-by: Hui Tang --- drivers/crypto/qat/qat_common/qat_algs.c | 11 +-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/crypto/qat/qat_common/qat_algs.c b/drivers/crypto/qat/qat_common/qat_algs.c index ff78c73..ea1c689 100644 --- a/drivers/crypto/qat/qat_common/qat_algs.c +++ b/drivers/crypto/qat/qat_common/qat_algs.c @@ -719,7 +719,7 @@ static int qat_alg_sgl_to_bufl(struct qat_crypto_instance *inst, struct qat_alg_buf_list *bufl; struct qat_alg_buf_list *buflout = NULL; dma_addr_t blp; - dma_addr_t bloutp = 0; + dma_addr_t bloutp; struct scatterlist *sg; size_t sz_out, sz = struct_size(bufl, bufers, n + 1); @@ -731,6 +731,9 @@ static int qat_alg_sgl_to_bufl(struct qat_crypto_instance *inst, if (unlikely(!bufl)) return -ENOMEM; + for_each_sg(sgl, sg, n, i) + bufl->bufers[i].addr = DMA_MAPPING_ERROR; + blp = dma_map_single(dev, bufl, sz, DMA_TO_DEVICE); if (unlikely(dma_mapping_error(dev, blp))) goto err_in; @@ -764,10 +767,14 @@ static int qat_alg_sgl_to_bufl(struct qat_crypto_instance *inst, dev_to_node(&GET_DEV(inst->accel_dev))); if (unlikely(!buflout)) goto err_in; + + bufers = buflout->bufers; + for_each_sg(sglout, sg, n, i) + bufers[i].addr = DMA_MAPPING_ERROR; + bloutp = dma_map_single(dev, buflout, sz_out, DMA_TO_DEVICE); if (unlikely(dma_mapping_error(dev, bloutp))) goto err_out; - bufers = buflout->bufers; for_each_sg(sglout, sg, n, i) { int y = sg_nctr; -- 2.8.1
[PATCH] video: fbdev: fix use of 'dma_map_single'
DMA_TO_DEVICE synchronisation must be done after the last modification of the memory region by the software and before it is handed off to the device. Signed-off-by: Hui Tang --- drivers/video/fbdev/grvga.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/grvga.c b/drivers/video/fbdev/grvga.c index 24818b2..25ae9ef 100644 --- a/drivers/video/fbdev/grvga.c +++ b/drivers/video/fbdev/grvga.c @@ -435,6 +435,8 @@ static int grvga_probe(struct platform_device *dev) retval = -ENOMEM; goto dealloc_cmap; } + + memset((unsigned long *) virtual_start, 0, grvga_mem_size); } else {/* Allocate frambuffer memory */ unsigned long page; @@ -449,6 +451,7 @@ static int grvga_probe(struct platform_device *dev) goto dealloc_cmap; } + memset((unsigned long *) virtual_start, 0, grvga_mem_size); physical_start = dma_map_single(&dev->dev, (void *)virtual_start, grvga_mem_size, DMA_TO_DEVICE); /* Set page reserved so that mmap will work. This is necessary @@ -463,8 +466,6 @@ static int grvga_probe(struct platform_device *dev) par->fb_alloced = 1; } - memset((unsigned long *) virtual_start, 0, grvga_mem_size); - info->screen_base = (char __iomem *) virtual_start; info->fix.smem_start = physical_start; info->fix.smem_len = grvga_mem_size; -- 2.8.1
[PATCH] crypto: qat - fix use of 'dma_map_single'
DMA_TO_DEVICE synchronisation must be done after the last modification of the memory region by the software and before it is handed off to the device. Signed-off-by: Hui Tang --- drivers/crypto/qat/qat_common/qat_algs.c | 23 --- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/crypto/qat/qat_common/qat_algs.c b/drivers/crypto/qat/qat_common/qat_algs.c index ff78c73..e88c534 100644 --- a/drivers/crypto/qat/qat_common/qat_algs.c +++ b/drivers/crypto/qat/qat_common/qat_algs.c @@ -731,10 +731,6 @@ static int qat_alg_sgl_to_bufl(struct qat_crypto_instance *inst, if (unlikely(!bufl)) return -ENOMEM; - blp = dma_map_single(dev, bufl, sz, DMA_TO_DEVICE); - if (unlikely(dma_mapping_error(dev, blp))) - goto err_in; - for_each_sg(sgl, sg, n, i) { int y = sg_nctr; @@ -750,6 +746,9 @@ static int qat_alg_sgl_to_bufl(struct qat_crypto_instance *inst, sg_nctr++; } bufl->num_bufs = sg_nctr; + blp = dma_map_single(dev, bufl, sz, DMA_TO_DEVICE); + if (unlikely(dma_mapping_error(dev, blp))) + goto err_in; qat_req->buf.bl = bufl; qat_req->buf.blp = blp; qat_req->buf.sz = sz; @@ -764,9 +763,6 @@ static int qat_alg_sgl_to_bufl(struct qat_crypto_instance *inst, dev_to_node(&GET_DEV(inst->accel_dev))); if (unlikely(!buflout)) goto err_in; - bloutp = dma_map_single(dev, buflout, sz_out, DMA_TO_DEVICE); - if (unlikely(dma_mapping_error(dev, bloutp))) - goto err_out; bufers = buflout->bufers; for_each_sg(sglout, sg, n, i) { int y = sg_nctr; @@ -784,6 +780,9 @@ static int qat_alg_sgl_to_bufl(struct qat_crypto_instance *inst, } buflout->num_bufs = sg_nctr; buflout->num_mapped_bufs = sg_nctr; + bloutp = dma_map_single(dev, buflout, sz_out, DMA_TO_DEVICE); + if (unlikely(dma_mapping_error(dev, bloutp))) + goto err_out; qat_req->buf.blout = buflout; qat_req->buf.bloutp = bloutp; qat_req->buf.sz_out = sz_out; @@ -795,17 +794,21 @@ static int qat_alg_sgl_to_bufl(struct qat_crypto_instance *inst, return 0; err_out: + if (!dma_mapping_error(dev, bloutp)) + dma_unmap_single(dev, bloutp, sz_out, DMA_TO_DEVICE); + n = sg_nents(sglout); for (i = 0; i < n; i++) if (!dma_mapping_error(dev, buflout->bufers[i].addr)) dma_unmap_single(dev, buflout->bufers[i].addr, buflout->bufers[i].len, DMA_BIDIRECTIONAL); - if (!dma_mapping_error(dev, bloutp)) - dma_unmap_single(dev, bloutp, sz_out, DMA_TO_DEVICE); kfree(buflout); err_in: + if (!dma_mapping_error(dev, blp)) + dma_unmap_single(dev, blp, sz, DMA_TO_DEVICE); + n = sg_nents(sgl); for (i = 0; i < n; i++) if (!dma_mapping_error(dev, bufl->bufers[i].addr)) @@ -813,8 +816,6 @@ static int qat_alg_sgl_to_bufl(struct qat_crypto_instance *inst, bufl->bufers[i].len, DMA_BIDIRECTIONAL); - if (!dma_mapping_error(dev, blp)) - dma_unmap_single(dev, blp, sz, DMA_TO_DEVICE); kfree(bufl); dev_err(dev, "Failed to map buf for dma\n"); -- 2.8.1
[PATCH] crypto: hisilicon/hpre - enable Elliptic curve cryptography
Enable x25519/x448/ecdh/ecdsa/sm2 algorithm on Kunpeng 930. Signed-off-by: Hui Tang --- drivers/crypto/hisilicon/hpre/hpre_main.c | 9 - 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/hisilicon/hpre/hpre_main.c b/drivers/crypto/hisilicon/hpre/hpre_main.c index 67f1fca..db170fc 100644 --- a/drivers/crypto/hisilicon/hpre/hpre_main.c +++ b/drivers/crypto/hisilicon/hpre/hpre_main.c @@ -30,6 +30,8 @@ #define HPRE_BD_ARUSR_CFG 0x301030 #define HPRE_BD_AWUSR_CFG 0x301034 #define HPRE_TYPES_ENB 0x301038 +#define HPRE_RSA_ENB BIT(0) +#define HPRE_ECC_ENB BIT(1) #define HPRE_DATA_RUSER_CFG0x30103c #define HPRE_DATA_WUSER_CFG0x301040 #define HPRE_INT_MASK 0x301400 @@ -348,7 +350,12 @@ static int hpre_set_user_domain_and_cache(struct hisi_qm *qm) val |= BIT(HPRE_TIMEOUT_ABNML_BIT); writel_relaxed(val, HPRE_ADDR(qm, HPRE_QM_ABNML_INT_MASK)); - writel(0x1, HPRE_ADDR(qm, HPRE_TYPES_ENB)); + if (qm->ver >= QM_HW_V3) + writel(HPRE_RSA_ENB | HPRE_ECC_ENB, + HPRE_ADDR(qm, HPRE_TYPES_ENB)); + else + writel(HPRE_RSA_ENB, HPRE_ADDR(qm, HPRE_TYPES_ENB)); + writel(HPRE_QM_VFG_AX_MASK, HPRE_ADDR(qm, HPRE_VFG_AXCACHE)); writel(0x0, HPRE_ADDR(qm, HPRE_BD_ENDIAN)); writel(0x0, HPRE_ADDR(qm, HPRE_INT_MASK)); -- 2.8.1
[PATCH 0/4] crypto: hisilicon - some updates to adapt Kunpeng930
1.Update clusters number for both Kunpeng920 and Kunpeng930. 2.Some bugfixs only on Kunpeng920, so added hardware version wrap. 3.Fix use of 'dma_map_single'. 4.Fix PASID on Kunpeng930. Hui Tang (2): crypto: hisilicon/hpre - adapt the number of clusters crypto: hisilicon/hpre - tiny fix Weili Qian (2): crypto:hisilicon/qm - fix use of "dma_map_single" crypto:hisilicon - PASID fixed on Kupeng 930 drivers/crypto/hisilicon/hpre/hpre.h | 8 ++- drivers/crypto/hisilicon/hpre/hpre_main.c | 100 +++--- drivers/crypto/hisilicon/qm.c | 61 +++--- drivers/crypto/hisilicon/qm.h | 1 + drivers/crypto/hisilicon/sec2/sec_main.c | 2 +- drivers/crypto/hisilicon/zip/zip_main.c | 2 +- 6 files changed, 110 insertions(+), 64 deletions(-) -- 2.8.1
[PATCH 3/4] crypto: hisilicon/qm - fix use of 'dma_map_single'
From: Weili Qian Calling 'dma_map_single' after the data is written to ensure that the cpu cache and dma cache are consistent. Signed-off-by: Weili Qian Signed-off-by: Hui Tang --- drivers/crypto/hisilicon/qm.c | 50 +++ 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/drivers/crypto/hisilicon/qm.c b/drivers/crypto/hisilicon/qm.c index 904b99a..93d4a21 100644 --- a/drivers/crypto/hisilicon/qm.c +++ b/drivers/crypto/hisilicon/qm.c @@ -1747,12 +1747,6 @@ static int qm_sq_ctx_cfg(struct hisi_qp *qp, int qp_id, u32 pasid) sqc = kzalloc(sizeof(struct qm_sqc), GFP_KERNEL); if (!sqc) return -ENOMEM; - sqc_dma = dma_map_single(dev, sqc, sizeof(struct qm_sqc), -DMA_TO_DEVICE); - if (dma_mapping_error(dev, sqc_dma)) { - kfree(sqc); - return -ENOMEM; - } INIT_QC_COMMON(sqc, qp->sqe_dma, pasid); if (ver == QM_HW_V1) { @@ -1765,6 +1759,13 @@ static int qm_sq_ctx_cfg(struct hisi_qp *qp, int qp_id, u32 pasid) sqc->cq_num = cpu_to_le16(qp_id); sqc->w13 = cpu_to_le16(QM_MK_SQC_W13(0, 1, qp->alg_type)); + sqc_dma = dma_map_single(dev, sqc, sizeof(struct qm_sqc), +DMA_TO_DEVICE); + if (dma_mapping_error(dev, sqc_dma)) { + kfree(sqc); + return -ENOMEM; + } + ret = qm_mb(qm, QM_MB_CMD_SQC, sqc_dma, qp_id, 0); dma_unmap_single(dev, sqc_dma, sizeof(struct qm_sqc), DMA_TO_DEVICE); kfree(sqc); @@ -1784,12 +1785,6 @@ static int qm_cq_ctx_cfg(struct hisi_qp *qp, int qp_id, u32 pasid) cqc = kzalloc(sizeof(struct qm_cqc), GFP_KERNEL); if (!cqc) return -ENOMEM; - cqc_dma = dma_map_single(dev, cqc, sizeof(struct qm_cqc), -DMA_TO_DEVICE); - if (dma_mapping_error(dev, cqc_dma)) { - kfree(cqc); - return -ENOMEM; - } INIT_QC_COMMON(cqc, qp->cqe_dma, pasid); if (ver == QM_HW_V1) { @@ -1802,6 +1797,13 @@ static int qm_cq_ctx_cfg(struct hisi_qp *qp, int qp_id, u32 pasid) } cqc->dw6 = cpu_to_le32(1 << QM_CQ_PHASE_SHIFT | 1 << QM_CQ_FLAG_SHIFT); + cqc_dma = dma_map_single(dev, cqc, sizeof(struct qm_cqc), +DMA_TO_DEVICE); + if (dma_mapping_error(dev, cqc_dma)) { + kfree(cqc); + return -ENOMEM; + } + ret = qm_mb(qm, QM_MB_CMD_CQC, cqc_dma, qp_id, 0); dma_unmap_single(dev, cqc_dma, sizeof(struct qm_cqc), DMA_TO_DEVICE); kfree(cqc); @@ -2558,15 +2560,9 @@ static int qm_eq_ctx_cfg(struct hisi_qm *qm) dma_addr_t eqc_dma; int ret; - eqc = kzalloc(sizeof(struct qm_eqc), GFP_KERNEL); //todo + eqc = kzalloc(sizeof(struct qm_eqc), GFP_KERNEL); if (!eqc) return -ENOMEM; - eqc_dma = dma_map_single(dev, eqc, sizeof(struct qm_eqc), -DMA_TO_DEVICE); - if (dma_mapping_error(dev, eqc_dma)) { - kfree(eqc); - return -ENOMEM; - } eqc->base_l = cpu_to_le32(lower_32_bits(qm->eqe_dma)); eqc->base_h = cpu_to_le32(upper_32_bits(qm->eqe_dma)); @@ -2574,6 +2570,13 @@ static int qm_eq_ctx_cfg(struct hisi_qm *qm) eqc->dw3 = cpu_to_le32(QM_EQE_AEQE_SIZE); eqc->dw6 = cpu_to_le32((QM_EQ_DEPTH - 1) | (1 << QM_EQC_PHASE_SHIFT)); + eqc_dma = dma_map_single(dev, eqc, sizeof(struct qm_eqc), +DMA_TO_DEVICE); + if (dma_mapping_error(dev, eqc_dma)) { + kfree(eqc); + return -ENOMEM; + } + ret = qm_mb(qm, QM_MB_CMD_EQC, eqc_dma, 0, 0); dma_unmap_single(dev, eqc_dma, sizeof(struct qm_eqc), DMA_TO_DEVICE); kfree(eqc); @@ -2591,6 +2594,11 @@ static int qm_aeq_ctx_cfg(struct hisi_qm *qm) aeqc = kzalloc(sizeof(struct qm_aeqc), GFP_KERNEL); if (!aeqc) return -ENOMEM; + + aeqc->base_l = cpu_to_le32(lower_32_bits(qm->aeqe_dma)); + aeqc->base_h = cpu_to_le32(upper_32_bits(qm->aeqe_dma)); + aeqc->dw6 = cpu_to_le32((QM_Q_DEPTH - 1) | (1 << QM_EQC_PHASE_SHIFT)); + aeqc_dma = dma_map_single(dev, aeqc, sizeof(struct qm_aeqc), DMA_TO_DEVICE); if (dma_mapping_error(dev, aeqc_dma)) { @@ -2598,10 +2606,6 @@ static int qm_aeq_ctx_cfg(struct hisi_qm *qm) return -ENOMEM; } - aeqc->base_l = cpu_to_le32(lower_32_bits(qm->aeqe_dma)); - aeqc->base_h = cpu_to_le32(upper_32_bits(qm->aeqe_dma)); - aeqc->dw6 = cpu_to_le32((QM_Q_DEPTH - 1) | (1 << QM_EQC_PHASE_SHIFT)); - ret = qm_mb(qm, QM_MB_CMD_AEQC, aeqc_dma, 0, 0); dma_unmap_single(dev, aeqc_dma, sizeof(struct qm_aeqc), DMA_TO_DEVICE); kfree(aeqc); -- 2.8.1
[PATCH 2/4] crypto: hisilicon/hpre - tiny fix
Update since some special settings only for Kunpeng920. Signed-off-by: Hui Tang --- drivers/crypto/hisilicon/hpre/hpre_main.c | 13 - 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/crypto/hisilicon/hpre/hpre_main.c b/drivers/crypto/hisilicon/hpre/hpre_main.c index 0045261..06448b8 100644 --- a/drivers/crypto/hisilicon/hpre/hpre_main.c +++ b/drivers/crypto/hisilicon/hpre/hpre_main.c @@ -318,7 +318,7 @@ static int hpre_set_cluster(struct hisi_qm *qm) } /* - * For Hi1620, we shoul disable FLR triggered by hardware (BME/PM/SRIOV). + * For Kunpeng 920, we shoul disable FLR triggered by hardware (BME/PM/SRIOV). * Or it may stay in D3 state when we bind and unbind hpre quickly, * as it does FLR triggered by hardware. */ @@ -376,11 +376,14 @@ static int hpre_set_user_domain_and_cache(struct hisi_qm *qm) if (ret) return -ETIMEDOUT; - ret = hpre_cfg_by_dsm(qm); - if (ret) - dev_err(dev, "acpi_evaluate_dsm err.\n"); + /* This setting is only needed by Kunpeng 920. */ + if (qm->ver == QM_HW_V2) { + ret = hpre_cfg_by_dsm(qm); + if (ret) + dev_err(dev, "acpi_evaluate_dsm err.\n"); - disable_flr_of_bme(qm); + disable_flr_of_bme(qm); + } return ret; } -- 2.8.1
[PATCH 1/4] crypto: hisilicon/hpre - adapt the number of clusters
HPRE of Kunpeng 930 is updated on cluster numbers, so we try to update this driver to make it running okay on Kunpeng920/Kunpeng930 chips. Signed-off-by: Hui Tang --- drivers/crypto/hisilicon/hpre/hpre.h | 8 ++-- drivers/crypto/hisilicon/hpre/hpre_main.c | 71 --- 2 files changed, 52 insertions(+), 27 deletions(-) diff --git a/drivers/crypto/hisilicon/hpre/hpre.h b/drivers/crypto/hisilicon/hpre/hpre.h index f69252b..181c109 100644 --- a/drivers/crypto/hisilicon/hpre/hpre.h +++ b/drivers/crypto/hisilicon/hpre/hpre.h @@ -14,8 +14,7 @@ enum { HPRE_CLUSTER0, HPRE_CLUSTER1, HPRE_CLUSTER2, - HPRE_CLUSTER3, - HPRE_CLUSTERS_NUM, + HPRE_CLUSTER3 }; enum hpre_ctrl_dbgfs_file { @@ -36,7 +35,10 @@ enum hpre_dfx_dbgfs_file { HPRE_DFX_FILE_NUM }; -#define HPRE_DEBUGFS_FILE_NUM(HPRE_DEBUG_FILE_NUM + HPRE_CLUSTERS_NUM - 1) +#define HPRE_CLUSTERS_NUM_V2 (HPRE_CLUSTER3 + 1) +#define HPRE_CLUSTERS_NUM_V3 1 +#define HPRE_CLUSTERS_NUM_MAX HPRE_CLUSTERS_NUM_V2 +#define HPRE_DEBUGFS_FILE_NUM (HPRE_DEBUG_FILE_NUM + HPRE_CLUSTERS_NUM_MAX - 1) struct hpre_debugfs_file { int index; diff --git a/drivers/crypto/hisilicon/hpre/hpre_main.c b/drivers/crypto/hisilicon/hpre/hpre_main.c index 3b3481e..0045261 100644 --- a/drivers/crypto/hisilicon/hpre/hpre_main.c +++ b/drivers/crypto/hisilicon/hpre/hpre_main.c @@ -73,7 +73,8 @@ #define HPRE_QM_AXI_CFG_MASK 0x #define HPRE_QM_VFG_AX_MASK0xff #define HPRE_BD_USR_MASK 0x3 -#define HPRE_CLUSTER_CORE_MASK 0xf +#define HPRE_CLUSTER_CORE_MASK_V2 0xf +#define HPRE_CLUSTER_CORE_MASK_V3 0xff #define HPRE_AM_OOO_SHUTDOWN_ENB 0x301044 #define HPRE_AM_OOO_SHUTDOWN_ENABLEBIT(0) @@ -86,6 +87,11 @@ #define HPRE_QM_PM_FLR BIT(11) #define HPRE_QM_SRIOV_FLR BIT(12) +#define HPRE_CLUSTERS_NUM(qm) \ + (((qm)->ver >= QM_HW_V3) ? HPRE_CLUSTERS_NUM_V3 : HPRE_CLUSTERS_NUM_V2) +#define HPRE_CLUSTER_CORE_MASK(qm) \ + (((qm)->ver >= QM_HW_V3) ? HPRE_CLUSTER_CORE_MASK_V3 :\ + HPRE_CLUSTER_CORE_MASK_V2) #define HPRE_VIA_MSI_DSM 1 #define HPRE_SQE_MASK_OFFSET 8 #define HPRE_SQE_MASK_LEN 24 @@ -279,6 +285,38 @@ static int hpre_cfg_by_dsm(struct hisi_qm *qm) return 0; } +static int hpre_set_cluster(struct hisi_qm *qm) +{ + u32 cluster_core_mask = HPRE_CLUSTER_CORE_MASK(qm); + u8 clusters_num = HPRE_CLUSTERS_NUM(qm); + struct device *dev = &qm->pdev->dev; + unsigned long offset; + u32 val = 0; + int ret, i; + + for (i = 0; i < clusters_num; i++) { + offset = i * HPRE_CLSTR_ADDR_INTRVL; + + /* clusters initiating */ + writel(cluster_core_mask, + HPRE_ADDR(qm, offset + HPRE_CORE_ENB)); + writel(0x1, HPRE_ADDR(qm, offset + HPRE_CORE_INI_CFG)); + ret = readl_relaxed_poll_timeout(HPRE_ADDR(qm, offset + + HPRE_CORE_INI_STATUS), val, + ((val & cluster_core_mask) == + cluster_core_mask), + HPRE_REG_RD_INTVRL_US, + HPRE_REG_RD_TMOUT_US); + if (ret) { + dev_err(dev, + "cluster %d int st status timeout!\n", i); + return -ETIMEDOUT; + } + } + + return 0; +} + /* * For Hi1620, we shoul disable FLR triggered by hardware (BME/PM/SRIOV). * Or it may stay in D3 state when we bind and unbind hpre quickly, @@ -298,9 +336,8 @@ static void disable_flr_of_bme(struct hisi_qm *qm) static int hpre_set_user_domain_and_cache(struct hisi_qm *qm) { struct device *dev = &qm->pdev->dev; - unsigned long offset; - int ret, i; u32 val; + int ret; writel(HPRE_QM_USR_CFG_MASK, HPRE_ADDR(qm, QM_ARUSER_M_CFG_ENABLE)); writel(HPRE_QM_USR_CFG_MASK, HPRE_ADDR(qm, QM_AWUSER_M_CFG_ENABLE)); @@ -335,25 +372,9 @@ static int hpre_set_user_domain_and_cache(struct hisi_qm *qm) return -ETIMEDOUT; } - for (i = 0; i < HPRE_CLUSTERS_NUM; i++) { - offset = i * HPRE_CLSTR_ADDR_INTRVL; - - /* clusters initiating */ - writel(HPRE_CLUSTER_CORE_MASK, - HPRE_ADDR(qm, offset + HPRE_CORE_ENB)); - writel(0x1, HPRE_ADDR(qm, offset + HPRE_CORE_INI_CFG)); - ret = readl_relaxed_poll_timeout(HPRE_ADDR(qm, offset + - HPRE_CORE_INI_STATUS), val, - ((val & HPRE_CLUSTER_CORE_MASK) == -
[PATCH 4/4] crypto: hisilicon - PASID fixed on Kunpeng 930
From: Weili Qian Enable PASID by setting 'sqc' and 'cqc' pasid bits per queue in Kunpeng 930. For Kunpeng 920, PASID is effective for all queues once set in SVA scenarios. Signed-off-by: Weili Qian Signed-off-by: Hui Tang --- drivers/crypto/hisilicon/hpre/hpre_main.c | 18 ++ drivers/crypto/hisilicon/qm.c | 11 +++ drivers/crypto/hisilicon/qm.h | 1 + drivers/crypto/hisilicon/sec2/sec_main.c | 2 +- drivers/crypto/hisilicon/zip/zip_main.c | 2 +- 5 files changed, 24 insertions(+), 10 deletions(-) diff --git a/drivers/crypto/hisilicon/hpre/hpre_main.c b/drivers/crypto/hisilicon/hpre/hpre_main.c index 06448b8..67f1fca 100644 --- a/drivers/crypto/hisilicon/hpre/hpre_main.c +++ b/drivers/crypto/hisilicon/hpre/hpre_main.c @@ -356,10 +356,6 @@ static int hpre_set_user_domain_and_cache(struct hisi_qm *qm) writel(0x0, HPRE_ADDR(qm, HPRE_COMM_CNT_CLR_CE)); writel(0x0, HPRE_ADDR(qm, HPRE_ECC_BYPASS)); - /* Enable data buffer pasid */ - if (qm->use_sva) - hpre_pasid_enable(qm); - writel(HPRE_BD_USR_MASK, HPRE_ADDR(qm, HPRE_BD_ARUSR_CFG)); writel(HPRE_BD_USR_MASK, HPRE_ADDR(qm, HPRE_BD_AWUSR_CFG)); writel(0x1, HPRE_ADDR(qm, HPRE_RDCHN_INI_CFG)); @@ -383,6 +379,10 @@ static int hpre_set_user_domain_and_cache(struct hisi_qm *qm) dev_err(dev, "acpi_evaluate_dsm err.\n"); disable_flr_of_bme(qm); + + /* Enable data buffer pasid */ + if (qm->use_sva) + hpre_pasid_enable(qm); } return ret; @@ -993,16 +993,18 @@ static void hpre_remove(struct pci_dev *pdev) return; } } + + hpre_debugfs_exit(qm); + hisi_qm_stop(qm, QM_NORMAL); + if (qm->fun_type == QM_HW_PF) { - if (qm->use_sva) + if (qm->use_sva && qm->ver == QM_HW_V2) hpre_pasid_disable(qm); hpre_cnt_regs_clear(qm); qm->debug.curr_qm_qp_num = 0; + hisi_qm_dev_err_uninit(qm); } - hpre_debugfs_exit(qm); - hisi_qm_stop(qm, QM_NORMAL); - hisi_qm_dev_err_uninit(qm); hisi_qm_uninit(qm); } diff --git a/drivers/crypto/hisilicon/qm.c b/drivers/crypto/hisilicon/qm.c index 93d4a21..c36c4a5 100644 --- a/drivers/crypto/hisilicon/qm.c +++ b/drivers/crypto/hisilicon/qm.c @@ -54,6 +54,8 @@ #define QM_SQ_PRIORITY_SHIFT 0 #define QM_SQ_ORDERS_SHIFT 4 #define QM_SQ_TYPE_SHIFT 8 +#define QM_QC_PASID_ENABLE 0x1 +#define QM_QC_PASID_ENABLE_SHIFT 7 #define QM_SQ_TYPE_MASKGENMASK(3, 0) #define QM_SQ_TAIL_IDX(sqc)((le16_to_cpu((sqc)->w11) >> 6) & 0x1) @@ -1685,6 +1687,7 @@ static struct hisi_qp *qm_create_qp_nolock(struct hisi_qm *qm, u8 alg_type) qp->req_cb = NULL; qp->qp_id = qp_id; qp->alg_type = alg_type; + qp->is_in_kernel = true; qm->qp_in_used++; atomic_set(&qp->qp_status.flags, QP_INIT); @@ -1759,6 +1762,10 @@ static int qm_sq_ctx_cfg(struct hisi_qp *qp, int qp_id, u32 pasid) sqc->cq_num = cpu_to_le16(qp_id); sqc->w13 = cpu_to_le16(QM_MK_SQC_W13(0, 1, qp->alg_type)); + if (ver >= QM_HW_V3 && qm->use_sva && !qp->is_in_kernel) + sqc->w11 = cpu_to_le16(QM_QC_PASID_ENABLE << + QM_QC_PASID_ENABLE_SHIFT); + sqc_dma = dma_map_single(dev, sqc, sizeof(struct qm_sqc), DMA_TO_DEVICE); if (dma_mapping_error(dev, sqc_dma)) { @@ -1797,6 +1804,9 @@ static int qm_cq_ctx_cfg(struct hisi_qp *qp, int qp_id, u32 pasid) } cqc->dw6 = cpu_to_le32(1 << QM_CQ_PHASE_SHIFT | 1 << QM_CQ_FLAG_SHIFT); + if (ver >= QM_HW_V3 && qm->use_sva && !qp->is_in_kernel) + cqc->w11 = cpu_to_le16(QM_QC_PASID_ENABLE); + cqc_dma = dma_map_single(dev, cqc, sizeof(struct qm_cqc), DMA_TO_DEVICE); if (dma_mapping_error(dev, cqc_dma)) { @@ -2067,6 +2077,7 @@ static int hisi_qm_uacce_get_queue(struct uacce_device *uacce, qp->uacce_q = q; qp->event_cb = qm_qp_event_notifier; qp->pasid = arg; + qp->is_in_kernel = false; return 0; } diff --git a/drivers/crypto/hisilicon/qm.h b/drivers/crypto/hisilicon/qm.h index c1dd0fc..8f5a3b9 100644 --- a/drivers/crypto/hisilicon/qm.h +++ b/drivers/crypto/hisilicon/qm.h @@ -288,6 +288,7 @@ struct hisi_qp { struct hisi_qm *qm; bool is_resetting; + bool is_in_kernel; u16 pasid; struct uacce_queue *uacce_q; }; diff --git a/drivers/crypto/hisilicon/sec2/sec
[PATCH] lib/stackdepot.c: fix the compile warning
fix the compile warning introduced by commit b9779abb09a8 ("lib: stackdepot: add support to disable stack depot") ../lib/stackdepot.c: In function ‘is_stack_depot_disabled’: ../lib/stackdepot.c:154:2: warning: ignoring return value of ‘kstrtobool’, declared with attribute warn_unused_result [-Wunused-result] 154 | kstrtobool(str, &stack_depot_disable); | ^ Signed-off-by: Hui Su --- lib/stackdepot.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/stackdepot.c b/lib/stackdepot.c index cc21116512a7..acd13f574f97 100644 --- a/lib/stackdepot.c +++ b/lib/stackdepot.c @@ -151,7 +151,9 @@ static struct stack_record **stack_table; static int __init is_stack_depot_disabled(char *str) { - kstrtobool(str, &stack_depot_disable); + int no_warn; + + no_warn = kstrtobool(str, &stack_depot_disable); if (stack_depot_disable) { pr_info("Stack Depot is disabled\n"); stack_table = NULL; -- 2.25.1
[PATCH] usemem: Remove the duplicate do_access
From: Hui Zhu Got following error when build usemem: gcc -O -c -Wall -g usemem.c -o usemem.o usemem.c:451:15: error: redefinition of ‘do_access’ unsigned long do_access(unsigned long *p, unsigned long idx, int read) ^ usemem.c:332:15: note: previous definition of ‘do_access’ was here unsigned long do_access(unsigned long *p, unsigned long idx, int read) ^ make: *** [usemem.o] Error 1 Remove the duplicate do_access to fix this error. Signed-off-by: Hui Zhu --- usemem.c | 12 1 file changed, 12 deletions(-) diff --git a/usemem.c b/usemem.c index 48c3d65..e2c46ec 100644 --- a/usemem.c +++ b/usemem.c @@ -329,18 +329,6 @@ void detach(void) } } -unsigned long do_access(unsigned long *p, unsigned long idx, int read) -{ - volatile unsigned long *vp = p; - - if (read) - return vp[idx]; /* read data */ - else { - vp[idx] = idx; /* write data */ - return 0; - } -} - unsigned long * allocate(unsigned long bytes) { unsigned long *p; -- 1.8.3.1
[PATCH] crypto: hisilicon/hpre - add ecc algorithm inqury for uacce device
Uacce SysFS support more algorithms inqury such as 'ecdh/ecdsa/sm2/x25519/x448' Signed-off-by: Hui Tang Reviewed-by: Zaibo Xu --- drivers/crypto/hisilicon/hpre/hpre_main.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/hisilicon/hpre/hpre_main.c b/drivers/crypto/hisilicon/hpre/hpre_main.c index d46086e..3b3481e 100644 --- a/drivers/crypto/hisilicon/hpre/hpre_main.c +++ b/drivers/crypto/hisilicon/hpre/hpre_main.c @@ -778,7 +778,10 @@ static int hpre_qm_init(struct hisi_qm *qm, struct pci_dev *pdev) return -EINVAL; } - qm->algs = "rsa\ndh\n"; + if (pdev->revision >= QM_HW_V3) + qm->algs = "rsa\ndh\necdh\nx25519\nx448\necdsa\nsm2\n"; + else + qm->algs = "rsa\ndh\n"; qm->mode = uacce_mode; qm->pdev = pdev; qm->ver = pdev->revision; -- 2.8.1
[PATCH] crypto: hisilicon/hpre - add two RAS correctable errors processing
1.One CE error is detecting timeout of generating a random number. 2.Another is detecting timeout of SVA prefetching address. Signed-off-by: Hui Tang Reviewed-by: Zaibo Xu --- drivers/crypto/hisilicon/hpre/hpre_main.c | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/crypto/hisilicon/hpre/hpre_main.c b/drivers/crypto/hisilicon/hpre/hpre_main.c index bf1fa08..d46086e 100644 --- a/drivers/crypto/hisilicon/hpre/hpre_main.c +++ b/drivers/crypto/hisilicon/hpre/hpre_main.c @@ -45,7 +45,7 @@ #define HPRE_CORE_IS_SCHD_OFFSET 0x90 #define HPRE_RAS_CE_ENB0x301410 -#define HPRE_HAC_RAS_CE_ENABLE 0x1 +#define HPRE_HAC_RAS_CE_ENABLE (BIT(0) | BIT(22) | BIT(23)) #define HPRE_RAS_NFE_ENB 0x301414 #define HPRE_HAC_RAS_NFE_ENABLE0x3e #define HPRE_RAS_FE_ENB0x301418 @@ -129,7 +129,11 @@ static const struct hpre_hw_error hpre_hw_errors[] = { { .int_msk = BIT(9), .msg = "cluster4_shb_timeout_int_set" }, { .int_msk = GENMASK(15, 10), .msg = "ooo_rdrsp_err_int_set" }, { .int_msk = GENMASK(21, 16), .msg = "ooo_wrrsp_err_int_set" }, - { /* sentinel */ } + { .int_msk = BIT(22), .msg = "pt_rng_timeout_int_set"}, + { .int_msk = BIT(23), .msg = "sva_fsm_timeout_int_set"}, + { + /* sentinel */ + } }; static const u64 hpre_cluster_offsets[] = { -- 2.8.1
[PATCH] crypto: hisilicon/hpre - delete ECC 1bit error reported threshold
Delete 'HPRE_RAS_ECC1BIT_TH' register setting of hpre, since register 'QM_RAS_CE_THRESHOLD' of qm has done this work. Signed-off-by: Hui Tang Reviewed-by: Zaibo Xu --- drivers/crypto/hisilicon/hpre/hpre_main.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/crypto/hisilicon/hpre/hpre_main.c b/drivers/crypto/hisilicon/hpre/hpre_main.c index ad8b691..bf1fa08 100644 --- a/drivers/crypto/hisilicon/hpre/hpre_main.c +++ b/drivers/crypto/hisilicon/hpre/hpre_main.c @@ -36,7 +36,6 @@ #define HPRE_INT_STATUS0x301800 #define HPRE_CORE_INT_ENABLE 0 #define HPRE_CORE_INT_DISABLE 0x003f -#define HPRE_RAS_ECC_1BIT_TH 0x30140c #define HPRE_RDCHN_INI_ST 0x301a00 #define HPRE_CLSTR_BASE0x302000 #define HPRE_CORE_EN_OFFSET0x04 @@ -312,7 +311,6 @@ static int hpre_set_user_domain_and_cache(struct hisi_qm *qm) writel(HPRE_QM_VFG_AX_MASK, HPRE_ADDR(qm, HPRE_VFG_AXCACHE)); writel(0x0, HPRE_ADDR(qm, HPRE_BD_ENDIAN)); writel(0x0, HPRE_ADDR(qm, HPRE_INT_MASK)); - writel(0x0, HPRE_ADDR(qm, HPRE_RAS_ECC_1BIT_TH)); writel(0x0, HPRE_ADDR(qm, HPRE_POISON_BYPASS)); writel(0x0, HPRE_ADDR(qm, HPRE_COMM_CNT_CLR_CE)); writel(0x0, HPRE_ADDR(qm, HPRE_ECC_BYPASS)); -- 2.8.1
[tip: sched/core] sched: Use task_current() instead of 'rq->curr == p'
The following commit has been merged into the sched/core branch of tip: Commit-ID: 65bcf072e20ed7597caa902f170f293662b0af3c Gitweb: https://git.kernel.org/tip/65bcf072e20ed7597caa902f170f293662b0af3c Author:Hui Su AuthorDate:Sat, 31 Oct 2020 01:32:23 +08:00 Committer: Peter Zijlstra CommitterDate: Thu, 14 Jan 2021 11:20:11 +01:00 sched: Use task_current() instead of 'rq->curr == p' Use the task_current() function where appropriate. No functional change. Signed-off-by: Hui Su Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Steven Rostedt (VMware) Link: https://lkml.kernel.org/r/20201030173223.GA52339@rlk --- kernel/sched/deadline.c | 2 +- kernel/sched/debug.c| 2 +- kernel/sched/fair.c | 6 +++--- kernel/sched/rt.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index 75686c6..5421782 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -2514,7 +2514,7 @@ static void switched_to_dl(struct rq *rq, struct task_struct *p) static void prio_changed_dl(struct rq *rq, struct task_struct *p, int oldprio) { - if (task_on_rq_queued(p) || rq->curr == p) { + if (task_on_rq_queued(p) || task_current(rq, p)) { #ifdef CONFIG_SMP /* * This might be too much, but unfortunately diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c index 2357921..486f403 100644 --- a/kernel/sched/debug.c +++ b/kernel/sched/debug.c @@ -486,7 +486,7 @@ static char *task_group_path(struct task_group *tg) static void print_task(struct seq_file *m, struct rq *rq, struct task_struct *p) { - if (rq->curr == p) + if (task_current(rq, p)) SEQ_printf(m, ">R"); else SEQ_printf(m, " %c", task_state_to_char(p)); diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 53802b7..197a514 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -5430,7 +5430,7 @@ static void hrtick_start_fair(struct rq *rq, struct task_struct *p) s64 delta = slice - ran; if (delta < 0) { - if (rq->curr == p) + if (task_current(rq, p)) resched_curr(rq); return; } @@ -10829,7 +10829,7 @@ prio_changed_fair(struct rq *rq, struct task_struct *p, int oldprio) * our priority decreased, or if we are not currently running on * this runqueue and our priority is higher than the current's */ - if (rq->curr == p) { + if (task_current(rq, p)) { if (p->prio > oldprio) resched_curr(rq); } else @@ -10962,7 +10962,7 @@ static void switched_to_fair(struct rq *rq, struct task_struct *p) * kick off the schedule if running, otherwise just see * if we can still preempt the current task. */ - if (rq->curr == p) + if (task_current(rq, p)) resched_curr(rq); else check_preempt_curr(rq, p, 0); diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c index dbe4629..8f720b7 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -2357,7 +2357,7 @@ prio_changed_rt(struct rq *rq, struct task_struct *p, int oldprio) if (!task_on_rq_queued(p)) return; - if (rq->curr == p) { + if (task_current(rq, p)) { #ifdef CONFIG_SMP /* * If our priority decreases while running, we
Re: [PATCH] mm/page_alloc: remove the static for local variable node_order
Hi, Matthew: On Wed, Dec 30, 2020 at 12:42:33PM +, Matthew Wilcox wrote: > On Wed, Dec 30, 2020 at 07:40:14PM +0800, Hui Su wrote: > > local variable node_order do not need the static here. > > It bloody well does. It can be up to 2^10 entries on x86 (and larger > on others) That's 4kB which you've now moved onto the stack. > Thanks for your explanation, this change will put too much onto the stack in some cases which i didn't consider. Please ignore this change. > Please, learn more about what you're doing. I suggest sending patches > to drivers/staging; that will help you learn how to submit patches to > linux.
[PATCH] mm/page_alloc: remove the static for local variable node_order
local variable node_order do not need the static here. Signed-off-by: Hui Su --- mm/page_alloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index bdbec4c98173..45e049ccf117 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -5864,7 +5864,7 @@ static void build_thisnode_zonelists(pg_data_t *pgdat) static void build_zonelists(pg_data_t *pgdat) { - static int node_order[MAX_NUMNODES]; + int node_order[MAX_NUMNODES]; int node, load, nr_nodes = 0; nodemask_t used_mask = NODE_MASK_NONE; int local_node, prev_node; -- 2.25.1
Re: [blokc/blk] d828aefa7a: xfstests.xfs.372.fail
On Sat, Dec 26, 2020 at 07:31:33PM +0800, kernel test robot wrote: > > Greeting, > > FYI, we noticed the following commit (built with gcc-9): > > commit: d828aefa7a1bdf7fbc5073fdb66da9bfb1264c21 ("[PATCH v2] > blokc/blk-merge: remove the next_bvec label in __blk_bios_map_sg()") > url: > https://github.com/0day-ci/linux/commits/Hui-Su/blokc-blk-merge-remove-the-next_bvec-label-in-__blk_bios_map_sg/20201223-202618 > base: https://git.kernel.org/cgit/linux/kernel/git/axboe/linux-block.git > for-next > > in testcase: xfstests > version: xfstests-x86_64-d41dcbd-1_20201218 > with following parameters: > > disk: 4HDD > fs: xfs > test: xfs-reflink-18 > ucode: 0x21 > > test-description: xfstests is a regression test suite for xfs and other files > ystems. > test-url: git://git.kernel.org/pub/scm/fs/xfs/xfstests-dev.git > > > on test machine: 4 threads Intel(R) Core(TM) i3-3220 CPU @ 3.30GHz with 8G > memory > > caused below changes (please refer to attached dmesg/kmsg for entire > log/backtrace): > > > > > If you fix the issue, kindly add following tag > Reported-by: kernel test robot Thanks, i will take a look at it.
[PATCH v2] blokc/blk-merge: remove the next_bvec label in __blk_bios_map_sg()
remove the next_bvec label in __blk_bios_map_sg(), simplify the logic of traversal bvec. Signed-off-by: Hui Su --- block/blk-merge.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/block/blk-merge.c b/block/blk-merge.c index 808768f6b174..aa113cbc0f35 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -494,15 +494,15 @@ static int __blk_bios_map_sg(struct request_queue *q, struct bio *bio, * to bio */ if (new_bio && - __blk_segment_map_sg_merge(q, &bvec, &bvprv, sg)) - goto next_bvec; + __blk_segment_map_sg_merge(q, &bvec, &bvprv, sg)) { + new_bio = false; + continue; + } if (bvec.bv_offset + bvec.bv_len <= PAGE_SIZE) nsegs += __blk_bvec_map_sg(bvec, sglist, sg); else nsegs += blk_bvec_map_sg(q, &bvec, sglist, sg); - next_bvec: - new_bio = false; } if (likely(bio->bi_iter.bi_size)) { bvprv = bvec; -- 2.25.1
Re: [PATCH] blokc/blk-merge: remove the next_bvec label in __blk_bios_map_sg()linux-bl...@vger.kernel.org (open list:BLOCK LAYER)
On Wed, Dec 23, 2020 at 08:33:07AM +, Christoph Hellwig wrote: > On Wed, Dec 23, 2020 at 12:31:58PM +0800, sh wrote: > > remove the next_bvec label in __blk_bios_map_sg(), simplify the logic > > of traversal bvec. > > What makes you believe that this simplifies anything? 1. this change remove the jump lable, so we do not need goto. 2. we do not need to assign flase to new_bio in the bio_for_each_bvec, we only need to assign false to new_bio at first. And I have resend a PATCH V2, this change have some format problem. Thanks.
Re: [PATCH] blokc/blk-merge: remove the next_bvec label in __blk_bios_map_sg()linux-bl...@vger.kernel.org (open list:BLOCK LAYER)
Hi, all: Please ignore this change, i will resend a patch V2 later.
[PATCH] mm/buffer.c: remove the macro check in check_irqs_on()
The macro irqs_disabled is always defined in include/linux/irqflags.h, so we don't need the macro check. Signed-off-by: Hui Su --- fs/buffer.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/fs/buffer.c b/fs/buffer.c index 32647d2011df..34b505542d96 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -1247,9 +1247,7 @@ static DEFINE_PER_CPU(struct bh_lru, bh_lrus) = {{ NULL }}; static inline void check_irqs_on(void) { -#ifdef irqs_disabled BUG_ON(irqs_disabled()); -#endif } /* -- 2.25.1
[PATCH] usemem: Add option touch-alloc
Some environment will not fault in memory even if MAP_POPULATE is set. This commit add option touch-alloc to read memory after allocate it to make sure the pages is fault in. Signed-off-by: Hui Zhu --- usemem.c | 37 + 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/usemem.c b/usemem.c index 6d1d575..d93691b 100644 --- a/usemem.c +++ b/usemem.c @@ -97,6 +97,7 @@ unsigned long opt_delay = 0; int opt_read_again = 0; int opt_punch_holes = 0; int opt_init_time = 0; +int opt_touch_alloc = 0; int nr_task; int nr_thread; int nr_cpu; @@ -157,6 +158,7 @@ void usage(int ok) "-Z|--read-again read memory again after access the memory\n" "--punch-holes free every other page after allocation\n" "--init-time remove the initialization time from the run time and show the initialization time\n" + "--touch-alloc read memory after allocate it\n" "-h|--help show this message\n" , ourname); @@ -197,6 +199,7 @@ static const struct option opts[] = { { "read-again" , 0, NULL, 'Z' }, { "punch-holes" , 0, NULL, 0 }, { "init-time" , 0, NULL, 0 }, + { "touch-alloc" , 0, NULL, 0 }, { "help", 0, NULL, 'h' }, { NULL , 0, NULL, 0 } }; @@ -326,6 +329,18 @@ void detach(void) } } +unsigned long do_access(unsigned long *p, unsigned long idx, int read) +{ + volatile unsigned long *vp = p; + + if (read) + return vp[idx]; /* read data */ + else { + vp[idx] = idx; /* write data */ + return 0; + } +} + unsigned long * allocate(unsigned long bytes) { unsigned long *p; @@ -352,6 +367,14 @@ unsigned long * allocate(unsigned long bytes) p = (unsigned long *)ALIGN((unsigned long)p, pagesize - 1); } + if (opt_touch_alloc) { + unsigned long i; + unsigned long m = bytes / sizeof(*p); + + for (i = 0; i < m; i += 1) + do_access(p, i, 1); + } + return p; } @@ -433,18 +456,6 @@ void shm_unlock(int seg_id) shmctl(seg_id, SHM_UNLOCK, NULL); } -unsigned long do_access(unsigned long *p, unsigned long idx, int read) -{ - volatile unsigned long *vp = p; - - if (read) - return vp[idx]; /* read data */ - else { - vp[idx] = idx; /* write data */ - return 0; - } -} - #define NSEC_PER_SEC (1UL * 1000 * 1000 * 1000) long nsec_sub(long nsec1, long nsec2) @@ -950,6 +961,8 @@ int main(int argc, char *argv[]) opt_punch_holes = 1; } else if (strcmp(opts[opt_index].name, "init-time") == 0) { opt_init_time = 1; + } else if (strcmp(opts[opt_index].name, "touch-alloc") == 0) { + opt_touch_alloc = 1; } else usage(1); break; -- 2.17.1
[PATCH] usemem: Add option init-time
From: Hui Zhu This commit add a new option init-time to remove the initialization time from the run time and show the initialization time. Signed-off-by: Hui Zhu --- usemem.c | 29 +++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/usemem.c b/usemem.c index 823647e..6d1d575 100644 --- a/usemem.c +++ b/usemem.c @@ -96,6 +96,7 @@ int opt_bind_interval = 0; unsigned long opt_delay = 0; int opt_read_again = 0; int opt_punch_holes = 0; +int opt_init_time = 0; int nr_task; int nr_thread; int nr_cpu; @@ -155,6 +156,7 @@ void usage(int ok) "-U|--hugetlballocate hugetlbfs page\n" "-Z|--read-again read memory again after access the memory\n" "--punch-holes free every other page after allocation\n" + "--init-time remove the initialization time from the run time and show the initialization time\n" "-h|--help show this message\n" , ourname); @@ -193,7 +195,8 @@ static const struct option opts[] = { { "delay" , 1, NULL, 'e' }, { "hugetlb" , 0, NULL, 'U' }, { "read-again" , 0, NULL, 'Z' }, - { "punch-holes" , 0, NULL, 0 }, + { "punch-holes" , 0, NULL, 0 }, + { "init-time" , 0, NULL, 0 }, { "help", 0, NULL, 'h' }, { NULL , 0, NULL, 0 } }; @@ -945,6 +948,8 @@ int main(int argc, char *argv[]) case 0: if (strcmp(opts[opt_index].name, "punch-holes") == 0) { opt_punch_holes = 1; + } else if (strcmp(opts[opt_index].name, "init-time") == 0) { + opt_init_time = 1; } else usage(1); break; @@ -1128,7 +1133,7 @@ int main(int argc, char *argv[]) if (optind != argc - 1) usage(0); - if (!opt_write_signal_read) + if (!opt_write_signal_read || opt_init_time) gettimeofday(&start_time, NULL); opt_bytes = memparse(argv[optind], NULL); @@ -1263,5 +1268,25 @@ int main(int argc, char *argv[]) if (!nr_task) nr_task = 1; + if (opt_init_time) { + struct timeval stop; + char buf[1024]; + size_t len; + unsigned long delta_us; + + gettimeofday(&stop, NULL); + delta_us = (stop.tv_sec - start_time.tv_sec) * 100 + + (stop.tv_usec - start_time.tv_usec); + len = snprintf(buf, sizeof(buf), + "the initialization time is %lu secs %lu usecs\n", + delta_us / 100, delta_us % 100); + fflush(stdout); + if (write(1, buf, len) != len) + fprintf(stderr, "WARNING: statistics output may be incomplete.\n"); + + if (!opt_write_signal_read) + gettimeofday(&start_time, NULL); + } + return do_tasks(); } -- 2.17.1
[PATCH] mm/memcontrol: remove the unnecessary rcu_read_[un]lock
the rcu_read_lock and rcu_read_unlock is unnecessary in: lock_page_lruvec() lock_page_lruvec_irq() lock_page_lruvec_irqsave() Signed-off-by: Hui Su --- mm/memcontrol.c | 6 -- 1 file changed, 6 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index e3c7ca7dc174..a19f820e8a3f 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -1396,10 +1396,8 @@ struct lruvec *lock_page_lruvec(struct page *page) struct lruvec *lruvec; struct pglist_data *pgdat = page_pgdat(page); - rcu_read_lock(); lruvec = mem_cgroup_page_lruvec(page, pgdat); spin_lock(&lruvec->lru_lock); - rcu_read_unlock(); lruvec_memcg_debug(lruvec, page); @@ -1411,10 +1409,8 @@ struct lruvec *lock_page_lruvec_irq(struct page *page) struct lruvec *lruvec; struct pglist_data *pgdat = page_pgdat(page); - rcu_read_lock(); lruvec = mem_cgroup_page_lruvec(page, pgdat); spin_lock_irq(&lruvec->lru_lock); - rcu_read_unlock(); lruvec_memcg_debug(lruvec, page); @@ -1426,10 +1422,8 @@ struct lruvec *lock_page_lruvec_irqsave(struct page *page, unsigned long *flags) struct lruvec *lruvec; struct pglist_data *pgdat = page_pgdat(page); - rcu_read_lock(); lruvec = mem_cgroup_page_lruvec(page, pgdat); spin_lock_irqsave(&lruvec->lru_lock, *flags); - rcu_read_unlock(); lruvec_memcg_debug(lruvec, page); -- 2.29.2
Re: [PATCH v41 00/24] Intel SGX foundations
On Fri, Nov 13, 2020 at 12:01:11AM +0200, Jarkko Sakkinen wrote: > Overview > > > Intel(R) SGX is new hardware functionality that can be used by > applications to populate protected regions of user code and data called > enclaves. Once activated, the new hardware protects enclave code and > data from outside access and modification. > > SGX implementations have existed on desktop processors for several > years. The upcoming 3rd Generation Intel Xeon Scalable Platform, > code-named ???Ice Lake??? will also support SGX[1]. > > Use Cases > = > > Enclaves provide a place to store secrets and process data with those > secrets. SGX has been used, for example, to decrypt video without > exposing the decryption keys to nosy debuggers that might be used to > subvert DRM. Software has generally been rewritten specifically to run > in enclaves, but there are also projects that try to run limited > unmodified software in enclaves[2]. > > SGX hardware is available in public clouds today. But, anyone wishing > to use it must use a modified distribution or side-load SGX support[3]. > > Hardware Implementation > === > > New memory controller hardware encrypts data transparently before > leaving the processor package. The randomly-generated encryption key > has a lifetime of exactly one power cycle. This mitigates attacks > originating outside the processor, like snooping DIMM traffic. > > Important Kernel Touch Points > = > > Although statically carved out of normal DRAM, enclave memory can not be > accessed or managed directly by the kernel and is marked by the firmware > as ???Reserved???. As a result, SGX support contains simple but analogous > functionality to the core mm such as a page allocator and reclaim. > > Entering and exiting enclaves is tricky business. Enclaves are > restricted from making system calls or taking interrupts directly. The > enclave will exit out to userspace before things like this can happen. > A new vDSO exception mechanism is introduced to help smooth over some of > the architectural rough edges and make the job of userspace easier. > > This implementation is picky and will decline to work on hardware which > is locked to Intel???s root of trust. > > 1. > https://newsroom.intel.com/news-releases/intel-xeon-scalable-platform-built-most-sensitive-workloads/ > 2. https://grapheneproject.io/ > 3. > https://docs.microsoft.com/en-us/azure/confidential-computing/quick-create-portal > > Other > = > > Sean Christopherson is a major contributor to this series. However, he > has left Intel and his @intel.com address will soon be bouncing. He > does not have a email he wants us to substitute or put in .mailmap for > now. To avoid subjecting everyone to bounces, we have commented out his > tag lines in the commit messages. > > Originally the code was based on early prototyping work of Suresh S. > > This patch set has been rebased on top of tip tree commit > c3c30db1b191bb1640a08bbcc593c212affcab75. Tested-by: Chunyang Hui The Occlum project (https://occlum.io/) is a libOS built on top of Intel SGX feature. We ran Occlum tests using v5.10 kernel with SGX patch v41 on SGX hardware with the Flexible Launch Control (FLC) feature and didn't find any problems. As Occlum core developers, we would like these patches to be merged. > v40 (2020-10-20): > * Change copyright years to 2016-2020 in the all files added. > https://lore.kernel.org/linux-sgx/20201003143925.gb800...@kroah.com/ > * Remove dual licensing and use GPL 2.0 unconditionally. > https://lore.kernel.org/linux-sgx/20201003143925.gb800...@kroah.com/ > * Remove platform capabilities checks from sgx_validate_secs(), as they are > validated together with the SIGSTRUCT capabilities in > sgx_ioc_enclave_init(). > > https://lore.kernel.org/linux-sgx/20201005020819.124724-1-jarkko.sakki...@linux.intel.com/ > * During the migration from radix_tree to xarray, the locks went missing > from sgx_encl_may_map(). Fix this by iterating with the enclave lock and > xarray lock held. > > https://lore.kernel.org/linux-sgx/20201003195440.gd20...@casper.infradead.org/ > * Verify in the #PF handler that the faulted page has equal or higher build > time permissions than the VMA permissions (i.e. the subset of {VM_READ, > VM_WRITE, VM_EXECUTE} in vma->vm_flags). Trigger a bus error, if this not > the case. By doing this, mmap() and mprotect() can be allowed to map an > address range, which has unpopulated pages, because the required > invariant will be checked before new pages are inserted to the process > address space. > * In the vDSO, do not save RBX before
Re: [PATCH v41 00/24] Intel SGX foundations
On Fri, Nov 13, 2020 at 12:01:11AM +0200, Jarkko Sakkinen wrote: > Overview > > > Intel(R) SGX is new hardware functionality that can be used by > applications to populate protected regions of user code and data called > enclaves. Once activated, the new hardware protects enclave code and > data from outside access and modification. > > SGX implementations have existed on desktop processors for several > years. The upcoming 3rd Generation Intel Xeon Scalable Platform, > code-named ???Ice Lake??? will also support SGX[1]. > > Use Cases > = > > Enclaves provide a place to store secrets and process data with those > secrets. SGX has been used, for example, to decrypt video without > exposing the decryption keys to nosy debuggers that might be used to > subvert DRM. Software has generally been rewritten specifically to run > in enclaves, but there are also projects that try to run limited > unmodified software in enclaves[2]. > > SGX hardware is available in public clouds today. But, anyone wishing > to use it must use a modified distribution or side-load SGX support[3]. > > Hardware Implementation > === > > New memory controller hardware encrypts data transparently before > leaving the processor package. The randomly-generated encryption key > has a lifetime of exactly one power cycle. This mitigates attacks > originating outside the processor, like snooping DIMM traffic. > > Important Kernel Touch Points > = > > Although statically carved out of normal DRAM, enclave memory can not be > accessed or managed directly by the kernel and is marked by the firmware > as ???Reserved???. As a result, SGX support contains simple but analogous > functionality to the core mm such as a page allocator and reclaim. > > Entering and exiting enclaves is tricky business. Enclaves are > restricted from making system calls or taking interrupts directly. The > enclave will exit out to userspace before things like this can happen. > A new vDSO exception mechanism is introduced to help smooth over some of > the architectural rough edges and make the job of userspace easier. > > This implementation is picky and will decline to work on hardware which > is locked to Intel???s root of trust. > > 1. > https://newsroom.intel.com/news-releases/intel-xeon-scalable-platform-built-most-sensitive-workloads/ > 2. https://grapheneproject.io/ > 3. > https://docs.microsoft.com/en-us/azure/confidential-computing/quick-create-portal > > Other > = > > Sean Christopherson is a major contributor to this series. However, he > has left Intel and his @intel.com address will soon be bouncing. He > does not have a email he wants us to substitute or put in .mailmap for > now. To avoid subjecting everyone to bounces, we have commented out his > tag lines in the commit messages. > > Originally the code was based on early prototyping work of Suresh S. > > This patch set has been rebased on top of tip tree commit > c3c30db1b191bb1640a08bbcc593c212affcab75. Tested-by: Chunyang Hui Occlum project (https://occlum.io/) is a libOS built on top of Intel SGX feature. We ran Occlum tests using v5.10 kernel with SGX patch v41 on SGX hardware with the Flexible Launch Control (FLC) feature and didn't find any problems. As Occlum core developers, we would like these patches to be merged. > v40 (2020-10-20): > * Change copyright years to 2016-2020 in the all files added. > https://lore.kernel.org/linux-sgx/20201003143925.gb800...@kroah.com/ > * Remove dual licensing and use GPL 2.0 unconditionally. > https://lore.kernel.org/linux-sgx/20201003143925.gb800...@kroah.com/ > * Remove platform capabilities checks from sgx_validate_secs(), as they are > validated together with the SIGSTRUCT capabilities in > sgx_ioc_enclave_init(). > > https://lore.kernel.org/linux-sgx/20201005020819.124724-1-jarkko.sakki...@linux.intel.com/ > * During the migration from radix_tree to xarray, the locks went missing > from sgx_encl_may_map(). Fix this by iterating with the enclave lock and > xarray lock held. > > https://lore.kernel.org/linux-sgx/20201003195440.gd20...@casper.infradead.org/ > * Verify in the #PF handler that the faulted page has equal or higher build > time permissions than the VMA permissions (i.e. the subset of {VM_READ, > VM_WRITE, VM_EXECUTE} in vma->vm_flags). Trigger a bus error, if this not > the case. By doing this, mmap() and mprotect() can be allowed to map an > address range, which has unpopulated pages, because the required > invariant will be checked before new pages are inserted to the process > address space. > * In the vDSO, do not save RBX before
[PATCH] samples/bpf/Makefile: Create tools/testing/selftests/bpf dir
From: Hui Zhu Got an error when I built samples/bpf in a separate directory: make O=../bk/ defconfig make -j64 bzImage make headers_install make V=1 M=samples/bpf ... ... make -C /home/teawater/kernel/linux/samples/bpf/../..//tools/build CFLAGS= LDFLAGS= fixdep make -f /home/teawater/kernel/linux/samples/bpf/../..//tools/build/Makefile.build dir=. obj=fixdep make all_cmd Warning: Kernel ABI header at 'tools/include/uapi/linux/netlink.h' differs from latest version at 'include/uapi/linux/netlink.h' Warning: Kernel ABI header at 'tools/include/uapi/linux/if_link.h' differs from latest version at 'include/uapi/linux/if_link.h' gcc -Wp,-MD,samples/bpf/../../tools/testing/selftests/bpf/.cgroup_helpers.o.d -Wall -O2 -Wmissing-prototypes -Wstrict-prototypes -I./usr/include -I/home/teawater/kernel/linux/tools/testing/selftests/bpf/ -I/home/teawater/kernel/linux/tools/lib/ -I/home/teawater/kernel/linux/tools/include -I/home/teawater/kernel/linux/tools/perf -DHAVE_ATTR_TEST=0 -c -o samples/bpf/../../tools/testing/selftests/bpf/cgroup_helpers.o /home/teawater/kernel/linux/samples/bpf/../../tools/testing/selftests/bpf/cgroup_helpers.c /home/teawater/kernel/linux/samples/bpf/../../tools/testing/selftests/bpf/cgroup_helpers.c:315:1: fatal error: opening dependency file samples/bpf/../../tools/testing/selftests/bpf/.cgroup_helpers.o.d: No such file or directory ls -al samples/bpf/../../tools/testing/selftests/bpf/ ls: cannot access 'samples/bpf/../../tools/testing/selftests/bpf/': No such file or directory There is no samples/bpf/../../tools/testing/selftests/bpf/ causing a compilation error. This commit add a "make -p" before build files in samples/bpf/../../tools/testing/selftests/bpf/ to handle the issue. Signed-off-by: Hui Zhu --- samples/bpf/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile index aeebf5d12f32..5b940eedf2e8 100644 --- a/samples/bpf/Makefile +++ b/samples/bpf/Makefile @@ -262,6 +262,7 @@ clean: $(LIBBPF): FORCE # Fix up variables inherited from Kbuild that tools/ build system won't like + mkdir -p $(obj)/../../tools/testing/selftests/bpf/ $(MAKE) -C $(dir $@) RM='rm -rf' EXTRA_CFLAGS="$(TPROGS_CFLAGS)" \ LDFLAGS=$(TPROGS_LDFLAGS) srctree=$(BPF_SAMPLES_PATH)/../../ O= -- 2.17.1
[tip: core/rcu] docs/rcu: Update the call_rcu() API
The following commit has been merged into the core/rcu branch of tip: Commit-ID: c386e29d43728778ddd642fa73cc582bee684171 Gitweb: https://git.kernel.org/tip/c386e29d43728778ddd642fa73cc582bee684171 Author:Hui Su AuthorDate:Thu, 15 Oct 2020 22:13:34 +08:00 Committer: Paul E. McKenney CommitterDate: Fri, 06 Nov 2020 17:02:43 -08:00 docs/rcu: Update the call_rcu() API This commit updates the documented API of call_rcu() to use the rcu_callback_t typedef instead of the open-coded function definition. Signed-off-by: Hui Su Signed-off-by: Paul E. McKenney --- Documentation/RCU/whatisRCU.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Documentation/RCU/whatisRCU.rst b/Documentation/RCU/whatisRCU.rst index fb3ff76..1a4723f 100644 --- a/Documentation/RCU/whatisRCU.rst +++ b/Documentation/RCU/whatisRCU.rst @@ -497,8 +497,7 @@ long -- there might be other high-priority work to be done. In such cases, one uses call_rcu() rather than synchronize_rcu(). The call_rcu() API is as follows:: - void call_rcu(struct rcu_head * head, - void (*func)(struct rcu_head *head)); + void call_rcu(struct rcu_head *head, rcu_callback_t func); This function invokes func(head) after a grace period has elapsed. This invocation might happen from either softirq or process context,
[linux-next] kernel panic when poweroff (Tree for Dec 11)
ree for Dec 11 can reproduce this problem stably(always panic when poweroff). Reported-by: Hui Su
[PATCH] fs/proc: make pde_get() return nothing
we don't need pde_get()'s return value, so make pde_get() return nothing Signed-off-by: Hui Su --- fs/proc/internal.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/proc/internal.h b/fs/proc/internal.h index 917cc85e3466..0abbd93a4a08 100644 --- a/fs/proc/internal.h +++ b/fs/proc/internal.h @@ -190,10 +190,9 @@ struct dentry *proc_lookup_de(struct inode *, struct dentry *, struct proc_dir_e extern int proc_readdir(struct file *, struct dir_context *); int proc_readdir_de(struct file *, struct dir_context *, struct proc_dir_entry *); -static inline struct proc_dir_entry *pde_get(struct proc_dir_entry *pde) +static inline void pde_get(struct proc_dir_entry *pde) { refcount_inc(&pde->refcnt); - return pde; } extern void pde_put(struct proc_dir_entry *); -- 2.29.2
Re: [PATCH] mm/page_alloc: simplify kmem cgroup charge/uncharge code
On Mon, Dec 07, 2020 at 09:28:46AM -0800, Shakeel Butt wrote: > On Mon, Dec 7, 2020 at 6:22 AM Hui Su wrote: > > The reason to keep __memcg_kmem_[un]charge_page functions is that they > were called in the very hot path. Can you please check the performance > impact of your change and if the generated code is actually same or > different. Hi, Shakeel: I objdump the mm/page_alloc.o and comapre them, it change the assemble code indeed. In fact, it change some code order, which i personally think won't have impact on performance. And i ran the ltp mm and conatiner test, it seems nothing abnormal. BUT i still want to check whether this change will have negative impact on perforance due to this change code was called in the very hot path like you said, AND saddly i did not find a way to quantify the impact on performance. Can you give me some suggestion about how to quantify the performance or some tool? Thanks.
[PATCH] mm/page_alloc: simplify kmem cgroup charge/uncharge code
Since the commit 60cd4bcd6238 ("memcg: localize memcg_kmem_enabled() check"), we have supplied the api which users don't have to explicitly check memcg_kmem_enabled(). Signed-off-by: Hui Su --- mm/page_alloc.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index eaa227a479e4..dc990a899ded 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1214,8 +1214,8 @@ static __always_inline bool free_pages_prepare(struct page *page, * Do not let hwpoison pages hit pcplists/buddy * Untie memcg state and reset page's owner */ - if (memcg_kmem_enabled() && PageKmemcg(page)) - __memcg_kmem_uncharge_page(page, order); + if (PageKmemcg(page)) + memcg_kmem_uncharge_page(page, order); reset_page_owner(page, order); return false; } @@ -1244,8 +1244,8 @@ static __always_inline bool free_pages_prepare(struct page *page, } if (PageMappingFlags(page)) page->mapping = NULL; - if (memcg_kmem_enabled() && PageKmemcg(page)) - __memcg_kmem_uncharge_page(page, order); + if (PageKmemcg(page)) + memcg_kmem_uncharge_page(page, order); if (check_free) bad += check_free_page(page); if (bad) @@ -4965,8 +4965,8 @@ __alloc_pages_nodemask(gfp_t gfp_mask, unsigned int order, int preferred_nid, page = __alloc_pages_slowpath(alloc_mask, order, &ac); out: - if (memcg_kmem_enabled() && (gfp_mask & __GFP_ACCOUNT) && page && - unlikely(__memcg_kmem_charge_page(page, gfp_mask, order) != 0)) { + if ((gfp_mask & __GFP_ACCOUNT) && page && + unlikely(memcg_kmem_charge_page(page, gfp_mask, order) != 0)) { __free_pages(page, order); page = NULL; } -- 2.29.2
[PATCH][next] arm64: fix the mm build error in mm/kfence/core.c
When I build kernel with ARCH=arm64, the building errors came out like this: CC mm/kfence/core.o In file included from ../mm/kfence/core.c:21: ../arch/arm64/include/asm/kfence.h: In function ‘kfence_protect_page’: ../arch/arm64/include/asm/kfence.h:12:2: error: implicit declaration of function ‘set_memory_valid’ [-Werror=implicit-function-declaration] 12 | set_memory_valid(addr, 1, !protect); | ^~~~ cc1: some warnings being treated as errors which introduced by commit d54febeba2ff ("kfence: use pt_regs to generate stack trace on faults"). Signed-off-by: Hui Su --- arch/arm64/include/asm/kfence.h | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/include/asm/kfence.h b/arch/arm64/include/asm/kfence.h index 6c0afeeab635..4d73e34da59d 100644 --- a/arch/arm64/include/asm/kfence.h +++ b/arch/arm64/include/asm/kfence.h @@ -4,6 +4,7 @@ #define __ASM_KFENCE_H #include +#include static inline bool arch_kfence_init_pool(void) { return true; } -- 2.25.1
Re: [PATCH] scsi: ses: Fix crash caused by kfree an invalid pointer
On 2020/11/29 13:12, Douglas Gilbert wrote: On 2020-11-28 6:27 p.m., James Bottomley wrote: On Sat, 2020-11-28 at 20:23 +0800, Ding Hui wrote: We can get a crash when disconnecting the iSCSI session, the call trace like this: [2a00fb70] kfree at 0830e224 [2a00fba0] ses_intf_remove at 01f200e4 [2a00fbd0] device_del at 086b6a98 [2a00fc50] device_unregister at 086b6d58 [2a00fc70] __scsi_remove_device at 0870608c [2a00fca0] scsi_remove_device at 08706134 [2a00fcc0] __scsi_remove_target at 087062e4 [2a00fd10] scsi_remove_target at 087064c0 [2a00fd70] __iscsi_unbind_session at 01c872c4 [2a00fdb0] process_one_work at 0810f35c [2a00fe00] worker_thread at 0810f648 [2a00fe70] kthread at 08116e98 In ses_intf_add, components count could be 0, and kcalloc 0 size scomp, but not saved in edev->component[i].scratch In this situation, edev->component[0].scratch is an invalid pointer, when kfree it in ses_intf_remove_enclosure, a crash like above would happen The call trace also could be other random cases when kfree cannot catch the invalid pointer We should not use edev->component[] array when the components count is 0 We also need check index when use edev->component[] array in ses_enclosure_data_process Tested-by: Zeng Zhicong Cc: stable # 2.6.25+ Signed-off-by: Ding Hui This doesn't really look to be the right thing to do: an enclosure which has no component can't usefully be controlled by the driver since there's nothing for it to do, so what we should do in this situation is refuse to attach like the proposed patch below. It does seem a bit odd that someone would build an enclosure that doesn't enclose anything, so would you mind running sg_ses -e '-e' is the short form of '--enumerate'. That will report the names and abbreviations of the diagnostic pages that the utility itself knows about (and supports). It won't show anything specific about the environment that sg_ses is executed in. You probably meant: sg_ses Examples of the likely forms are: sg_ses /dev/bsg/1:0:0:0 sg_ses /dev/sg2 sg_ses /dev/ses0 This from a nearby machine: $ lsscsi -gs [3:0:0:0] disk ATA Samsung SSD 850 1B6Q /dev/sda /dev/sg0 120GB [4:0:0:0] disk IBM-207x HUSMM8020ASS20 J4B6 /dev/sdc /dev/sg2 200GB [4:0:1:0] disk ATA INTEL SSDSC2KW25 003C /dev/sdd /dev/sg3 256GB [4:0:2:0] disk SEAGATE ST1NM0096 E005 /dev/sde /dev/sg4 10.0TB [4:0:3:0] enclosu Areca Te ARC-802801.37.69 0137 - /dev/sg5 - [4:0:4:0] enclosu Intel RES2SV240 0d00 - /dev/sg6 - [7:0:0:0] disk Kingston DataTravelerMini PMAP /dev/sdb /dev/sg1 1.03GB [N:0:0:1] disk WDC WDS256G1X0C-00ENX0__1 /dev/nvme0n1 - 256GB # sg_ses /dev/sg5 Areca Te ARC-802801.37.69 0137 Supported diagnostic pages: Supported Diagnostic Pages [sdp] [0x0] Configuration (SES) [cf] [0x1] Enclosure Status/Control (SES) [ec,es] [0x2] String In/Out (SES) [str] [0x4] Threshold In/Out (SES) [th] [0x5] Element Descriptor (SES) [ed] [0x7] Additional Element Status (SES-2) [aes] [0xa] Supported SES Diagnostic Pages (SES-2) [ssp] [0xd] Download Microcode (SES-2) [dm] [0xe] Subenclosure Nickname (SES-2) [snic] [0xf] Protocol Specific (SAS transport) [] [0x3f] # sg_ses -p cf /dev/sg5 Areca Te ARC-802801.37.69 0137 Configuration diagnostic page: number of secondary subenclosures: 0 generation code: 0x0 enclosure descriptor list Subenclosure identifier: 0 [primary] relative ES process id: 1, number of ES processes: 1 number of type descriptor headers: 9 enclosure logical identifier (hex): d5b401503fc0ec16 enclosure vendor: Areca Te product: ARC-802801.37.69 rev: 0137 vendor-specific data: 11 22 33 44 55 00 00 00 ."3DU... type descriptor header and text list Element type: Array device slot, subenclosure id: 0 number of possible elements: 24 text: ArrayDevicesInSubEnclsr0 Element type: Enclosure, subenclosure id: 0 number of possible elements: 1 text: EnclosureElementInSubEnclsr0 Element type: SAS expander, subenclosure id: 0 number of possible elements: 1 text: SAS Expander Element type: Cooling, subenclosure id: 0 number of possible elements: 5 text: CoolingElementInSubEnclsr0 Element type: Temperature sensor, subenclosure id: 0 number of possible elements: 2 text: TempSensorsInSubEnclsr0 Element type: Voltage sensor, subenclosure id: 0 number of possible elements: 2 text: VoltageSensorsInSubEnclsr0 Element type: SAS connector, subenc
[PATCH] scsi: ses: Fix crash caused by kfree an invalid pointer
We can get a crash when disconnecting the iSCSI session, the call trace like this: [2a00fb70] kfree at 0830e224 [2a00fba0] ses_intf_remove at 01f200e4 [2a00fbd0] device_del at 086b6a98 [2a00fc50] device_unregister at 086b6d58 [2a00fc70] __scsi_remove_device at 0870608c [2a00fca0] scsi_remove_device at 08706134 [2a00fcc0] __scsi_remove_target at 087062e4 [2a00fd10] scsi_remove_target at 087064c0 [2a00fd70] __iscsi_unbind_session at 01c872c4 [2a00fdb0] process_one_work at 0810f35c [2a00fe00] worker_thread at 0810f648 [2a00fe70] kthread at 08116e98 In ses_intf_add, components count could be 0, and kcalloc 0 size scomp, but not saved in edev->component[i].scratch In this situation, edev->component[0].scratch is an invalid pointer, when kfree it in ses_intf_remove_enclosure, a crash like above would happen The call trace also could be other random cases when kfree cannot catch the invalid pointer We should not use edev->component[] array when the components count is 0 We also need check index when use edev->component[] array in ses_enclosure_data_process Tested-by: Zeng Zhicong Cc: stable # 2.6.25+ Signed-off-by: Ding Hui --- drivers/scsi/ses.c | 18 ++ 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c index c2afba2a5414..f5ef0a91f0eb 100644 --- a/drivers/scsi/ses.c +++ b/drivers/scsi/ses.c @@ -477,9 +477,6 @@ static int ses_enclosure_find_by_addr(struct enclosure_device *edev, int i; struct ses_component *scomp; - if (!edev->component[0].scratch) - return 0; - for (i = 0; i < edev->components; i++) { scomp = edev->component[i].scratch; if (scomp->addr != efd->addr) @@ -565,8 +562,10 @@ static void ses_enclosure_data_process(struct enclosure_device *edev, components++, type_ptr[0], name); - else + else if (components < edev->components) ecomp = &edev->component[components++]; + else + ecomp = ERR_PTR(-EINVAL); if (!IS_ERR(ecomp)) { if (addl_desc_ptr) @@ -731,9 +730,11 @@ static int ses_intf_add(struct device *cdev, buf = NULL; } page2_not_supported: - scomp = kcalloc(components, sizeof(struct ses_component), GFP_KERNEL); - if (!scomp) - goto err_free; + if (components > 0) { + scomp = kcalloc(components, sizeof(struct ses_component), GFP_KERNEL); + if (!scomp) + goto err_free; + } edev = enclosure_register(cdev->parent, dev_name(&sdev->sdev_gendev), components, &ses_enclosure_callbacks); @@ -813,7 +814,8 @@ static void ses_intf_remove_enclosure(struct scsi_device *sdev) kfree(ses_dev->page2); kfree(ses_dev); - kfree(edev->component[0].scratch); + if (edev->components > 0) + kfree(edev->component[0].scratch); put_device(&edev->edev); enclosure_unregister(edev); -- 2.17.1
[PATCH] mm/compaction: make defer_compaction and compaction_deferred static
defer_compaction() and compaction_deferred() and compaction_restarting() in mm/compaction.c won't be used in other files, so make them static, and remove the declaration in the header file. Take the chance to fix a typo. Signed-off-by: Hui Su --- include/linux/compaction.h | 12 mm/compaction.c| 8 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/include/linux/compaction.h b/include/linux/compaction.h index 1de5a1151ee7..ed4070ed41ef 100644 --- a/include/linux/compaction.h +++ b/include/linux/compaction.h @@ -98,11 +98,8 @@ extern void reset_isolation_suitable(pg_data_t *pgdat); extern enum compact_result compaction_suitable(struct zone *zone, int order, unsigned int alloc_flags, int highest_zoneidx); -extern void defer_compaction(struct zone *zone, int order); -extern bool compaction_deferred(struct zone *zone, int order); extern void compaction_defer_reset(struct zone *zone, int order, bool alloc_success); -extern bool compaction_restarting(struct zone *zone, int order); /* Compaction has made some progress and retrying makes sense */ static inline bool compaction_made_progress(enum compact_result result) @@ -194,15 +191,6 @@ static inline enum compact_result compaction_suitable(struct zone *zone, int ord return COMPACT_SKIPPED; } -static inline void defer_compaction(struct zone *zone, int order) -{ -} - -static inline bool compaction_deferred(struct zone *zone, int order) -{ - return true; -} - static inline bool compaction_made_progress(enum compact_result result) { return false; diff --git a/mm/compaction.c b/mm/compaction.c index 13cb7a961b31..60135a820b55 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -157,7 +157,7 @@ EXPORT_SYMBOL(__ClearPageMovable); * allocation success. 1 << compact_defer_shift, compactions are skipped up * to a limit of 1 << COMPACT_MAX_DEFER_SHIFT */ -void defer_compaction(struct zone *zone, int order) +static void defer_compaction(struct zone *zone, int order) { zone->compact_considered = 0; zone->compact_defer_shift++; @@ -172,7 +172,7 @@ void defer_compaction(struct zone *zone, int order) } /* Returns true if compaction should be skipped this time */ -bool compaction_deferred(struct zone *zone, int order) +static bool compaction_deferred(struct zone *zone, int order) { unsigned long defer_limit = 1UL << zone->compact_defer_shift; @@ -209,7 +209,7 @@ void compaction_defer_reset(struct zone *zone, int order, } /* Returns true if restarting compaction after many failures */ -bool compaction_restarting(struct zone *zone, int order) +static bool compaction_restarting(struct zone *zone, int order) { if (order < zone->compact_order_failed) return false; @@ -237,7 +237,7 @@ static void reset_cached_positions(struct zone *zone) } /* - * Compound pages of >= pageblock_order should consistenly be skipped until + * Compound pages of >= pageblock_order should consistently be skipped until * released. It is always pointless to compact pages of such order (if they are * migratable), and the pageblocks they occupy cannot contain any free pages. */ -- 2.29.2
[PATCH] hwtracing: stm: fix return value of error branch in stm_heartbeat_init
ret would be reset by stm_source_register_device after first loop, so we should reassign ret while allocation failed for stm_heartbeat[i].data.name Reported-by: Hulk Robot Fixes: 119291853038 ("stm class: Add heartbeat stm source device") Signed-off-by: Wang Hui --- drivers/hwtracing/stm/heartbeat.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/hwtracing/stm/heartbeat.c b/drivers/hwtracing/stm/heartbeat.c index 3e7df1c0477f..81d7b21d31ec 100644 --- a/drivers/hwtracing/stm/heartbeat.c +++ b/drivers/hwtracing/stm/heartbeat.c @@ -64,7 +64,7 @@ static void stm_heartbeat_unlink(struct stm_source_data *data) static int stm_heartbeat_init(void) { - int i, ret = -ENOMEM; + int i, ret; if (nr_devs < 0 || nr_devs > STM_HEARTBEAT_MAX) return -EINVAL; @@ -72,8 +72,10 @@ static int stm_heartbeat_init(void) for (i = 0; i < nr_devs; i++) { stm_heartbeat[i].data.name = kasprintf(GFP_KERNEL, "heartbeat.%d", i); - if (!stm_heartbeat[i].data.name) + if (!stm_heartbeat[i].data.name) { + ret = -ENOMEM; goto fail_unregister; + } stm_heartbeat[i].data.nr_chans = 1; stm_heartbeat[i].data.link = stm_heartbeat_link; -- 2.29.0
Re: + mm-shmem-use-kmem_cache_zalloc-in-shmem_alloc_inode.patch added to -mm tree
On Mon, Nov 16, 2020 at 10:17:20PM -0800, Hugh Dickins wrote: > On Mon, 16 Nov 2020, a...@linux-foundation.org wrote: > > > > The patch titled > > Subject: mm/shmem: use kmem_cache_zalloc in shmem_alloc_inode() > > has been added to the -mm tree. Its filename is > > mm-shmem-use-kmem_cache_zalloc-in-shmem_alloc_inode.patch > > > > This patch should soon appear at > > > > https://ozlabs.org/~akpm/mmots/broken-out/mm-shmem-use-kmem_cache_zalloc-in-shmem_alloc_inode.patch > > and later at > > > > https://ozlabs.org/~akpm/mmotm/broken-out/mm-shmem-use-kmem_cache_zalloc-in-shmem_alloc_inode.patch > > > > Before you just go and hit "reply", please: > >a) Consider who else should be cc'ed > >b) Prefer to cc a suitable mailing list as well > >c) Ideally: find the original patch on the mailing list and do a > > reply-to-all to that, adding suitable additional cc's > > > > *** Remember to use Documentation/process/submit-checklist.rst when testing > > your code *** > > > > The -mm tree is included into linux-next and is updated > > there every 3-4 working days > > > > -- > > From: Hui Su > > Subject: mm/shmem: use kmem_cache_zalloc in shmem_alloc_inode() > > Andrew, Stephen, please revert this untested "cleanup" from your > trees a.s.a.p: it's a disaster for anyone using shmem/tmpfs. > > > > > in shmem_get_inode(): > > new_inode(); > > new_inode_pseudo(); > > alloc_inode(); > > ops->alloc_inode(); -> shmem_alloc_inode() > > kmem_cache_alloc(); > > > > memset(info, 0, (char *)inode - (char *)info); > > > > So use kmem_cache_zalloc() in shmem_alloc_inode(), > > and remove the memset in shmem_get_inode(). > > I could not follow that argument at all. The shmem_inode_cachep > uses a constructor, and the memset shown is of only a portion of > the whole inode. zeroing the entire inode quickly crashes the > kernel, after showing errors. > > (If you're lucky enough to have a readable display at that point: > I did not, but got on better with framebuffer than drm/i915; and > I wonder if there's a separate bug in that area too, because fixing > this shmem issue is not enough to get my drm/i915 rc4-mm1 booting.) > Sorry, I thought it was a small change before, so I forgot to test it. It's SO STUPID. I'm really sorry. > > > > Link: https://lkml.kernel.org/r/20201115174026.GA365412@rlk > > Signed-off-by: Hui Su > > NAK. Hui Su, please test your "cleanups" before sending them. > I will remember it, thanks. I have spent two evenings building a patch automated test platform using qemu and jenkins. > I'm sorry for being slow to respond, but the priority appeared > to be to get Matthew Wilcox's series running reliably, so I had not > got around to checking the less urgent shmem patches before they > slipped into mmotm - there may well be more that I want to NAK, > but this is the dangerous one. > > Thanks, > Hugh >
Re: [PATCH] mm/lru: simplify is_file_lru() and is_active_lru()
On Tue, Nov 17, 2020 at 05:59:00PM +, Matthew Wilcox wrote: > On Wed, Nov 18, 2020 at 01:56:58AM +0800, Hui Su wrote: > > On Tue, Nov 17, 2020 at 05:47:27PM +, Matthew Wilcox wrote: > > > On Wed, Nov 18, 2020 at 01:46:33AM +0800, Hui Su wrote: > > > > On Tue, Nov 17, 2020 at 05:41:17PM +, Matthew Wilcox wrote: > > > > > On Wed, Nov 18, 2020 at 01:12:42AM +0800, Hui Su wrote: > > > > > > lru_list lru bit 0 can tell whether the list is > > > > > > avtive lru-list or not. > > > > > > lru_list lru bit 1 can tell whether the list is > > > > > > file lru-list or not. > > > > > > > > > > > > And fix some define type in shrink_active_list() > > > > > > and get_scan_count(). > > > > > > > > > > > > v1->v2: > > > > > > correct the commit message, and fix the define type. > > > > > > > > > > No, still incorrect. > > > > > > > > I am a little confused, can you tell in detail? > > > > > > Have you booted a kernel with this change? Have you run any kind of > > > tests on it? > > > > Yes, I boot it with qemu-system-x86_64-4.1.50 on ubuntu20.04: > > qemu-system-x86_64 -kernel > > /home/rlk/workspace/compile/out/arch/x86_64/boot/bzImage -hda \ > > /home/rlk/myspace/qemu_build/rootfs.img -append "root=/dev/sda > > console=ttyS0" -nographic > > > > using the kernel compiled with ubuntu20.04's default .config. > > > > It seems nothing abnormal. > > And i did not do other test. > > Maybe you should ... how about LTP? I think that's pretty straightforward > to set up and run. Hi Matthew: Thanks for your advice, i finally setup a test platform powered by jenkins and QEMU emulator version 4.2.1 with two evening. This is the things that i always wanted to do but didn't do. I apply this change based on the commit: 4d02da974ea8, and compile it with x86_64_defconfig: make bzImage O=/var/lib/jenkins/workspace/linux_kernel_ltp/out/ Then start qemu: sudo qemu-system-x86_64 \ -kernel /var/lib/jenkins/workspace/linux_kernel_ltp/out/arch/x86/boot/bzImage \ -hda /home/ubuntu/myspace/qemu_build/ubuntu.img \ -hdb /home/ubuntu/myspace/qemu_build/init.img \ -append "root=/dev/sda console=ttyS0" \ -nographic \ -m 1024 \ -fsdev local,id=fs1,path=/home/ubuntu/workspace,security_model=none \ -device virtio-9p-pci,fsdev=fs1,mount_tag=jeff-host-code Then run the ltp test: sudo bash /opt/ltp/runltp -f mm The result is: Test Start Time: Sat Nov 21 02:06:46 2020 - Testcase Result Exit Value -- -- mm01 PASS 0 mm02 PASS 0 mtest01PASS 0 mtest01w PASS 0 mtest05PASS 0 mtest06FAIL 2 mtest06_2 PASS 0 mtest06_3 PASS 0 mem02 PASS 0 mmapstress01 PASS 0 mmapstress02 PASS 0 mmapstress03 PASS 0 mmapstress04 PASS 0 mmapstress05 PASS 0 mmapstress06 PASS 0 mmapstress07 PASS 0 mmapstress08 PASS 0 mmapstress09 PASS 0 mmapstress10 PASS 0 mmap10 PASS 0 mmap10_1 PASS 0 mmap10_2 CONF 32 mmap10_3 CONF 32 mmap10_4 CONF 32 ksm01 CONF 32 ksm01_1CONF 32 ksm02 CONF 32 ksm02_1CONF 32 ksm03 CON
[tip: x86/cleanups] x86/dumpstack: Make show_trace_log_lvl() static
The following commit has been merged into the x86/cleanups branch of tip: Commit-ID: 09a217c10504bcaef911cf2af74e424338efe629 Gitweb: https://git.kernel.org/tip/09a217c10504bcaef911cf2af74e424338efe629 Author:Hui Su AuthorDate:Fri, 13 Nov 2020 21:39:43 +08:00 Committer: Borislav Petkov CommitterDate: Tue, 17 Nov 2020 19:05:32 +01:00 x86/dumpstack: Make show_trace_log_lvl() static show_trace_log_lvl() is not used by other compilation units so make it static and remove the declaration from the header file. Signed-off-by: Hui Su Signed-off-by: Borislav Petkov Link: https://lkml.kernel.org/r/20201113133943.GA136221@rlk --- arch/x86/include/asm/stacktrace.h | 3 --- arch/x86/kernel/dumpstack.c | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h index 4960064..f248eb2 100644 --- a/arch/x86/include/asm/stacktrace.h +++ b/arch/x86/include/asm/stacktrace.h @@ -88,9 +88,6 @@ get_stack_pointer(struct task_struct *task, struct pt_regs *regs) return (unsigned long *)task->thread.sp; } -void show_trace_log_lvl(struct task_struct *task, struct pt_regs *regs, - unsigned long *stack, const char *log_lvl); - /* The form of the top of the frame on the stack */ struct stack_frame { struct stack_frame *next_frame; diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c index 25c06b6..067de0d 100644 --- a/arch/x86/kernel/dumpstack.c +++ b/arch/x86/kernel/dumpstack.c @@ -168,7 +168,7 @@ static void show_regs_if_on_stack(struct stack_info *info, struct pt_regs *regs, } } -void show_trace_log_lvl(struct task_struct *task, struct pt_regs *regs, +static void show_trace_log_lvl(struct task_struct *task, struct pt_regs *regs, unsigned long *stack, const char *log_lvl) { struct unwind_state state;
Re: [PATCH] mm/lru: simplify is_file_lru() and is_active_lru()
On Tue, Nov 17, 2020 at 05:59:00PM +, Matthew Wilcox wrote: > On Wed, Nov 18, 2020 at 01:56:58AM +0800, Hui Su wrote: > > On Tue, Nov 17, 2020 at 05:47:27PM +, Matthew Wilcox wrote: > > > On Wed, Nov 18, 2020 at 01:46:33AM +0800, Hui Su wrote: > > > > On Tue, Nov 17, 2020 at 05:41:17PM +, Matthew Wilcox wrote: > > > > > On Wed, Nov 18, 2020 at 01:12:42AM +0800, Hui Su wrote: > > > > > > lru_list lru bit 0 can tell whether the list is > > > > > > avtive lru-list or not. > > > > > > lru_list lru bit 1 can tell whether the list is > > > > > > file lru-list or not. > > > > > > > > > > > > And fix some define type in shrink_active_list() > > > > > > and get_scan_count(). > > > > > > > > > > > > v1->v2: > > > > > > correct the commit message, and fix the define type. > > > > > > > > > > No, still incorrect. > > > > > > > > I am a little confused, can you tell in detail? > > > > > > Have you booted a kernel with this change? Have you run any kind of > > > tests on it? > > > > Yes, I boot it with qemu-system-x86_64-4.1.50 on ubuntu20.04: > > qemu-system-x86_64 -kernel > > /home/rlk/workspace/compile/out/arch/x86_64/boot/bzImage -hda \ > > /home/rlk/myspace/qemu_build/rootfs.img -append "root=/dev/sda > > console=ttyS0" -nographic > > > > using the kernel compiled with ubuntu20.04's default .config. > > > > It seems nothing abnormal. > > And i did not do other test. > > Maybe you should ... how about LTP? I think that's pretty straightforward > to set up and run. Thanks for your advice, Matthew. I will set up an ltp test envirment, thanks again. And Please ignore this change for now.
Re: [PATCH] mm/lru: simplify is_file_lru() and is_active_lru()
On Tue, Nov 17, 2020 at 05:41:17PM +, Matthew Wilcox wrote: > On Wed, Nov 18, 2020 at 01:12:42AM +0800, Hui Su wrote: > > lru_list lru bit 0 can tell whether the list is > > avtive lru-list or not. > > lru_list lru bit 1 can tell whether the list is > > file lru-list or not. > > > > And fix some define type in shrink_active_list() > > and get_scan_count(). > > > > v1->v2: > > correct the commit message, and fix the define type. > > No, still incorrect. I am a little confused, can you tell in detail? Thanks.
Re: [PATCH] mm/lru: simplify is_file_lru() and is_active_lru()
On Tue, Nov 17, 2020 at 05:47:27PM +, Matthew Wilcox wrote: > On Wed, Nov 18, 2020 at 01:46:33AM +0800, Hui Su wrote: > > On Tue, Nov 17, 2020 at 05:41:17PM +, Matthew Wilcox wrote: > > > On Wed, Nov 18, 2020 at 01:12:42AM +0800, Hui Su wrote: > > > > lru_list lru bit 0 can tell whether the list is > > > > avtive lru-list or not. > > > > lru_list lru bit 1 can tell whether the list is > > > > file lru-list or not. > > > > > > > > And fix some define type in shrink_active_list() > > > > and get_scan_count(). > > > > > > > > v1->v2: > > > > correct the commit message, and fix the define type. > > > > > > No, still incorrect. > > > > I am a little confused, can you tell in detail? > > Have you booted a kernel with this change? Have you run any kind of > tests on it? Yes, I boot it with qemu-system-x86_64-4.1.50 on ubuntu20.04: qemu-system-x86_64 -kernel /home/rlk/workspace/compile/out/arch/x86_64/boot/bzImage -hda \ /home/rlk/myspace/qemu_build/rootfs.img -append "root=/dev/sda console=ttyS0" -nographic using the kernel compiled with ubuntu20.04's default .config. It seems nothing abnormal. And i did not do other test.
[PATCH] mm/lru: simplify is_file_lru() and is_active_lru()
lru_list lru bit 0 can tell whether the list is avtive lru-list or not. lru_list lru bit 1 can tell whether the list is file lru-list or not. And fix some define type in shrink_active_list() and get_scan_count(). v1->v2: correct the commit message, and fix the define type. Signed-off-by: Hui Su --- include/linux/mmzone.h | 4 ++-- mm/vmscan.c| 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index fb3bf696c05e..294369c652d0 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -258,12 +258,12 @@ enum lru_list { static inline bool is_file_lru(enum lru_list lru) { - return (lru == LRU_INACTIVE_FILE || lru == LRU_ACTIVE_FILE); + return lru & LRU_FILE; } static inline bool is_active_lru(enum lru_list lru) { - return (lru == LRU_ACTIVE_ANON || lru == LRU_ACTIVE_FILE); + return lru & LRU_ACTIVE; } #define ANON_AND_FILE 2 diff --git a/mm/vmscan.c b/mm/vmscan.c index 7b4e31eac2cf..7d8ea2fc87fc 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2020,7 +2020,7 @@ static void shrink_active_list(unsigned long nr_to_scan, struct page *page; unsigned nr_deactivate, nr_activate; unsigned nr_rotated = 0; - int file = is_file_lru(lru); + bool file = is_file_lru(lru); struct pglist_data *pgdat = lruvec_pgdat(lruvec); lru_add_drain(); @@ -2323,7 +2323,7 @@ static void get_scan_count(struct lruvec *lruvec, struct scan_control *sc, denominator = ap + fp; out: for_each_evictable_lru(lru) { - int file = is_file_lru(lru); + bool file = is_file_lru(lru); unsigned long lruvec_size; unsigned long scan; unsigned long protection; -- 2.29.0
Re: [PATCH] mm/lru: simplify is_file_lru() and is_active_lru()
On Wed, Nov 18, 2020 at 12:49:19AM +0800, Hui Su wrote: > page->lru bit 0 can tell whether the page is > avtive page or not. > page->lru bit 1 can tell whether the page is > file page or not. > > Signed-off-by: Hui Su > --- > include/linux/mmzone.h | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h > index fb3bf696c05e..294369c652d0 100644 > --- a/include/linux/mmzone.h > +++ b/include/linux/mmzone.h > @@ -258,12 +258,12 @@ enum lru_list { > > static inline bool is_file_lru(enum lru_list lru) > { > - return (lru == LRU_INACTIVE_FILE || lru == LRU_ACTIVE_FILE); > + return lru & LRU_FILE; > } > > static inline bool is_active_lru(enum lru_list lru) > { > - return (lru == LRU_ACTIVE_ANON || lru == LRU_ACTIVE_FILE); > + return lru & LRU_ACTIVE; > } > > #define ANON_AND_FILE 2 > -- > 2.29.0 The commit message is not correct, please ignore this change.
[PATCH] mm/lru: simplify is_file_lru() and is_active_lru()
page->lru bit 0 can tell whether the page is avtive page or not. page->lru bit 1 can tell whether the page is file page or not. Signed-off-by: Hui Su --- include/linux/mmzone.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index fb3bf696c05e..294369c652d0 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -258,12 +258,12 @@ enum lru_list { static inline bool is_file_lru(enum lru_list lru) { - return (lru == LRU_INACTIVE_FILE || lru == LRU_ACTIVE_FILE); + return lru & LRU_FILE; } static inline bool is_active_lru(enum lru_list lru) { - return (lru == LRU_ACTIVE_ANON || lru == LRU_ACTIVE_FILE); + return lru & LRU_ACTIVE; } #define ANON_AND_FILE 2 -- 2.29.0
[PATCH] namespace: make timens_on_fork() return nothing
timens_on_fork() always return 0, and maybe not need to judge the return value in copy_namespaces(). So make timens_on_fork() return nothing and do not judge its return val in copy_namespaces(). Signed-off-by: Hui Su --- include/linux/time_namespace.h | 6 +++--- kernel/nsproxy.c | 7 +-- kernel/time/namespace.c| 6 ++ 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/include/linux/time_namespace.h b/include/linux/time_namespace.h index 5b6031385db0..74a88ce0cd3c 100644 --- a/include/linux/time_namespace.h +++ b/include/linux/time_namespace.h @@ -45,7 +45,7 @@ struct time_namespace *copy_time_ns(unsigned long flags, struct user_namespace *user_ns, struct time_namespace *old_ns); void free_time_ns(struct kref *kref); -int timens_on_fork(struct nsproxy *nsproxy, struct task_struct *tsk); +void timens_on_fork(struct nsproxy *nsproxy, struct task_struct *tsk); struct vdso_data *arch_get_vdso_data(void *vvar_page); static inline void put_time_ns(struct time_namespace *ns) @@ -122,10 +122,10 @@ struct time_namespace *copy_time_ns(unsigned long flags, return old_ns; } -static inline int timens_on_fork(struct nsproxy *nsproxy, +static inline void timens_on_fork(struct nsproxy *nsproxy, struct task_struct *tsk) { - return 0; + return; } static inline void timens_add_monotonic(struct timespec64 *ts) { } diff --git a/kernel/nsproxy.c b/kernel/nsproxy.c index 12dd41b39a7f..e2e6c5dc433f 100644 --- a/kernel/nsproxy.c +++ b/kernel/nsproxy.c @@ -153,7 +153,6 @@ int copy_namespaces(unsigned long flags, struct task_struct *tsk) struct nsproxy *old_ns = tsk->nsproxy; struct user_namespace *user_ns = task_cred_xxx(tsk, user_ns); struct nsproxy *new_ns; - int ret; if (likely(!(flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWPID | CLONE_NEWNET | @@ -180,11 +179,7 @@ int copy_namespaces(unsigned long flags, struct task_struct *tsk) if (IS_ERR(new_ns)) return PTR_ERR(new_ns); - ret = timens_on_fork(new_ns, tsk); - if (ret) { - free_nsproxy(new_ns); - return ret; - } + timens_on_fork(new_ns, tsk); tsk->nsproxy = new_ns; return 0; diff --git a/kernel/time/namespace.c b/kernel/time/namespace.c index afc65e6be33e..e0f9509b17c3 100644 --- a/kernel/time/namespace.c +++ b/kernel/time/namespace.c @@ -308,22 +308,20 @@ static int timens_install(struct nsset *nsset, struct ns_common *new) return 0; } -int timens_on_fork(struct nsproxy *nsproxy, struct task_struct *tsk) +void timens_on_fork(struct nsproxy *nsproxy, struct task_struct *tsk) { struct ns_common *nsc = &nsproxy->time_ns_for_children->ns; struct time_namespace *ns = to_time_ns(nsc); /* create_new_namespaces() already incremented the ref counter */ if (nsproxy->time_ns == nsproxy->time_ns_for_children) - return 0; + return; get_time_ns(ns); put_time_ns(nsproxy->time_ns); nsproxy->time_ns = ns; timens_commit(tsk, ns); - - return 0; } static struct user_namespace *timens_owner(struct ns_common *ns) -- 2.29.0
Re: [PATCH] namespace: make timens_on_fork() return nothing
Please ignore this change.
[PATCH v2] namespace: make timens_on_fork() return nothing
timens_on_fork() always return 0, and maybe not need to judge the return value in copy_namespaces(). So make timens_on_fork() return nothing and do not judge its return val in copy_namespaces(). Signed-off-by: Hui Su --- include/linux/time_namespace.h | 6 +++--- kernel/nsproxy.c | 7 +-- kernel/time/namespace.c| 6 ++ 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/include/linux/time_namespace.h b/include/linux/time_namespace.h index 5b6031385db0..74a88ce0cd3c 100644 --- a/include/linux/time_namespace.h +++ b/include/linux/time_namespace.h @@ -45,7 +45,7 @@ struct time_namespace *copy_time_ns(unsigned long flags, struct user_namespace *user_ns, struct time_namespace *old_ns); void free_time_ns(struct kref *kref); -int timens_on_fork(struct nsproxy *nsproxy, struct task_struct *tsk); +void timens_on_fork(struct nsproxy *nsproxy, struct task_struct *tsk); struct vdso_data *arch_get_vdso_data(void *vvar_page); static inline void put_time_ns(struct time_namespace *ns) @@ -122,10 +122,10 @@ struct time_namespace *copy_time_ns(unsigned long flags, return old_ns; } -static inline int timens_on_fork(struct nsproxy *nsproxy, +static inline void timens_on_fork(struct nsproxy *nsproxy, struct task_struct *tsk) { - return 0; + return; } static inline void timens_add_monotonic(struct timespec64 *ts) { } diff --git a/kernel/nsproxy.c b/kernel/nsproxy.c index 12dd41b39a7f..e2e6c5dc433f 100644 --- a/kernel/nsproxy.c +++ b/kernel/nsproxy.c @@ -153,7 +153,6 @@ int copy_namespaces(unsigned long flags, struct task_struct *tsk) struct nsproxy *old_ns = tsk->nsproxy; struct user_namespace *user_ns = task_cred_xxx(tsk, user_ns); struct nsproxy *new_ns; - int ret; if (likely(!(flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWPID | CLONE_NEWNET | @@ -180,11 +179,7 @@ int copy_namespaces(unsigned long flags, struct task_struct *tsk) if (IS_ERR(new_ns)) return PTR_ERR(new_ns); - ret = timens_on_fork(new_ns, tsk); - if (ret) { - free_nsproxy(new_ns); - return ret; - } + timens_on_fork(new_ns, tsk); tsk->nsproxy = new_ns; return 0; diff --git a/kernel/time/namespace.c b/kernel/time/namespace.c index afc65e6be33e..e0f9509b17c3 100644 --- a/kernel/time/namespace.c +++ b/kernel/time/namespace.c @@ -308,22 +308,20 @@ static int timens_install(struct nsset *nsset, struct ns_common *new) return 0; } -int timens_on_fork(struct nsproxy *nsproxy, struct task_struct *tsk) +void timens_on_fork(struct nsproxy *nsproxy, struct task_struct *tsk) { struct ns_common *nsc = &nsproxy->time_ns_for_children->ns; struct time_namespace *ns = to_time_ns(nsc); /* create_new_namespaces() already incremented the ref counter */ if (nsproxy->time_ns == nsproxy->time_ns_for_children) - return 0; + return; get_time_ns(ns); put_time_ns(nsproxy->time_ns); nsproxy->time_ns = ns; timens_commit(tsk, ns); - - return 0; } static struct user_namespace *timens_owner(struct ns_common *ns) -- 2.29.0
Re: [PATCH] nsproxy: remove judge of timens_on_fork()'s return val
On Tue, Nov 17, 2020 at 12:30:26AM -0800, Andrey Vagin wrote: > On Sun, Nov 15, 2020 at 10:36 AM Hui Su wrote: > > > > timens_on_fork() always return 0, and maybe not > > need to judge the return value in copy_namespaces(). > > Thank you for cleaning this up. I think we can go even further and > change timens_on_fork to return nothing: > > -int timens_on_fork(struct nsproxy *nsproxy, struct task_struct *tsk) > +void timens_on_fork(struct nsproxy *nsproxy, struct task_struct *tsk) > { > struct ns_common *nsc = &nsproxy->time_ns_for_children->ns; > struct time_namespace *ns = to_time_ns(nsc); > > /* create_new_namespaces() already incremented the ref counter */ > if (nsproxy->time_ns == nsproxy->time_ns_for_children) > - return 0; > + return; > > get_time_ns(ns); > put_time_ns(nsproxy->time_ns); > nsproxy->time_ns = ns; > > timens_commit(tsk, ns); > - > - return 0; > } > > > > > > Signed-off-by: Hui Su > > --- > > kernel/nsproxy.c | 7 +-- > > 1 file changed, 1 insertion(+), 6 deletions(-) > > > > diff --git a/kernel/nsproxy.c b/kernel/nsproxy.c > > index 12dd41b39a7f..e2e6c5dc433f 100644 > > --- a/kernel/nsproxy.c > > +++ b/kernel/nsproxy.c > > @@ -153,7 +153,6 @@ int copy_namespaces(unsigned long flags, struct > > task_struct *tsk) > > struct nsproxy *old_ns = tsk->nsproxy; > > struct user_namespace *user_ns = task_cred_xxx(tsk, user_ns); > > struct nsproxy *new_ns; > > - int ret; > > > > if (likely(!(flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC | > > CLONE_NEWPID | CLONE_NEWNET | > > @@ -180,11 +179,7 @@ int copy_namespaces(unsigned long flags, struct > > task_struct *tsk) > > if (IS_ERR(new_ns)) > > return PTR_ERR(new_ns); > > > > - ret = timens_on_fork(new_ns, tsk); > > - if (ret) { > > - free_nsproxy(new_ns); > > - return ret; > > - } > > + timens_on_fork(new_ns, tsk); > > > > tsk->nsproxy = new_ns; > > return 0; > > -- > > 2.29.0 > > > > Yeah, thank for your reply, Andrey. I will resend PATCH V2 with makeing timens_on_fork() return nothing. Thanks.
Re: + mm-shmem-use-kmem_cache_zalloc-in-shmem_alloc_inode.patch added to -mm tree
On Tue, Nov 17, 2020 at 06:12:46PM +1100, Stephen Rothwell wrote: > Hi Hugh, > > On Mon, 16 Nov 2020 22:17:20 -0800 (PST) Hugh Dickins > wrote: > > > > On Mon, 16 Nov 2020, a...@linux-foundation.org wrote: > > > > > > The patch titled > > > Subject: mm/shmem: use kmem_cache_zalloc in shmem_alloc_inode() > > > has been added to the -mm tree. Its filename is > > > mm-shmem-use-kmem_cache_zalloc-in-shmem_alloc_inode.patch > > > > > > This patch should soon appear at > > > > > > https://ozlabs.org/~akpm/mmots/broken-out/mm-shmem-use-kmem_cache_zalloc-in-shmem_alloc_inode.patch > > > and later at > > > > > > https://ozlabs.org/~akpm/mmotm/broken-out/mm-shmem-use-kmem_cache_zalloc-in-shmem_alloc_inode.patch > > > > > > Before you just go and hit "reply", please: > > >a) Consider who else should be cc'ed > > >b) Prefer to cc a suitable mailing list as well > > >c) Ideally: find the original patch on the mailing list and do a > > > reply-to-all to that, adding suitable additional cc's > > > > > > *** Remember to use Documentation/process/submit-checklist.rst when > > > testing your code *** > > > > > > The -mm tree is included into linux-next and is updated > > > there every 3-4 working days > > > > > > -- > > > From: Hui Su > > > Subject: mm/shmem: use kmem_cache_zalloc in shmem_alloc_inode() > > > > Andrew, Stephen, please revert this untested "cleanup" from your > > trees a.s.a.p: it's a disaster for anyone using shmem/tmpfs. > > Thanks for that. I have also bisected my boot failures to that commit > and so have reverted it from linux-next today. > > -- > Cheers, > Stephen Rothwell Sorry for not full testing the change. Please ignore this change. Thanks.
[PATCH] mm/compaction: move compaction_suitable's comment to right place
Since commit 837d026d560c ("mm/compaction: more trace to understand when/why compaction start/finish"), the comment place is not suitable. So move compaction_suitable's comment to right place. Signed-off-by: Hui Su --- mm/compaction.c | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/mm/compaction.c b/mm/compaction.c index 13cb7a961b31..8bfd6e089511 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -2070,13 +2070,6 @@ static enum compact_result compact_finished(struct compact_control *cc) return ret; } -/* - * compaction_suitable: Is this suitable to run compaction on this zone now? - * Returns - * COMPACT_SKIPPED - If there are too few free pages for compaction - * COMPACT_SUCCESS - If the allocation would succeed without compaction - * COMPACT_CONTINUE - If compaction should run now - */ static enum compact_result __compaction_suitable(struct zone *zone, int order, unsigned int alloc_flags, int highest_zoneidx, @@ -2120,6 +2113,13 @@ static enum compact_result __compaction_suitable(struct zone *zone, int order, return COMPACT_CONTINUE; } +/* + * compaction_suitable: Is this suitable to run compaction on this zone now? + * Returns + * COMPACT_SKIPPED - If there are too few free pages for compaction + * COMPACT_SUCCESS - If the allocation would succeed without compaction + * COMPACT_CONTINUE - If compaction should run now + */ enum compact_result compaction_suitable(struct zone *zone, int order, unsigned int alloc_flags, int highest_zoneidx) -- 2.29.0
[PATCH] nsproxy: remove judge of timens_on_fork()'s return val
timens_on_fork() always return 0, and maybe not need to judge the return value in copy_namespaces(). Signed-off-by: Hui Su --- kernel/nsproxy.c | 7 +-- 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/kernel/nsproxy.c b/kernel/nsproxy.c index 12dd41b39a7f..e2e6c5dc433f 100644 --- a/kernel/nsproxy.c +++ b/kernel/nsproxy.c @@ -153,7 +153,6 @@ int copy_namespaces(unsigned long flags, struct task_struct *tsk) struct nsproxy *old_ns = tsk->nsproxy; struct user_namespace *user_ns = task_cred_xxx(tsk, user_ns); struct nsproxy *new_ns; - int ret; if (likely(!(flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWPID | CLONE_NEWNET | @@ -180,11 +179,7 @@ int copy_namespaces(unsigned long flags, struct task_struct *tsk) if (IS_ERR(new_ns)) return PTR_ERR(new_ns); - ret = timens_on_fork(new_ns, tsk); - if (ret) { - free_nsproxy(new_ns); - return ret; - } + timens_on_fork(new_ns, tsk); tsk->nsproxy = new_ns; return 0; -- 2.29.0
[PATCH] nsproxy: use put_nsproxy() in switch_task_namespaces()
Use put_nsproxy() instead of ' if (atomic_dec_and_test(&ns->count)) { free_nsproxy(ns); }' in switch_task_namespaces(). and remove the whitespace by the way. Signed-off-by: Hui Su --- kernel/nsproxy.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/nsproxy.c b/kernel/nsproxy.c index 12dd41b39a7f..3ebfd090398a 100644 --- a/kernel/nsproxy.c +++ b/kernel/nsproxy.c @@ -173,7 +173,7 @@ int copy_namespaces(unsigned long flags, struct task_struct *tsk) * it along with CLONE_NEWIPC. */ if ((flags & (CLONE_NEWIPC | CLONE_SYSVSEM)) == - (CLONE_NEWIPC | CLONE_SYSVSEM)) + (CLONE_NEWIPC | CLONE_SYSVSEM)) return -EINVAL; new_ns = create_new_namespaces(flags, tsk, user_ns, tsk->fs); @@ -250,8 +250,8 @@ void switch_task_namespaces(struct task_struct *p, struct nsproxy *new) p->nsproxy = new; task_unlock(p); - if (ns && atomic_dec_and_test(&ns->count)) - free_nsproxy(ns); + if (ns) + put_nsproxy(ns); } void exit_task_namespaces(struct task_struct *p) -- 2.29.0
[PATCH] mm/shmem: use kmem_cache_zalloc in shmem_alloc_inode()
in shmem_get_inode(): new_inode(); new_inode_pseudo(); alloc_inode(); ops->alloc_inode(); -> shmem_alloc_inode() kmem_cache_alloc(); memset(info, 0, (char *)inode - (char *)info); So use kmem_cache_zalloc() in shmem_alloc_inode(), and remove the memset in shmem_get_inode(). Signed-off-by: Hui Su --- mm/shmem.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index 537c137698f8..b84adda45461 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2308,7 +2308,6 @@ static struct inode *shmem_get_inode(struct super_block *sb, const struct inode inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode); inode->i_generation = prandom_u32(); info = SHMEM_I(inode); - memset(info, 0, (char *)inode - (char *)info); spin_lock_init(&info->lock); atomic_set(&info->stop_eviction, 0); info->seals = F_SEAL_SEAL; @@ -3828,7 +3827,7 @@ static struct kmem_cache *shmem_inode_cachep; static struct inode *shmem_alloc_inode(struct super_block *sb) { struct shmem_inode_info *info; - info = kmem_cache_alloc(shmem_inode_cachep, GFP_KERNEL); + info = kmem_cache_zalloc(shmem_inode_cachep, GFP_KERNEL); if (!info) return NULL; return &info->vfs_inode; -- 2.29.0
[PATCH v3] mm/shmem.c: make shmem_mapping() inline
shmem_mapping() isn't worth an out-of-line call from any callsite. So make it inline by - make shmem_aops global - export shmem_aops - inline the shmem_mapping() and replace the direct call 'shmem_aops' with shmem_mapping() in shmem.c. v1->v2: remove the inline for func declaration in shmem_fs.h v2->v3: make shmem_aops global, and export it to modules. Signed-off-by: Hui Su --- include/linux/shmem_fs.h | 6 +- mm/shmem.c | 16 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h index a5a5d1d4d7b1..d82b6f396588 100644 --- a/include/linux/shmem_fs.h +++ b/include/linux/shmem_fs.h @@ -67,7 +67,11 @@ extern unsigned long shmem_get_unmapped_area(struct file *, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags); extern int shmem_lock(struct file *file, int lock, struct user_struct *user); #ifdef CONFIG_SHMEM -extern bool shmem_mapping(struct address_space *mapping); +extern const struct address_space_operations shmem_aops; +static inline bool shmem_mapping(struct address_space *mapping) +{ + return mapping->a_ops == &shmem_aops; +} #else static inline bool shmem_mapping(struct address_space *mapping) { diff --git a/mm/shmem.c b/mm/shmem.c index 537c137698f8..b7361fce50bc 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -246,7 +246,7 @@ static inline void shmem_inode_unacct_blocks(struct inode *inode, long pages) } static const struct super_operations shmem_ops; -static const struct address_space_operations shmem_aops; +const struct address_space_operations shmem_aops; static const struct file_operations shmem_file_operations; static const struct inode_operations shmem_inode_operations; static const struct inode_operations shmem_dir_inode_operations; @@ -1152,7 +1152,7 @@ static void shmem_evict_inode(struct inode *inode) struct shmem_inode_info *info = SHMEM_I(inode); struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb); - if (inode->i_mapping->a_ops == &shmem_aops) { + if (shmem_mapping(inode->i_mapping)) { shmem_unacct_size(info->flags, inode->i_size); inode->i_size = 0; shmem_truncate_range(inode, 0, (loff_t)-1); @@ -1858,7 +1858,7 @@ static int shmem_getpage_gfp(struct inode *inode, pgoff_t index, } /* shmem_symlink() */ - if (mapping->a_ops != &shmem_aops) + if (!shmem_mapping(mapping)) goto alloc_nohuge; if (shmem_huge == SHMEM_HUGE_DENY || sgp_huge == SGP_NOHUGE) goto alloc_nohuge; @@ -2352,11 +2352,6 @@ static struct inode *shmem_get_inode(struct super_block *sb, const struct inode return inode; } -bool shmem_mapping(struct address_space *mapping) -{ - return mapping->a_ops == &shmem_aops; -} - static int shmem_mfill_atomic_pte(struct mm_struct *dst_mm, pmd_t *dst_pmd, struct vm_area_struct *dst_vma, @@ -3865,7 +3860,7 @@ static void shmem_destroy_inodecache(void) kmem_cache_destroy(shmem_inode_cachep); } -static const struct address_space_operations shmem_aops = { +const struct address_space_operations shmem_aops = { .writepage = shmem_writepage, .set_page_dirty = __set_page_dirty_no_writeback, #ifdef CONFIG_TMPFS @@ -3877,6 +3872,7 @@ static const struct address_space_operations shmem_aops = { #endif .error_remove_page = generic_error_remove_page, }; +EXPORT_SYMBOL(shmem_aops); static const struct file_operations shmem_file_operations = { .mmap = shmem_mmap, @@ -4312,7 +4308,7 @@ struct page *shmem_read_mapping_page_gfp(struct address_space *mapping, struct page *page; int error; - BUG_ON(mapping->a_ops != &shmem_aops); + BUG_ON(!shmem_mapping(mapping)); error = shmem_getpage_gfp(inode, index, &page, SGP_CACHE, gfp, NULL, NULL, NULL); if (error) -- 2.29.0
Re: [PATCH v2] mm/shmem.c: make shmem_mapping() inline
On Sat, Nov 14, 2020 at 10:50:39AM -0800, Andrew Morton wrote: > On Sat, 14 Nov 2020 13:51:34 +0800 Hui Su wrote: > > > inline the shmem_mapping(), and use shmem_mapping() > > instead of 'inode->i_mapping->a_ops == &shmem_aops' > > in shmem_evict_inode(). > > > > ... > > > > --- a/mm/shmem.c > > +++ b/mm/shmem.c > > @@ -1152,7 +1152,7 @@ static void shmem_evict_inode(struct inode *inode) > > struct shmem_inode_info *info = SHMEM_I(inode); > > struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb); > > > > - if (inode->i_mapping->a_ops == &shmem_aops) { > > + if (shmem_mapping(inode->i_mapping)) { > > shmem_unacct_size(info->flags, inode->i_size); > > inode->i_size = 0; > > shmem_truncate_range(inode, 0, (loff_t)-1); > > @@ -2352,7 +2352,7 @@ static struct inode *shmem_get_inode(struct > > super_block *sb, const struct inode > > return inode; > > } > > > > -bool shmem_mapping(struct address_space *mapping) > > +inline bool shmem_mapping(struct address_space *mapping) > > { > > return mapping->a_ops == &shmem_aops; > > } > > huh. I'd have expected the inlining in shmem_evict_inode() to not work > because the compiler hasn't seen the definition yet. But gcc has > evidently become smarter about that. > > But really, shmem_mapping() isn't worth an out-of-line call from any > callsite - it would be best to make it inlined everywhere. > > - make shmem_aops global > - declare shmem_aops in shmem_fs.h > - export shmem_aops to modules for drivers/dma-buf/udmabuf.c > - include linux/fs.h in shmem_fs.h for address_space_operations (we already > include fs.h via swap.h, but we shouldn't depend on that) > - make shmem_mapping() a static inline in shmem_fs.h. Yeah, thanks. i will resend a PATCH V3 later.
[PATCH v2] mm/shmem.c: make shmem_mapping() inline
inline the shmem_mapping(), and use shmem_mapping() instead of 'inode->i_mapping->a_ops == &shmem_aops' in shmem_evict_inode(). v1->v2: remove the inline for func declaration in shmem_fs.h Reviewed-by: Pankaj Gupta Reported-by: kernel test robot Signed-off-by: Hui Su --- mm/shmem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index 537c137698f8..7395d8e8226a 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1152,7 +1152,7 @@ static void shmem_evict_inode(struct inode *inode) struct shmem_inode_info *info = SHMEM_I(inode); struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb); - if (inode->i_mapping->a_ops == &shmem_aops) { + if (shmem_mapping(inode->i_mapping)) { shmem_unacct_size(info->flags, inode->i_size); inode->i_size = 0; shmem_truncate_range(inode, 0, (loff_t)-1); @@ -2352,7 +2352,7 @@ static struct inode *shmem_get_inode(struct super_block *sb, const struct inode return inode; } -bool shmem_mapping(struct address_space *mapping) +inline bool shmem_mapping(struct address_space *mapping) { return mapping->a_ops == &shmem_aops; } -- 2.29.0
Re: [PATCH] mm/shmem.c: make shmem_mapping() inline
On Sat, Nov 14, 2020 at 12:54:47AM +0800, kernel test robot wrote: > Hi Hui, > > Thank you for the patch! Perhaps something to improve: > > [auto build test WARNING on mmotm/master] > > url: > https://github.com/0day-ci/linux/commits/Hui-Su/mm-shmem-c-make-shmem_mapping-inline/20201113-215549 > base: git://git.cmpxchg.org/linux-mmotm.git master > config: arm-randconfig-s032-20201113 (attached as .config) > compiler: arm-linux-gnueabi-gcc (GCC) 9.3.0 > reproduce: > wget > https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O > ~/bin/make.cross > chmod +x ~/bin/make.cross > # apt-get install sparse > # sparse version: v0.6.3-107-gaf3512a6-dirty > # > https://github.com/0day-ci/linux/commit/0434762d5523a3d702cd589a7f8e3771fee7b3b2 > git remote add linux-review https://github.com/0day-ci/linux > git fetch --no-tags linux-review > Hui-Su/mm-shmem-c-make-shmem_mapping-inline/20201113-215549 > git checkout 0434762d5523a3d702cd589a7f8e3771fee7b3b2 > # save the attached .config to linux build tree > COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 > CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=arm > > If you fix the issue, kindly add following tag as appropriate > Reported-by: kernel test robot > > > "sparse warnings: (new ones prefixed by >>)" >mm/filemap.c: note: in included file: > >> include/linux/shmem_fs.h:66:33: sparse: sparse: marked inline, but without > >> a definition > >> include/linux/shmem_fs.h:66:33: sparse: sparse: marked inline, but without > >> a definition > >> include/linux/shmem_fs.h:66:33: sparse: sparse: marked inline, but without > >> a definition > -- >mm/truncate.c: note: in included file: > >> include/linux/shmem_fs.h:66:33: sparse: sparse: marked inline, but without > >> a definition > >> include/linux/shmem_fs.h:66:33: sparse: sparse: marked inline, but without > >> a definition > >> include/linux/shmem_fs.h:66:33: sparse: sparse: marked inline, but without > >> a definition > -- >mm/memfd.c: note: in included file: > >> include/linux/shmem_fs.h:66:33: sparse: sparse: marked inline, but without > >> a definition > > vim +66 include/linux/shmem_fs.h > > 48 > 49/* > 50 * Functions in mm/shmem.c called directly from elsewhere: > 51 */ > 52extern const struct fs_parameter_description > shmem_fs_parameters; > 53extern int shmem_init(void); > 54extern int shmem_init_fs_context(struct fs_context *fc); > 55extern struct file *shmem_file_setup(const char *name, > 56loff_t size, unsigned > long flags); > 57extern struct file *shmem_kernel_file_setup(const char *name, > loff_t size, > 58unsigned long > flags); > 59extern struct file *shmem_file_setup_with_mnt(struct vfsmount > *mnt, > 60const char *name, loff_t size, unsigned long > flags); > 61extern int shmem_zero_setup(struct vm_area_struct *); > 62extern unsigned long shmem_get_unmapped_area(struct file *, > unsigned long addr, > 63unsigned long len, unsigned long pgoff, > unsigned long flags); > 64extern int shmem_lock(struct file *file, int lock, struct > user_struct *user); > 65#ifdef CONFIG_SHMEM > > 66extern inline bool shmem_mapping(struct address_space *mapping); > 67#else > 68static inline bool shmem_mapping(struct address_space *mapping) > 69{ > 70return false; > 71} > 72#endif /* CONFIG_SHMEM */ > 73extern void shmem_unlock_mapping(struct address_space *mapping); > 74extern struct page *shmem_read_mapping_page_gfp(struct > address_space *mapping, > 75pgoff_t index, gfp_t > gfp_mask); > 76extern void shmem_truncate_range(struct inode *inode, loff_t > start, loff_t end); > 77extern int shmem_unuse(unsigned int type, bool frontswap, > 78 unsigned long *fs_pages_to_unuse); > 79 > > --- > 0-DAY CI Kernel Test Service, Intel Corporation > https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org Thanks for your test. I will resend a PATCH V2 later.
[PATCH] mm/shmem.c: make shmem_mapping() inline
inline the shmem_mapping(), and use shmem_mapping() instead of 'inode->i_mapping->a_ops == &shmem_aops' in shmem_evict_inode(). Signed-off-by: Hui Su --- include/linux/shmem_fs.h | 2 +- mm/shmem.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h index a5a5d1d4d7b1..154a16fe7fd5 100644 --- a/include/linux/shmem_fs.h +++ b/include/linux/shmem_fs.h @@ -67,7 +67,7 @@ extern unsigned long shmem_get_unmapped_area(struct file *, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags); extern int shmem_lock(struct file *file, int lock, struct user_struct *user); #ifdef CONFIG_SHMEM -extern bool shmem_mapping(struct address_space *mapping); +extern inline bool shmem_mapping(struct address_space *mapping); #else static inline bool shmem_mapping(struct address_space *mapping) { diff --git a/mm/shmem.c b/mm/shmem.c index 537c137698f8..7395d8e8226a 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1152,7 +1152,7 @@ static void shmem_evict_inode(struct inode *inode) struct shmem_inode_info *info = SHMEM_I(inode); struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb); - if (inode->i_mapping->a_ops == &shmem_aops) { + if (shmem_mapping(inode->i_mapping)) { shmem_unacct_size(info->flags, inode->i_size); inode->i_size = 0; shmem_truncate_range(inode, 0, (loff_t)-1); @@ -2352,7 +2352,7 @@ static struct inode *shmem_get_inode(struct super_block *sb, const struct inode return inode; } -bool shmem_mapping(struct address_space *mapping) +inline bool shmem_mapping(struct address_space *mapping) { return mapping->a_ops == &shmem_aops; } -- 2.29.0
[PATCH] mm/page_counter: use page_counter_read in page_counter_set_max
use page_counter_read() in page_counter_set_max(). Signed-off-by: Hui Su --- mm/page_counter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/page_counter.c b/mm/page_counter.c index b24a60b28bb0..c6860f51b6c6 100644 --- a/mm/page_counter.c +++ b/mm/page_counter.c @@ -183,14 +183,14 @@ int page_counter_set_max(struct page_counter *counter, unsigned long nr_pages) * the limit, so if it sees the old limit, we see the * modified counter and retry. */ - usage = atomic_long_read(&counter->usage); + usage = page_counter_read(counter); if (usage > nr_pages) return -EBUSY; old = xchg(&counter->max, nr_pages); - if (atomic_long_read(&counter->usage) <= usage) + if (page_counter_read(counter) <= usage) return 0; counter->max = old; -- 2.29.0
[PATCH] x86/dumpstack: make show_trace_log_lvl() static
show_trace_log_lvl() won't be used by other files, so make it static and remove the declaration from the header file. Signed-off-by: Hui Su --- arch/x86/include/asm/stacktrace.h | 3 --- arch/x86/kernel/dumpstack.c | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h index 49600643faba..f248eb2ac2d4 100644 --- a/arch/x86/include/asm/stacktrace.h +++ b/arch/x86/include/asm/stacktrace.h @@ -88,9 +88,6 @@ get_stack_pointer(struct task_struct *task, struct pt_regs *regs) return (unsigned long *)task->thread.sp; } -void show_trace_log_lvl(struct task_struct *task, struct pt_regs *regs, - unsigned long *stack, const char *log_lvl); - /* The form of the top of the frame on the stack */ struct stack_frame { struct stack_frame *next_frame; diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c index 25c06b67e7e0..067de0d0fa4f 100644 --- a/arch/x86/kernel/dumpstack.c +++ b/arch/x86/kernel/dumpstack.c @@ -168,7 +168,7 @@ static void show_regs_if_on_stack(struct stack_info *info, struct pt_regs *regs, } } -void show_trace_log_lvl(struct task_struct *task, struct pt_regs *regs, +static void show_trace_log_lvl(struct task_struct *task, struct pt_regs *regs, unsigned long *stack, const char *log_lvl) { struct unwind_state state; -- 2.29.0
[PATCH] fs/kernfs: remove the double check of dentry->inode
In both kernfs_node_from_dentry() and in kernfs_dentry_node(), we will check the dentry->inode is NULL or not, which is superfluous. So remove the check in kernfs_node_from_dentry(). Signed-off-by: Hui Su --- fs/kernfs/dir.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c index 9aec80b9d7c6..b062c666df05 100644 --- a/fs/kernfs/dir.c +++ b/fs/kernfs/dir.c @@ -604,8 +604,7 @@ const struct dentry_operations kernfs_dops = { */ struct kernfs_node *kernfs_node_from_dentry(struct dentry *dentry) { - if (dentry->d_sb->s_op == &kernfs_sops && - !d_really_is_negative(dentry)) + if (dentry->d_sb->s_op == &kernfs_sops) return kernfs_dentry_node(dentry); return NULL; } -- 2.29.0