> -----Original Message-----
> From: David Ahern <dsah...@gmail.com>
> Sent: Tuesday, October 06, 2020 10:56 PM
> To: Keller, Jacob E <jacob.e.kel...@intel.com>; netdev@vger.kernel.org; Jakub
> Kicinski <k...@kernel.org>; Shannon Nelson <snel...@pensando.io>
> Subject: Re: [iproute2-next v2 1/1] devlink: display elapsed time during flash
> update
> 
> On 9/30/20 4:40 PM, Jacob Keller wrote:
> > @@ -3124,12 +3140,19 @@ static int cmd_dev_flash_status_cb(const struct
> nlmsghdr *nlh, void *data)
> >             done =
> mnl_attr_get_u64(tb[DEVLINK_ATTR_FLASH_UPDATE_STATUS_DONE]);
> >     if (tb[DEVLINK_ATTR_FLASH_UPDATE_STATUS_TOTAL])
> >             total =
> mnl_attr_get_u64(tb[DEVLINK_ATTR_FLASH_UPDATE_STATUS_TOTAL]);
> > +   if (tb[DEVLINK_ATTR_FLASH_UPDATE_STATUS_TIMEOUT])
> > +           ctx->status_msg_timeout =
> mnl_attr_get_u64(tb[DEVLINK_ATTR_FLASH_UPDATE_STATUS_TIMEOUT]);
> > +   else
> > +           ctx->status_msg_timeout = 0;
> >
> >     if (!nullstrcmp(msg, ctx->last_msg) &&
> >         !nullstrcmp(component, ctx->last_component) &&
> >         ctx->last_pc && ctx->not_first) {
> >             pr_out_tty("\b\b\b\b\b"); /* clean percentage */
> >     } else {
> > +           /* only update the last status timestamp if the message changed
> */
> > +           gettimeofday(&ctx->time_of_last_status, NULL);
> 
> gettimeofday/REALCLOCK should not be used for measuring time differences.
> 

Ah. Good point. This should use CLOCK_MONOTONIC instead, right?

> > +
> >             if (ctx->not_first)
> >                     pr_out("\n");
> >             if (component) {
> > @@ -3155,11 +3178,72 @@ static int cmd_dev_flash_status_cb(const struct
> nlmsghdr *nlh, void *data)
> >     return MNL_CB_STOP;
> >  }
> >
> > +static void cmd_dev_flash_time_elapsed(struct cmd_dev_flash_status_ctx
> *ctx)
> > +{
> > +   struct timeval now, res;
> > +
> > +   gettimeofday(&now, NULL);
> > +   timersub(&now, &ctx->time_of_last_status, &res);
> > +

Reply via email to