From patchwork Thu Jul 25 07:59:45 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen Gang X-Patchwork-Id: 261607 X-Patchwork-Delegate: benh@kernel.crashing.org Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [IPv6:::1]) by ozlabs.org (Postfix) with ESMTP id 067A22C0165 for ; Thu, 25 Jul 2013 18:01:21 +1000 (EST) Received: from intranet.asianux.com (intranet.asianux.com [58.214.24.6]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 9018F2C00D4 for ; Thu, 25 Jul 2013 18:00:48 +1000 (EST) Received: by intranet.asianux.com (Postfix, from userid 103) id 3C0491840370; Thu, 25 Jul 2013 16:00:45 +0800 (CST) X-Spam-Score: -100.8 X-Spam-Checker-Version: SpamAssassin 3.1.9 (2007-02-13) on intranet.asianux.com X-Spam-Level: X-Spam-Status: No, score=-100.8 required=5.0 tests=AWL,BAYES_00, RATWARE_GECKO_BUILD,USER_IN_WHITELIST autolearn=no version=3.1.9 Received: from [10.1.0.143] (unknown [219.143.36.82]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by intranet.asianux.com (Postfix) with ESMTP id BC2A71840253; Thu, 25 Jul 2013 16:00:44 +0800 (CST) Message-ID: <51F0DAF1.9060702@asianux.com> Date: Thu, 25 Jul 2013 15:59:45 +0800 From: Chen Gang User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: Benjamin Herrenschmidt Subject: Re: [PATCH v2] powerpc: kernel: remove useless code which related with 'max_cpus' References: <51ECCA10.7010709@asianux.com> <51ECCEA8.5040406@linux.vnet.ibm.com> <51ECD0BF.8080605@asianux.com> <51ECD3D4.9020405@asianux.com> <51ECD664.7040708@linux.vnet.ibm.com> <20130723134431.GF31944@concordia> <51EF1F97.3070409@asianux.com> <20130724011640.GA6042@concordia> <51EF375D.9060006@asianux.com> <20130725031501.GA15673@concordia> <1374729381.6142.59.camel@pasglop> <51F0B68F.4000402@asianux.com> <1374731505.6142.64.camel@pasglop> <51F0C2E8.3050005@asianux.com> <1374737592.6142.67.camel@pasglop> In-Reply-To: <1374737592.6142.67.camel@pasglop> Cc: chenhui.zhao@freescale.com, "paulus@samba.org" , "Srivatsa S. Bhat" , Thomas Gleixner , "linuxppc-dev@lists.ozlabs.org" X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" On 07/25/2013 03:33 PM, Benjamin Herrenschmidt wrote: > On Thu, 2013-07-25 at 14:17 +0800, Chen Gang wrote: >> > >> > Hmm... for an extern function (espeically have been implemented in >> > various modules), normally, we can assume it may fail in some cases >> > (although now, we don't know what cases can cause its failure). >> > >> > If "we don't have a good way to handle the failure", "print the related >> > warning message" is an executable choice (or "BUG_ON()", if it is critical). >> > >> > So, if the performance is not sensible, I still suggest to let extern >> > function have return value. > This is not a module function. We are not doing a uni course on how to > write C code here. Be real. In our case, 'module' points to various sub directories of arch/powerpc (maybe 'module' is not quite precise, it is easy misunderstand). The real world is not conflict with "how to write C code". For my opinion: one fix may like below (assume have removed max_cpus) which is more reasonable for code readers. -----------------------------diff begin------------------------------ -----------------------------diff end-------------------------------- Thanks diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c index 7edbd5b..53155f4 100644 --- a/arch/powerpc/kernel/smp.c +++ b/arch/powerpc/kernel/smp.c @@ -347,7 +347,7 @@ void __init smp_prepare_cpus(unsigned int max_cpus) cpumask_set_cpu(boot_cpuid, cpu_core_mask(boot_cpuid)); if (smp_ops && smp_ops->probe) - smp_ops->probe(); + BUG_ON(smp_ops->probe() < 0); } void smp_prepare_boot_cpu(void)