Message ID | 20230213191510.2237360-1-trix@redhat.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2532442wrn; Mon, 13 Feb 2023 11:32:01 -0800 (PST) X-Google-Smtp-Source: AK7set/kj3HTI3yCl8MG5/xw5tieCRSW+x8GYeSw7GlWaclRUoRHx9AwScHXhpSJ8w7/rHtMhh3B X-Received: by 2002:a17:907:214f:b0:878:74a9:1869 with SMTP id rk15-20020a170907214f00b0087874a91869mr119166ejb.3.1676316721823; Mon, 13 Feb 2023 11:32:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676316721; cv=none; d=google.com; s=arc-20160816; b=Hj9WFz0OXPEn1YO1zxNo6m5mGf/7aulXxLilXhhT2l/xwKiyz+cF90UaAYuL0bf1PA i+FCdDF26wosc+xxW8LfhtPplA10ku5Mf6nWINrFWWVhkkUNtVITpBemlEePy+HGlAif uI5K+ZYe4dYYiJ16MX5TLxMmjQz1WTz9omjJAR7MgYh12edZVKMfaKSDdMTak7CEYvO/ 0w9y+oAINgxgQUZ+ykZb1idJTZgaNohaHEDy2NnNMjwZFz5X39Id8gY/XkWUZpg3V61B Bk1KEvfZxaEpFQmTOb0m3xiJr5PMu+k77I4Q02iH2yR1btgprUsqXlhA1dpHydPVnCLK NORw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=uhQrqnCkN4d3EAtVP7068dcMTmtPV8cpYn4riXUGRrk=; b=Dm857HuZZzpd7u/6q/ija4zZi59XTRXa+5NoquRevsT8yRU6eKe+18kfPS+ajWTjkF LwUraBXNdBggxfJYuxZzFOEwlZ6kGJo5oUwP0ZCZKrmdUotEjRH4hb3wnWj49Jdu7Jdr rPTddV4NX7N3kK2+zxgoo8dxHDwGFB1nm2J+TGZFkYbGAH44kxo5xpxiYyU28SCiqAPP COKNaLFgdRpFoCl30qqU/OyYZuKH09eE4er5weQVCvZGPQrir+qsZd68XB92LKHOquw2 T3RbcqR0SettQXg1kz8VvtQEDy/PxnQe5mVcOP223EfTFyZPZ4UMwzi4yYwQVMDGoy5C wJbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Gybqfe3K; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e22-20020a170906749600b008b128c10e7asi437519ejl.215.2023.02.13.11.31.38; Mon, 13 Feb 2023 11:32:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Gybqfe3K; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230165AbjBMTQD (ORCPT <rfc822;tebrre53rla2o@gmail.com> + 99 others); Mon, 13 Feb 2023 14:16:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230160AbjBMTQC (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 13 Feb 2023 14:16:02 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 258CF20067 for <linux-kernel@vger.kernel.org>; Mon, 13 Feb 2023 11:15:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676315718; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=uhQrqnCkN4d3EAtVP7068dcMTmtPV8cpYn4riXUGRrk=; b=Gybqfe3Ki77KOqK4GYR/DqkGwlkTALWHORQuz2tarJd1qio9bWvqKyt6tEqQruv/jdeUje LQCs0ObBhXCc2K+eRGrMdXjRnrGe6XALIvClRlhPKTFOdyyFS1l6V/QlUQ8y9UUAemaM9M LD8SkToRRWyx4SCQIIgk4pcHE8lgfn4= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-21-0hLX_oN8OmayjHKAjpRNHQ-1; Mon, 13 Feb 2023 14:15:17 -0500 X-MC-Unique: 0hLX_oN8OmayjHKAjpRNHQ-1 Received: by mail-qv1-f69.google.com with SMTP id dz7-20020ad45887000000b0056e9274a7e1so5288774qvb.5 for <linux-kernel@vger.kernel.org>; Mon, 13 Feb 2023 11:15:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=uhQrqnCkN4d3EAtVP7068dcMTmtPV8cpYn4riXUGRrk=; b=j8e90ToCr0X4/5oEEBSnOiPFp0oxSjwY4g5dJta5tai1pja+RNCIvf4MHJHkDM3aJc ktfr2lNawcCi1b/o2bxZi9HdOQbHqFE97hDIQIvH+u9OGizeI2lCJKziWw5ngFw/861/ cJUcD1q4u2JDB7pGRniAQLGzxEKKA2v49ZWp3EiA/pg8O49sZdf5I5e7F6gRPqE+KCub U2CCpXOqJJS/5S/DrWvQIm+QmVPXK4JXrqgk5DNiRx64OZIevREpAxrcp3CHe3xn4Wrn O6jrOUaVOwMmoA2PS9nWPxJvTgNIYC4kfkiB3N3nuLZBt5h6u9owjNx3BttJybowajpc qjpg== X-Gm-Message-State: AO0yUKWD+xoJzAcHOhraIQosSoPZUFA1CHAGC1XvpzjK5OP0R0WcOujX p6CY5BIzWSbdabcRiPg6nqPsv5bfOioMj6WVis2Q4KmDnZNJPteJczgf7mY1iG47fppxa2k0/XM T61szt9UB+VRvi359V/Pu+P4Q X-Received: by 2002:a05:622a:1052:b0:3b6:313a:e27a with SMTP id f18-20020a05622a105200b003b6313ae27amr47315514qte.40.1676315716713; Mon, 13 Feb 2023 11:15:16 -0800 (PST) X-Received: by 2002:a05:622a:1052:b0:3b6:313a:e27a with SMTP id f18-20020a05622a105200b003b6313ae27amr47315471qte.40.1676315716450; Mon, 13 Feb 2023 11:15:16 -0800 (PST) Received: from borg.redhat.com (024-205-208-113.res.spectrum.com. [24.205.208.113]) by smtp.gmail.com with ESMTPSA id o62-20020a374141000000b0072ad54e36b2sm10248485qka.93.2023.02.13.11.15.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Feb 2023 11:15:16 -0800 (PST) From: Tom Rix <trix@redhat.com> To: yazen.ghannam@amd.com, bp@alien8.de, tony.luck@intel.com, james.morse@arm.com, mchehab@kernel.org, rric@kernel.org Cc: linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org, Tom Rix <trix@redhat.com> Subject: [PATCH] EDAC/amd64: remove unneeded call to reserve_mc_sibling_devs() Date: Mon, 13 Feb 2023 11:15:10 -0800 Message-Id: <20230213191510.2237360-1-trix@redhat.com> X-Mailer: git-send-email 2.26.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757745482904287384?= X-GMAIL-MSGID: =?utf-8?q?1757745482904287384?= |
Series |
EDAC/amd64: remove unneeded call to reserve_mc_sibling_devs()
|
|
Commit Message
Tom Rix
Feb. 13, 2023, 7:15 p.m. UTC
cpp_check reports
drivers/edac/amd64_edac.c:3943:37: error: Uninitialized variable: pci_id1 [uninitvar]
ret = reserve_mc_sibling_devs(pvt, pci_id1, pci_id2);
^
drivers/edac/amd64_edac.c:3943:46: error: Uninitialized variable: pci_id2 [uninitvar]
ret = reserve_mc_sibling_devs(pvt, pci_id1, pci_id2);
^
The call to reserve_mc_sibling_devs() will not fail because
if (pvt->umc)
return 0;
reserve_mc_sibling_devs() is only called by hw_info_get() and pvt->umc is only set
in hw_info_get(), so with fam >= 0x17, the call to reserver_mc_siblings will
just return, so the call the call is not needed. And when that call is moved
the check for umc is not needed.
Signed-off-by: Tom Rix <trix@redhat.com>
---
drivers/edac/amd64_edac.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
Comments
On Mon, Feb 13, 2023 at 11:15:10AM -0800, Tom Rix wrote: > cpp_check reports > drivers/edac/amd64_edac.c:3943:37: error: Uninitialized variable: pci_id1 [uninitvar] > ret = reserve_mc_sibling_devs(pvt, pci_id1, pci_id2); > ^ > drivers/edac/amd64_edac.c:3943:46: error: Uninitialized variable: pci_id2 [uninitvar] > ret = reserve_mc_sibling_devs(pvt, pci_id1, pci_id2); > ^ > The call to reserve_mc_sibling_devs() will not fail because > if (pvt->umc) > return 0; > > reserve_mc_sibling_devs() is only called by hw_info_get() and pvt->umc is only set > in hw_info_get(), so with fam >= 0x17, the call to reserver_mc_siblings will > just return, so the call the call is not needed. And when that call is moved > the check for umc is not needed. > > Signed-off-by: Tom Rix <trix@redhat.com> > --- Link to similar patch from Nathan: https://lore.kernel.org/linux-edac/20230213-amd64_edac-wsometimes-uninitialized-v1-1-5bde32b89e02@kernel.org/ Hi Tom and Nathan, These errors are encountered when extra warnings are enabled, correct? I think the following patch would resolve this issue. This is part of a set that isn't fully applied. https://lore.kernel.org/linux-edac/20230127170419.1824692-12-yazen.ghannam@amd.com/ Boris, Do you think one of these patches should be applied or just hold off until the entire original set is applied? As for myself, I'll start including builds with extra warnings enabled for each patch in my workflow. Currently I do a regular build for each patch and a build with extra warnings for the entire set. Thanks, Yazen
On Mon, Feb 13, 2023 at 08:12:38PM +0000, Yazen Ghannam wrote: > These errors are encountered when extra warnings are enabled, correct? It says so in the warning which one it is: -Werror,-Wsometimes-uninitialized Don't know if we enable that one for clang with W= or Nathan adds additional switches. > I think the following patch would resolve this issue. This is part of a set > that isn't fully applied. > https://lore.kernel.org/linux-edac/20230127170419.1824692-12-yazen.ghannam@amd.com/ > > Boris, > Do you think one of these patches should be applied or just hold off until the > entire original set is applied? I still wanted to go through the rest but I'm not sure I'll have time for it before the merge window. So unless this is breaking some silly testing scenario, I'd say I'll leave things as they are. Once I take yours, that silly false positive will go away and we can forget about it. > As for myself, I'll start including builds with extra warnings enabled > for each patch in my workflow. Currently I do a regular build for each > patch and a build with extra warnings for the entire set. Dunno, I'd say with false positives we have bigger fish to fry... Thx.
On Mon, Feb 13, 2023 at 09:23:47PM +0100, Borislav Petkov wrote: > On Mon, Feb 13, 2023 at 08:12:38PM +0000, Yazen Ghannam wrote: > > These errors are encountered when extra warnings are enabled, correct? > > It says so in the warning which one it is: -Werror,-Wsometimes-uninitialized > > Don't know if we enable that one for clang with W= or Nathan adds > additional switches. -Wsometimes-uninitialized is part of clang's -Wall so it is on by default in all builds, regardless of W= -Werror comes from CONFIG_WERROR, which is enabled with allmodconfig. > > I think the following patch would resolve this issue. This is part of a set > > that isn't fully applied. > > https://lore.kernel.org/linux-edac/20230127170419.1824692-12-yazen.ghannam@amd.com/ > > > > Boris, > > Do you think one of these patches should be applied or just hold off until the > > entire original set is applied? > > I still wanted to go through the rest but I'm not sure I'll have time > for it before the merge window. So unless this is breaking some silly > testing scenario, I'd say I'll leave things as they are. This breaks allmodconfig with clang, so it would be great if one of these solutions was applied in the meantime. Cheers, Nathan
On 2/13/23 12:28 PM, Nathan Chancellor wrote: > On Mon, Feb 13, 2023 at 09:23:47PM +0100, Borislav Petkov wrote: >> On Mon, Feb 13, 2023 at 08:12:38PM +0000, Yazen Ghannam wrote: >>> These errors are encountered when extra warnings are enabled, correct? >> It says so in the warning which one it is: -Werror,-Wsometimes-uninitialized >> >> Don't know if we enable that one for clang with W= or Nathan adds >> additional switches. > -Wsometimes-uninitialized is part of clang's -Wall so it is on by > default in all builds, regardless of W= > > -Werror comes from CONFIG_WERROR, which is enabled with allmodconfig. > >>> I think the following patch would resolve this issue. This is part of a set >>> that isn't fully applied. >>> https://lore.kernel.org/linux-edac/20230127170419.1824692-12-yazen.ghannam@amd.com/ >>> >>> Boris, >>> Do you think one of these patches should be applied or just hold off until the >>> entire original set is applied? >> I still wanted to go through the rest but I'm not sure I'll have time >> for it before the merge window. So unless this is breaking some silly >> testing scenario, I'd say I'll leave things as they are. > This breaks allmodconfig with clang, so it would be great if one of > these solutions was applied in the meantime. This happens at least on allyesconfig clang W=1,2, i do not know about default, it's in a bad state as well. It would be great if the clang build was working. Nathan's patch is fine, go with that. Tom > > Cheers, > Nathan >
On Mon, Feb 13, 2023 at 01:17:51PM -0800, Tom Rix wrote: > > On 2/13/23 12:28 PM, Nathan Chancellor wrote: > > On Mon, Feb 13, 2023 at 09:23:47PM +0100, Borislav Petkov wrote: > > > On Mon, Feb 13, 2023 at 08:12:38PM +0000, Yazen Ghannam wrote: > > > > These errors are encountered when extra warnings are enabled, correct? > > > It says so in the warning which one it is: -Werror,-Wsometimes-uninitialized > > > > > > Don't know if we enable that one for clang with W= or Nathan adds > > > additional switches. > > -Wsometimes-uninitialized is part of clang's -Wall so it is on by > > default in all builds, regardless of W= > > > > -Werror comes from CONFIG_WERROR, which is enabled with allmodconfig. > > > > > > I think the following patch would resolve this issue. This is part of a set > > > > that isn't fully applied. > > > > https://lore.kernel.org/linux-edac/20230127170419.1824692-12-yazen.ghannam@amd.com/ > > > > > > > > Boris, > > > > Do you think one of these patches should be applied or just hold off until the > > > > entire original set is applied? > > > I still wanted to go through the rest but I'm not sure I'll have time > > > for it before the merge window. So unless this is breaking some silly > > > testing scenario, I'd say I'll leave things as they are. > > This breaks allmodconfig with clang, so it would be great if one of > > these solutions was applied in the meantime. > > This happens at least on allyesconfig clang W=1,2, i do not know about > default, it's in a bad state as well. > Yes, this breaks on a default clang build. I just used "make LLVM=1" with the same config I used before, and I see the error. GCC doesn't seem to have a comparable warning to "-Wsometimes-uninitialized". I went back and tried W=123 and no warnings in this code. Building with clang was straightforward, so I'll try to include it in my workflow in the future. > It would be great if the clang build was working. > > Nathan's patch is fine, go with that. > I agree Nathan's patch is fine, but would you all be okay with a simpler change? Initializing the variables (as below) will silence the warnings, and we know this is a false positive. Eventually this function will be reworked, so a trivial workaround seems okay. What do y'all think? Thanks, Yazen ------ diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c index 1c4bef1cdf28..5b42533f306a 100644 --- a/drivers/edac/amd64_edac.c +++ b/drivers/edac/amd64_edac.c @@ -3928,7 +3928,7 @@ static const struct attribute_group *amd64_edac_attr_groups[] = { static int hw_info_get(struct amd64_pvt *pvt) { - u16 pci_id1, pci_id2; + u16 pci_id1 = 0, pci_id2 = 0; int ret; if (pvt->fam >= 0x17) { ------
On Mon, Feb 13, 2023 at 10:11:38PM +0000, Yazen Ghannam wrote: > On Mon, Feb 13, 2023 at 01:17:51PM -0800, Tom Rix wrote: > > > > On 2/13/23 12:28 PM, Nathan Chancellor wrote: > > > On Mon, Feb 13, 2023 at 09:23:47PM +0100, Borislav Petkov wrote: > > > > On Mon, Feb 13, 2023 at 08:12:38PM +0000, Yazen Ghannam wrote: > > > > > These errors are encountered when extra warnings are enabled, correct? > > > > It says so in the warning which one it is: -Werror,-Wsometimes-uninitialized > > > > > > > > Don't know if we enable that one for clang with W= or Nathan adds > > > > additional switches. > > > -Wsometimes-uninitialized is part of clang's -Wall so it is on by > > > default in all builds, regardless of W= > > > > > > -Werror comes from CONFIG_WERROR, which is enabled with allmodconfig. > > > > > > > > I think the following patch would resolve this issue. This is part of a set > > > > > that isn't fully applied. > > > > > https://lore.kernel.org/linux-edac/20230127170419.1824692-12-yazen.ghannam@amd.com/ > > > > > > > > > > Boris, > > > > > Do you think one of these patches should be applied or just hold off until the > > > > > entire original set is applied? > > > > I still wanted to go through the rest but I'm not sure I'll have time > > > > for it before the merge window. So unless this is breaking some silly > > > > testing scenario, I'd say I'll leave things as they are. > > > This breaks allmodconfig with clang, so it would be great if one of > > > these solutions was applied in the meantime. > > > > This happens at least on allyesconfig clang W=1,2, i do not know about > > default, it's in a bad state as well. > > > > Yes, this breaks on a default clang build. I just used "make LLVM=1" with the > same config I used before, and I see the error. > > GCC doesn't seem to have a comparable warning to "-Wsometimes-uninitialized". > I went back and tried W=123 and no warnings in this code. GCC's -Wmaybe-uninitialized uses interprocedural analysis I believe, which would allow it to see that it is not possible for these variables to be used uninitialized. However, that type of analysis can go wrong with optimizations pretty quickly, so it was disabled for the kernel under normal builds and W=1; W=2 will show those instances again but again, I would not expect there to be one here. > Building with clang was straightforward, so I'll try to include it in my > workflow in the future. > > > It would be great if the clang build was working. > > > > Nathan's patch is fine, go with that. > > > > I agree Nathan's patch is fine, but would you all be okay with a simpler > change? Initializing the variables (as below) will silence the warnings, and > we know this is a false positive. Eventually this function will be reworked, > so a trivial workaround seems okay. What do y'all think? I have no objections. Will you send the patch? Consider it Reviewed-by: Nathan Chancellor <nathan@kernel.org> in advanced. Thanks for taking a further look at this problem! Cheers, Nathan > > Thanks, > Yazen > > ------ > > diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c > index 1c4bef1cdf28..5b42533f306a 100644 > --- a/drivers/edac/amd64_edac.c > +++ b/drivers/edac/amd64_edac.c > @@ -3928,7 +3928,7 @@ static const struct attribute_group > *amd64_edac_attr_groups[] = { > > static int hw_info_get(struct amd64_pvt *pvt) > { > - u16 pci_id1, pci_id2; > + u16 pci_id1 = 0, pci_id2 = 0; > int ret; > > if (pvt->fam >= 0x17) { > > ------
diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c index 1c4bef1cdf28..f6d50561c106 100644 --- a/drivers/edac/amd64_edac.c +++ b/drivers/edac/amd64_edac.c @@ -3179,9 +3179,6 @@ static void decode_umc_error(int node_id, struct mce *m) static int reserve_mc_sibling_devs(struct amd64_pvt *pvt, u16 pci_id1, u16 pci_id2) { - if (pvt->umc) - return 0; - /* Reserve the ADDRESS MAP Device */ pvt->F1 = pci_get_related_function(pvt->F3->vendor, pci_id1, pvt->F3); if (!pvt->F1) { @@ -3938,11 +3935,11 @@ static int hw_info_get(struct amd64_pvt *pvt) } else { pci_id1 = fam_type->f1_id; pci_id2 = fam_type->f2_id; - } - ret = reserve_mc_sibling_devs(pvt, pci_id1, pci_id2); - if (ret) - return ret; + ret = reserve_mc_sibling_devs(pvt, pci_id1, pci_id2); + if (ret) + return ret; + } read_mc_regs(pvt);