* [net] devlink: Add method for time-stamp on reporter's dump
@ 2019-08-22 8:17 Aya Levin
2019-08-22 14:06 ` Andrew Lunn
0 siblings, 1 reply; 4+ messages in thread
From: Aya Levin @ 2019-08-22 8:17 UTC (permalink / raw)
To: David S. Miller; +Cc: Jiri Pirko, netdev, linux-kernel, Aya Levin
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.
Fixes: c8e1da0bf923 ("devlink: Add health report functionality")
Signed-off-by: Aya Levin <ayal@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
---
include/uapi/linux/devlink.h | 2 ++
net/core/devlink.c | 6 ++++++
2 files changed, 8 insertions(+)
diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h
index ffc993256527..4dd4e4e7b19b 100644
--- a/include/uapi/linux/devlink.h
+++ b/include/uapi/linux/devlink.h
@@ -348,6 +348,8 @@ enum devlink_attr {
DEVLINK_ATTR_PORT_PCI_PF_NUMBER, /* u16 */
DEVLINK_ATTR_PORT_PCI_VF_NUMBER, /* u16 */
+ DEVLINK_ATTR_HEALTH_REPORTER_DUMP_TSPEC,
+
/* add new attributes above here, update the policy in devlink.c */
__DEVLINK_ATTR_MAX,
diff --git a/net/core/devlink.c b/net/core/devlink.c
index d3dbb904bf3b..b26875c4329b 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -4577,6 +4577,7 @@ struct devlink_health_reporter {
bool auto_recover;
u8 health_state;
u64 dump_ts;
+ struct timespec dump_real_ts;
u64 error_count;
u64 recovery_count;
u64 last_recovery_ts;
@@ -4749,6 +4750,7 @@ static int devlink_health_do_dump(struct devlink_health_reporter *reporter,
goto dump_err;
reporter->dump_ts = jiffies;
+ reporter->dump_real_ts = ktime_to_timespec(ktime_get_real());
return 0;
@@ -4911,6 +4913,10 @@ devlink_nl_health_reporter_fill(struct sk_buff *msg,
jiffies_to_msecs(reporter->dump_ts),
DEVLINK_ATTR_PAD))
goto reporter_nest_cancel;
+ if (reporter->dump_fmsg &&
+ nla_put(msg, DEVLINK_ATTR_HEALTH_REPORTER_DUMP_TSPEC,
+ sizeof(reporter->dump_real_ts), &reporter->dump_real_ts))
+ goto reporter_nest_cancel;
nla_nest_end(msg, reporter_attr);
genlmsg_end(msg, hdr);
--
2.14.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [net] devlink: Add method for time-stamp on reporter's dump
2019-08-22 8:17 [net] devlink: Add method for time-stamp on reporter's dump Aya Levin
@ 2019-08-22 14:06 ` Andrew Lunn
2019-08-22 17:40 ` Ido Schimmel
0 siblings, 1 reply; 4+ messages in thread
From: Andrew Lunn @ 2019-08-22 14:06 UTC (permalink / raw)
To: Aya Levin; +Cc: David S. Miller, Jiri Pirko, netdev, linux-kernel
On Thu, Aug 22, 2019 at 11:17:51AM +0300, Aya Levin wrote:
> 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.
Hi Aya
Is this year 2038 safe? I don't know enough about this to answer the
question myself.
Thanks
Andrew
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [net] devlink: Add method for time-stamp on reporter's dump
2019-08-22 14:06 ` Andrew Lunn
@ 2019-08-22 17:40 ` Ido Schimmel
2019-08-22 19:11 ` Arnd Bergmann
0 siblings, 1 reply; 4+ messages in thread
From: Ido Schimmel @ 2019-08-22 17:40 UTC (permalink / raw)
To: Andrew Lunn, arnd
Cc: Aya Levin, David S. Miller, Jiri Pirko, netdev, linux-kernel
On Thu, Aug 22, 2019 at 04:06:35PM +0200, Andrew Lunn wrote:
> On Thu, Aug 22, 2019 at 11:17:51AM +0300, Aya Levin wrote:
> > 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.
>
> Hi Aya
>
> Is this year 2038 safe? I don't know enough about this to answer the
> question myself.
Hi Andrew,
Good point. 'struct timespec' is not considered year 2038 safe and
unfortunately I recently made the mistake of using it to communicate
timestamps to user space over netlink. :/ The code is still in net-next,
so I will fix it while I can.
Arnd, would it be acceptable to use 'struct __kernel_timespec' instead?
Thanks
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [net] devlink: Add method for time-stamp on reporter's dump
2019-08-22 17:40 ` Ido Schimmel
@ 2019-08-22 19:11 ` Arnd Bergmann
0 siblings, 0 replies; 4+ messages in thread
From: Arnd Bergmann @ 2019-08-22 19:11 UTC (permalink / raw)
To: Ido Schimmel
Cc: Andrew Lunn, Aya Levin, David S. Miller, Jiri Pirko, Networking,
Linux Kernel Mailing List
On Thu, Aug 22, 2019 at 7:40 PM Ido Schimmel <idosch@idosch.org> wrote:
> On Thu, Aug 22, 2019 at 04:06:35PM +0200, Andrew Lunn wrote:
> > On Thu, Aug 22, 2019 at 11:17:51AM +0300, Aya Levin wrote:
> > > 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.
> >
> > Is this year 2038 safe? I don't know enough about this to answer the
> > question myself.
>
> Good point. 'struct timespec' is not considered year 2038 safe and
> unfortunately I recently made the mistake of using it to communicate
> timestamps to user space over netlink. :/ The code is still in net-next,
> so I will fix it while I can.
>
> Arnd, would it be acceptable to use 'struct __kernel_timespec' instead?
The in-kernel representation should just use 'timespec64' if you need
separate seconds and nanoseconds, you can convert that to
__kernel_timespec while copying to user space.
However, please consider two other points:
- for simplicity, the general recommendation is to use 64-bit nanoseconds
without separate seconds for timestamps
- instead of CLOCK_REALTIME, you could use CLOCK_MONOTONIC
timestamps that are not affected by clock_settime() or leap second jumps.
Arnd
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-08-22 19:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-22 8:17 [net] devlink: Add method for time-stamp on reporter's dump Aya Levin
2019-08-22 14:06 ` Andrew Lunn
2019-08-22 17:40 ` Ido Schimmel
2019-08-22 19:11 ` Arnd Bergmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).