Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753922AbdLSXhe convert rfc822-to-8bit (ORCPT ); Tue, 19 Dec 2017 18:37:34 -0500 Received: from mga14.intel.com ([192.55.52.115]:45884 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753538AbdLSXhc (ORCPT ); Tue, 19 Dec 2017 18:37:32 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,429,1508828400"; d="scan'208";a="15008664" From: "Dilger, Andreas" To: NeilBrown CC: "Drokin, Oleg" , James Simmons , Greg Kroah-Hartman , lkml , lustre Subject: Re: [PATCH 2/2] staging: lustre: disable preempt while sampling processor id. Thread-Topic: [PATCH 2/2] staging: lustre: disable preempt while sampling processor id. Thread-Index: AQHTeFREdDz36nhRtEO1YtlbuiizKKNL2h8A Date: Tue, 19 Dec 2017 23:37:31 +0000 Message-ID: <124DA88F-854D-41B0-9A3C-84AE37D4DD24@intel.com> References: <151363798156.11899.768707943431676479.stgit@noble> <151363810776.11899.1696679196545013564.stgit@noble> In-Reply-To: <151363810776.11899.1696679196545013564.stgit@noble> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.254.4.20] Content-Type: text/plain; charset="us-ascii" Content-ID: <294A9331EA7B5947A55C5A027F680F1F@intel.com> Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1735 Lines: 64 On Dec 18, 2017, at 16:01, NeilBrown wrote: > > Calling smp_processor_id() without disabling preemption > triggers a warning (if CONFIG_DEBUG_PREEMPT). > I think the result of cfs_cpt_current() is only used as a hint for > load balancing, rather than as a precise and stable indicator of > the current CPU. So it doesn't need to be called with > preemption disabled. > > So disable preemption inside cfs_cpt_current() to silence the warning. > > Signed-off-by: NeilBrown Reviewed-by: Andreas Dilger > --- > .../staging/lustre/lnet/libcfs/linux/linux-cpu.c | 13 +++++++------ > 1 file changed, 7 insertions(+), 6 deletions(-) > > diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c > index d30650f8dcb4..ca8518b8a3e0 100644 > --- a/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c > +++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-cpu.c > @@ -517,19 +517,20 @@ EXPORT_SYMBOL(cfs_cpt_spread_node); > int > cfs_cpt_current(struct cfs_cpt_table *cptab, int remap) > { > - int cpu = smp_processor_id(); > - int cpt = cptab->ctb_cpu2cpt[cpu]; > + int cpu; > + int cpt; > > - if (cpt < 0) { > - if (!remap) > - return cpt; > + preempt_disable(); > + cpu = smp_processor_id(); > + cpt = cptab->ctb_cpu2cpt[cpu]; > > + if (cpt < 0 && remap) { > /* don't return negative value for safety of upper layer, > * instead we shadow the unknown cpu to a valid partition ID > */ > cpt = cpu % cptab->ctb_nparts; > } > - > + preempt_enable(); > return cpt; > } > EXPORT_SYMBOL(cfs_cpt_current); > > Cheers, Andreas -- Andreas Dilger Lustre Principal Architect Intel Corporation