[PATCH 1/2] phy:phy-brcm-us: Use PTR_ERR_OR_ZERO to replace the open code
PTR_ERR_OR_ZERO has implemented the if(IS_ERR(...)) + PTR_ERR, So just replace them rather than duplicating its implement. Signed-off-by: zhong jiang --- drivers/phy/broadcom/phy-brcm-usb.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/phy/broadcom/phy-brcm-usb.c b/drivers/phy/broadcom/phy-brcm-usb.c index d1dab36..f59b1dc 100644 --- a/drivers/phy/broadcom/phy-brcm-usb.c +++ b/drivers/phy/broadcom/phy-brcm-usb.c @@ -372,10 +372,8 @@ static int brcm_usb_phy_probe(struct platform_device *pdev) clk_disable(priv->usb_30_clk); phy_provider = devm_of_phy_provider_register(dev, brcm_usb_phy_xlate); - if (IS_ERR(phy_provider)) - return PTR_ERR(phy_provider); - return 0; + return PTR_ERR_OR_ZERO(phy_provider); } #ifdef CONFIG_PM_SLEEP -- 1.7.12.4
[PATCH 0/2] phy: Use PTR_ERR_OR_ZERO to replace the open code
The issue is detected with the help of Coccinelle. zhong jiang (2): phy:phy-brcm-us: Use PTR_ERR_OR_ZERO to replace the open code phy:phy-lantiq-rcu-usb2: Use PTR_ERR_OR_ZERO to replace the open code drivers/phy/broadcom/phy-brcm-usb.c | 4 +--- drivers/phy/lantiq/phy-lantiq-rcu-usb2.c | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) -- 1.7.12.4
[PATCH 0/2] phy: Use PTR_ERR_OR_ZERO to replace the open code
The issue is detected with the help of Coccinelle. zhong jiang (2): phy:phy-brcm-us: Use PTR_ERR_OR_ZERO to replace the open code phy:phy-lantiq-rcu-usb2: Use PTR_ERR_OR_ZERO to replace the open code drivers/phy/broadcom/phy-brcm-usb.c | 4 +--- drivers/phy/lantiq/phy-lantiq-rcu-usb2.c | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) -- 1.7.12.4
[PATCH 2/2] phy:phy-lantiq-rcu-usb2: Use PTR_ERR_OR_ZERO to replace the open code
PTR_ERR_OR_ZERO has implemented the if(IS_ERR(...)) + PTR_ERR, So just replace them rather than duplicating its implement. Signed-off-by: zhong jiang --- drivers/phy/lantiq/phy-lantiq-rcu-usb2.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/phy/lantiq/phy-lantiq-rcu-usb2.c b/drivers/phy/lantiq/phy-lantiq-rcu-usb2.c index 986224f..a918c5b 100644 --- a/drivers/phy/lantiq/phy-lantiq-rcu-usb2.c +++ b/drivers/phy/lantiq/phy-lantiq-rcu-usb2.c @@ -196,10 +196,8 @@ static int ltq_rcu_usb2_of_parse(struct ltq_rcu_usb2_priv *priv, } priv->phy_reset = devm_reset_control_get_optional(dev, "phy"); - if (IS_ERR(priv->phy_reset)) - return PTR_ERR(priv->phy_reset); - return 0; + return PTR_ERR_OR_ZERO(priv->phy_reset); } static int ltq_rcu_usb2_phy_probe(struct platform_device *pdev) -- 1.7.12.4
[PATCH 2/2] phy:phy-lantiq-rcu-usb2: Use PTR_ERR_OR_ZERO to replace the open code
PTR_ERR_OR_ZERO has implemented the if(IS_ERR(...)) + PTR_ERR, So just replace them rather than duplicating its implement. Signed-off-by: zhong jiang --- drivers/phy/lantiq/phy-lantiq-rcu-usb2.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/phy/lantiq/phy-lantiq-rcu-usb2.c b/drivers/phy/lantiq/phy-lantiq-rcu-usb2.c index 986224f..a918c5b 100644 --- a/drivers/phy/lantiq/phy-lantiq-rcu-usb2.c +++ b/drivers/phy/lantiq/phy-lantiq-rcu-usb2.c @@ -196,10 +196,8 @@ static int ltq_rcu_usb2_of_parse(struct ltq_rcu_usb2_priv *priv, } priv->phy_reset = devm_reset_control_get_optional(dev, "phy"); - if (IS_ERR(priv->phy_reset)) - return PTR_ERR(priv->phy_reset); - return 0; + return PTR_ERR_OR_ZERO(priv->phy_reset); } static int ltq_rcu_usb2_phy_probe(struct platform_device *pdev) -- 1.7.12.4
Re: [PATCH] staging:pci-mt7621: Use PTR_ERR_OR_ZERO to replace the open code
On 2018/8/13 19:26, Sergio Paracuellos wrote: > On Mon, Aug 13, 2018 at 12:54 PM, zhong jiang wrote: >> PTR_ERR_OR_ZERO has implemented the if(IS_ERR(...)) + PTR_ERR, So >> just replace them rather than duplicating its implement. >> >> Signed-off-by: zhong jiang >> --- >> drivers/staging/mt7621-pci/pci-mt7621.c | 4 +--- >> 1 file changed, 1 insertion(+), 3 deletions(-) >> >> diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c >> b/drivers/staging/mt7621-pci/pci-mt7621.c >> index a49e279..9a8ff1d 100644 >> --- a/drivers/staging/mt7621-pci/pci-mt7621.c >> +++ b/drivers/staging/mt7621-pci/pci-mt7621.c >> @@ -403,10 +403,8 @@ static int mt7621_pcie_parse_dt(struct mt7621_pcie >> *pcie) >> } >> >> pcie->base = devm_ioremap_resource(dev, ); >> - if (IS_ERR(pcie->base)) >> - return PTR_ERR(pcie->base); >> >> - return 0; >> + return PTR_ERR_OR_ZERO(pcie->base); >> } > Hi Zhong, > > Thanks for this. This driver is in the middle of cleanup and this > function is not doing all the DT parse > yet, so this patch looks good but after applying this series (if they > work and are good enough to be applied) > has no sense. > > See: > http://driverdev.linuxdriverproject.org/pipermail/driverdev-devel/2018-August/124890.html > > Best regards, > Sergio Paracuellos Thank you for let me know that. Sincerely, zhong jiang >> static int mt7621_pcie_request_resources(struct mt7621_pcie *pcie, >> -- >> 1.7.12.4 >> > . >
Re: [PATCH] staging:pci-mt7621: Use PTR_ERR_OR_ZERO to replace the open code
On 2018/8/13 19:26, Sergio Paracuellos wrote: > On Mon, Aug 13, 2018 at 12:54 PM, zhong jiang wrote: >> PTR_ERR_OR_ZERO has implemented the if(IS_ERR(...)) + PTR_ERR, So >> just replace them rather than duplicating its implement. >> >> Signed-off-by: zhong jiang >> --- >> drivers/staging/mt7621-pci/pci-mt7621.c | 4 +--- >> 1 file changed, 1 insertion(+), 3 deletions(-) >> >> diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c >> b/drivers/staging/mt7621-pci/pci-mt7621.c >> index a49e279..9a8ff1d 100644 >> --- a/drivers/staging/mt7621-pci/pci-mt7621.c >> +++ b/drivers/staging/mt7621-pci/pci-mt7621.c >> @@ -403,10 +403,8 @@ static int mt7621_pcie_parse_dt(struct mt7621_pcie >> *pcie) >> } >> >> pcie->base = devm_ioremap_resource(dev, ); >> - if (IS_ERR(pcie->base)) >> - return PTR_ERR(pcie->base); >> >> - return 0; >> + return PTR_ERR_OR_ZERO(pcie->base); >> } > Hi Zhong, > > Thanks for this. This driver is in the middle of cleanup and this > function is not doing all the DT parse > yet, so this patch looks good but after applying this series (if they > work and are good enough to be applied) > has no sense. > > See: > http://driverdev.linuxdriverproject.org/pipermail/driverdev-devel/2018-August/124890.html > > Best regards, > Sergio Paracuellos Thank you for let me know that. Sincerely, zhong jiang >> static int mt7621_pcie_request_resources(struct mt7621_pcie *pcie, >> -- >> 1.7.12.4 >> > . >
[PATCH] staging:pci-mt7621: Use PTR_ERR_OR_ZERO to replace the open code
PTR_ERR_OR_ZERO has implemented the if(IS_ERR(...)) + PTR_ERR, So just replace them rather than duplicating its implement. Signed-off-by: zhong jiang --- drivers/staging/mt7621-pci/pci-mt7621.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index a49e279..9a8ff1d 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -403,10 +403,8 @@ static int mt7621_pcie_parse_dt(struct mt7621_pcie *pcie) } pcie->base = devm_ioremap_resource(dev, ); - if (IS_ERR(pcie->base)) - return PTR_ERR(pcie->base); - return 0; + return PTR_ERR_OR_ZERO(pcie->base); } static int mt7621_pcie_request_resources(struct mt7621_pcie *pcie, -- 1.7.12.4
[PATCH] staging:pci-mt7621: Use PTR_ERR_OR_ZERO to replace the open code
PTR_ERR_OR_ZERO has implemented the if(IS_ERR(...)) + PTR_ERR, So just replace them rather than duplicating its implement. Signed-off-by: zhong jiang --- drivers/staging/mt7621-pci/pci-mt7621.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index a49e279..9a8ff1d 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -403,10 +403,8 @@ static int mt7621_pcie_parse_dt(struct mt7621_pcie *pcie) } pcie->base = devm_ioremap_resource(dev, ); - if (IS_ERR(pcie->base)) - return PTR_ERR(pcie->base); - return 0; + return PTR_ERR_OR_ZERO(pcie->base); } static int mt7621_pcie_request_resources(struct mt7621_pcie *pcie, -- 1.7.12.4
[PATCH] arm:pm: Use kmemdup to replace duplicating its implementation
kmemdup is better than kmalloc() + memcpy(), and we do not like open code. So just use kmemdup instead. Signed-off-by: zhong jiang --- arch/arm/mach-lpc32xx/pm.c | 7 ++- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/arch/arm/mach-lpc32xx/pm.c b/arch/arm/mach-lpc32xx/pm.c index 6247157..6eefff8 100644 --- a/arch/arm/mach-lpc32xx/pm.c +++ b/arch/arm/mach-lpc32xx/pm.c @@ -86,7 +86,8 @@ static int lpc32xx_pm_enter(suspend_state_t state) void *iram_swap_area; /* Allocate some space for temporary IRAM storage */ - iram_swap_area = kmalloc(lpc32xx_sys_suspend_sz, GFP_KERNEL); + iram_swap_area = kmemdup((void *)TEMP_IRAM_AREA, + lpc32xx_sys_suspend_sz, GFP_KERNEL); if (!iram_swap_area) { printk(KERN_ERR "PM Suspend: cannot allocate memory to save portion " @@ -94,10 +95,6 @@ static int lpc32xx_pm_enter(suspend_state_t state) return -ENOMEM; } - /* Backup a small area of IRAM used for the suspend code */ - memcpy(iram_swap_area, (void *) TEMP_IRAM_AREA, - lpc32xx_sys_suspend_sz); - /* * Copy code to suspend system into IRAM. The suspend code * needs to run from IRAM as DRAM may no longer be available -- 1.7.12.4
[PATCH] arm:pm: Use kmemdup to replace duplicating its implementation
kmemdup is better than kmalloc() + memcpy(), and we do not like open code. So just use kmemdup instead. Signed-off-by: zhong jiang --- arch/arm/mach-lpc32xx/pm.c | 7 ++- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/arch/arm/mach-lpc32xx/pm.c b/arch/arm/mach-lpc32xx/pm.c index 6247157..6eefff8 100644 --- a/arch/arm/mach-lpc32xx/pm.c +++ b/arch/arm/mach-lpc32xx/pm.c @@ -86,7 +86,8 @@ static int lpc32xx_pm_enter(suspend_state_t state) void *iram_swap_area; /* Allocate some space for temporary IRAM storage */ - iram_swap_area = kmalloc(lpc32xx_sys_suspend_sz, GFP_KERNEL); + iram_swap_area = kmemdup((void *)TEMP_IRAM_AREA, + lpc32xx_sys_suspend_sz, GFP_KERNEL); if (!iram_swap_area) { printk(KERN_ERR "PM Suspend: cannot allocate memory to save portion " @@ -94,10 +95,6 @@ static int lpc32xx_pm_enter(suspend_state_t state) return -ENOMEM; } - /* Backup a small area of IRAM used for the suspend code */ - memcpy(iram_swap_area, (void *) TEMP_IRAM_AREA, - lpc32xx_sys_suspend_sz); - /* * Copy code to suspend system into IRAM. The suspend code * needs to run from IRAM as DRAM may no longer be available -- 1.7.12.4
[PATCH] ia64:tioce_provider: Use kmemdup rather than implement the function
The kmemdup has implemented the function that kmalloc() + memcpy will do. So just replace them to make the code concise. Signed-off-by: zhong jiang --- arch/ia64/sn/pci/tioce_provider.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/ia64/sn/pci/tioce_provider.c b/arch/ia64/sn/pci/tioce_provider.c index 3bd9abc..9ba61bc 100644 --- a/arch/ia64/sn/pci/tioce_provider.c +++ b/arch/ia64/sn/pci/tioce_provider.c @@ -1000,11 +1000,11 @@ * Allocate kernel bus soft and copy from prom. */ - tioce_common = kzalloc(sizeof(struct tioce_common), GFP_KERNEL); + tioce_common = kmemdup(prom_bussoft, sizeof(struct tioce_common), + GFP_KERNEL); if (!tioce_common) return NULL; - memcpy(tioce_common, prom_bussoft, sizeof(struct tioce_common)); tioce_common->ce_pcibus.bs_base = (unsigned long) ioremap(REGION_OFFSET(tioce_common->ce_pcibus.bs_base), sizeof(struct tioce_common)); -- 1.7.12.4
[PATCH] ia64:tioce_provider: Use kmemdup rather than implement the function
The kmemdup has implemented the function that kmalloc() + memcpy will do. So just replace them to make the code concise. Signed-off-by: zhong jiang --- arch/ia64/sn/pci/tioce_provider.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/ia64/sn/pci/tioce_provider.c b/arch/ia64/sn/pci/tioce_provider.c index 3bd9abc..9ba61bc 100644 --- a/arch/ia64/sn/pci/tioce_provider.c +++ b/arch/ia64/sn/pci/tioce_provider.c @@ -1000,11 +1000,11 @@ * Allocate kernel bus soft and copy from prom. */ - tioce_common = kzalloc(sizeof(struct tioce_common), GFP_KERNEL); + tioce_common = kmemdup(prom_bussoft, sizeof(struct tioce_common), + GFP_KERNEL); if (!tioce_common) return NULL; - memcpy(tioce_common, prom_bussoft, sizeof(struct tioce_common)); tioce_common->ce_pcibus.bs_base = (unsigned long) ioremap(REGION_OFFSET(tioce_common->ce_pcibus.bs_base), sizeof(struct tioce_common)); -- 1.7.12.4
[PATCH] arm:pmsa-v8: remove some extra semicolon
There are some extra semicolon in pmsa-v8.c. So just remove them. I detect the issue with the help of Coccinelle. Signed-off-by: zhong jiang --- arch/arm/mm/pmsa-v8.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm/mm/pmsa-v8.c b/arch/arm/mm/pmsa-v8.c index 617a83d..0d7d5fb 100644 --- a/arch/arm/mm/pmsa-v8.c +++ b/arch/arm/mm/pmsa-v8.c @@ -165,7 +165,7 @@ static int __init pmsav8_setup_ram(unsigned int number, phys_addr_t start,phys_a return -EINVAL; bar = start; - lar = (end - 1) & ~(PMSAv8_MINALIGN - 1);; + lar = (end - 1) & ~(PMSAv8_MINALIGN - 1); bar |= PMSAv8_AP_PL1RW_PL0RW | PMSAv8_RGN_SHARED; lar |= PMSAv8_LAR_IDX(PMSAv8_RGN_NORMAL) | PMSAv8_LAR_EN; @@ -181,7 +181,7 @@ static int __init pmsav8_setup_io(unsigned int number, phys_addr_t start,phys_ad return -EINVAL; bar = start; - lar = (end - 1) & ~(PMSAv8_MINALIGN - 1);; + lar = (end - 1) & ~(PMSAv8_MINALIGN - 1); bar |= PMSAv8_AP_PL1RW_PL0RW | PMSAv8_RGN_SHARED | PMSAv8_BAR_XN; lar |= PMSAv8_LAR_IDX(PMSAv8_RGN_DEVICE_nGnRnE) | PMSAv8_LAR_EN; -- 1.7.12.4
[PATCH] arm:pmsa-v8: remove some extra semicolon
There are some extra semicolon in pmsa-v8.c. So just remove them. I detect the issue with the help of Coccinelle. Signed-off-by: zhong jiang --- arch/arm/mm/pmsa-v8.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm/mm/pmsa-v8.c b/arch/arm/mm/pmsa-v8.c index 617a83d..0d7d5fb 100644 --- a/arch/arm/mm/pmsa-v8.c +++ b/arch/arm/mm/pmsa-v8.c @@ -165,7 +165,7 @@ static int __init pmsav8_setup_ram(unsigned int number, phys_addr_t start,phys_a return -EINVAL; bar = start; - lar = (end - 1) & ~(PMSAv8_MINALIGN - 1);; + lar = (end - 1) & ~(PMSAv8_MINALIGN - 1); bar |= PMSAv8_AP_PL1RW_PL0RW | PMSAv8_RGN_SHARED; lar |= PMSAv8_LAR_IDX(PMSAv8_RGN_NORMAL) | PMSAv8_LAR_EN; @@ -181,7 +181,7 @@ static int __init pmsav8_setup_io(unsigned int number, phys_addr_t start,phys_ad return -EINVAL; bar = start; - lar = (end - 1) & ~(PMSAv8_MINALIGN - 1);; + lar = (end - 1) & ~(PMSAv8_MINALIGN - 1); bar |= PMSAv8_AP_PL1RW_PL0RW | PMSAv8_RGN_SHARED | PMSAv8_BAR_XN; lar |= PMSAv8_LAR_IDX(PMSAv8_RGN_DEVICE_nGnRnE) | PMSAv8_LAR_EN; -- 1.7.12.4
[PATCH 0/2] arm64: remove some extra semicolon
There are some extra semicolon in arm64 architecture. Just remove them. zhong jiang (2): arm64/kprobes: remove an extra semicolon in arch_prepare_kprobe arm64:guest: remove some extra semicolon in kvm_target_cpu arch/arm64/kernel/probes/kprobes.c | 2 +- arch/arm64/kvm/guest.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) -- 1.7.12.4
[PATCH 0/2] arm64: remove some extra semicolon
There are some extra semicolon in arm64 architecture. Just remove them. zhong jiang (2): arm64/kprobes: remove an extra semicolon in arch_prepare_kprobe arm64:guest: remove some extra semicolon in kvm_target_cpu arch/arm64/kernel/probes/kprobes.c | 2 +- arch/arm64/kvm/guest.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) -- 1.7.12.4
[PATCH 1/2] arm64/kprobes: remove an extra semicolon in arch_prepare_kprobe
There is an extra semicolon in arch_prepare_kprobe, remove it. Signed-off-by: zhong jiang --- arch/arm64/kernel/probes/kprobes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/kernel/probes/kprobes.c b/arch/arm64/kernel/probes/kprobes.c index e78c3ef..9b65132 100644 --- a/arch/arm64/kernel/probes/kprobes.c +++ b/arch/arm64/kernel/probes/kprobes.c @@ -107,7 +107,7 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p) if (!p->ainsn.api.insn) return -ENOMEM; break; - }; + } /* prepare the instruction */ if (p->ainsn.api.insn) -- 1.7.12.4
[PATCH 2/2] arm64:guest: remove some extra semicolon in kvm_target_cpu
There are some extra semicolon in kvm_target_cpu, remove it. Signed-off-by: zhong jiang --- arch/arm64/kvm/guest.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c index 07256b0..a74f84d 100644 --- a/arch/arm64/kvm/guest.c +++ b/arch/arm64/kvm/guest.c @@ -338,15 +338,15 @@ int __attribute_const__ kvm_target_cpu(void) return KVM_ARM_TARGET_CORTEX_A53; case ARM_CPU_PART_CORTEX_A57: return KVM_ARM_TARGET_CORTEX_A57; - }; + } break; case ARM_CPU_IMP_APM: switch (part_number) { case APM_CPU_PART_POTENZA: return KVM_ARM_TARGET_XGENE_POTENZA; - }; + } break; - }; + } /* Return a default generic target */ return KVM_ARM_TARGET_GENERIC_V8; -- 1.7.12.4
[PATCH 1/2] arm64/kprobes: remove an extra semicolon in arch_prepare_kprobe
There is an extra semicolon in arch_prepare_kprobe, remove it. Signed-off-by: zhong jiang --- arch/arm64/kernel/probes/kprobes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/kernel/probes/kprobes.c b/arch/arm64/kernel/probes/kprobes.c index e78c3ef..9b65132 100644 --- a/arch/arm64/kernel/probes/kprobes.c +++ b/arch/arm64/kernel/probes/kprobes.c @@ -107,7 +107,7 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p) if (!p->ainsn.api.insn) return -ENOMEM; break; - }; + } /* prepare the instruction */ if (p->ainsn.api.insn) -- 1.7.12.4
[PATCH 2/2] arm64:guest: remove some extra semicolon in kvm_target_cpu
There are some extra semicolon in kvm_target_cpu, remove it. Signed-off-by: zhong jiang --- arch/arm64/kvm/guest.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c index 07256b0..a74f84d 100644 --- a/arch/arm64/kvm/guest.c +++ b/arch/arm64/kvm/guest.c @@ -338,15 +338,15 @@ int __attribute_const__ kvm_target_cpu(void) return KVM_ARM_TARGET_CORTEX_A53; case ARM_CPU_PART_CORTEX_A57: return KVM_ARM_TARGET_CORTEX_A57; - }; + } break; case ARM_CPU_IMP_APM: switch (part_number) { case APM_CPU_PART_POTENZA: return KVM_ARM_TARGET_XGENE_POTENZA; - }; + } break; - }; + } /* Return a default generic target */ return KVM_ARM_TARGET_GENERIC_V8; -- 1.7.12.4
[PATCH] drivers/thermal/tegra: fix a doule free devce node
Device node iterators will get the return node. Meawhile, It is also put the previous device node. An explicit put will cause a double put. Signed-off-by: zhong jiang --- drivers/thermal/tegra/soctherm.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/thermal/tegra/soctherm.c b/drivers/thermal/tegra/soctherm.c index ed28110..3aa55c9 100644 --- a/drivers/thermal/tegra/soctherm.c +++ b/drivers/thermal/tegra/soctherm.c @@ -980,7 +980,6 @@ static void soctherm_init_hw_throt_cdev(struct platform_device *pdev) tcd = thermal_of_cooling_device_register(np_stcc, (char *)name, ts, _cooling_ops); - of_node_put(np_stcc); if (IS_ERR_OR_NULL(tcd)) { dev_err(dev, "throttle-cfg: %s: failed to register cooling device\n", -- 1.7.12.4
[PATCH] drivers/thermal/tegra: fix a doule free devce node
Device node iterators will get the return node. Meawhile, It is also put the previous device node. An explicit put will cause a double put. Signed-off-by: zhong jiang --- drivers/thermal/tegra/soctherm.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/thermal/tegra/soctherm.c b/drivers/thermal/tegra/soctherm.c index ed28110..3aa55c9 100644 --- a/drivers/thermal/tegra/soctherm.c +++ b/drivers/thermal/tegra/soctherm.c @@ -980,7 +980,6 @@ static void soctherm_init_hw_throt_cdev(struct platform_device *pdev) tcd = thermal_of_cooling_device_register(np_stcc, (char *)name, ts, _cooling_ops); - of_node_put(np_stcc); if (IS_ERR_OR_NULL(tcd)) { dev_err(dev, "throttle-cfg: %s: failed to register cooling device\n", -- 1.7.12.4
[PATCH] drivers/block/drbd: remove the null check for kmem_cache_destroy
kmem_cache_destroy has taken null pointer into account. So it is safe to drop the null check before calling the function. Signed-off-by: zhong jiang --- drivers/block/drbd/drbd_main.c | 12 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c index a80809b..ef8212a 100644 --- a/drivers/block/drbd/drbd_main.c +++ b/drivers/block/drbd/drbd_main.c @@ -2103,14 +2103,10 @@ static void drbd_destroy_mempools(void) mempool_exit(_md_io_page_pool); mempool_exit(_ee_mempool); mempool_exit(_request_mempool); - if (drbd_ee_cache) - kmem_cache_destroy(drbd_ee_cache); - if (drbd_request_cache) - kmem_cache_destroy(drbd_request_cache); - if (drbd_bm_ext_cache) - kmem_cache_destroy(drbd_bm_ext_cache); - if (drbd_al_ext_cache) - kmem_cache_destroy(drbd_al_ext_cache); + kmem_cache_destroy(drbd_ee_cache); + kmem_cache_destroy(drbd_request_cache); + kmem_cache_destroy(drbd_bm_ext_cache); + kmem_cache_destroy(drbd_al_ext_cache); drbd_ee_cache= NULL; drbd_request_cache = NULL; -- 1.7.12.4
[PATCH] drivers/block/drbd: remove the null check for kmem_cache_destroy
kmem_cache_destroy has taken null pointer into account. So it is safe to drop the null check before calling the function. Signed-off-by: zhong jiang --- drivers/block/drbd/drbd_main.c | 12 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c index a80809b..ef8212a 100644 --- a/drivers/block/drbd/drbd_main.c +++ b/drivers/block/drbd/drbd_main.c @@ -2103,14 +2103,10 @@ static void drbd_destroy_mempools(void) mempool_exit(_md_io_page_pool); mempool_exit(_ee_mempool); mempool_exit(_request_mempool); - if (drbd_ee_cache) - kmem_cache_destroy(drbd_ee_cache); - if (drbd_request_cache) - kmem_cache_destroy(drbd_request_cache); - if (drbd_bm_ext_cache) - kmem_cache_destroy(drbd_bm_ext_cache); - if (drbd_al_ext_cache) - kmem_cache_destroy(drbd_al_ext_cache); + kmem_cache_destroy(drbd_ee_cache); + kmem_cache_destroy(drbd_request_cache); + kmem_cache_destroy(drbd_bm_ext_cache); + kmem_cache_destroy(drbd_al_ext_cache); drbd_ee_cache= NULL; drbd_request_cache = NULL; -- 1.7.12.4
[PATCH] drivers/block/aoe/aoedev: NULL check is not needed for mempool_destroy
mempool_destroy has taken the null pointer into account. So it is safe to remove the null check. Signed-off-by: zhong jiang --- drivers/block/aoe/aoedev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/block/aoe/aoedev.c b/drivers/block/aoe/aoedev.c index 697f735..41060e9 100644 --- a/drivers/block/aoe/aoedev.c +++ b/drivers/block/aoe/aoedev.c @@ -284,8 +284,8 @@ e = t + d->ntargets; for (; t < e && *t; t++) freetgt(d, *t); - if (d->bufpool) - mempool_destroy(d->bufpool); + + mempool_destroy(d->bufpool); skbpoolfree(d); minor_free(d->sysminor); -- 1.7.12.4
[PATCH] drivers/block/aoe/aoedev: NULL check is not needed for mempool_destroy
mempool_destroy has taken the null pointer into account. So it is safe to remove the null check. Signed-off-by: zhong jiang --- drivers/block/aoe/aoedev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/block/aoe/aoedev.c b/drivers/block/aoe/aoedev.c index 697f735..41060e9 100644 --- a/drivers/block/aoe/aoedev.c +++ b/drivers/block/aoe/aoedev.c @@ -284,8 +284,8 @@ e = t + d->ntargets; for (; t < e && *t; t++) freetgt(d, *t); - if (d->bufpool) - mempool_destroy(d->bufpool); + + mempool_destroy(d->bufpool); skbpoolfree(d); minor_free(d->sysminor); -- 1.7.12.4
[PATCH] drivers/block/mtip32xx: remove the null check for debugfs_remove_recursive
debugfs_remove_recursive has taken null pointer into account. So it is safe to drop the null check before calling the funtion. Signed-off-by: zhong jiang --- drivers/block/mtip32xx/mtip32xx.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c index 2b6d6bc..d0666f5c 100644 --- a/drivers/block/mtip32xx/mtip32xx.c +++ b/drivers/block/mtip32xx/mtip32xx.c @@ -2574,8 +2574,7 @@ static int mtip_hw_debugfs_init(struct driver_data *dd) static void mtip_hw_debugfs_exit(struct driver_data *dd) { - if (dd->dfs_node) - debugfs_remove_recursive(dd->dfs_node); + debugfs_remove_recursive(dd->dfs_node); } /* -- 1.7.12.4
[PATCH] drivers/block/mtip32xx: remove the null check for debugfs_remove_recursive
debugfs_remove_recursive has taken null pointer into account. So it is safe to drop the null check before calling the funtion. Signed-off-by: zhong jiang --- drivers/block/mtip32xx/mtip32xx.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c index 2b6d6bc..d0666f5c 100644 --- a/drivers/block/mtip32xx/mtip32xx.c +++ b/drivers/block/mtip32xx/mtip32xx.c @@ -2574,8 +2574,7 @@ static int mtip_hw_debugfs_init(struct driver_data *dd) static void mtip_hw_debugfs_exit(struct driver_data *dd) { - if (dd->dfs_node) - debugfs_remove_recursive(dd->dfs_node); + debugfs_remove_recursive(dd->dfs_node); } /* -- 1.7.12.4
[PATCH] staging: gasket: remove some extra semicolon
That semicolons are unneeded, Just remove them. Signed-off-by: zhong jiang --- drivers/staging/gasket/gasket_interrupt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/gasket/gasket_interrupt.c b/drivers/staging/gasket/gasket_interrupt.c index 09c3d07..1cfbc12 100644 --- a/drivers/staging/gasket/gasket_interrupt.c +++ b/drivers/staging/gasket/gasket_interrupt.c @@ -386,7 +386,7 @@ int gasket_interrupt_init(struct gasket_dev *gasket_dev, const char *name, "Cannot handle unsupported interrupt type %d\n", interrupt_data->type); ret = -EINVAL; - }; + } if (ret) { /* Failing to setup interrupts will cause the device to report @@ -445,7 +445,7 @@ int gasket_interrupt_reinit(struct gasket_dev *gasket_dev) "Cannot handle unsupported interrupt type %d\n", gasket_dev->interrupt_data->type); ret = -EINVAL; - }; + } if (ret) { /* Failing to setup MSIx will cause the device @@ -493,7 +493,7 @@ void gasket_interrupt_cleanup(struct gasket_dev *gasket_dev) dev_dbg(gasket_dev->dev, "Cannot handle unsupported interrupt type %d\n", interrupt_data->type); - }; + } kfree(interrupt_data->interrupt_counts); kfree(interrupt_data->eventfd_ctxs); -- 1.7.12.4
[PATCH] staging: gasket: remove some extra semicolon
That semicolons are unneeded, Just remove them. Signed-off-by: zhong jiang --- drivers/staging/gasket/gasket_interrupt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/gasket/gasket_interrupt.c b/drivers/staging/gasket/gasket_interrupt.c index 09c3d07..1cfbc12 100644 --- a/drivers/staging/gasket/gasket_interrupt.c +++ b/drivers/staging/gasket/gasket_interrupt.c @@ -386,7 +386,7 @@ int gasket_interrupt_init(struct gasket_dev *gasket_dev, const char *name, "Cannot handle unsupported interrupt type %d\n", interrupt_data->type); ret = -EINVAL; - }; + } if (ret) { /* Failing to setup interrupts will cause the device to report @@ -445,7 +445,7 @@ int gasket_interrupt_reinit(struct gasket_dev *gasket_dev) "Cannot handle unsupported interrupt type %d\n", gasket_dev->interrupt_data->type); ret = -EINVAL; - }; + } if (ret) { /* Failing to setup MSIx will cause the device @@ -493,7 +493,7 @@ void gasket_interrupt_cleanup(struct gasket_dev *gasket_dev) dev_dbg(gasket_dev->dev, "Cannot handle unsupported interrupt type %d\n", interrupt_data->type); - }; + } kfree(interrupt_data->interrupt_counts); kfree(interrupt_data->eventfd_ctxs); -- 1.7.12.4
Re: [PATCH 1/3] fs/btrfs/disk-io: Remove unneeded variable "err"
On 2018/8/5 23:27, Joe Perches wrote: > On Sun, 2018-08-05 at 23:02 +0800, zhong jiang wrote: >> The err is not used after initalization, So remove it and make >> the function to be void function. > [] >> diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c > [] >> @@ -4193,7 +4192,6 @@ static int btrfs_destroy_delayed_refs(struct >> btrfs_transaction *trans, >> if (atomic_read(_refs->num_entries) == 0) { >> spin_unlock(_refs->lock); >> btrfs_info(fs_info, "delayed_refs has NO entry"); >> -return ret; > Think a little more about this please. > This is not a sensible removal. I am sorry for stupid mistake. I will repost. Thanks, zhong jiang >> } >> >> while ((node = rb_first(_refs->href_root)) != NULL) { > > . >
Re: [PATCH 1/3] fs/btrfs/disk-io: Remove unneeded variable "err"
On 2018/8/5 23:27, Joe Perches wrote: > On Sun, 2018-08-05 at 23:02 +0800, zhong jiang wrote: >> The err is not used after initalization, So remove it and make >> the function to be void function. > [] >> diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c > [] >> @@ -4193,7 +4192,6 @@ static int btrfs_destroy_delayed_refs(struct >> btrfs_transaction *trans, >> if (atomic_read(_refs->num_entries) == 0) { >> spin_unlock(_refs->lock); >> btrfs_info(fs_info, "delayed_refs has NO entry"); >> -return ret; > Think a little more about this please. > This is not a sensible removal. I am sorry for stupid mistake. I will repost. Thanks, zhong jiang >> } >> >> while ((node = rb_first(_refs->href_root)) != NULL) { > > . >
Re: [PATCH 0/3] Remove uneeded variable "err"
On 2018/8/6 3:14, Nikolay Borisov wrote: > > On 5.08.2018 18:02, zhong jiang wrote: >> zhong jiang (3): >> fs/btrfs/disk-io: Remove unneeded variable "err" >> fs/btrfs/extent-tree: remove redudant variable "err" >> fs/btrfs/tree-log: remove the unneeded variable "err" >> >> fs/btrfs/disk-io.c | 12 >> fs/btrfs/extent-tree.c | 6 ++ >> fs/btrfs/tree-log.c| 5 + >> fs/btrfs/tree-log.h| 2 +- >> 4 files changed, 8 insertions(+), 17 deletions(-) >> > > NAK on the whole series on the basis of using a bulk commit message > which doesn't really describe the changes of each individual commit. If > you want those changes to eventually be merged resubmit the series with > individual reasoning for every commit. > > It's sorry for using a bulk commit message. I will repost with a patch because it solves the same issue. Thanks, zhong jiang
Re: [PATCH 0/3] Remove uneeded variable "err"
On 2018/8/6 3:14, Nikolay Borisov wrote: > > On 5.08.2018 18:02, zhong jiang wrote: >> zhong jiang (3): >> fs/btrfs/disk-io: Remove unneeded variable "err" >> fs/btrfs/extent-tree: remove redudant variable "err" >> fs/btrfs/tree-log: remove the unneeded variable "err" >> >> fs/btrfs/disk-io.c | 12 >> fs/btrfs/extent-tree.c | 6 ++ >> fs/btrfs/tree-log.c| 5 + >> fs/btrfs/tree-log.h| 2 +- >> 4 files changed, 8 insertions(+), 17 deletions(-) >> > > NAK on the whole series on the basis of using a bulk commit message > which doesn't really describe the changes of each individual commit. If > you want those changes to eventually be merged resubmit the series with > individual reasoning for every commit. > > It's sorry for using a bulk commit message. I will repost with a patch because it solves the same issue. Thanks, zhong jiang
Re: [PATCH] net/bridge/br_multicast: remove redundant variable "err"
On 2018/8/6 8:33, David Miller wrote: > From: zhong jiang > Date: Sun, 5 Aug 2018 22:18:43 +0800 > >> @@ -1797,7 +1795,7 @@ static int br_multicast_ipv4_rcv(struct net_bridge *br, >> struct sk_buff *skb_trimmed = NULL; >> const unsigned char *src; >> struct igmphdr *ih; >> -int err; >> +int err = 0; >> >> err = ip_mc_check_igmp(skb, _trimmed); > The initialization of err to '0' is unnecessary, it gets assigned on > the very next line. > > . > That's right. I will drop that change and repost. Thanks, zhong jiang
Re: [PATCH] net/bridge/br_multicast: remove redundant variable "err"
On 2018/8/6 8:33, David Miller wrote: > From: zhong jiang > Date: Sun, 5 Aug 2018 22:18:43 +0800 > >> @@ -1797,7 +1795,7 @@ static int br_multicast_ipv4_rcv(struct net_bridge *br, >> struct sk_buff *skb_trimmed = NULL; >> const unsigned char *src; >> struct igmphdr *ih; >> -int err; >> +int err = 0; >> >> err = ip_mc_check_igmp(skb, _trimmed); > The initialization of err to '0' is unnecessary, it gets assigned on > the very next line. > > . > That's right. I will drop that change and repost. Thanks, zhong jiang
Re: [PATCH] drivers/staging: Remove some unneeded semicolon
On 2018/8/6 9:27, Gao Xiang wrote: > Hi Jiang, > > On 2018/8/5 21:57, zhong jiang wrote: >> That semicolons are unneeded, JUst remove them. >> >> Signed-off-by: zhong jiang > Thanks for your patch. Since erofs and gasket are different feature, it is > better to seperate into two patches. > and could you please cc linux-erofs mailing list > as well? > > Yes, there is an extra semicolon in z_erofs_vle_unzip_all, it was reported by > Julia Lawall several days ago. > Actually, there is a patch in linux-erofs mailing list, but it seems that > Chao hasn't reviewed it yet... > > https://lists.ozlabs.org/pipermail/linux-erofs/2018-August/000303.html > > I will add Signed-off-by: zhong jiang to the original > patch if if you don't mind, do you? do it. Thanks. Then I will just resend the gasket feature separately. Thanks, zhong jiang > Thanks, > Gao Xiang > > . >
Re: [PATCH] drivers/staging: Remove some unneeded semicolon
On 2018/8/6 9:27, Gao Xiang wrote: > Hi Jiang, > > On 2018/8/5 21:57, zhong jiang wrote: >> That semicolons are unneeded, JUst remove them. >> >> Signed-off-by: zhong jiang > Thanks for your patch. Since erofs and gasket are different feature, it is > better to seperate into two patches. > and could you please cc linux-erofs mailing list > as well? > > Yes, there is an extra semicolon in z_erofs_vle_unzip_all, it was reported by > Julia Lawall several days ago. > Actually, there is a patch in linux-erofs mailing list, but it seems that > Chao hasn't reviewed it yet... > > https://lists.ozlabs.org/pipermail/linux-erofs/2018-August/000303.html > > I will add Signed-off-by: zhong jiang to the original > patch if if you don't mind, do you? do it. Thanks. Then I will just resend the gasket feature separately. Thanks, zhong jiang > Thanks, > Gao Xiang > > . >
[PATCH] drivers/staging: Remove some unneeded semicolon
That semicolons are unneeded, JUst remove them. Signed-off-by: zhong jiang --- drivers/staging/erofs/unzip_vle.c | 2 +- drivers/staging/gasket/gasket_interrupt.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/erofs/unzip_vle.c b/drivers/staging/erofs/unzip_vle.c index 1030ca5..e5ceb68 100644 --- a/drivers/staging/erofs/unzip_vle.c +++ b/drivers/staging/erofs/unzip_vle.c @@ -1016,7 +1016,7 @@ static void z_erofs_vle_unzip_all(struct super_block *sb, owned = READ_ONCE(grp->next); z_erofs_vle_unzip(sb, grp, page_pool); - }; + } } static void z_erofs_vle_unzip_wq(struct work_struct *work) diff --git a/drivers/staging/gasket/gasket_interrupt.c b/drivers/staging/gasket/gasket_interrupt.c index 09c3d07..1cfbc12 100644 --- a/drivers/staging/gasket/gasket_interrupt.c +++ b/drivers/staging/gasket/gasket_interrupt.c @@ -386,7 +386,7 @@ int gasket_interrupt_init(struct gasket_dev *gasket_dev, const char *name, "Cannot handle unsupported interrupt type %d\n", interrupt_data->type); ret = -EINVAL; - }; + } if (ret) { /* Failing to setup interrupts will cause the device to report @@ -445,7 +445,7 @@ int gasket_interrupt_reinit(struct gasket_dev *gasket_dev) "Cannot handle unsupported interrupt type %d\n", gasket_dev->interrupt_data->type); ret = -EINVAL; - }; + } if (ret) { /* Failing to setup MSIx will cause the device @@ -493,7 +493,7 @@ void gasket_interrupt_cleanup(struct gasket_dev *gasket_dev) dev_dbg(gasket_dev->dev, "Cannot handle unsupported interrupt type %d\n", interrupt_data->type); - }; + } kfree(interrupt_data->interrupt_counts); kfree(interrupt_data->eventfd_ctxs); -- 1.7.12.4
[PATCH] drivers/staging: Remove some unneeded semicolon
That semicolons are unneeded, JUst remove them. Signed-off-by: zhong jiang --- drivers/staging/erofs/unzip_vle.c | 2 +- drivers/staging/gasket/gasket_interrupt.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/erofs/unzip_vle.c b/drivers/staging/erofs/unzip_vle.c index 1030ca5..e5ceb68 100644 --- a/drivers/staging/erofs/unzip_vle.c +++ b/drivers/staging/erofs/unzip_vle.c @@ -1016,7 +1016,7 @@ static void z_erofs_vle_unzip_all(struct super_block *sb, owned = READ_ONCE(grp->next); z_erofs_vle_unzip(sb, grp, page_pool); - }; + } } static void z_erofs_vle_unzip_wq(struct work_struct *work) diff --git a/drivers/staging/gasket/gasket_interrupt.c b/drivers/staging/gasket/gasket_interrupt.c index 09c3d07..1cfbc12 100644 --- a/drivers/staging/gasket/gasket_interrupt.c +++ b/drivers/staging/gasket/gasket_interrupt.c @@ -386,7 +386,7 @@ int gasket_interrupt_init(struct gasket_dev *gasket_dev, const char *name, "Cannot handle unsupported interrupt type %d\n", interrupt_data->type); ret = -EINVAL; - }; + } if (ret) { /* Failing to setup interrupts will cause the device to report @@ -445,7 +445,7 @@ int gasket_interrupt_reinit(struct gasket_dev *gasket_dev) "Cannot handle unsupported interrupt type %d\n", gasket_dev->interrupt_data->type); ret = -EINVAL; - }; + } if (ret) { /* Failing to setup MSIx will cause the device @@ -493,7 +493,7 @@ void gasket_interrupt_cleanup(struct gasket_dev *gasket_dev) dev_dbg(gasket_dev->dev, "Cannot handle unsupported interrupt type %d\n", interrupt_data->type); - }; + } kfree(interrupt_data->interrupt_counts); kfree(interrupt_data->eventfd_ctxs); -- 1.7.12.4
Re: [PATCH] kernel/kthread: Make function __kthread_queue_delayed_work static
On 2018/8/3 21:21, Steven Rostedt wrote: > On Fri, 3 Aug 2018 20:40:02 +0800 > zhong jiang wrote: > >> Fix the following warning. >> >> kernel/kthread.c:859:6: warning: symbol '__kthread_queue_delayed_work' was >> not declared. Should it be static? > > This should go via the trivial tree. > >> Signed-off-by: zhong jiang >> --- >> kernel/kthread.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/kernel/kthread.c b/kernel/kthread.c >> index 087d18d..3c661a0 100644 >> --- a/kernel/kthread.c >> +++ b/kernel/kthread.c >> @@ -856,7 +856,7 @@ void kthread_delayed_work_timer_fn(struct timer_list *t) >> } >> EXPORT_SYMBOL(kthread_delayed_work_timer_fn); >> >> -void __kthread_queue_delayed_work(struct kthread_worker *worker, >> +static void __kthread_queue_delayed_work(struct kthread_worker *worker, >>struct kthread_delayed_work *dwork, >>unsigned long delay) > Although, one could say you should align the parameters too, but that's > not a big deal. Anyway... > > Reviewed-by: Steven Rostedt (VMware) Thanks , I will notice for next time. > -- Steve > >> { > > . >
Re: [PATCH] kernel/kthread: Make function __kthread_queue_delayed_work static
On 2018/8/3 21:21, Steven Rostedt wrote: > On Fri, 3 Aug 2018 20:40:02 +0800 > zhong jiang wrote: > >> Fix the following warning. >> >> kernel/kthread.c:859:6: warning: symbol '__kthread_queue_delayed_work' was >> not declared. Should it be static? > > This should go via the trivial tree. > >> Signed-off-by: zhong jiang >> --- >> kernel/kthread.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/kernel/kthread.c b/kernel/kthread.c >> index 087d18d..3c661a0 100644 >> --- a/kernel/kthread.c >> +++ b/kernel/kthread.c >> @@ -856,7 +856,7 @@ void kthread_delayed_work_timer_fn(struct timer_list *t) >> } >> EXPORT_SYMBOL(kthread_delayed_work_timer_fn); >> >> -void __kthread_queue_delayed_work(struct kthread_worker *worker, >> +static void __kthread_queue_delayed_work(struct kthread_worker *worker, >>struct kthread_delayed_work *dwork, >>unsigned long delay) > Although, one could say you should align the parameters too, but that's > not a big deal. Anyway... > > Reviewed-by: Steven Rostedt (VMware) Thanks , I will notice for next time. > -- Steve > >> { > > . >
Re: [PATCH] ext4/mballoc: Remove unneeded variable "err"
On 2018/8/5 5:24, Theodore Y. Ts'o wrote: > On Sat, Aug 04, 2018 at 07:04:56PM +0800, zhong jiang wrote: >> The err is not used after initalization. So just remove the variable. >> >> Signed-off-by: zhong jiang > I'll apply this patch, but how did you generate the diff? The > function name here is all wrong: > >> diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c >> index 8b24d3d..e29fce2 100644 >> --- a/fs/ext4/mballoc.c >> +++ b/fs/ext4/mballoc.c >> @@ -3801,7 +3801,6 @@ static int ext4_mb_new_preallocation(struct >> ext4_allocation_context *ac) >^ > > The lines in question are from ext4_mb_release_inode_pa(), *not* > ext4_mb_new_preallocation(). So when I inspected the patch visually, > my first reaction was, "there's no way this patch would apply". > > But then I looked at the C code changed by the patch, and I was > surprised to see that it applied correctly in a completely different > function, and when I regenerated the patch, the line numbers matched > yours --- so the only thing "wrong" in your patch is the function name. > > So that raises the question --- how did you create the diff in this-rc > patch? What version of git? And what version of the kernel? > > Regards, > > - Ted > > . > I create the diff in this patch again ,but get the same result . the git version is git version 1.7.12.4 but I create the diff in git version 1.8.3.1. It shows the correct function name. The kernel version is 4.18-rc7. I will upgrade the git version. Thanks, zhong jiang
Re: [PATCH] ext4/mballoc: Remove unneeded variable "err"
On 2018/8/5 5:24, Theodore Y. Ts'o wrote: > On Sat, Aug 04, 2018 at 07:04:56PM +0800, zhong jiang wrote: >> The err is not used after initalization. So just remove the variable. >> >> Signed-off-by: zhong jiang > I'll apply this patch, but how did you generate the diff? The > function name here is all wrong: > >> diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c >> index 8b24d3d..e29fce2 100644 >> --- a/fs/ext4/mballoc.c >> +++ b/fs/ext4/mballoc.c >> @@ -3801,7 +3801,6 @@ static int ext4_mb_new_preallocation(struct >> ext4_allocation_context *ac) >^ > > The lines in question are from ext4_mb_release_inode_pa(), *not* > ext4_mb_new_preallocation(). So when I inspected the patch visually, > my first reaction was, "there's no way this patch would apply". > > But then I looked at the C code changed by the patch, and I was > surprised to see that it applied correctly in a completely different > function, and when I regenerated the patch, the line numbers matched > yours --- so the only thing "wrong" in your patch is the function name. > > So that raises the question --- how did you create the diff in this-rc > patch? What version of git? And what version of the kernel? > > Regards, > > - Ted > > . > I create the diff in this patch again ,but get the same result . the git version is git version 1.7.12.4 but I create the diff in git version 1.8.3.1. It shows the correct function name. The kernel version is 4.18-rc7. I will upgrade the git version. Thanks, zhong jiang
[PATCH] ext4/mballoc: Remove unneeded variable "err"
The err is not used after initalization. So just remove the variable. Signed-off-by: zhong jiang --- fs/ext4/mballoc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index 8b24d3d..e29fce2 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -3801,7 +3801,6 @@ static int ext4_mb_new_preallocation(struct ext4_allocation_context *ac) ext4_group_t group; ext4_grpblk_t bit; unsigned long long grp_blk_start; - int err = 0; int free = 0; BUG_ON(pa->pa_deleted == 0); @@ -3842,7 +3841,7 @@ static int ext4_mb_new_preallocation(struct ext4_allocation_context *ac) } atomic_add(free, >s_mb_discarded); - return err; + return 0; } static noinline_for_stack int -- 1.7.12.4
[PATCH] ext4/mballoc: Remove unneeded variable "err"
The err is not used after initalization. So just remove the variable. Signed-off-by: zhong jiang --- fs/ext4/mballoc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index 8b24d3d..e29fce2 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -3801,7 +3801,6 @@ static int ext4_mb_new_preallocation(struct ext4_allocation_context *ac) ext4_group_t group; ext4_grpblk_t bit; unsigned long long grp_blk_start; - int err = 0; int free = 0; BUG_ON(pa->pa_deleted == 0); @@ -3842,7 +3841,7 @@ static int ext4_mb_new_preallocation(struct ext4_allocation_context *ac) } atomic_add(free, >s_mb_discarded); - return err; + return 0; } static noinline_for_stack int -- 1.7.12.4
[PATCH] kernel/kthread: Make function __kthread_queue_delayed_work static
Fix the following warning. kernel/kthread.c:859:6: warning: symbol '__kthread_queue_delayed_work' was not declared. Should it be static? Signed-off-by: zhong jiang --- kernel/kthread.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/kthread.c b/kernel/kthread.c index 087d18d..3c661a0 100644 --- a/kernel/kthread.c +++ b/kernel/kthread.c @@ -856,7 +856,7 @@ void kthread_delayed_work_timer_fn(struct timer_list *t) } EXPORT_SYMBOL(kthread_delayed_work_timer_fn); -void __kthread_queue_delayed_work(struct kthread_worker *worker, +static void __kthread_queue_delayed_work(struct kthread_worker *worker, struct kthread_delayed_work *dwork, unsigned long delay) { -- 1.7.12.4
[PATCH] kernel/kthread: Make function __kthread_queue_delayed_work static
Fix the following warning. kernel/kthread.c:859:6: warning: symbol '__kthread_queue_delayed_work' was not declared. Should it be static? Signed-off-by: zhong jiang --- kernel/kthread.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/kthread.c b/kernel/kthread.c index 087d18d..3c661a0 100644 --- a/kernel/kthread.c +++ b/kernel/kthread.c @@ -856,7 +856,7 @@ void kthread_delayed_work_timer_fn(struct timer_list *t) } EXPORT_SYMBOL(kthread_delayed_work_timer_fn); -void __kthread_queue_delayed_work(struct kthread_worker *worker, +static void __kthread_queue_delayed_work(struct kthread_worker *worker, struct kthread_delayed_work *dwork, unsigned long delay) { -- 1.7.12.4
[PATCH] sched/topology: Make some local variable static
Fix the following warning. kernel/sched/topology.c:10:15: warning: symbol 'sched_domains_tmpmask' was not declared. Should it be static? kernel/sched/topology.c:11:15: warning: symbol 'sched_domains_tmpmask2' was not declared. Should it be static? Signed-off-by: zhong jiang --- kernel/sched/topology.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c index 56a0fed..cf3d756 100644 --- a/kernel/sched/topology.c +++ b/kernel/sched/topology.c @@ -7,8 +7,8 @@ DEFINE_MUTEX(sched_domains_mutex); /* Protected by sched_domains_mutex: */ -cpumask_var_t sched_domains_tmpmask; -cpumask_var_t sched_domains_tmpmask2; +static cpumask_var_t sched_domains_tmpmask; +static cpumask_var_t sched_domains_tmpmask2; #ifdef CONFIG_SCHED_DEBUG -- 1.7.12.4
[PATCH] sched/topology: Make some local variable static
Fix the following warning. kernel/sched/topology.c:10:15: warning: symbol 'sched_domains_tmpmask' was not declared. Should it be static? kernel/sched/topology.c:11:15: warning: symbol 'sched_domains_tmpmask2' was not declared. Should it be static? Signed-off-by: zhong jiang --- kernel/sched/topology.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c index 56a0fed..cf3d756 100644 --- a/kernel/sched/topology.c +++ b/kernel/sched/topology.c @@ -7,8 +7,8 @@ DEFINE_MUTEX(sched_domains_mutex); /* Protected by sched_domains_mutex: */ -cpumask_var_t sched_domains_tmpmask; -cpumask_var_t sched_domains_tmpmask2; +static cpumask_var_t sched_domains_tmpmask; +static cpumask_var_t sched_domains_tmpmask2; #ifdef CONFIG_SCHED_DEBUG -- 1.7.12.4
Re: [PATCH linux-next] driver/gpu: Fix mismatch in funciton argument type
On 2018/7/22 13:41, zhong jiang wrote: > Fix the following warning: > > drivers/gpu/drm/nouveau/dispnv50/wndw.c:570:1: error: symbol 'nv50_wndw_new_' > redeclared with different type > (originally declared at drivers/gpu/drm/nouveau/dispnv50/wndw.h:39) - > incompatible argument 7 (different signedness) > > Signed-off-by: zhong jiang > --- > drivers/gpu/drm/nouveau/dispnv50/wndw.h | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/nouveau/dispnv50/wndw.h > b/drivers/gpu/drm/nouveau/dispnv50/wndw.h > index b0b6428..0770683 100644 > --- a/drivers/gpu/drm/nouveau/dispnv50/wndw.h > +++ b/drivers/gpu/drm/nouveau/dispnv50/wndw.h > @@ -38,8 +38,8 @@ struct nv50_wndw { > > int nv50_wndw_new_(const struct nv50_wndw_func *, struct drm_device *, > enum drm_plane_type, const char *name, int index, > -const u32 *format, enum nv50_disp_interlock_type, > -u32 interlock_data, u32 heads, struct nv50_wndw **); > +const u32 *format, u32 heads, enum nv50_disp_interlock_type, > +u32 interlock_data, struct nv50_wndw **); > void nv50_wndw_init(struct nv50_wndw *); > void nv50_wndw_fini(struct nv50_wndw *); > void nv50_wndw_flush_set(struct nv50_wndw *, u32 *interlock, ping ?
Re: [PATCH linux-next] driver/gpu: Fix mismatch in funciton argument type
On 2018/7/22 13:41, zhong jiang wrote: > Fix the following warning: > > drivers/gpu/drm/nouveau/dispnv50/wndw.c:570:1: error: symbol 'nv50_wndw_new_' > redeclared with different type > (originally declared at drivers/gpu/drm/nouveau/dispnv50/wndw.h:39) - > incompatible argument 7 (different signedness) > > Signed-off-by: zhong jiang > --- > drivers/gpu/drm/nouveau/dispnv50/wndw.h | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/nouveau/dispnv50/wndw.h > b/drivers/gpu/drm/nouveau/dispnv50/wndw.h > index b0b6428..0770683 100644 > --- a/drivers/gpu/drm/nouveau/dispnv50/wndw.h > +++ b/drivers/gpu/drm/nouveau/dispnv50/wndw.h > @@ -38,8 +38,8 @@ struct nv50_wndw { > > int nv50_wndw_new_(const struct nv50_wndw_func *, struct drm_device *, > enum drm_plane_type, const char *name, int index, > -const u32 *format, enum nv50_disp_interlock_type, > -u32 interlock_data, u32 heads, struct nv50_wndw **); > +const u32 *format, u32 heads, enum nv50_disp_interlock_type, > +u32 interlock_data, struct nv50_wndw **); > void nv50_wndw_init(struct nv50_wndw *); > void nv50_wndw_fini(struct nv50_wndw *); > void nv50_wndw_flush_set(struct nv50_wndw *, u32 *interlock, ping ?
Re: [Question] A novel case happened when using mempool allocate memory.
On 2018/8/2 21:31, Matthew Wilcox wrote: > On Thu, Aug 02, 2018 at 02:22:03PM +0800, zhong jiang wrote: >> On 2018/8/1 23:37, Matthew Wilcox wrote: >>> Please post the code. >> when module is loaded. we create the specific mempool. The code flow is as >> follows. > I actually meant "post the code you are testing", not "write out some > pseudocode". > > . > The source code is as follow about mempool utility. ** * @brief 元素的类型顺序与 @smio_mem_type_t的定义顺序一致 */ static smio_mem_mng_t g_smio_mem[] = { { .name = "MEDIA_INFO", .min_pool_size = 128, .item_size = sizeof(smio_media_info_t), .slab_cache = NULL, }, { .name = "DSW_IO_REQ", .min_pool_size = 1024, .item_size = sizeof(dsw_io_req_t), .slab_cache = NULL, }, { .name = "DSW_IO_PAGE", .min_pool_size = 1024, .item_size = sizeof(dsw_page_t) * DSW_MAX_PAGE_PER_REQ, .slab_cache = NULL, }, { .name = "32_ARRAY", .min_pool_size = 1024, .item_size = sizeof(void *) * 32, .slab_cache = NULL, }, { .name = "SCSI_SENSE_BUF", .min_pool_size = 1024, .item_size = sizeof(char) * SCSI_SENSE_BUFFERSIZE, .slab_cache = NULL, }, }; /** * @brief 申请数据类型内存 * * @param id 申请者模块ID * @param type 申请内存的类型 * * @return 成功返回内存块的首地址;失败返回NULL */ void *smio_mem_alloc(smio_module_id_t id, smio_mem_type_t type) { void *m = NULL; smio_mem_mng_t *pool_mng = NULL; SMIO_ASSERT_RETURN(id < SMIO_MOD_ID_BUTT, NULL); SMIO_ASSERT_RETURN(type < SMIO_MEM_TYPE_BUTT, NULL); pool_mng = _smio_mem[type]; SMIO_LOG_DEBUG("alloc %s, size: %d\n", pool_mng->name, pool_mng->item_size); m = mempool_alloc(pool_mng->pool, GFP_KERNEL); if (NULL == m) { return NULL; } memset(m, 0, pool_mng->item_size); atomic_inc(_mng->statistics[id]); return m; } EXPORT_SYMBOL(smio_mem_alloc); /** * @brief 释放内存块 * * @param id 申请者的模块ID * @param type 内存块的类型 * @param m 内在的首地址 */ void smio_mem_free(smio_module_id_t id, smio_mem_type_t type, void *m) { smio_mem_mng_t *pool_mng = NULL; SMIO_ASSERT(NULL != m); SMIO_ASSERT(id < SMIO_MOD_ID_BUTT); SMIO_ASSERT(type < SMIO_MEM_TYPE_BUTT); pool_mng = _smio_mem[type]; mempool_free(m, pool_mng->pool); atomic_dec(_mng->statistics[id]); } EXPORT_SYMBOL(smio_mem_free); /** * @brief 创建管理内在池 * * @param pool_mng 内存类型管理结构 * * @return 成功返回@SMIO_OK;失败返回@SMIO_ERR */ static int smio_mem_pool_create(smio_mem_mng_t *pool_mng) { int i; SMIO_ASSERT_RETURN(NULL != pool_mng, SMIO_ERR); pool_mng->slab_cache = kmem_cache_create(pool_mng->name, pool_mng->item_size, 0, 0, NULL); if (SMIO_IS_ERR_OR_NULL(pool_mng->slab_cache)) { SMIO_LOG_ERR("kmem_cache_create for %s failed\n", pool_mng->name); return SMIO_ERR; } pool_mng->pool = mempool_create(pool_mng->min_pool_size, mempool_alloc_slab, mempool_free_slab, pool_mng->slab_cache); if (NULL == pool_mng->pool) { SMIO_LOG_ERR("pool create for %s failed\n", pool_mng->name); kmem_cache_destroy(pool_mng->slab_cache); return SMIO_ERR; } for (i = 0; i < SMIO_MOD_ID_BUTT; i++) { atomic_set(_mng->statistics[i], 0); } return SMIO_OK; } /** * @brief 清除内存池 * * @param pool_mng 所要清除的内存池 */ void smio_mem_pool_destroy(smio_mem_mng_t *pool_mng) { SMIO_ASSERT(NULL != pool_mng); if (NULL != pool_mng->pool) { mempool_destroy(pool_mng->pool); pool_mng->pool = NULL; } if (NULL != pool_mng->slab_cache) { kmem_cache_destroy(pool_mng->slab_cache); pool_mng->slab_cache = NULL; } } /** * @brief 内存管理单元初始化 * * @return 成功返回@SMIO_OK;失败返回@SMIO_ERR */ int smio_mem_init(void) { int i; int pool_num = (int) SMIO_ARRAY_SIZE(g_smio_mem); int ret = SMIO_OK; bool free = SMIO_FALSE; for (i = 0; i < pool_num; i++) { SMIO_LOG_INFO("memory of %s initialize, min_pool_size: %d, item_size: %d\n", g_smio_mem[i].name, g_smio_mem[i].min_pool_size, g_smio_mem[i].item_size); if (SMIO_OK != smio_mem_pool_create(_smio_mem[i])) { SMIO_LOG_ERR("memory of %s initialize failed\n", g_smio_mem[i].name); ret = SMIO_ERR; free = SMIO_TRUE; break; } } /* clean if smio_mem_pool_create failed*/ while ((SMIO_TRUE == free) && (--i >= 0)) { smio_mem_pool_destroy(_smio_mem[i]); } return ret; } /** * @brief 内存管理模块清除退出 */ void smio_mem_exit(void) { int i; int pool_num = (int) SMIO_ARRAY_SIZE(g_smio_mem); for (i = 0; i < pool_num; i++) { smio_mem_pool_destroy(_smio_mem[i]); } }
Re: [Question] A novel case happened when using mempool allocate memory.
On 2018/8/2 21:31, Matthew Wilcox wrote: > On Thu, Aug 02, 2018 at 02:22:03PM +0800, zhong jiang wrote: >> On 2018/8/1 23:37, Matthew Wilcox wrote: >>> Please post the code. >> when module is loaded. we create the specific mempool. The code flow is as >> follows. > I actually meant "post the code you are testing", not "write out some > pseudocode". > > . > The source code is as follow about mempool utility. ** * @brief 元素的类型顺序与 @smio_mem_type_t的定义顺序一致 */ static smio_mem_mng_t g_smio_mem[] = { { .name = "MEDIA_INFO", .min_pool_size = 128, .item_size = sizeof(smio_media_info_t), .slab_cache = NULL, }, { .name = "DSW_IO_REQ", .min_pool_size = 1024, .item_size = sizeof(dsw_io_req_t), .slab_cache = NULL, }, { .name = "DSW_IO_PAGE", .min_pool_size = 1024, .item_size = sizeof(dsw_page_t) * DSW_MAX_PAGE_PER_REQ, .slab_cache = NULL, }, { .name = "32_ARRAY", .min_pool_size = 1024, .item_size = sizeof(void *) * 32, .slab_cache = NULL, }, { .name = "SCSI_SENSE_BUF", .min_pool_size = 1024, .item_size = sizeof(char) * SCSI_SENSE_BUFFERSIZE, .slab_cache = NULL, }, }; /** * @brief 申请数据类型内存 * * @param id 申请者模块ID * @param type 申请内存的类型 * * @return 成功返回内存块的首地址;失败返回NULL */ void *smio_mem_alloc(smio_module_id_t id, smio_mem_type_t type) { void *m = NULL; smio_mem_mng_t *pool_mng = NULL; SMIO_ASSERT_RETURN(id < SMIO_MOD_ID_BUTT, NULL); SMIO_ASSERT_RETURN(type < SMIO_MEM_TYPE_BUTT, NULL); pool_mng = _smio_mem[type]; SMIO_LOG_DEBUG("alloc %s, size: %d\n", pool_mng->name, pool_mng->item_size); m = mempool_alloc(pool_mng->pool, GFP_KERNEL); if (NULL == m) { return NULL; } memset(m, 0, pool_mng->item_size); atomic_inc(_mng->statistics[id]); return m; } EXPORT_SYMBOL(smio_mem_alloc); /** * @brief 释放内存块 * * @param id 申请者的模块ID * @param type 内存块的类型 * @param m 内在的首地址 */ void smio_mem_free(smio_module_id_t id, smio_mem_type_t type, void *m) { smio_mem_mng_t *pool_mng = NULL; SMIO_ASSERT(NULL != m); SMIO_ASSERT(id < SMIO_MOD_ID_BUTT); SMIO_ASSERT(type < SMIO_MEM_TYPE_BUTT); pool_mng = _smio_mem[type]; mempool_free(m, pool_mng->pool); atomic_dec(_mng->statistics[id]); } EXPORT_SYMBOL(smio_mem_free); /** * @brief 创建管理内在池 * * @param pool_mng 内存类型管理结构 * * @return 成功返回@SMIO_OK;失败返回@SMIO_ERR */ static int smio_mem_pool_create(smio_mem_mng_t *pool_mng) { int i; SMIO_ASSERT_RETURN(NULL != pool_mng, SMIO_ERR); pool_mng->slab_cache = kmem_cache_create(pool_mng->name, pool_mng->item_size, 0, 0, NULL); if (SMIO_IS_ERR_OR_NULL(pool_mng->slab_cache)) { SMIO_LOG_ERR("kmem_cache_create for %s failed\n", pool_mng->name); return SMIO_ERR; } pool_mng->pool = mempool_create(pool_mng->min_pool_size, mempool_alloc_slab, mempool_free_slab, pool_mng->slab_cache); if (NULL == pool_mng->pool) { SMIO_LOG_ERR("pool create for %s failed\n", pool_mng->name); kmem_cache_destroy(pool_mng->slab_cache); return SMIO_ERR; } for (i = 0; i < SMIO_MOD_ID_BUTT; i++) { atomic_set(_mng->statistics[i], 0); } return SMIO_OK; } /** * @brief 清除内存池 * * @param pool_mng 所要清除的内存池 */ void smio_mem_pool_destroy(smio_mem_mng_t *pool_mng) { SMIO_ASSERT(NULL != pool_mng); if (NULL != pool_mng->pool) { mempool_destroy(pool_mng->pool); pool_mng->pool = NULL; } if (NULL != pool_mng->slab_cache) { kmem_cache_destroy(pool_mng->slab_cache); pool_mng->slab_cache = NULL; } } /** * @brief 内存管理单元初始化 * * @return 成功返回@SMIO_OK;失败返回@SMIO_ERR */ int smio_mem_init(void) { int i; int pool_num = (int) SMIO_ARRAY_SIZE(g_smio_mem); int ret = SMIO_OK; bool free = SMIO_FALSE; for (i = 0; i < pool_num; i++) { SMIO_LOG_INFO("memory of %s initialize, min_pool_size: %d, item_size: %d\n", g_smio_mem[i].name, g_smio_mem[i].min_pool_size, g_smio_mem[i].item_size); if (SMIO_OK != smio_mem_pool_create(_smio_mem[i])) { SMIO_LOG_ERR("memory of %s initialize failed\n", g_smio_mem[i].name); ret = SMIO_ERR; free = SMIO_TRUE; break; } } /* clean if smio_mem_pool_create failed*/ while ((SMIO_TRUE == free) && (--i >= 0)) { smio_mem_pool_destroy(_smio_mem[i]); } return ret; } /** * @brief 内存管理模块清除退出 */ void smio_mem_exit(void) { int i; int pool_num = (int) SMIO_ARRAY_SIZE(g_smio_mem); for (i = 0; i < pool_num; i++) { smio_mem_pool_destroy(_smio_mem[i]); } }
[tip:x86/cleanups] x86/iommu: Use NULL instead of 0
Commit-ID: 0b2c1aec49ddb2260894df6c69ae7b34142ff936 Gitweb: https://git.kernel.org/tip/0b2c1aec49ddb2260894df6c69ae7b34142ff936 Author: Zhong Jiang AuthorDate: Sat, 21 Jul 2018 16:33:24 +0800 Committer: Thomas Gleixner CommitDate: Thu, 2 Aug 2018 14:33:19 +0200 x86/iommu: Use NULL instead of 0 Fixes the following sparse warning: arch/x86/kernel/pci-iommu_table.c:63:37: warning: Using plain integer as NULL pointer Signed-off-by: zhong jiang Signed-off-by: Thomas Gleixner Cc: Cc: Link: https://lkml.kernel.org/r/1532162004-24670-1-git-send-email-zhongji...@huawei.com --- arch/x86/kernel/pci-iommu_table.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c index 4dfd90a75e63..2e9006c1e240 100644 --- a/arch/x86/kernel/pci-iommu_table.c +++ b/arch/x86/kernel/pci-iommu_table.c @@ -60,7 +60,7 @@ void __init check_iommu_entries(struct iommu_table_entry *start, printk(KERN_ERR "CYCLIC DEPENDENCY FOUND! %pS depends on %pS and vice-versa. BREAKING IT.\n", p->detect, q->detect); /* Heavy handed way..*/ - x->depend = 0; + x->depend = NULL; } }
[tip:x86/cleanups] x86/iommu: Use NULL instead of 0
Commit-ID: 0b2c1aec49ddb2260894df6c69ae7b34142ff936 Gitweb: https://git.kernel.org/tip/0b2c1aec49ddb2260894df6c69ae7b34142ff936 Author: Zhong Jiang AuthorDate: Sat, 21 Jul 2018 16:33:24 +0800 Committer: Thomas Gleixner CommitDate: Thu, 2 Aug 2018 14:33:19 +0200 x86/iommu: Use NULL instead of 0 Fixes the following sparse warning: arch/x86/kernel/pci-iommu_table.c:63:37: warning: Using plain integer as NULL pointer Signed-off-by: zhong jiang Signed-off-by: Thomas Gleixner Cc: Cc: Link: https://lkml.kernel.org/r/1532162004-24670-1-git-send-email-zhongji...@huawei.com --- arch/x86/kernel/pci-iommu_table.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c index 4dfd90a75e63..2e9006c1e240 100644 --- a/arch/x86/kernel/pci-iommu_table.c +++ b/arch/x86/kernel/pci-iommu_table.c @@ -60,7 +60,7 @@ void __init check_iommu_entries(struct iommu_table_entry *start, printk(KERN_ERR "CYCLIC DEPENDENCY FOUND! %pS depends on %pS and vice-versa. BREAKING IT.\n", p->detect, q->detect); /* Heavy handed way..*/ - x->depend = 0; + x->depend = NULL; } }
[tip:x86/platform] x86/platform/olpc: Use PTR_ERR_OR_ZERO()
Commit-ID: c7ba9f7cb55926605983187a68624999b93abb94 Gitweb: https://git.kernel.org/tip/c7ba9f7cb55926605983187a68624999b93abb94 Author: zhong jiang AuthorDate: Wed, 1 Aug 2018 00:08:06 +0800 Committer: Thomas Gleixner CommitDate: Thu, 2 Aug 2018 14:25:40 +0200 x86/platform/olpc: Use PTR_ERR_OR_ZERO() Replace the open coded equivalent with PTR_ERR_OR_ZERO(). Signed-off-by: zhong jiang Signed-off-by: Thomas Gleixner Link: https://lkml.kernel.org/r/1533053286-34990-1-git-send-email-zhongji...@huawei.com --- arch/x86/platform/olpc/olpc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/arch/x86/platform/olpc/olpc.c b/arch/x86/platform/olpc/olpc.c index 7c3077e58fa0..f0e920fb98ad 100644 --- a/arch/x86/platform/olpc/olpc.c +++ b/arch/x86/platform/olpc/olpc.c @@ -311,10 +311,8 @@ static int __init add_xo1_platform_devices(void) return PTR_ERR(pdev); pdev = platform_device_register_simple("olpc-xo1", -1, NULL, 0); - if (IS_ERR(pdev)) - return PTR_ERR(pdev); - return 0; + return PTR_ERR_OR_ZERO(pdev); } static int olpc_xo1_ec_probe(struct platform_device *pdev)
[tip:x86/platform] x86/platform/olpc: Use PTR_ERR_OR_ZERO()
Commit-ID: c7ba9f7cb55926605983187a68624999b93abb94 Gitweb: https://git.kernel.org/tip/c7ba9f7cb55926605983187a68624999b93abb94 Author: zhong jiang AuthorDate: Wed, 1 Aug 2018 00:08:06 +0800 Committer: Thomas Gleixner CommitDate: Thu, 2 Aug 2018 14:25:40 +0200 x86/platform/olpc: Use PTR_ERR_OR_ZERO() Replace the open coded equivalent with PTR_ERR_OR_ZERO(). Signed-off-by: zhong jiang Signed-off-by: Thomas Gleixner Link: https://lkml.kernel.org/r/1533053286-34990-1-git-send-email-zhongji...@huawei.com --- arch/x86/platform/olpc/olpc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/arch/x86/platform/olpc/olpc.c b/arch/x86/platform/olpc/olpc.c index 7c3077e58fa0..f0e920fb98ad 100644 --- a/arch/x86/platform/olpc/olpc.c +++ b/arch/x86/platform/olpc/olpc.c @@ -311,10 +311,8 @@ static int __init add_xo1_platform_devices(void) return PTR_ERR(pdev); pdev = platform_device_register_simple("olpc-xo1", -1, NULL, 0); - if (IS_ERR(pdev)) - return PTR_ERR(pdev); - return 0; + return PTR_ERR_OR_ZERO(pdev); } static int olpc_xo1_ec_probe(struct platform_device *pdev)
[tip:core/debugobjects] debugobjects: Remove redundant NULL pointer check
Commit-ID: 3ff4f80a74fd38398ae1bd8a458ba9c51aa0dd44 Gitweb: https://git.kernel.org/tip/3ff4f80a74fd38398ae1bd8a458ba9c51aa0dd44 Author: Zhong Jiang AuthorDate: Wed, 1 Aug 2018 00:24:58 +0800 Committer: Thomas Gleixner CommitDate: Thu, 2 Aug 2018 13:53:04 +0200 debugobjects: Remove redundant NULL pointer check kmem_cache_destroy() has a built in NULL pointer check, so the one at the call can be removed. Signed-off-by: Zhong Jiang Signed-off-by: Thomas Gleixner Cc: Cc: Cc: Link: https://lkml.kernel.org/r/1533054298-35824-1-git-send-email-zhongji...@huawei.com --- lib/debugobjects.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/debugobjects.c b/lib/debugobjects.c index 24c1df0d7466..70935ed91125 100644 --- a/lib/debugobjects.c +++ b/lib/debugobjects.c @@ -1188,8 +1188,7 @@ void __init debug_objects_mem_init(void) if (!obj_cache || debug_objects_replace_static_objects()) { debug_objects_enabled = 0; - if (obj_cache) - kmem_cache_destroy(obj_cache); + kmem_cache_destroy(obj_cache); pr_warn("out of memory.\n"); } else debug_objects_selftest();
[tip:core/debugobjects] debugobjects: Remove redundant NULL pointer check
Commit-ID: 3ff4f80a74fd38398ae1bd8a458ba9c51aa0dd44 Gitweb: https://git.kernel.org/tip/3ff4f80a74fd38398ae1bd8a458ba9c51aa0dd44 Author: Zhong Jiang AuthorDate: Wed, 1 Aug 2018 00:24:58 +0800 Committer: Thomas Gleixner CommitDate: Thu, 2 Aug 2018 13:53:04 +0200 debugobjects: Remove redundant NULL pointer check kmem_cache_destroy() has a built in NULL pointer check, so the one at the call can be removed. Signed-off-by: Zhong Jiang Signed-off-by: Thomas Gleixner Cc: Cc: Cc: Link: https://lkml.kernel.org/r/1533054298-35824-1-git-send-email-zhongji...@huawei.com --- lib/debugobjects.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/debugobjects.c b/lib/debugobjects.c index 24c1df0d7466..70935ed91125 100644 --- a/lib/debugobjects.c +++ b/lib/debugobjects.c @@ -1188,8 +1188,7 @@ void __init debug_objects_mem_init(void) if (!obj_cache || debug_objects_replace_static_objects()) { debug_objects_enabled = 0; - if (obj_cache) - kmem_cache_destroy(obj_cache); + kmem_cache_destroy(obj_cache); pr_warn("out of memory.\n"); } else debug_objects_selftest();
[PATCH v2 0/4] Use dma_zalloc_coherent and kvcalloc to replace open code
v1->v2: According to Andy and Joe suggestions. [patch 1/4] get rid of unnessary parens and use kvcalloc and kvfree to replace the vmalloc and vfree. [patch 2/4] modify the changelog as Andy's suggestion. [patch 3/4] replace vmalloc and vfree by using kvcalloc adn kvfree. [patch 4/4] do nothing. just add Andy's review-by. zhong jiang (4): driver/scsi/fnic/fnic_trace: Use kvcalloc instead of vmalloc+memset drivers/scsi/dpt_i2o: Use dma_zalloc_coherent to repalce dma_alloc_coherent+memset drivers/scsi/snic/snic_trc: Use kvcalloc instead of vmalloc+memset drivers/scsi/mvsas/mv_init: Use dma_zalloc_coherent to replace dma_alloc_coherent+memset drivers/scsi/dpt_i2o.c | 12 drivers/scsi/fnic/fnic_trace.c | 7 +++ drivers/scsi/mvsas/mv_init.c | 12 drivers/scsi/snic/snic_trc.c | 7 +++ 4 files changed, 14 insertions(+), 24 deletions(-) -- 1.7.12.4
[PATCH v2 0/4] Use dma_zalloc_coherent and kvcalloc to replace open code
v1->v2: According to Andy and Joe suggestions. [patch 1/4] get rid of unnessary parens and use kvcalloc and kvfree to replace the vmalloc and vfree. [patch 2/4] modify the changelog as Andy's suggestion. [patch 3/4] replace vmalloc and vfree by using kvcalloc adn kvfree. [patch 4/4] do nothing. just add Andy's review-by. zhong jiang (4): driver/scsi/fnic/fnic_trace: Use kvcalloc instead of vmalloc+memset drivers/scsi/dpt_i2o: Use dma_zalloc_coherent to repalce dma_alloc_coherent+memset drivers/scsi/snic/snic_trc: Use kvcalloc instead of vmalloc+memset drivers/scsi/mvsas/mv_init: Use dma_zalloc_coherent to replace dma_alloc_coherent+memset drivers/scsi/dpt_i2o.c | 12 drivers/scsi/fnic/fnic_trace.c | 7 +++ drivers/scsi/mvsas/mv_init.c | 12 drivers/scsi/snic/snic_trc.c | 7 +++ 4 files changed, 14 insertions(+), 24 deletions(-) -- 1.7.12.4
[PATCH v2 3/4] drivers/scsi/snic/snic_trc: Use kvcalloc instead of vmalloc+memset
The kvcalloc is better than vmalloc() + memset() , So replace them. Signed-off-by: zhong jiang --- drivers/scsi/snic/snic_trc.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/snic/snic_trc.c b/drivers/scsi/snic/snic_trc.c index fc60c93..e766fa2 100644 --- a/drivers/scsi/snic/snic_trc.c +++ b/drivers/scsi/snic/snic_trc.c @@ -125,8 +125,8 @@ struct snic_trc_data * void *tbuf = NULL; int tbuf_sz = 0, ret; - tbuf_sz = (snic_trace_max_pages * PAGE_SIZE); - tbuf = vmalloc(tbuf_sz); + tbuf_sz = snic_trace_max_pages * PAGE_SIZE; + tbuf = kvcalloc(snic_trace_max_pages, PAGE_SIZE, GFP_KERNEL); if (!tbuf) { SNIC_ERR("Failed to Allocate Trace Buffer Size. %d\n", tbuf_sz); SNIC_ERR("Trace Facility not enabled.\n"); @@ -135,7 +135,6 @@ struct snic_trc_data * return ret; } - memset(tbuf, 0, tbuf_sz); trc->buf = (struct snic_trc_data *) tbuf; spin_lock_init(>lock); @@ -173,7 +172,7 @@ struct snic_trc_data * snic_trc_debugfs_term(); if (trc->buf) { - vfree(trc->buf); + kvfree(trc->buf); trc->buf = NULL; } -- 1.7.12.4
[PATCH v2 3/4] drivers/scsi/snic/snic_trc: Use kvcalloc instead of vmalloc+memset
The kvcalloc is better than vmalloc() + memset() , So replace them. Signed-off-by: zhong jiang --- drivers/scsi/snic/snic_trc.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/snic/snic_trc.c b/drivers/scsi/snic/snic_trc.c index fc60c93..e766fa2 100644 --- a/drivers/scsi/snic/snic_trc.c +++ b/drivers/scsi/snic/snic_trc.c @@ -125,8 +125,8 @@ struct snic_trc_data * void *tbuf = NULL; int tbuf_sz = 0, ret; - tbuf_sz = (snic_trace_max_pages * PAGE_SIZE); - tbuf = vmalloc(tbuf_sz); + tbuf_sz = snic_trace_max_pages * PAGE_SIZE; + tbuf = kvcalloc(snic_trace_max_pages, PAGE_SIZE, GFP_KERNEL); if (!tbuf) { SNIC_ERR("Failed to Allocate Trace Buffer Size. %d\n", tbuf_sz); SNIC_ERR("Trace Facility not enabled.\n"); @@ -135,7 +135,6 @@ struct snic_trc_data * return ret; } - memset(tbuf, 0, tbuf_sz); trc->buf = (struct snic_trc_data *) tbuf; spin_lock_init(>lock); @@ -173,7 +172,7 @@ struct snic_trc_data * snic_trc_debugfs_term(); if (trc->buf) { - vfree(trc->buf); + kvfree(trc->buf); trc->buf = NULL; } -- 1.7.12.4
Re: [Question] A novel case happened when using mempool allocate memory.
On 2018/8/1 23:37, Matthew Wilcox wrote: > On Wed, Aug 01, 2018 at 11:31:15PM +0800, zhong jiang wrote: >> Hi, Everyone >> >> I ran across the following novel case similar to memory leak in linux-4.1 >> stable when allocating >> memory object by kmem_cache_alloc. it rarely can be reproduced. >> >> I create a specific mempool with 24k size based on the slab. it can not be >> merged with >> other kmem cache. I record the allocation and free usage by >> atomic_add/sub.After a while, >> I watch the specific slab consume most of total memory. After halting the >> code execution. >> The counter of allocation and free is equal. Therefore, I am sure that >> module have released >> all meory resource. but the statistic of specific slab is very high but >> stable by checking /proc/slabinfo. > Please post the code. > > . > when module is loaded. we create the specific mempool. The code flow is as follows. mem_pool_create() { slab_cache = kmem_cache_create(name, item_size, 0, 0 , NULL); mempoll_create(min_pool_size, mempool_alloc_slab, mempool_free_slab, slab_cache); //min_pool_size is assigned to 1024 atomic_set(pool->statistics, 0); } we allocate memory from specific mempool , The code flow is as follows. mem_alloc() { mempool_alloc(pool, gfp_flags); atomic_inc(pool->statistics); } we release memory to specific mempool . The code flow is as follows. mem_free() { mempool_free(object_ptr, pool); atomic_dec(pool->statistics); } when we unregister the module, the memory has been taken up will get back the system. the code flow is as follows. mem_pool_destroy() { mempool_destroy(pool); kmem_cache_destroy(slab_cache); } >From the above information. I assume the specific kmem_cache will not take up >overmuch memory when halting the execution and pool->statistics is equal to 0. I have no idea about the issue. Thanks zhong jiang
Re: [Question] A novel case happened when using mempool allocate memory.
On 2018/8/1 23:37, Matthew Wilcox wrote: > On Wed, Aug 01, 2018 at 11:31:15PM +0800, zhong jiang wrote: >> Hi, Everyone >> >> I ran across the following novel case similar to memory leak in linux-4.1 >> stable when allocating >> memory object by kmem_cache_alloc. it rarely can be reproduced. >> >> I create a specific mempool with 24k size based on the slab. it can not be >> merged with >> other kmem cache. I record the allocation and free usage by >> atomic_add/sub.After a while, >> I watch the specific slab consume most of total memory. After halting the >> code execution. >> The counter of allocation and free is equal. Therefore, I am sure that >> module have released >> all meory resource. but the statistic of specific slab is very high but >> stable by checking /proc/slabinfo. > Please post the code. > > . > when module is loaded. we create the specific mempool. The code flow is as follows. mem_pool_create() { slab_cache = kmem_cache_create(name, item_size, 0, 0 , NULL); mempoll_create(min_pool_size, mempool_alloc_slab, mempool_free_slab, slab_cache); //min_pool_size is assigned to 1024 atomic_set(pool->statistics, 0); } we allocate memory from specific mempool , The code flow is as follows. mem_alloc() { mempool_alloc(pool, gfp_flags); atomic_inc(pool->statistics); } we release memory to specific mempool . The code flow is as follows. mem_free() { mempool_free(object_ptr, pool); atomic_dec(pool->statistics); } when we unregister the module, the memory has been taken up will get back the system. the code flow is as follows. mem_pool_destroy() { mempool_destroy(pool); kmem_cache_destroy(slab_cache); } >From the above information. I assume the specific kmem_cache will not take up >overmuch memory when halting the execution and pool->statistics is equal to 0. I have no idea about the issue. Thanks zhong jiang
Re: [PATCH] fs/binfmt_elf: remove the same condition check
On 2018/8/2 11:04, Al Viro wrote: > On Thu, Aug 02, 2018 at 10:00:28AM +0800, zhong jiang wrote: >> dump_align is used to double check in a expression. It is redundant. >> so just remove one of them. > > What makes you think that it is redundant? > I am sorry for that. Maybe I miss something. Thanks zhong jiang >> Signed-off-by: zhong jiang >> --- >> fs/binfmt_elf.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c >> index efae2fb..b6c5b02 100644 >> --- a/fs/binfmt_elf.c >> +++ b/fs/binfmt_elf.c >> @@ -1439,7 +1439,7 @@ static int writenote(struct memelfnote *men, struct >> coredump_params *cprm) >> >> return dump_emit(cprm, , sizeof(en)) && >> dump_emit(cprm, men->name, en.n_namesz) && dump_align(cprm, 4) && >> -dump_emit(cprm, men->data, men->datasz) && dump_align(cprm, 4); >> +dump_emit(cprm, men->data, men->datasz); >> } >> >> static void fill_elf_header(struct elfhdr *elf, int segs, >> -- >> 1.7.12.4 >> > . >
Re: [PATCH] fs/binfmt_elf: remove the same condition check
On 2018/8/2 11:04, Al Viro wrote: > On Thu, Aug 02, 2018 at 10:00:28AM +0800, zhong jiang wrote: >> dump_align is used to double check in a expression. It is redundant. >> so just remove one of them. > > What makes you think that it is redundant? > I am sorry for that. Maybe I miss something. Thanks zhong jiang >> Signed-off-by: zhong jiang >> --- >> fs/binfmt_elf.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c >> index efae2fb..b6c5b02 100644 >> --- a/fs/binfmt_elf.c >> +++ b/fs/binfmt_elf.c >> @@ -1439,7 +1439,7 @@ static int writenote(struct memelfnote *men, struct >> coredump_params *cprm) >> >> return dump_emit(cprm, , sizeof(en)) && >> dump_emit(cprm, men->name, en.n_namesz) && dump_align(cprm, 4) && >> -dump_emit(cprm, men->data, men->datasz) && dump_align(cprm, 4); >> +dump_emit(cprm, men->data, men->datasz); >> } >> >> static void fill_elf_header(struct elfhdr *elf, int segs, >> -- >> 1.7.12.4 >> > . >
Re: [PATCH] fs/binfmt_elf: remove the same condition check
On 2018/8/2 10:34, Matthew Wilcox wrote: > On Thu, Aug 02, 2018 at 10:00:28AM +0800, zhong jiang wrote: >> dump_align is used to double check in a expression. It is redundant. >> so just remove one of them. > You're wrong. Functions in C can have side-effects (and this one does). > > Ok, I miss that. Thank you for clarification. Thanks, zhong jiang
Re: [PATCH] fs/binfmt_elf: remove the same condition check
On 2018/8/2 10:34, Matthew Wilcox wrote: > On Thu, Aug 02, 2018 at 10:00:28AM +0800, zhong jiang wrote: >> dump_align is used to double check in a expression. It is redundant. >> so just remove one of them. > You're wrong. Functions in C can have side-effects (and this one does). > > Ok, I miss that. Thank you for clarification. Thanks, zhong jiang
Re: [PATCH] fs/binfmt_elf_fdpic: remove redundant condition check in writenote
plese ingore it. On 2018/8/2 10:04, zhong jiang wrote: > It is unncessary to use double test for a expression. so just > remove one of them. > > Signed-off-by: zhong jiang > --- > fs/binfmt_elf_fdpic.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c > index b53bb37..5162372 100644 > --- a/fs/binfmt_elf_fdpic.c > +++ b/fs/binfmt_elf_fdpic.c > @@ -1288,7 +1288,7 @@ static int writenote(struct memelfnote *men, struct > coredump_params *cprm) > > return dump_emit(cprm, , sizeof(en)) && > dump_emit(cprm, men->name, en.n_namesz) && dump_align(cprm, 4) > && > - dump_emit(cprm, men->data, men->datasz) && dump_align(cprm, 4); > + dump_emit(cprm, men->data, men->datasz); > } > > static inline void fill_elf_fdpic_header(struct elfhdr *elf, int segs)
Re: [PATCH] fs/binfmt_elf_fdpic: remove redundant condition check in writenote
plese ingore it. On 2018/8/2 10:04, zhong jiang wrote: > It is unncessary to use double test for a expression. so just > remove one of them. > > Signed-off-by: zhong jiang > --- > fs/binfmt_elf_fdpic.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c > index b53bb37..5162372 100644 > --- a/fs/binfmt_elf_fdpic.c > +++ b/fs/binfmt_elf_fdpic.c > @@ -1288,7 +1288,7 @@ static int writenote(struct memelfnote *men, struct > coredump_params *cprm) > > return dump_emit(cprm, , sizeof(en)) && > dump_emit(cprm, men->name, en.n_namesz) && dump_align(cprm, 4) > && > - dump_emit(cprm, men->data, men->datasz) && dump_align(cprm, 4); > + dump_emit(cprm, men->data, men->datasz); > } > > static inline void fill_elf_fdpic_header(struct elfhdr *elf, int segs)
[PATCH] fs/binfmt_elf_fdpic: remove redundant condition check in writenote
It is unncessary to use double test for a expression. so just remove one of them. Signed-off-by: zhong jiang --- fs/binfmt_elf_fdpic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c index b53bb37..5162372 100644 --- a/fs/binfmt_elf_fdpic.c +++ b/fs/binfmt_elf_fdpic.c @@ -1288,7 +1288,7 @@ static int writenote(struct memelfnote *men, struct coredump_params *cprm) return dump_emit(cprm, , sizeof(en)) && dump_emit(cprm, men->name, en.n_namesz) && dump_align(cprm, 4) && - dump_emit(cprm, men->data, men->datasz) && dump_align(cprm, 4); + dump_emit(cprm, men->data, men->datasz); } static inline void fill_elf_fdpic_header(struct elfhdr *elf, int segs) -- 1.7.12.4
[PATCH] fs/binfmt_elf_fdpic: remove redundant condition check in writenote
It is unncessary to use double test for a expression. so just remove one of them. Signed-off-by: zhong jiang --- fs/binfmt_elf_fdpic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c index b53bb37..5162372 100644 --- a/fs/binfmt_elf_fdpic.c +++ b/fs/binfmt_elf_fdpic.c @@ -1288,7 +1288,7 @@ static int writenote(struct memelfnote *men, struct coredump_params *cprm) return dump_emit(cprm, , sizeof(en)) && dump_emit(cprm, men->name, en.n_namesz) && dump_align(cprm, 4) && - dump_emit(cprm, men->data, men->datasz) && dump_align(cprm, 4); + dump_emit(cprm, men->data, men->datasz); } static inline void fill_elf_fdpic_header(struct elfhdr *elf, int segs) -- 1.7.12.4
[PATCH] fs/binfmt_elf: remove the same condition check
dump_align is used to double check in a expression. It is redundant. so just remove one of them. Signed-off-by: zhong jiang --- fs/binfmt_elf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index efae2fb..b6c5b02 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c @@ -1439,7 +1439,7 @@ static int writenote(struct memelfnote *men, struct coredump_params *cprm) return dump_emit(cprm, , sizeof(en)) && dump_emit(cprm, men->name, en.n_namesz) && dump_align(cprm, 4) && - dump_emit(cprm, men->data, men->datasz) && dump_align(cprm, 4); + dump_emit(cprm, men->data, men->datasz); } static void fill_elf_header(struct elfhdr *elf, int segs, -- 1.7.12.4
[PATCH] fs/binfmt_elf: remove the same condition check
dump_align is used to double check in a expression. It is redundant. so just remove one of them. Signed-off-by: zhong jiang --- fs/binfmt_elf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index efae2fb..b6c5b02 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c @@ -1439,7 +1439,7 @@ static int writenote(struct memelfnote *men, struct coredump_params *cprm) return dump_emit(cprm, , sizeof(en)) && dump_emit(cprm, men->name, en.n_namesz) && dump_align(cprm, 4) && - dump_emit(cprm, men->data, men->datasz) && dump_align(cprm, 4); + dump_emit(cprm, men->data, men->datasz); } static void fill_elf_header(struct elfhdr *elf, int segs, -- 1.7.12.4
[Question] A novel case happened when using mempool allocate memory.
Hi, Everyone I ran across the following novel case similar to memory leak in linux-4.1 stable when allocating memory object by kmem_cache_alloc. it rarely can be reproduced. I create a specific mempool with 24k size based on the slab. it can not be merged with other kmem cache. I record the allocation and free usage by atomic_add/sub. After a while, I watch the specific slab consume most of total memory. After halting the code execution. The counter of allocation and free is equal. Therefore, I am sure that module have released all meory resource. but the statistic of specific slab is very high but stable by checking /proc/slabinfo. but It is strange that the specific slab will free get back all memory when unregister the module. I got the following information from specific slab data structure when halt the module execution. kmem_cache_node kmem_cache nr_partial = 1, min_partial = 7 partial = { cpu_partial = 2 next = 0x7c00085cae20 object_size = 24576 prev = 0x7c00085cae20 }, nr_slabs = { counter = 365610 }, total_objects = { counter = 365610 }, full = { next = 0x8013e44f75f0, prev = 0x8013e44f75f0 }, >From the above restricted information , we can know that the node full list is >empty. and partial list only have a slab. A slab contain a object. I think that most of slab stay in the cpu_partial list even though it seems to be impossible theoretically. because I come to the conclusion based on the case that slab take up the memory will be release when unregister the moudle. but I check the code(mm/slub.c) carefully . I can not find any clue to prove my assumption. I will be appreciate if anyone have any idea about the case. Thanks zhong jiang
[Question] A novel case happened when using mempool allocate memory.
Hi, Everyone I ran across the following novel case similar to memory leak in linux-4.1 stable when allocating memory object by kmem_cache_alloc. it rarely can be reproduced. I create a specific mempool with 24k size based on the slab. it can not be merged with other kmem cache. I record the allocation and free usage by atomic_add/sub. After a while, I watch the specific slab consume most of total memory. After halting the code execution. The counter of allocation and free is equal. Therefore, I am sure that module have released all meory resource. but the statistic of specific slab is very high but stable by checking /proc/slabinfo. but It is strange that the specific slab will free get back all memory when unregister the module. I got the following information from specific slab data structure when halt the module execution. kmem_cache_node kmem_cache nr_partial = 1, min_partial = 7 partial = { cpu_partial = 2 next = 0x7c00085cae20 object_size = 24576 prev = 0x7c00085cae20 }, nr_slabs = { counter = 365610 }, total_objects = { counter = 365610 }, full = { next = 0x8013e44f75f0, prev = 0x8013e44f75f0 }, >From the above restricted information , we can know that the node full list is >empty. and partial list only have a slab. A slab contain a object. I think that most of slab stay in the cpu_partial list even though it seems to be impossible theoretically. because I come to the conclusion based on the case that slab take up the memory will be release when unregister the moudle. but I check the code(mm/slub.c) carefully . I can not find any clue to prove my assumption. I will be appreciate if anyone have any idea about the case. Thanks zhong jiang
[PATCH] drivers/staging/mt7621-eth: Use dma_zalloc_coherent to replace dma_alloc_coherent+memset
we prefer to use dma_zalloc_coherent rather than dam_alloc_coherent+memset Signed-off-by: zhong jiang --- drivers/staging/mt7621-eth/mtk_eth_soc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/mt7621-eth/mtk_eth_soc.c b/drivers/staging/mt7621-eth/mtk_eth_soc.c index f9b593ca..7135075 100644 --- a/drivers/staging/mt7621-eth/mtk_eth_soc.c +++ b/drivers/staging/mt7621-eth/mtk_eth_soc.c @@ -1396,14 +1396,13 @@ static int mtk_qdma_tx_alloc_tx(struct mtk_eth *eth) if (!ring->tx_buf) goto no_tx_mem; - ring->tx_dma = dma_alloc_coherent(eth->dev, + ring->tx_dma = dma_zalloc_coherent(eth->dev, ring->tx_ring_size * sz, >tx_phys, GFP_ATOMIC | __GFP_ZERO); if (!ring->tx_dma) goto no_tx_mem; - memset(ring->tx_dma, 0, ring->tx_ring_size * sz); for (i = 0; i < ring->tx_ring_size; i++) { int next = (i + 1) % ring->tx_ring_size; u32 next_ptr = ring->tx_phys + next * sz; -- 1.7.12.4
[PATCH] drivers/staging/mt7621-eth: Use dma_zalloc_coherent to replace dma_alloc_coherent+memset
we prefer to use dma_zalloc_coherent rather than dam_alloc_coherent+memset Signed-off-by: zhong jiang --- drivers/staging/mt7621-eth/mtk_eth_soc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/mt7621-eth/mtk_eth_soc.c b/drivers/staging/mt7621-eth/mtk_eth_soc.c index f9b593ca..7135075 100644 --- a/drivers/staging/mt7621-eth/mtk_eth_soc.c +++ b/drivers/staging/mt7621-eth/mtk_eth_soc.c @@ -1396,14 +1396,13 @@ static int mtk_qdma_tx_alloc_tx(struct mtk_eth *eth) if (!ring->tx_buf) goto no_tx_mem; - ring->tx_dma = dma_alloc_coherent(eth->dev, + ring->tx_dma = dma_zalloc_coherent(eth->dev, ring->tx_ring_size * sz, >tx_phys, GFP_ATOMIC | __GFP_ZERO); if (!ring->tx_dma) goto no_tx_mem; - memset(ring->tx_dma, 0, ring->tx_ring_size * sz); for (i = 0; i < ring->tx_ring_size; i++) { int next = (i + 1) % ring->tx_ring_size; u32 next_ptr = ring->tx_phys + next * sz; -- 1.7.12.4
[PATCH] kernel/module: Use kmemdup to replace kmalloc+memcpy
we prefer to the kmemdup rather than kmalloc+memcpy. so just replace them. Signed-off-by: zhong jiang --- kernel/module.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/kernel/module.c b/kernel/module.c index 20344e4..6746c85 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -2057,21 +2057,19 @@ static int copy_module_elf(struct module *mod, struct load_info *info) /* Elf section header table */ size = sizeof(*info->sechdrs) * info->hdr->e_shnum; - mod->klp_info->sechdrs = kmalloc(size, GFP_KERNEL); + mod->klp_info->sechdrs = kmemdup(info->sechdrs, size, GFP_KERNEL); if (mod->klp_info->sechdrs == NULL) { ret = -ENOMEM; goto free_info; } - memcpy(mod->klp_info->sechdrs, info->sechdrs, size); /* Elf section name string table */ size = info->sechdrs[info->hdr->e_shstrndx].sh_size; - mod->klp_info->secstrings = kmalloc(size, GFP_KERNEL); + mod->klp_info->secstrings = kmemdup(info->secstrings, size, GFP_KERNEL); if (mod->klp_info->secstrings == NULL) { ret = -ENOMEM; goto free_sechdrs; } - memcpy(mod->klp_info->secstrings, info->secstrings, size); /* Elf symbol section index */ symndx = info->index.sym; -- 1.7.12.4
[PATCH] kernel/module: Use kmemdup to replace kmalloc+memcpy
we prefer to the kmemdup rather than kmalloc+memcpy. so just replace them. Signed-off-by: zhong jiang --- kernel/module.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/kernel/module.c b/kernel/module.c index 20344e4..6746c85 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -2057,21 +2057,19 @@ static int copy_module_elf(struct module *mod, struct load_info *info) /* Elf section header table */ size = sizeof(*info->sechdrs) * info->hdr->e_shnum; - mod->klp_info->sechdrs = kmalloc(size, GFP_KERNEL); + mod->klp_info->sechdrs = kmemdup(info->sechdrs, size, GFP_KERNEL); if (mod->klp_info->sechdrs == NULL) { ret = -ENOMEM; goto free_info; } - memcpy(mod->klp_info->sechdrs, info->sechdrs, size); /* Elf section name string table */ size = info->sechdrs[info->hdr->e_shstrndx].sh_size; - mod->klp_info->secstrings = kmalloc(size, GFP_KERNEL); + mod->klp_info->secstrings = kmemdup(info->secstrings, size, GFP_KERNEL); if (mod->klp_info->secstrings == NULL) { ret = -ENOMEM; goto free_sechdrs; } - memcpy(mod->klp_info->secstrings, info->secstrings, size); /* Elf symbol section index */ symndx = info->index.sym; -- 1.7.12.4
[PATCH] lib/debugobjects: remove redundant check when free the object
kmem_cache_destroy has taken the null check into account. so just remove the unnecessary check. Signed-off-by: zhong jiang --- lib/debugobjects.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/debugobjects.c b/lib/debugobjects.c index 994be48..7a6d80b 100644 --- a/lib/debugobjects.c +++ b/lib/debugobjects.c @@ -1185,8 +1185,7 @@ void __init debug_objects_mem_init(void) if (!obj_cache || debug_objects_replace_static_objects()) { debug_objects_enabled = 0; - if (obj_cache) - kmem_cache_destroy(obj_cache); + kmem_cache_destroy(obj_cache); pr_warn("out of memory.\n"); } else debug_objects_selftest(); -- 1.7.12.4
[PATCH] lib/debugobjects: remove redundant check when free the object
kmem_cache_destroy has taken the null check into account. so just remove the unnecessary check. Signed-off-by: zhong jiang --- lib/debugobjects.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/debugobjects.c b/lib/debugobjects.c index 994be48..7a6d80b 100644 --- a/lib/debugobjects.c +++ b/lib/debugobjects.c @@ -1185,8 +1185,7 @@ void __init debug_objects_mem_init(void) if (!obj_cache || debug_objects_replace_static_objects()) { debug_objects_enabled = 0; - if (obj_cache) - kmem_cache_destroy(obj_cache); + kmem_cache_destroy(obj_cache); pr_warn("out of memory.\n"); } else debug_objects_selftest(); -- 1.7.12.4
[PATCH] lib/sg_pool: remove unnecessary null check when free the object
kmem_cache_destroy/mempool_destroy has taken null check into account. so remove the redundant check. Signed-off-by: zhong jiang --- lib/sg_pool.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/sg_pool.c b/lib/sg_pool.c index 6dd3061..d1c1e63 100644 --- a/lib/sg_pool.c +++ b/lib/sg_pool.c @@ -148,10 +148,9 @@ static __init int sg_pool_init(void) cleanup_sdb: for (i = 0; i < SG_MEMPOOL_NR; i++) { struct sg_pool *sgp = sg_pools + i; - if (sgp->pool) - mempool_destroy(sgp->pool); - if (sgp->slab) - kmem_cache_destroy(sgp->slab); + + mempool_destroy(sgp->pool); + kmem_cache_destroy(sgp->slab); } return -ENOMEM; -- 1.7.12.4
[PATCH] lib/sg_pool: remove unnecessary null check when free the object
kmem_cache_destroy/mempool_destroy has taken null check into account. so remove the redundant check. Signed-off-by: zhong jiang --- lib/sg_pool.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/sg_pool.c b/lib/sg_pool.c index 6dd3061..d1c1e63 100644 --- a/lib/sg_pool.c +++ b/lib/sg_pool.c @@ -148,10 +148,9 @@ static __init int sg_pool_init(void) cleanup_sdb: for (i = 0; i < SG_MEMPOOL_NR; i++) { struct sg_pool *sgp = sg_pools + i; - if (sgp->pool) - mempool_destroy(sgp->pool); - if (sgp->slab) - kmem_cache_destroy(sgp->slab); + + mempool_destroy(sgp->pool); + kmem_cache_destroy(sgp->slab); } return -ENOMEM; -- 1.7.12.4
Re: [PATCH] lib/sg_pool,debugobjects: remove unnecessary null check when free the object
On 2018/8/1 0:21, Thomas Gleixner wrote: > On Tue, 31 Jul 2018, zhong jiang wrote: > >> kmem_cache_destroy/mempool_destroy has taken null check into account. >> so remove the redundant check. > Please split the patch so they can be applied independently by the relevant > maintainers. > > Thanks, > > tglx > > . > Ok, will do . Thanks, zhong jiang
Re: [PATCH] lib/sg_pool,debugobjects: remove unnecessary null check when free the object
On 2018/8/1 0:21, Thomas Gleixner wrote: > On Tue, 31 Jul 2018, zhong jiang wrote: > >> kmem_cache_destroy/mempool_destroy has taken null check into account. >> so remove the redundant check. > Please split the patch so they can be applied independently by the relevant > maintainers. > > Thanks, > > tglx > > . > Ok, will do . Thanks, zhong jiang
[PATCH] x86/platform/olpc: Use the PTR_ERR_OR_ZERO to simplify the code
use PTR_ERR_OR_ZERO is better than the open code Signed-off-by: zhong jiang --- arch/x86/platform/olpc/olpc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/arch/x86/platform/olpc/olpc.c b/arch/x86/platform/olpc/olpc.c index 7c3077e..f0e920f 100644 --- a/arch/x86/platform/olpc/olpc.c +++ b/arch/x86/platform/olpc/olpc.c @@ -311,10 +311,8 @@ static int __init add_xo1_platform_devices(void) return PTR_ERR(pdev); pdev = platform_device_register_simple("olpc-xo1", -1, NULL, 0); - if (IS_ERR(pdev)) - return PTR_ERR(pdev); - return 0; + return PTR_ERR_OR_ZERO(pdev); } static int olpc_xo1_ec_probe(struct platform_device *pdev) -- 1.7.12.4
[PATCH] x86/platform/olpc: Use the PTR_ERR_OR_ZERO to simplify the code
use PTR_ERR_OR_ZERO is better than the open code Signed-off-by: zhong jiang --- arch/x86/platform/olpc/olpc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/arch/x86/platform/olpc/olpc.c b/arch/x86/platform/olpc/olpc.c index 7c3077e..f0e920f 100644 --- a/arch/x86/platform/olpc/olpc.c +++ b/arch/x86/platform/olpc/olpc.c @@ -311,10 +311,8 @@ static int __init add_xo1_platform_devices(void) return PTR_ERR(pdev); pdev = platform_device_register_simple("olpc-xo1", -1, NULL, 0); - if (IS_ERR(pdev)) - return PTR_ERR(pdev); - return 0; + return PTR_ERR_OR_ZERO(pdev); } static int olpc_xo1_ec_probe(struct platform_device *pdev) -- 1.7.12.4
[PATCH] lib/sg_pool,debugobjects: remove unnecessary null check when free the object
kmem_cache_destroy/mempool_destroy has taken null check into account. so remove the redundant check. Signed-off-by: zhong jiang --- lib/debugobjects.c | 3 +-- lib/sg_pool.c | 7 +++ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/debugobjects.c b/lib/debugobjects.c index 994be48..7a6d80b 100644 --- a/lib/debugobjects.c +++ b/lib/debugobjects.c @@ -1185,8 +1185,7 @@ void __init debug_objects_mem_init(void) if (!obj_cache || debug_objects_replace_static_objects()) { debug_objects_enabled = 0; - if (obj_cache) - kmem_cache_destroy(obj_cache); + kmem_cache_destroy(obj_cache); pr_warn("out of memory.\n"); } else debug_objects_selftest(); diff --git a/lib/sg_pool.c b/lib/sg_pool.c index 6dd3061..d1c1e63 100644 --- a/lib/sg_pool.c +++ b/lib/sg_pool.c @@ -148,10 +148,9 @@ static __init int sg_pool_init(void) cleanup_sdb: for (i = 0; i < SG_MEMPOOL_NR; i++) { struct sg_pool *sgp = sg_pools + i; - if (sgp->pool) - mempool_destroy(sgp->pool); - if (sgp->slab) - kmem_cache_destroy(sgp->slab); + + mempool_destroy(sgp->pool); + kmem_cache_destroy(sgp->slab); } return -ENOMEM; -- 1.7.12.4
[PATCH] lib/sg_pool,debugobjects: remove unnecessary null check when free the object
kmem_cache_destroy/mempool_destroy has taken null check into account. so remove the redundant check. Signed-off-by: zhong jiang --- lib/debugobjects.c | 3 +-- lib/sg_pool.c | 7 +++ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/debugobjects.c b/lib/debugobjects.c index 994be48..7a6d80b 100644 --- a/lib/debugobjects.c +++ b/lib/debugobjects.c @@ -1185,8 +1185,7 @@ void __init debug_objects_mem_init(void) if (!obj_cache || debug_objects_replace_static_objects()) { debug_objects_enabled = 0; - if (obj_cache) - kmem_cache_destroy(obj_cache); + kmem_cache_destroy(obj_cache); pr_warn("out of memory.\n"); } else debug_objects_selftest(); diff --git a/lib/sg_pool.c b/lib/sg_pool.c index 6dd3061..d1c1e63 100644 --- a/lib/sg_pool.c +++ b/lib/sg_pool.c @@ -148,10 +148,9 @@ static __init int sg_pool_init(void) cleanup_sdb: for (i = 0; i < SG_MEMPOOL_NR; i++) { struct sg_pool *sgp = sg_pools + i; - if (sgp->pool) - mempool_destroy(sgp->pool); - if (sgp->slab) - kmem_cache_destroy(sgp->slab); + + mempool_destroy(sgp->pool); + kmem_cache_destroy(sgp->slab); } return -ENOMEM; -- 1.7.12.4
[PATCH] driver/hwtracing: use ERR_CAST instead of ERR_PTR
Use ERR_CAT inlined function to replace the ERR_PTR(PTR_ERR). It make the code more concise. Signed-off-by: zhong jiang --- drivers/hwtracing/coresight/coresight-tmc-etr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c index 2eda5de..1196364 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etr.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c @@ -536,7 +536,7 @@ static void tmc_etr_sg_table_populate(struct etr_sg_table *etr_table) sg_table = tmc_alloc_sg_table(dev, node, nr_tpages, nr_dpages, pages); if (IS_ERR(sg_table)) { kfree(etr_table); - return ERR_PTR(PTR_ERR(sg_table)); + return ERR_CAST(sg_table); } etr_table->sg_table = sg_table; -- 1.7.12.4
[PATCH] driver/hwtracing: use ERR_CAST instead of ERR_PTR
Use ERR_CAT inlined function to replace the ERR_PTR(PTR_ERR). It make the code more concise. Signed-off-by: zhong jiang --- drivers/hwtracing/coresight/coresight-tmc-etr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c index 2eda5de..1196364 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etr.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c @@ -536,7 +536,7 @@ static void tmc_etr_sg_table_populate(struct etr_sg_table *etr_table) sg_table = tmc_alloc_sg_table(dev, node, nr_tpages, nr_dpages, pages); if (IS_ERR(sg_table)) { kfree(etr_table); - return ERR_PTR(PTR_ERR(sg_table)); + return ERR_CAST(sg_table); } etr_table->sg_table = sg_table; -- 1.7.12.4
[tip:x86/boot] x86/boot/KASLR: Make local variable mem_limit static
Commit-ID: 5db1b1e1ee34871b1965b3f890e3ccbdb185fa52 Gitweb: https://git.kernel.org/tip/5db1b1e1ee34871b1965b3f890e3ccbdb185fa52 Author: zhong jiang AuthorDate: Mon, 30 Jul 2018 21:44:33 +0800 Committer: Thomas Gleixner CommitDate: Mon, 30 Jul 2018 19:46:03 +0200 x86/boot/KASLR: Make local variable mem_limit static Fix the following sparse warning: arch/x86/boot/compressed/kaslr.c:102:20: warning: symbol 'mem_limit' was not declared. Should it be static? Signed-off-by: zhong jiang Signed-off-by: Thomas Gleixner Cc: Link: https://lkml.kernel.org/r/1532958273-47725-1-git-send-email-zhongji...@huawei.com --- arch/x86/boot/compressed/kaslr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c index 531c9876f573..302517929932 100644 --- a/arch/x86/boot/compressed/kaslr.c +++ b/arch/x86/boot/compressed/kaslr.c @@ -102,7 +102,7 @@ static bool memmap_too_large; /* Store memory limit specified by "mem=nn[KMG]" or "memmap=nn[KMG]" */ -unsigned long long mem_limit = ULLONG_MAX; +static unsigned long long mem_limit = ULLONG_MAX; enum mem_avoid_index {
[tip:x86/boot] x86/boot/KASLR: Make local variable mem_limit static
Commit-ID: 5db1b1e1ee34871b1965b3f890e3ccbdb185fa52 Gitweb: https://git.kernel.org/tip/5db1b1e1ee34871b1965b3f890e3ccbdb185fa52 Author: zhong jiang AuthorDate: Mon, 30 Jul 2018 21:44:33 +0800 Committer: Thomas Gleixner CommitDate: Mon, 30 Jul 2018 19:46:03 +0200 x86/boot/KASLR: Make local variable mem_limit static Fix the following sparse warning: arch/x86/boot/compressed/kaslr.c:102:20: warning: symbol 'mem_limit' was not declared. Should it be static? Signed-off-by: zhong jiang Signed-off-by: Thomas Gleixner Cc: Link: https://lkml.kernel.org/r/1532958273-47725-1-git-send-email-zhongji...@huawei.com --- arch/x86/boot/compressed/kaslr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c index 531c9876f573..302517929932 100644 --- a/arch/x86/boot/compressed/kaslr.c +++ b/arch/x86/boot/compressed/kaslr.c @@ -102,7 +102,7 @@ static bool memmap_too_large; /* Store memory limit specified by "mem=nn[KMG]" or "memmap=nn[KMG]" */ -unsigned long long mem_limit = ULLONG_MAX; +static unsigned long long mem_limit = ULLONG_MAX; enum mem_avoid_index {
[PATCH] x86/boot/KASLR: Make local variable mem_limit static
Fix the following sparse warning: arch/x86/boot/compressed/kaslr.c:102:20: warning: symbol 'mem_limit' was not declared. Should it be static? Signed-off-by: zhong jiang --- arch/x86/boot/compressed/kaslr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c index 5aae509..d1e19f3 100644 --- a/arch/x86/boot/compressed/kaslr.c +++ b/arch/x86/boot/compressed/kaslr.c @@ -99,7 +99,7 @@ struct mem_vector { /* Store memory limit specified by "mem=nn[KMG]" or "memmap=nn[KMG]" */ -unsigned long long mem_limit = ULLONG_MAX; +static unsigned long long mem_limit = ULLONG_MAX; enum mem_avoid_index { -- 1.7.12.4
[PATCH] x86/boot/KASLR: Make local variable mem_limit static
Fix the following sparse warning: arch/x86/boot/compressed/kaslr.c:102:20: warning: symbol 'mem_limit' was not declared. Should it be static? Signed-off-by: zhong jiang --- arch/x86/boot/compressed/kaslr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c index 5aae509..d1e19f3 100644 --- a/arch/x86/boot/compressed/kaslr.c +++ b/arch/x86/boot/compressed/kaslr.c @@ -99,7 +99,7 @@ struct mem_vector { /* Store memory limit specified by "mem=nn[KMG]" or "memmap=nn[KMG]" */ -unsigned long long mem_limit = ULLONG_MAX; +static unsigned long long mem_limit = ULLONG_MAX; enum mem_avoid_index { -- 1.7.12.4
Re: [PATCH v11 19/26] mm: provide speculative fault infrastructure
On 2018/7/25 18:44, Laurent Dufour wrote: > > On 25/07/2018 11:04, zhong jiang wrote: >> On 2018/7/25 0:10, Laurent Dufour wrote: >>> On 24/07/2018 16:26, zhong jiang wrote: >>>> On 2018/5/17 19:06, Laurent Dufour wrote: >>>>> From: Peter Zijlstra >>>>> >>>>> Provide infrastructure to do a speculative fault (not holding >>>>> mmap_sem). >>>>> >>>>> The not holding of mmap_sem means we can race against VMA >>>>> change/removal and page-table destruction. We use the SRCU VMA freeing >>>>> to keep the VMA around. We use the VMA seqcount to detect change >>>>> (including umapping / page-table deletion) and we use gup_fast() style >>>>> page-table walking to deal with page-table races. >>>>> >>>>> Once we've obtained the page and are ready to update the PTE, we >>>>> validate if the state we started the fault with is still valid, if >>>>> not, we'll fail the fault with VM_FAULT_RETRY, otherwise we update the >>>>> PTE and we're done. >>>>> >>>>> Signed-off-by: Peter Zijlstra (Intel) >>>>> >>>>> [Manage the newly introduced pte_spinlock() for speculative page >>>>> fault to fail if the VMA is touched in our back] >>>>> [Rename vma_is_dead() to vma_has_changed() and declare it here] >>>>> [Fetch p4d and pud] >>>>> [Set vmd.sequence in __handle_mm_fault()] >>>>> [Abort speculative path when handle_userfault() has to be called] >>>>> [Add additional VMA's flags checks in handle_speculative_fault()] >>>>> [Clear FAULT_FLAG_ALLOW_RETRY in handle_speculative_fault()] >>>>> [Don't set vmf->pte and vmf->ptl if pte_map_lock() failed] >>>>> [Remove warning comment about waiting for !seq&1 since we don't want >>>>> to wait] >>>>> [Remove warning about no huge page support, mention it explictly] >>>>> [Don't call do_fault() in the speculative path as __do_fault() calls >>>>> vma->vm_ops->fault() which may want to release mmap_sem] >>>>> [Only vm_fault pointer argument for vma_has_changed()] >>>>> [Fix check against huge page, calling pmd_trans_huge()] >>>>> [Use READ_ONCE() when reading VMA's fields in the speculative path] >>>>> [Explicitly check for __HAVE_ARCH_PTE_SPECIAL as we can't support for >>>>> processing done in vm_normal_page()] >>>>> [Check that vma->anon_vma is already set when starting the speculative >>>>> path] >>>>> [Check for memory policy as we can't support MPOL_INTERLEAVE case due to >>>>> the processing done in mpol_misplaced()] >>>>> [Don't support VMA growing up or down] >>>>> [Move check on vm_sequence just before calling handle_pte_fault()] >>>>> [Don't build SPF services if !CONFIG_SPECULATIVE_PAGE_FAULT] >>>>> [Add mem cgroup oom check] >>>>> [Use READ_ONCE to access p*d entries] >>>>> [Replace deprecated ACCESS_ONCE() by READ_ONCE() in vma_has_changed()] >>>>> [Don't fetch pte again in handle_pte_fault() when running the speculative >>>>> path] >>>>> [Check PMD against concurrent collapsing operation] >>>>> [Try spin lock the pte during the speculative path to avoid deadlock with >>>>> other CPU's invalidating the TLB and requiring this CPU to catch the >>>>> inter processor's interrupt] >>>>> [Move define of FAULT_FLAG_SPECULATIVE here] >>>>> [Introduce __handle_speculative_fault() and add a check against >>>>> mm->mm_users in handle_speculative_fault() defined in mm.h] >>>>> Signed-off-by: Laurent Dufour >>>>> --- >>>>> include/linux/hugetlb_inline.h | 2 +- >>>>> include/linux/mm.h | 30 >>>>> include/linux/pagemap.h| 4 +- >>>>> mm/internal.h | 16 +- >>>>> mm/memory.c| 340 >>>>> - >>>>> 5 files changed, 385 insertions(+), 7 deletions(-) >>>>> >>>>> diff --git a/include/linux/hugetlb_inline.h >>>>> b/include/linux/hugetlb_inline.h >>>>> index 0660a03d37d9..9e25283d6fc9 100644 >>>>> --- a/include/linux/hugetlb_inline.h >>>>> +++ b/include/linux/hugetlb_inline.