2018-06-12 10:19:09

by Chengguang Xu

[permalink] [raw]
Subject: [RESEND PATCH] x86: remove redundant check for kmem_cache_create()

The flag 'SLAB_PANIC' implies panic when encouter failure,
so there is no need to check NULL pointer and return error
code.

Signed-off-by: Chengguang Xu <[email protected]>
---
arch/x86/mm/pgtable.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
index 47b5951..4392414 100644
--- a/arch/x86/mm/pgtable.c
+++ b/arch/x86/mm/pgtable.c
@@ -312,14 +312,14 @@ static void pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmds[])

static struct kmem_cache *pgd_cache;

-static int __init pgd_cache_init(void)
+static void __init pgd_cache_init(void)
{
/*
* When PAE kernel is running as a Xen domain, it does not use
* shared kernel pmd. And this requires a whole page for pgd.
*/
if (!SHARED_KERNEL_PMD)
- return 0;
+ return;

/*
* when PAE kernel is not running as a Xen domain, it uses
@@ -329,10 +329,6 @@ static int __init pgd_cache_init(void)
*/
pgd_cache = kmem_cache_create("pgd_cache", PGD_SIZE, PGD_ALIGN,
SLAB_PANIC, NULL);
- if (!pgd_cache)
- return -ENOMEM;
-
- return 0;
}
core_initcall(pgd_cache_init);

--
1.8.3.1



2018-06-12 11:29:23

by kernel test robot

[permalink] [raw]
Subject: Re: [RESEND PATCH] x86: remove redundant check for kmem_cache_create()

Hi Chengguang,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on tip/x86/core]
[also build test WARNING on v4.17 next-20180612]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Chengguang-Xu/x86-remove-redundant-check-for-kmem_cache_create/20180612-182134
config: i386-randconfig-a1-201823 (attached as .config)
compiler: gcc-4.9 (Debian 4.9.4-2) 4.9.4
reproduce:
# save the attached .config to linux build tree
make ARCH=i386

All warnings (new ones prefixed by >>):

