From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932514AbcIEJ3e (ORCPT ); Mon, 5 Sep 2016 05:29:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42714 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932192AbcIEJ3c (ORCPT ); Mon, 5 Sep 2016 05:29:32 -0400 Subject: Re: [PATCH 3/4] x86/smpboot: Replace one kzalloc() call by kcalloc() To: SF Markus Elfring , x86@kernel.org, Andi Kleen , Boris Ostrovsky , Borislav Petkov , "H. Peter Anvin" , Ingo Molnar , Jiri Olsa , =?UTF-8?B?SsO8cmdlbiBHcm/Dnw==?= , Len Brown , Peter Zijlstra , Thomas Gleixner References: <6dacb257-d15c-8ea1-9dd4-0440a5ecfd1d@users.sourceforge.net> <037dd2c0-a53a-285a-cfff-c4355b4673e3@redhat.com> Cc: LKML , kernel-janitors@vger.kernel.org, Julia Lawall From: Paolo Bonzini Message-ID: <66d77474-57df-ea4d-db73-10c56b6feaee@redhat.com> Date: Mon, 5 Sep 2016 11:29:24 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <037dd2c0-a53a-285a-cfff-c4355b4673e3@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 05 Sep 2016 09:29:31 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/09/2016 11:26, Paolo Bonzini wrote: > > > On 05/09/2016 10:12, SF Markus Elfring wrote: >> From: Markus Elfring >> 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 >> --- >> 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