Message ID | 20221020124458.22153-1-farbere@amazon.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp98942wrr; Thu, 20 Oct 2022 06:05:56 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7H1KeC6eqGS7LVv5LBoW7aSNqWdb1ewCvwLnP1KojZP8o3u3JI8aW/a4reG2gAiS6XDYNz X-Received: by 2002:a17:902:7b95:b0:178:ab50:76b5 with SMTP id w21-20020a1709027b9500b00178ab5076b5mr14015521pll.161.1666271145561; Thu, 20 Oct 2022 06:05:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666271145; cv=none; d=google.com; s=arc-20160816; b=qL8yw5s4+ccyKJx0uHY4Aphmt+iparTyuceJ5bUzY+IJFnQudpcjuf0HIZhyx28g7/ U3TcAX+zj1n3CqaBCN1aBqZs0UvguzFmRAoAdlpmIr6qYWwcxyxF5RKyUZI285vebX/t rEss05RKX5N1GzRmF+O1pAPSWlIqwKFOJkYlHKhjk+G22USB9om+iWJOG04pjemMAam9 vzxxVOzd/JSbzawhCHEgGCInOil1h74UtJxPHvxxX+NCwN5qLls2LtEgAFKs8NqMcAyl dti59+pbJMUwCejCCCcMA7ShTpU+XO5ypAPUx0p6vyJO/POqbSXF7CM86oLuIrZMwylR echg== 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=g+Mj6CRyj2LV1ySn2gOnQJn4NQ7XWVLANWajuKVQIGI=; b=yrQxw4DYO9E1RkULP1nJUyARperiwi/yJUxwe06B8bm8R3P3UMFp0nB8swjKNC0U8P jDy6+NRZokBJrJUfGiwqMVxobRIIO5DBarycpZ1N3vXqJyUUxTRa56COssviraRwu1iV ZzRgZkTnBUGiudE6727KaqjjSOga+XP90LqFFvpX239PnKkVCSKLST2KKnGrIHWXV/no ixiIvef4NeiUB+ZGXAfPqdya7AVtsHgYO89i4pRB+2IM+pq2Aqj1vsbc6J0dfG9hcBoS ASTr/GEw2mlH3magFa1BW/U3DW96q/uuvdbQoAYqK+io2ppBPPlbazr4HvQ9k3gQ+5En lWvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=eQZ0V3ZL; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k10-20020a056a00134a00b00562fc008395si21804968pfu.341.2022.10.20.06.05.20; Thu, 20 Oct 2022 06:05:45 -0700 (PDT) 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=@amazon.com header.s=amazon201209 header.b=eQZ0V3ZL; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230217AbiJTMpK (ORCPT <rfc822;ruipengqi7@gmail.com> + 99 others); Thu, 20 Oct 2022 08:45:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230136AbiJTMpH (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 20 Oct 2022 08:45:07 -0400 Received: from smtp-fw-6002.amazon.com (smtp-fw-6002.amazon.com [52.95.49.90]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E09AFF8FE; Thu, 20 Oct 2022 05:45:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1666269905; x=1697805905; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=g+Mj6CRyj2LV1ySn2gOnQJn4NQ7XWVLANWajuKVQIGI=; b=eQZ0V3ZLWnl1AWwHWO4dXzuw7D7RDcRajyUkDSx0x6P0rih0T3HIOIl6 fNe27++bUIJ314uzrHiM87S5W56RQDZY//nRY4cRsDEiLEBudJbxaHOH6 w6mHufeVyF5q9TdJxhhTgsOyKgLyJ6NMw++USa7i5WEiFg1tIfCHcVOQ2 o=; X-IronPort-AV: E=Sophos;i="5.95,198,1661817600"; d="scan'208";a="257694944" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-iad-1a-e823fbde.us-east-1.amazon.com) ([10.43.8.6]) by smtp-border-fw-6002.iad6.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Oct 2022 12:45:02 +0000 Received: from EX13MTAUWB001.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan3.iad.amazon.com [10.40.163.38]) by email-inbound-relay-iad-1a-e823fbde.us-east-1.amazon.com (Postfix) with ESMTPS id 30B70C0A0C; Thu, 20 Oct 2022 12:44:59 +0000 (UTC) Received: from EX19D013UWA004.ant.amazon.com (10.13.138.207) by EX13MTAUWB001.ant.amazon.com (10.43.161.207) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Thu, 20 Oct 2022 12:44:59 +0000 Received: from EX13MTAUEB002.ant.amazon.com (10.43.60.12) by EX19D013UWA004.ant.amazon.com (10.13.138.207) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1118.15; Thu, 20 Oct 2022 12:44:59 +0000 Received: from dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (172.19.116.181) by mail-relay.amazon.com (10.43.60.234) with Microsoft SMTP Server id 15.0.1497.42 via Frontend Transport; Thu, 20 Oct 2022 12:44:58 +0000 Received: by dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (Postfix, from userid 14301484) id 2E7284BBA; Thu, 20 Oct 2022 12:44:58 +0000 (UTC) From: Eliav Farber <farbere@amazon.com> To: <bp@alien8.de>, <mchehab@kernel.org>, <tony.luck@intel.com>, <james.morse@arm.com>, <rric@kernel.org>, <linux-edac@vger.kernel.org>, <linux-kernel@vger.kernel.org> CC: <talel@amazon.com>, <jonnyc@amazon.com>, <hhhawa@amazon.com>, <hanochu@amazon.com>, <farbere@amazon.com>, <itamark@amazon.com>, <shellykz@amazon.com>, <amitlavi@amazon.com>, <dkl@amazon.com> Subject: [PATCH v2] edac: fix period calculation in edac_device_reset_delay_period() Date: Thu, 20 Oct 2022 12:44:58 +0000 Message-ID: <20221020124458.22153-1-farbere@amazon.com> X-Mailer: git-send-email 2.37.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_SPF_WL 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?1747207506779463568?= X-GMAIL-MSGID: =?utf-8?q?1747211932734551883?= |
Series |
[v2] edac: fix period calculation in edac_device_reset_delay_period()
|
|
Commit Message
Farber, Eliav
Oct. 20, 2022, 12:44 p.m. UTC
Fix period calculation in case user sets a value of 1000.
The input of round_jiffies_relative() should be in jiffies and not in
milli-seconds.
Signed-off-by: Eliav Farber <farbere@amazon.com>
---
v2 --> v1:
- Fix the bug without modifying jiffs which is used to set
edac_dev->delay.
drivers/edac/edac_device.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
Comments
On Thu, Oct 20, 2022 at 12:44:58PM +0000, Eliav Farber wrote: > Fix period calculation in case user sets a value of 1000. > The input of round_jiffies_relative() should be in jiffies and not in > milli-seconds. > > Signed-off-by: Eliav Farber <farbere@amazon.com> Fixes: c4cf3b454eca ("EDAC: Rework workqueue handling") I guess. Also, I think the one-liner below does the same, no? --- diff --git a/drivers/edac/edac_device.c b/drivers/edac/edac_device.c index 19522c568aa5..88942a6edc2c 100644 --- a/drivers/edac/edac_device.c +++ b/drivers/edac/edac_device.c @@ -399,7 +399,7 @@ void edac_device_reset_delay_period(struct edac_device_ctl_info *edac_dev, unsigned long jiffs = msecs_to_jiffies(value); if (value == 1000) - jiffs = round_jiffies_relative(value); + jiffs = round_jiffies_relative(jiffs); edac_dev->poll_msec = value; edac_dev->delay = jiffs;
On 12/29/2022 5:23 PM, Borislav Petkov wrote: > On Thu, Oct 20, 2022 at 12:44:58PM +0000, Eliav Farber wrote: >> Fix period calculation in case user sets a value of 1000. >> The input of round_jiffies_relative() should be in jiffies and not in >> milli-seconds. >> >> Signed-off-by: Eliav Farber <farbere@amazon.com> > > Fixes: c4cf3b454eca ("EDAC: Rework workqueue handling") > > I guess. > > Also, I think the one-liner below does the same, no? The one-liner below will not work. See the comment in edac_device_workq_setup() that explains why round is used: " optimize here for the 1 second case, which will be normal value, to fire ON the 1 second time event. This helps reduce all sorts of timers firing on sub-second basis, while they are happy to fire together on the 1 second exactly " So only the first schedule should be rounded. But all other schedules after that should be 1000ms. When rounding jiffs and saving it in edac_dev->delay it means that all future schedules will not be with the correct delay. The fix I suggested is the same logic used in: - edac_device_workq_setup() - edac_device_workq_function() -- Regards, Eliav > --- > > diff --git a/drivers/edac/edac_device.c b/drivers/edac/edac_device.c > index 19522c568aa5..88942a6edc2c 100644 > --- a/drivers/edac/edac_device.c > +++ b/drivers/edac/edac_device.c > @@ -399,7 +399,7 @@ void edac_device_reset_delay_period(struct > edac_device_ctl_info *edac_dev, > unsigned long jiffs = msecs_to_jiffies(value); > > if (value == 1000) > - jiffs = round_jiffies_relative(value); > + jiffs = round_jiffies_relative(jiffs); > > edac_dev->poll_msec = value; > edac_dev->delay = jiffs; > > -- > Regards/Gruss, > Boris. > > https://people.kernel.org/tglx/notes-about-netiquette
On Thu, Dec 29, 2022 at 10:17:48PM +0200, Farber, Eliav wrote: > The one-liner below will not work. See the comment in > edac_device_workq_setup() that explains why round is used: Bah, right you are - there's that "optimization". Ok, I've applied this: --- From: Eliav Farber <farbere@amazon.com> Date: Thu, 20 Oct 2022 12:44:58 +0000 Subject: [PATCH] EDAC/device: Fix period calculation in edac_device_reset_delay_period() Fix period calculation in case user sets a value of 1000. The input of round_jiffies_relative() should be in jiffies and not in milli-seconds. [ bp: Use the same code pattern as in edac_device_workq_setup() for clarity. ] Fixes: c4cf3b454eca ("EDAC: Rework workqueue handling") Signed-off-by: Eliav Farber <farbere@amazon.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Link: https://lore.kernel.org/r/20221020124458.22153-1-farbere@amazon.com --- drivers/edac/edac_device.c | 17 ++++++++--------- drivers/edac/edac_module.h | 2 +- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/edac/edac_device.c b/drivers/edac/edac_device.c index 19522c568aa5..878deb4880cd 100644 --- a/drivers/edac/edac_device.c +++ b/drivers/edac/edac_device.c @@ -394,17 +394,16 @@ static void edac_device_workq_teardown(struct edac_device_ctl_info *edac_dev) * Then restart the workq on the new delay */ void edac_device_reset_delay_period(struct edac_device_ctl_info *edac_dev, - unsigned long value) + unsigned long msec) { - unsigned long jiffs = msecs_to_jiffies(value); - - if (value == 1000) - jiffs = round_jiffies_relative(value); - - edac_dev->poll_msec = value; - edac_dev->delay = jiffs; + edac_dev->poll_msec = msec; + edac_dev->delay = msecs_to_jiffies(msec); - edac_mod_work(&edac_dev->work, jiffs); + /* See comment in edac_device_workq_setup() above */ + if (edac_dev->poll_msec == 1000) + edac_mod_work(&edac_dev->work, round_jiffies_relative(edac_dev->delay)); + else + edac_mod_work(&edac_dev->work, edac_dev->delay); } int edac_device_alloc_index(void) diff --git a/drivers/edac/edac_module.h b/drivers/edac/edac_module.h index 763c076d96f2..47593afdc234 100644 --- a/drivers/edac/edac_module.h +++ b/drivers/edac/edac_module.h @@ -53,7 +53,7 @@ bool edac_stop_work(struct delayed_work *work); bool edac_mod_work(struct delayed_work *work, unsigned long delay); extern void edac_device_reset_delay_period(struct edac_device_ctl_info - *edac_dev, unsigned long value); + *edac_dev, unsigned long msec); extern void edac_mc_reset_delay_period(unsigned long value); /*
diff --git a/drivers/edac/edac_device.c b/drivers/edac/edac_device.c index 19522c568aa5..e944dd9b3593 100644 --- a/drivers/edac/edac_device.c +++ b/drivers/edac/edac_device.c @@ -398,13 +398,13 @@ void edac_device_reset_delay_period(struct edac_device_ctl_info *edac_dev, { unsigned long jiffs = msecs_to_jiffies(value); - if (value == 1000) - jiffs = round_jiffies_relative(value); - edac_dev->poll_msec = value; edac_dev->delay = jiffs; - edac_mod_work(&edac_dev->work, jiffs); + if (value == 1000) + edac_mod_work(&edac_dev->work, round_jiffies_relative(jiffs)); + else + edac_mod_work(&edac_dev->work, jiffs); } int edac_device_alloc_index(void)