In file included from include/linux/printk.h:5:0,
from include/linux/kernel.h:13,
from include/asm-generic/bug.h:15,
from arch/x86/include/asm/bug.h:81,
from include/linux/bug.h:4,
from include/linux/mmdebug.h:4,
from include/linux/mm.h:8,
from arch/x86/mm/pgtable.c:1:
>> arch/x86/mm/pgtable.c:327:15: warning: initialization from incompatible pointer type
core_initcall(pgd_cache_init);
^
include/linux/init.h:166:58: note: in definition of macro '__define_initcall'
__attribute__((__section__(".initcall" #id ".init"))) = fn;
^
arch/x86/mm/pgtable.c:327:1: note: in expansion of macro 'core_initcall'
core_initcall(pgd_cache_init);
^

vim +327 arch/x86/mm/pgtable.c

1db491f7 Fenghua Yu 2015-01-15 308
d524db50 Chengguang Xu 2018-06-12 309 static void __init pgd_cache_init(void)
1db491f7 Fenghua Yu 2015-01-15 310 {
1db491f7 Fenghua Yu 2015-01-15 311 /*
1db491f7 Fenghua Yu 2015-01-15 312 * When PAE kernel is running as a Xen domain, it does not use
1db491f7 Fenghua Yu 2015-01-15 313 * shared kernel pmd. And this requires a whole page for pgd.
1db491f7 Fenghua Yu 2015-01-15 314 */
1db491f7 Fenghua Yu 2015-01-15 315 if (!SHARED_KERNEL_PMD)
d524db50 Chengguang Xu 2018-06-12 316 return;
1db491f7 Fenghua Yu 2015-01-15 317
1db491f7 Fenghua Yu 2015-01-15 318 /*
1db491f7 Fenghua Yu 2015-01-15 319 * when PAE kernel is not running as a Xen domain, it uses
1db491f7 Fenghua Yu 2015-01-15 320 * shared kernel pmd. Shared kernel pmd does not require a whole
1db491f7 Fenghua Yu 2015-01-15 321 * page for pgd. We are able to just allocate a 32-byte for pgd.
1db491f7 Fenghua Yu 2015-01-15 322 * During boot time, we create a 32-byte slab for pgd table allocation.
1db491f7 Fenghua Yu 2015-01-15 323 */
1db491f7 Fenghua Yu 2015-01-15 324 pgd_cache = kmem_cache_create("pgd_cache", PGD_SIZE, PGD_ALIGN,
1db491f7 Fenghua Yu 2015-01-15 325 SLAB_PANIC, NULL);
1db491f7 Fenghua Yu 2015-01-15 326 }
1db491f7 Fenghua Yu 2015-01-15 @327 core_initcall(pgd_cache_init);
1db491f7 Fenghua Yu 2015-01-15 328

:::::: The code at line 327 was first introduced by commit
:::::: 1db491f77b6ed0f32f1d4a3ac40a5be9524f1914 x86/mm: Reduce PAE-mode per task pgd allocation overhead from 4K to 32 bytes

:::::: TO: Fenghua Yu <[email protected]>
:::::: CC: Ingo Molnar <[email protected]>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation


Attachments:
(No filename) (3.41 kB)
.config.gz (26.82 kB)
Download all attachments

2018-06-12 11:39:33

by Chengguang Xu

[permalink] [raw]
Subject: Re: [RESEND PATCH] x86: remove redundant check for kmem_cache_create()

So still need to keep return type as int, I??ll fix in V2.

Thanks.


> ?? 2018??6??12?գ?????7:27??kbuild test robot <[email protected]> д????
>
> Hi Chengguang,
>
> Thank you for the patch! Perhaps something to improve:
>
> [auto build test WARNING on tip/x86/core]
> [also build test WARNING on v4.17 next-20180612]
> [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
>
> url: https://github.com/0day-ci/linux/commits/Chengguang-Xu/x86-remove-redundant-check-for-kmem_cache_create/20180612-182134
> config: i386-randconfig-a1-201823 (attached as .config)
> compiler: gcc-4.9 (Debian 4.9.4-2) 4.9.4
> reproduce:
> # save the attached .config to linux build tree
> make ARCH=i386
>
> All warnings (new ones prefixed by >>):
>
> In file included from include/linux/printk.h:5:0,
> from include/linux/kernel.h:13,
> from include/asm-generic/bug.h:15,
> from arch/x86/include/asm/bug.h:81,
> from include/linux/bug.h:4,
> from include/linux/mmdebug.h:4,
> from include/linux/mm.h:8,
> from arch/x86/mm/pgtable.c:1:
>>> arch/x86/mm/pgtable.c:327:15: warning: initialization from incompatible pointer type
> core_initcall(pgd_cache_init);
> ^
> include/linux/init.h:166:58: note: in definition of macro '__define_initcall'
> __attribute__((__section__(".initcall" #id ".init"))) = fn;
> ^
> arch/x86/mm/pgtable.c:327:1: note: in expansion of macro 'core_initcall'
> core_initcall(pgd_cache_init);
> ^
>
> vim +327 arch/x86/mm/pgtable.c
>
> 1db491f7 Fenghua Yu 2015-01-15 308
> d524db50 Chengguang Xu 2018-06-12 309 static void __init pgd_cache_init(void)
> 1db491f7 Fenghua Yu 2015-01-15 310 {
> 1db491f7 Fenghua Yu 2015-01-15 311 /*
> 1db491f7 Fenghua Yu 2015-01-15 312 * When PAE kernel is running as a Xen domain, it does not use
> 1db491f7 Fenghua Yu 2015-01-15 313 * shared kernel pmd. And this requires a whole page for pgd.
> 1db491f7 Fenghua Yu 2015-01-15 314 */
> 1db491f7 Fenghua Yu 2015-01-15 315 if (!SHARED_KERNEL_PMD)
> d524db50 Chengguang Xu 2018-06-12 316 return;
> 1db491f7 Fenghua Yu 2015-01-15 317
> 1db491f7 Fenghua Yu 2015-01-15 318 /*
> 1db491f7 Fenghua Yu 2015-01-15 319 * when PAE kernel is not running as a Xen domain, it uses
> 1db491f7 Fenghua Yu 2015-01-15 320 * shared kernel pmd. Shared kernel pmd does not require a whole
> 1db491f7 Fenghua Yu 2015-01-15 321 * page for pgd. We are able to just allocate a 32-byte for pgd.
> 1db491f7 Fenghua Yu 2015-01-15 322 * During boot time, we create a 32-byte slab for pgd table allocation.
> 1db491f7 Fenghua Yu 2015-01-15 323 */
> 1db491f7 Fenghua Yu 2015-01-15 324 pgd_cache = kmem_cache_create("pgd_cache", PGD_SIZE, PGD_ALIGN,
> 1db491f7 Fenghua Yu 2015-01-15 325 SLAB_PANIC, NULL);
> 1db491f7 Fenghua Yu 2015-01-15 326 }
> 1db491f7 Fenghua Yu 2015-01-15 @327 core_initcall(pgd_cache_init);
> 1db491f7 Fenghua Yu 2015-01-15 328
>
> :::::: The code at line 327 was first introduced by commit
> :::::: 1db491f77b6ed0f32f1d4a3ac40a5be9524f1914 x86/mm: Reduce PAE-mode per task pgd allocation overhead from 4K to 32 bytes
>
> :::::: TO: Fenghua Yu <[email protected]>
> :::::: CC: Ingo Molnar <[email protected]>
>
> ---
> 0-DAY kernel test infrastructure Open Source Technology Center
> https://lists.01.org/pipermail/kbuild-all Intel Corporation
> <.config.gz>


2018-06-12 14:35:44

by kernel test robot

[permalink] [raw]
Subject: Re: [RESEND PATCH] x86: remove redundant check for kmem_cache_create()

Hi Chengguang,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on tip/x86/core]
[also build test ERROR on v4.17 next-20180612]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Chengguang-Xu/x86-remove-redundant-check-for-kmem_cache_create/20180612-182134
config: i386-randconfig-x012-201823 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=i386

All error/warnings (new ones prefixed by >>):

In file included from include/linux/printk.h:5:0,
from include/linux/kernel.h:13,
from include/asm-generic/bug.h:15,
from arch/x86/include/asm/bug.h:81,
from include/linux/bug.h:4,
from include/linux/mmdebug.h:4,
from include/linux/mm.h:8,
from arch/x86/mm/pgtable.c:1:
>> arch/x86/mm/pgtable.c:327:15: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
core_initcall(pgd_cache_init);
^
include/linux/init.h:166:58: note: in definition of macro '__define_initcall'
__attribute__((__section__(".initcall" #id ".init"))) = fn;
^~
>> arch/x86/mm/pgtable.c:327:1: note: in expansion of macro 'core_initcall'
core_initcall(pgd_cache_init);
^~~~~~~~~~~~~
cc1: some warnings being treated as errors

vim +327 arch/x86/mm/pgtable.c

1db491f7 Fenghua Yu 2015-01-15 308
d524db50 Chengguang Xu 2018-06-12 309 static void __init pgd_cache_init(void)
1db491f7 Fenghua Yu 2015-01-15 310 {
1db491f7 Fenghua Yu 2015-01-15 311 /*
1db491f7 Fenghua Yu 2015-01-15 312 * When PAE kernel is running as a Xen domain, it does not use
1db491f7 Fenghua Yu 2015-01-15 313 * shared kernel pmd. And this requires a whole page for pgd.
1db491f7 Fenghua Yu 2015-01-15 314 */
1db491f7 Fenghua Yu 2015-01-15 315 if (!SHARED_KERNEL_PMD)
d524db50 Chengguang Xu 2018-06-12 316 return;
1db491f7 Fenghua Yu 2015-01-15 317
1db491f7 Fenghua Yu 2015-01-15 318 /*
1db491f7 Fenghua Yu 2015-01-15 319 * when PAE kernel is not running as a Xen domain, it uses
1db491f7 Fenghua Yu 2015-01-15 320 * shared kernel pmd. Shared kernel pmd does not require a whole
1db491f7 Fenghua Yu 2015-01-15 321 * page for pgd. We are able to just allocate a 32-byte for pgd.
1db491f7 Fenghua Yu 2015-01-15 322 * During boot time, we create a 32-byte slab for pgd table allocation.
1db491f7 Fenghua Yu 2015-01-15 323 */
1db491f7 Fenghua Yu 2015-01-15 324 pgd_cache = kmem_cache_create("pgd_cache", PGD_SIZE, PGD_ALIGN,
1db491f7 Fenghua Yu 2015-01-15 325 SLAB_PANIC, NULL);
1db491f7 Fenghua Yu 2015-01-15 326 }
1db491f7 Fenghua Yu 2015-01-15 @327 core_initcall(pgd_cache_init);
1db491f7 Fenghua Yu 2015-01-15 328

:::::: The code at line 327 was first introduced by commit
:::::: 1db491f77b6ed0f32f1d4a3ac40a5be9524f1914 x86/mm: Reduce PAE-mode per task pgd allocation overhead from 4K to 32 bytes

:::::: TO: Fenghua Yu <[email protected]>
:::::: CC: Ingo Molnar <[email protected]>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation


Attachments:
(No filename) (3.50 kB)
.config.gz (30.99 kB)
Download all attachments