Skip to content

Commit d279505

Browse files
ayalevin123davem330
authored andcommitted
devlink: Add method for time-stamp on reporter's dump
When setting the dump's time-stamp, use ktime_get_real in addition to jiffies. This simplifies the user space implementation and bypasses some inconsistent behavior with translating jiffies to current time. The time taken is transformed into nsec, to comply with y2038 issue. Fixes: c8e1da0 ("devlink: Add health report functionality") Signed-off-by: Aya Levin <[email protected]> Acked-by: Jiri Pirko <[email protected]> Acked-by: Arnd Bergmann <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 40a1dce commit d279505

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

include/uapi/linux/devlink.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,7 @@ enum devlink_attr {
421421

422422
DEVLINK_ATTR_RELOAD_FAILED, /* u8 0 or 1 */
423423

424+
DEVLINK_ATTR_HEALTH_REPORTER_DUMP_TS_NS, /* u64 */
424425
/* add new attributes above here, update the policy in devlink.c */
425426

426427
__DEVLINK_ATTR_MAX,

net/core/devlink.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4618,6 +4618,7 @@ struct devlink_health_reporter {
46184618
bool auto_recover;
46194619
u8 health_state;
46204620
u64 dump_ts;
4621+
u64 dump_real_ts;
46214622
u64 error_count;
46224623
u64 recovery_count;
46234624
u64 last_recovery_ts;
@@ -4790,6 +4791,7 @@ static int devlink_health_do_dump(struct devlink_health_reporter *reporter,
47904791
goto dump_err;
47914792

47924793
reporter->dump_ts = jiffies;
4794+
reporter->dump_real_ts = ktime_get_real_ns();
47934795

47944796
return 0;
47954797

@@ -4952,6 +4954,10 @@ devlink_nl_health_reporter_fill(struct sk_buff *msg,
49524954
jiffies_to_msecs(reporter->dump_ts),
49534955
DEVLINK_ATTR_PAD))
49544956
goto reporter_nest_cancel;
4957+
if (reporter->dump_fmsg &&
4958+
nla_put_u64_64bit(msg, DEVLINK_ATTR_HEALTH_REPORTER_DUMP_TS_NS,
4959+
reporter->dump_real_ts, DEVLINK_ATTR_PAD))
4960+
goto reporter_nest_cancel;
49554961

49564962
nla_nest_end(msg, reporter_attr);
49574963
genlmsg_end(msg, hdr);

0 commit comments

Comments
 (0)