[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1752768442-264413-3-git-send-email-tariqt@nvidia.com>
Date: Thu, 17 Jul 2025 19:07:19 +0300
From: Tariq Toukan <tariqt@...dia.com>
To: Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>, Andrew Lunn <andrew+netdev@...n.ch>, "David
S. Miller" <davem@...emloft.net>, Jiri Pirko <jiri@...nulli.us>, Jiri Pirko
<jiri@...dia.com>
CC: Saeed Mahameed <saeed@...nel.org>, Gal Pressman <gal@...dia.com>, "Leon
Romanovsky" <leon@...nel.org>, Shahar Shitrit <shshitrit@...dia.com>, "Donald
Hunter" <donald.hunter@...il.com>, Jonathan Corbet <corbet@....net>, "Brett
Creeley" <brett.creeley@....com>, Michael Chan <michael.chan@...adcom.com>,
Pavan Chebbi <pavan.chebbi@...adcom.com>, Cai Huoqing
<cai.huoqing@...ux.dev>, Tony Nguyen <anthony.l.nguyen@...el.com>, "Przemek
Kitszel" <przemyslaw.kitszel@...el.com>, Sunil Goutham
<sgoutham@...vell.com>, Linu Cherian <lcherian@...vell.com>, Geetha sowjanya
<gakula@...vell.com>, Jerin Jacob <jerinj@...vell.com>, hariprasad
<hkelam@...vell.com>, "Subbaraya Sundeep" <sbhatta@...vell.com>, Saeed
Mahameed <saeedm@...dia.com>, "Tariq Toukan" <tariqt@...dia.com>, Mark Bloch
<mbloch@...dia.com>, Ido Schimmel <idosch@...dia.com>, Petr Machata
<petrm@...dia.com>, Manish Chopra <manishc@...vell.com>,
<netdev@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<linux-doc@...r.kernel.org>, <intel-wired-lan@...ts.osuosl.org>,
<linux-rdma@...r.kernel.org>
Subject: [PATCH net-next 2/5] devlink: Move health reporter recovery abort logic to a separate function
From: Shahar Shitrit <shshitrit@...dia.com>
Extract the health reporter recovery abort logic into a separate
function devlink_health_recover_abort().
The function encapsulates the conditions for aborting recovery:
- When auto-recovery is disabled
- When previous error wasn't recovered
- When within the grace period after last recovery
Signed-off-by: Shahar Shitrit <shshitrit@...dia.com>
Reviewed-by: Jiri Pirko <jiri@...dia.com>
Reviewed-by: Carolina Jubran <cjubran@...dia.com>
Signed-off-by: Tariq Toukan <tariqt@...dia.com>
---
net/devlink/health.c | 31 +++++++++++++++++++++++--------
1 file changed, 23 insertions(+), 8 deletions(-)
diff --git a/net/devlink/health.c b/net/devlink/health.c
index ba144b7426fa..9d0d4a9face7 100644
--- a/net/devlink/health.c
+++ b/net/devlink/health.c
@@ -586,12 +586,33 @@ static int devlink_health_do_dump(struct devlink_health_reporter *reporter,
return err;
}
+static bool
+devlink_health_recover_abort(struct devlink_health_reporter *reporter,
+ enum devlink_health_reporter_state prev_state)
+{
+ unsigned long recover_ts_threshold;
+
+ if (!reporter->auto_recover)
+ return false;
+
+ /* abort if the previous error wasn't recovered */
+ if (prev_state != DEVLINK_HEALTH_REPORTER_STATE_HEALTHY)
+ return true;
+
+ recover_ts_threshold = reporter->last_recovery_ts +
+ msecs_to_jiffies(reporter->graceful_period);
+ if (reporter->last_recovery_ts && reporter->recovery_count &&
+ time_is_after_jiffies(recover_ts_threshold))
+ return true;
+
+ return false;
+}
+
int devlink_health_report(struct devlink_health_reporter *reporter,
const char *msg, void *priv_ctx)
{
enum devlink_health_reporter_state prev_health_state;
struct devlink *devlink = reporter->devlink;
- unsigned long recover_ts_threshold;
int ret;
/* write a log message of the current error */
@@ -602,13 +623,7 @@ int devlink_health_report(struct devlink_health_reporter *reporter,
reporter->health_state = DEVLINK_HEALTH_REPORTER_STATE_ERROR;
devlink_recover_notify(reporter, DEVLINK_CMD_HEALTH_REPORTER_RECOVER);
- /* abort if the previous error wasn't recovered */
- recover_ts_threshold = reporter->last_recovery_ts +
- msecs_to_jiffies(reporter->graceful_period);
- if (reporter->auto_recover &&
- (prev_health_state != DEVLINK_HEALTH_REPORTER_STATE_HEALTHY ||
- (reporter->last_recovery_ts && reporter->recovery_count &&
- time_is_after_jiffies(recover_ts_threshold)))) {
+ if (devlink_health_recover_abort(reporter, prev_health_state)) {
trace_devlink_health_recover_aborted(devlink,
reporter->ops->name,
reporter->health_state,
--
2.31.1
Powered by blists - more mailing lists