Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1476224

Re: [PATCH 1/4] x86/smpboot: Use kmalloc_array() in smp_init_package_map()

From Thomas Gleixner <tglx@linutronix.de>
Newsgroups linux.kernel
Subject Re: [PATCH 1/4] x86/smpboot: Use kmalloc_array() in smp_init_package_map()
Date 2016-09-05 11:30 +0200
Message-ID <sdYo2-1OC-7@gated-at.bofh.it> (permalink)
References <sdX8C-15T-13@gated-at.bofh.it> <sdXii-1av-13@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Mon, 5 Sep 2016, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 5 Sep 2016 08:30:20 +0200
> 
> * A multiplication for the size determination of a memory allocation
>   indicated that an array data structure should be processed.
>   Thus use the corresponding function "kmalloc_array".
> 
>   This issue was detected by using the Coccinelle software.
> 
> * Replace the specification of a data type by a pointer dereference
>   to make the corresponding size determination a bit safer according to
>   the Linux coding style convention.
> 
> * Move a calculation for one function call.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  arch/x86/kernel/smpboot.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
> index 3878725..36cf27e 100644
> --- a/arch/x86/kernel/smpboot.c
> +++ b/arch/x86/kernel/smpboot.c
> @@ -349,9 +349,12 @@ static void __init smp_init_package_map(void)
>  	 * package can be smaller than the actual used apic ids.
>  	 */
>  	max_physical_pkg_id = DIV_ROUND_UP(MAX_LOCAL_APIC, ncpus);
> -	size = max_physical_pkg_id * sizeof(unsigned int);
> -	physical_to_logical_pkg = kmalloc(size, GFP_KERNEL);
> -	memset(physical_to_logical_pkg, 0xff, size);
> +	physical_to_logical_pkg = kmalloc_array(max_physical_pkg_id,
> +						sizeof(*physical_to_logical_pkg),
> +						GFP_KERNEL);
> +	memset(physical_to_logical_pkg,
> +	       0xff,
> +	       sizeof(*physical_to_logical_pkg) * max_physical_pkg_id);


Why are you replacing well readable code by this line breaked crap?

Stop acting like a shell script or we might replace you by one.

Thanks,

	tglx

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/4] x86/smpboot: Fine-tuning for smp_init_package_map() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-05 10:10 +0200
  [PATCH 1/4] x86/smpboot: Use kmalloc_array() in  smp_init_package_map() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-05 10:20 +0200
    Re: [PATCH 1/4] x86/smpboot: Use kmalloc_array() in  smp_init_package_map() Thomas Gleixner <tglx@linutronix.de> - 2016-09-05 11:30 +0200
  [PATCH 4/4] x86/smpboot: Return directly after a failed kcalloc() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-05 10:20 +0200
  [PATCH 2/4] x86/smpboot: Return directly after a failed  kmalloc_array() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-05 10:20 +0200
  [PATCH 3/4] x86/smpboot: Replace one kzalloc() call by kcalloc() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-05 10:20 +0200
    Re: [PATCH 3/4] x86/smpboot: Replace one kzalloc() call by kcalloc() Paolo Bonzini <pbonzini@redhat.com> - 2016-09-05 11:30 +0200
    Re: [PATCH 3/4] x86/smpboot: Replace one kzalloc() call by kcalloc() Paolo Bonzini <pbonzini@redhat.com> - 2016-09-05 11:30 +0200

csiph-web