linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: "SF Markus Elfring" <elfring@users.sourceforge.net>,
	x86@kernel.org, "Andi Kleen" <ak@linux.intel.com>,
	"Boris Ostrovsky" <boris.ostrovsky@oracle.com>,
	"Borislav Petkov" <bp@suse.de>, "H. Peter Anvin" <hpa@zytor.com>,
	"Ingo Molnar" <mingo@redhat.com>, "Jiri Olsa" <jolsa@redhat.com>,
	"Jürgen Groß" <jgross@suse.com>,
	"Len Brown" <len.brown@intel.com>,
	"Peter Zijlstra" <peterz@infradead.org>,
	"Thomas Gleixner" <tglx@linutronix.de>
Cc: LKML <linux-kernel@vger.kernel.org>,
	kernel-janitors@vger.kernel.org,
	Julia Lawall <julia.lawall@lip6.fr>
Subject: Re: [PATCH 3/4] x86/smpboot: Replace one kzalloc() call by kcalloc()
Date: Mon, 5 Sep 2016 11:29:24 +0200	[thread overview]
Message-ID: <66d77474-57df-ea4d-db73-10c56b6feaee@redhat.com> (raw)
In-Reply-To: <037dd2c0-a53a-285a-cfff-c4355b4673e3@redhat.com>



On 05/09/2016 11:26, Paolo Bonzini wrote:
> 
> 
> On 05/09/2016 10:12, SF Markus Elfring wrote:
>> From: Markus Elfring <elfring@users.sourceforge.net>
>> Date: Mon, 5 Sep 2016 09:29:40 +0200
>>
>> * The script "checkpatch.pl" can point information out like the following.
>>
>>   WARNING: Prefer kcalloc over kzalloc with multiply
>>
>>   Thus fix the affected source code place.
>>
>> * 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.
>>
>> * Delete the local variable "size" which became unnecessary with
>>   this refactoring.
>>
>> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
>> ---
>>  arch/x86/kernel/smpboot.c | 6 +++---
>>  1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
>> index 2ce06ef..e3fdc44 100644
>> --- a/arch/x86/kernel/smpboot.c
>> +++ b/arch/x86/kernel/smpboot.c
>> @@ -311,7 +311,6 @@ EXPORT_SYMBOL(topology_phys_to_logical_pkg);
>>  static void __init smp_init_package_map(void)
>>  {
>>  	unsigned int ncpus, cpu;
>> -	size_t size;
>>  
>>  	/*
>>  	 * Today neither Intel nor AMD support heterogenous systems. That
>> @@ -357,8 +356,9 @@ static void __init smp_init_package_map(void)
>>  	memset(physical_to_logical_pkg,
>>  	       0xff,
>>  	       sizeof(*physical_to_logical_pkg) * max_physical_pkg_id);
>> -	size = BITS_TO_LONGS(max_physical_pkg_id) * sizeof(unsigned long);
>> -	physical_package_map = kzalloc(size, GFP_KERNEL);
>> +	physical_package_map = kcalloc(BITS_TO_LONGS(max_physical_pkg_id),
>> +				       sizeof(*physical_package_map),
>> +				       GFP_KERNEL);
> 
> This is bitmap_alloc.

Doh, bitmap_alloc is only in tools/include/linux/bitmap.h, but perhaps
it makes sense to add it to include/linux/bitmap.h or
include/linux/slab.h too...

Paolo

  reply	other threads:[~2016-09-05  9:29 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-05  8:05 [PATCH 0/4] x86/smpboot: Fine-tuning for smp_init_package_map() SF Markus Elfring
2016-09-05  8:10 ` [PATCH 1/4] x86/smpboot: Use kmalloc_array() in smp_init_package_map() SF Markus Elfring
2016-09-05  9:19   ` Thomas Gleixner
2016-09-05  8:11 ` [PATCH 2/4] x86/smpboot: Return directly after a failed kmalloc_array() SF Markus Elfring
2016-09-05  8:12 ` [PATCH 3/4] x86/smpboot: Replace one kzalloc() call by kcalloc() SF Markus Elfring
2016-09-05  9:26   ` Paolo Bonzini
2016-09-05  9:29     ` Paolo Bonzini [this message]
2016-09-05  8:13 ` [PATCH 4/4] x86/smpboot: Return directly after a failed kcalloc() SF Markus Elfring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=66d77474-57df-ea4d-db73-10c56b6feaee@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=ak@linux.intel.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=bp@suse.de \
    --cc=elfring@users.sourceforge.net \
    --cc=hpa@zytor.com \
    --cc=jgross@suse.com \
    --cc=jolsa@redhat.com \
    --cc=julia.lawall@lip6.fr \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=len.brown@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).