From patchwork Thu Aug 22 08:17:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aya Levin X-Patchwork-Id: 1151373 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=mellanox.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 46Dcq83JZ8z9s00 for ; Thu, 22 Aug 2019 18:18:12 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732217AbfHVISI (ORCPT ); Thu, 22 Aug 2019 04:18:08 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:46536 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726319AbfHVISI (ORCPT ); Thu, 22 Aug 2019 04:18:08 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from ayal@mellanox.com) with ESMTPS (AES256-SHA encrypted); 22 Aug 2019 11:18:02 +0300 Received: from dev-l-vrt-210.mtl.labs.mlnx (dev-l-vrt-210.mtl.labs.mlnx [10.134.210.1]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x7M8I2gV009936; Thu, 22 Aug 2019 11:18:02 +0300 Received: from dev-l-vrt-210.mtl.labs.mlnx (localhost [127.0.0.1]) by dev-l-vrt-210.mtl.labs.mlnx (8.15.2/8.15.2/Debian-8ubuntu1) with ESMTP id x7M8I2W6022032; Thu, 22 Aug 2019 11:18:02 +0300 Received: (from ayal@localhost) by dev-l-vrt-210.mtl.labs.mlnx (8.15.2/8.15.2/Submit) id x7M8I1Rv022031; Thu, 22 Aug 2019 11:18:01 +0300 From: Aya Levin To: "David S. Miller" Cc: Jiri Pirko , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Aya Levin Subject: [net] devlink: Add method for time-stamp on reporter's dump Date: Thu, 22 Aug 2019 11:17:51 +0300 Message-Id: <1566461871-21992-1-git-send-email-ayal@mellanox.com> X-Mailer: git-send-email 1.8.4.3 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 Acked-by: Jiri Pirko --- 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); From patchwork Thu Aug 22 11:05:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aya Levin X-Patchwork-Id: 1151495 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=mellanox.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 46DhXh3y6Dz9s3Z for ; Thu, 22 Aug 2019 21:05:56 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388005AbfHVLFy (ORCPT ); Thu, 22 Aug 2019 07:05:54 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:33432 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729922AbfHVLFy (ORCPT ); Thu, 22 Aug 2019 07:05:54 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from ayal@mellanox.com) with ESMTPS (AES256-SHA encrypted); 22 Aug 2019 14:05:49 +0300 Received: from dev-l-vrt-210.mtl.labs.mlnx (dev-l-vrt-210.mtl.labs.mlnx [10.134.210.1]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x7MB5n1N016291; Thu, 22 Aug 2019 14:05:49 +0300 Received: from dev-l-vrt-210.mtl.labs.mlnx (localhost [127.0.0.1]) by dev-l-vrt-210.mtl.labs.mlnx (8.15.2/8.15.2/Debian-8ubuntu1) with ESMTP id x7MB5nZx028572; Thu, 22 Aug 2019 14:05:49 +0300 Received: (from ayal@localhost) by dev-l-vrt-210.mtl.labs.mlnx (8.15.2/8.15.2/Submit) id x7MB5nDq028571; Thu, 22 Aug 2019 14:05:49 +0300 From: Aya Levin To: netdev@vger.kernel.org, Stephen Hemminger , Jiri Pirko Cc: Moshe Shemesh , Aya Levin Subject: [iproute2, master 2/2] devlink: Add a new time-stamp format for health reporter's dump Date: Thu, 22 Aug 2019 14:05:42 +0300 Message-Id: <1566471942-28529-3-git-send-email-ayal@mellanox.com> X-Mailer: git-send-email 1.8.4.3 In-Reply-To: <1566471942-28529-1-git-send-email-ayal@mellanox.com> References: <1566461871-21992-1-git-send-email-ayal@mellanox.com> <1566471942-28529-1-git-send-email-ayal@mellanox.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Introduce a new attribute representing a new time-stamp format: current time instead of jiffies. If the new attribute was received, translate the time-stamp accordingly. Fixes: 2f1242efe9d0 ("devlink: Add devlink health show command") Signed-off-by: Aya Levin Acked-by: Jiri Pirko --- devlink/devlink.c | 20 +++++++++++++++++++- include/uapi/linux/devlink.h | 2 ++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/devlink/devlink.c b/devlink/devlink.c index f1d9de8e151d..623d1b52c4ca 100644 --- a/devlink/devlink.c +++ b/devlink/devlink.c @@ -6197,6 +6197,22 @@ out: pr_out_str(dl, "last_dump_time", dump_time); } +static void pr_out_dump_report_timestamp(struct dl *dl, const struct nlattr *attr) +{ + char dump_date[HEALTH_REPORTER_TIMESTAMP_FMT_LEN]; + char dump_time[HEALTH_REPORTER_TIMESTAMP_FMT_LEN]; + struct timespec *ts = mnl_attr_get_payload(attr); + struct tm *tm; + + tm = localtime(&ts->tv_sec); + + strftime(dump_date, HEALTH_REPORTER_TIMESTAMP_FMT_LEN, "%Y-%m-%d", tm); + strftime(dump_time, HEALTH_REPORTER_TIMESTAMP_FMT_LEN, "%H:%M:%S", tm); + + pr_out_str(dl, "last_dump_date", dump_date); + pr_out_str(dl, "last_dump_time", dump_time); +} + static void pr_out_health(struct dl *dl, struct nlattr **tb_health) { struct nlattr *tb[DEVLINK_ATTR_MAX + 1] = {}; @@ -6228,7 +6244,9 @@ static void pr_out_health(struct dl *dl, struct nlattr **tb_health) mnl_attr_get_u64(tb[DEVLINK_ATTR_HEALTH_REPORTER_ERR_COUNT])); pr_out_u64(dl, "recover", mnl_attr_get_u64(tb[DEVLINK_ATTR_HEALTH_REPORTER_RECOVER_COUNT])); - if (tb[DEVLINK_ATTR_HEALTH_REPORTER_DUMP_TS]) + if (tb[DEVLINK_ATTR_HEALTH_REPORTER_DUMP_TSPEC]) + pr_out_dump_report_timestamp(dl, tb[DEVLINK_ATTR_HEALTH_REPORTER_DUMP_TSPEC]); + else if (tb[DEVLINK_ATTR_HEALTH_REPORTER_DUMP_TS]) pr_out_dump_reporter_format_logtime(dl, tb[DEVLINK_ATTR_HEALTH_REPORTER_DUMP_TS]); if (tb[DEVLINK_ATTR_HEALTH_REPORTER_GRACEFUL_PERIOD]) pr_out_u64(dl, "grace_period", diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h index fc195cbd66f4..3f8532711315 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,