Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752213AbdHDVCj (ORCPT ); Fri, 4 Aug 2017 17:02:39 -0400 Received: from g4t3426.houston.hpe.com ([15.241.140.75]:43338 "EHLO g4t3426.houston.hpe.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751268AbdHDVCg (ORCPT ); Fri, 4 Aug 2017 17:02:36 -0400 From: "Kani, Toshimitsu" To: "bp@alien8.de" CC: "linux-edac@vger.kernel.org" , "lenb@kernel.org" , "mchehab@kernel.org" , "tony.luck@intel.com" , "linux-kernel@vger.kernel.org" , "rjw@rjwysocki.net" , "linux-acpi@vger.kernel.org" Subject: Re: [PATCH v2 4/7] ghes_edac: avoid multiple calls to dmi_walk() Thread-Topic: [PATCH v2 4/7] ghes_edac: avoid multiple calls to dmi_walk() Thread-Index: AQHTDKTuWyxK/OMe00e0Ovda8CeGBqJzlIKAgAEZcQA= Date: Fri, 4 Aug 2017 21:02:17 +0000 Message-ID: <1501879964.2042.117.camel@hpe.com> References: <20170803215753.30553-1-toshi.kani@hpe.com> <20170803215753.30553-5-toshi.kani@hpe.com> <20170804040525.GE12082@nazgul.tnic> In-Reply-To: <20170804040525.GE12082@nazgul.tnic> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=toshi.kani@hpe.com; x-originating-ip: [15.219.147.8] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DF4PR84MB0185;6:Y+qE7jNTQ/HFJ8MVAQYXdbIttVj3UNY3ERXml2PuSVWP5pz4xpDPjb+kd748WFQsxbkkX+Q4luUD783EEHkd7HAlck0T7XLaX70E07dBXEsrTI7eRUU0EaeZ6Bmz2McAWiYAeqXK/Ng4l0JYeGgzcKQWoEx/M3b631H/zojAAU5njEkc4nco8g+hyDEBntmmUrwgTuANJalM5GSPhXnGURnnsFF9h2+DWt3aENg6joST/zR0TofJVc88Odk3kRll/FtNd+aiS39HsVFUhAfL1b6HZSEzBOlmxkr/8k3G+nbVqgrnHeTAyfvX7Cozt9Y778inUk7m3Neb6XVg9sLgag==;5:zoTf4yOz5V3l6YmqbMvWSVv7f9VIeJ+XkpQXM0DGoNhKY1IcnyXDJUr3CPoPe+6lG3QjQp2IxL6TH1ib+te4B0cCiKP34MoTL7mhXSGdOd9Uql1mCfOM3toEISouiXWJIYpeYshPGRUw4jolQ8906A==;24:+TpsHnlAXXhfTmBHje8J0MzRxrTmEKnuzF6TittHX04umSxOIiGe/cd02RkukIvvHfF2jCblFwUZ7nXq81wM0oUtNIC7QvYfziR17/XHgZQ=;7:zzt1zxTKv8v0MJnyrgjyysHUcBa+sIi/Xp2wNvIjDa8LkPZXlTdMdEPUO/xVE1JZ29FBBFwBkbQvFVRo7qNec2b/jSwq7FeQVP4+PIAY6Xb52C3g5OM5hjtrAVUIlRPdL6aBjAnDio5tJuM+qcDscdGRGJpaB3onfw7EIOcgG/BvZUDSpLlfTBeROG4RFwYcuFPMFCa2kASOLbTUGOaUPfhpmACJ83sc7gdoS7nAq9M= x-ms-office365-filtering-correlation-id: b87637b6-51ff-4794-4971-08d4db7c16f5 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(48565401081)(2017052603031)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:DF4PR84MB0185; x-ms-traffictypediagnostic: DF4PR84MB0185: x-exchange-antispam-report-test: UriScan:(227479698468861); x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(3002001)(100000703101)(100105400095)(6055026)(6041248)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123564025)(20161123560025)(20161123558100)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:DF4PR84MB0185;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:DF4PR84MB0185; x-forefront-prvs: 0389EDA07F x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(39860400002)(39840400002)(39410400002)(39850400002)(39400400002)(39450400003)(24454002)(377424004)(189002)(199003)(36756003)(5640700003)(106356001)(6436002)(6512007)(54906002)(6246003)(81166006)(81156014)(1730700003)(8676002)(5660300001)(8936002)(33646002)(305945005)(3660700001)(7736002)(103116003)(25786009)(2351001)(3280700002)(2501003)(2906002)(105586002)(478600001)(189998001)(6916009)(229853002)(86362001)(14454004)(6506006)(101416001)(66066001)(97736004)(2950100002)(4326008)(68736007)(2900100001)(76176999)(54356999)(38730400002)(53936002)(102836003)(3846002)(110136004)(50986999)(6116002)(77096006)(6486002);DIR:OUT;SFP:1102;SCL:1;SRVR:DF4PR84MB0185;H:DF4PR84MB0187.NAMPRD84.PROD.OUTLOOK.COM;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="utf-8" Content-ID: <9C7235CF1EDB634C8FE73BD985DD43FC@NAMPRD84.PROD.OUTLOOK.COM> MIME-Version: 1.0 X-MS-Exchange-CrossTenant-originalarrivaltime: 04 Aug 2017 21:02:17.2590 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 105b2061-b669-4b31-92ac-24d304d195dc X-MS-Exchange-Transport-CrossTenantHeadersStamped: DF4PR84MB0185 X-OriginatorOrg: hpe.com Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by nfs id v74L2iIC004435 Content-Length: 2180 Lines: 60 On Fri, 2017-08-04 at 06:05 +0200, Borislav Petkov wrote: > On Thu, Aug 03, 2017 at 03:57:50PM -0600, Toshi Kani wrote: > > ghes_edac_register() is called for each GHES platform device > > instantiated per a GHES entry in ACPI HEST table.  dmi_walk() > > counts the number of DIMMs on the system, and there is no need > > to call it multiple times. > > > > Change ghes_edac_register() to call dmi_walk() only when > > 'num_dimm' is uninitialized. > > > > Signed-off-by: Toshi Kani > > Suggested-by: Borislav Petkov > > Cc: Borislav Petkov > > Cc: Mauro Carvalho Chehab > > --- > >  drivers/edac/ghes_edac.c |    9 ++++++--- > >  1 file changed, 6 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/edac/ghes_edac.c b/drivers/edac/ghes_edac.c > > index 4e61a62..2e9ce9c 100644 > > --- a/drivers/edac/ghes_edac.c > > +++ b/drivers/edac/ghes_edac.c > > @@ -407,15 +407,18 @@ > > EXPORT_SYMBOL_GPL(ghes_edac_report_mem_error); > >   > >  int ghes_edac_register(struct ghes *ghes, struct device *dev) > >  { > > - bool fake = false; > > - int rc, num_dimm = 0; > >   struct mem_ctl_info *mci; > >   struct edac_mc_layer layers[1]; > >   struct ghes_edac_pvt *pvt; > >   struct ghes_edac_dimm_fill dimm_fill; > > + int rc; > > + > > + static int num_dimm; > > + static bool fake; > >   > >   /* Get the number of DIMMs */ > > - dmi_walk(ghes_edac_count_dimms, &num_dimm); > > + if (num_dimm == 0) > > + dmi_walk(ghes_edac_count_dimms, &num_dimm); > > So the problem is that ghes_edac_register() gets called multiple > times depending on how many GHES platform devices are on the system. > But yet they all scan *all* DIMMs. So instead you should return if > the DIMMs have been counted already and not register a second time. > > Which makes that whole mc counting kinda useless. So you could rip > that out too. > > Unless I'm missing something... GHES platform devices correspond to GHES entries, which define firmware interfaces to report generic memory errors to the OS, such as NMI and SCI. These devices are associated with all DIMMs, not a particular DIMM. Thanks, -Toshi