From patchwork Fri Feb 15 06:38:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dexuan Cui X-Patchwork-Id: 10814253 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0444F17D5 for ; Fri, 15 Feb 2019 06:38:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB0662E8F4 for ; Fri, 15 Feb 2019 06:38:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CEDEF2E98E; Fri, 15 Feb 2019 06:38:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CE48A2E8F4 for ; Fri, 15 Feb 2019 06:38:30 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 71707208AE363; Thu, 14 Feb 2019 22:38:30 -0800 (PST) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=40.107.132.132; helo=apc01-pu1-obe.outbound.protection.outlook.com; envelope-from=decui@microsoft.com; receiver=linux-nvdimm@lists.01.org Received: from APC01-PU1-obe.outbound.protection.outlook.com (mail-eopbgr1320132.outbound.protection.outlook.com [40.107.132.132]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id D9DCD202E5300 for ; Thu, 14 Feb 2019 22:38:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Afn6JxnSwzE08Ila6HCAPsH1hzH4CjQkVzas6ODtTD8=; b=AR/iiykza7fPZKxuFo/nQ+o8JBndoG4cBBTEjUOzR8Y6b4dZR80zAYDfWds8bNbO7+ODbL/hS0/hIat/7c3xXI5hkOXINcy2xaeW6sDQvYbG2qTwKz1MhxMqsZvY0U41zKugcIQ5/udLluy+LGQya6ABJvrSWq+NjyPinm/yY1o= Received: from PU1P153MB0169.APCP153.PROD.OUTLOOK.COM (10.170.189.13) by PU1P153MB0172.APCP153.PROD.OUTLOOK.COM (10.170.189.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1643.1; Fri, 15 Feb 2019 06:38:25 +0000 Received: from PU1P153MB0169.APCP153.PROD.OUTLOOK.COM ([fe80::7822:a20:e63c:de2f]) by PU1P153MB0169.APCP153.PROD.OUTLOOK.COM ([fe80::7822:a20:e63c:de2f%9]) with mapi id 15.20.1643.008; Fri, 15 Feb 2019 06:38:25 +0000 From: Dexuan Cui To: Dave Jiang , Vishal Verma , Dan Williams , "linux-nvdimm@lists.01.org" Subject: [ndctl PATCH] ndctl, monitor: support NVDIMM_FAMILY_HYPERV Thread-Topic: [ndctl PATCH] ndctl, monitor: support NVDIMM_FAMILY_HYPERV Thread-Index: AdTE+PQoL7B6mC1VRhyS4CgRoaT3/Q== Date: Fri, 15 Feb 2019 06:38:24 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=True; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Owner=decui@microsoft.com; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2019-02-15T06:38:22.7998817Z; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Name=General; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Application=Microsoft Azure Information Protection; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ActionId=3a5129d1-91c6-4f36-95f8-c94f4c36f46e; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Extended_MSFT_Method=Automatic x-originating-ip: [2601:600:a280:1760:bc23:4518:225:7204] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 7007078f-701f-423b-012b-08d693103006 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600110)(711020)(4605085)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:PU1P153MB0172; x-ms-traffictypediagnostic: PU1P153MB0172: x-microsoft-exchange-diagnostics: =?us-ascii?Q?1; PU1P153MB0172; 23:RQB3s93MsS8YWO+t9iAQqGLcsxpDwfGGltw4yTzuK?= mdWFmR9e6IfTaQyuQoTIVRI/NcABLZQUJ9tReJb/9wrIPyUvSKyxVL7t1HcnP7mqXGZKEtIIqiZDw52fZvNt8zC1CpqZsqqrl/XAdcjLAyrhOlx1SgzJbnph4HK4fU1WJEv9zk5KUxGKSS9G/ulxb2JU+u76Ysng/XkLrJMhPmOvXfOqWVu8+htDp6POoQVqFdi4lPrV0DypA1XkEBgnNjn1iTBgevp9sCiCGXx+CbQ8oDnSxgcFFRJAX56Rkfe9imMA7b4X4luSdILesvGSo2EhvIHYKoXTo0vk1ag/Q+vdEYqSZzTX+7WFdrhcoUk2OTpjp5oFhgaYSptsJfhV9qXowQKC6XKZYNc6Rm1p9W4lghqV1FogRHXvGYj3eUnc4M/x/H12iZr7MGKKYO554cQbzJVaPAojv4hjgQUqnsn/J1LbIx0swIbUcfIMY2LfoLOTqQV4B64t54qYyI2XP+E8Ztb/kKYTskRilk4HrQvPUFb36+NEvCzG5vh8qyvBOm03WqI67lNBs0ONTdmbQmjXh17AB7tRefp/pB1/U60a9w4exzdDJotUPDeW3T7Z8okhlcgXLrcXEXO691xC1GCoIGqrcFdAECzNORrEr4XoCkrz7JUoFijVz1Hqghn/HHxwAc7CQPby54YULIj+gP32Wd52dj1PZalhpkgOH8v3lrIScrqf/XTqSerCuURNm8sG+/Gyri+M9B3Jej3uaPtmTd0Qqv4NeNfCtk3fYsI2ubRC/NLZQ69t2a21qAKijyiWVjb5zipnd3QpmDwLBnRwVXIVfDbQJaDZ0vclDIo9DHN5ccJL0rRZYxq9ZqlCItSl0XuUkwxaOMHg4etfdWN5D1E8/JBjN6PX0n8cXoyWQK4xaPiQ9e1XeEcLl+Zj1lR4dAUbb/0fOHKpFChr92ZAZb+sTdHoMt8wHnW1lB3gmweLIe7p/kdhAv5Z/21UDNnK0a2KapylTALmSjM7HaUm5mvlS2ohif87d6T100bryCtHo3WJQMAQn3L2B7ccztB4wnbul2CFVtgMW3uvx+C7g9RsnZ5qth7811ByXmyL6In9ostqRDS2LQb457JPVQJG7UdC51HrsfanKGdiThik7q3x2momVkID1Z0VAKwsb4m+nKI76VLov5out7xLYi0aI/PRdFhepvbvSUQaqGz x-microsoft-antispam-prvs: x-forefront-prvs: 09497C15EB x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(366004)(346002)(396003)(376002)(136003)(39860400002)(189003)(199004)(110136005)(55016002)(8990500004)(97736004)(476003)(186003)(22452003)(4326008)(10290500003)(33656002)(316002)(478600001)(6116002)(105586002)(25786009)(305945005)(7696005)(7736002)(6346003)(9686003)(68736007)(53936002)(106356001)(74316002)(102836004)(99286004)(8676002)(2501003)(71190400001)(71200400001)(81156014)(81166006)(14444005)(256004)(46003)(6506007)(2906002)(10090500001)(6436002)(8936002)(86612001)(107886003)(486006)(14454004)(86362001); DIR:OUT; SFP:1102; SCL:1; SRVR:PU1P153MB0172; H:PU1P153MB0169.APCP153.PROD.OUTLOOK.COM; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=decui@microsoft.com; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: vQ4eLDwd3Y5A6gB51Y4HcuGu0cFjN/4LmrUDe4JXep/ZBlltpCrc6Gw8WeOGZb39eb3Q73tO8ZUvgCAmxv23NmxrQAgLHsXYyvEQNGirHiteO28eUEmjniKmraDOYkY+Renmh03cMhk0kJzcQwcmJH5++w9CzxXXItS9TJjBe2AUfmND0wuovZdpfS7T8aIMpqQ3kj+h1qGSTMgMsaP1Z33n5CZTFT6EWzBS0R4NWkOllz2TUxCJDCpPSKjb+TycbuxgYWeUGhqebLA4+Dq/yESZyBfJMfjC2hgGx9BN4cS/BtH+BMck0Jl1kZd5JLGXUgAzREHqiBRpNjF6KLrrqQZKwPGC6ZYJbbNaLy6FjUk8FHGSPEKgQCLBoclZSjRBzsLb0z89IJNWVEF0Pdc9mrkhdIYYb8TntEHTesw/eVA= MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7007078f-701f-423b-012b-08d693103006 X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Feb 2019 06:38:24.9835 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: PU1P153MB0172 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael Kelley Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP Currently "ndctl monitor" fails for NVDIMM_FAMILY_HYPERV due to "no smart support". Actually NVDIMM_FAMILY_HYPERV doesn't use ND_CMD_SMART to get the health info. Instead, it uses ND_CMD_CALL, so the checking here can't apply, and NVDIMM_FAMILY_HYPERV doesn't support threshold alarms. Let's skip the unnecessary checking for NVDIMM_FAMILY_HYPERV. With the patch, when an error happens, we can log it with such a message: {"timestamp":"1550209474.683237420","pid":3874,"event": {"dimm-spares-remaining":false,"dimm-media-temperature":false, "dimm-controller-temperature":false,"dimm-health-state":true, "dimm-unclean-shutdown":false},"dimm":{"dev":"nmem1", "id":"04d5-01-1701-01000000","handle":1,"phys_id":0,"health": {"health_state":"critical","shutdown_count":8}}} Here the meaning info is: "health": {"health_state":"critical","shutdown_count":8} Signed-off-by: Dexuan Cui Reviewed-by: Johannes Thumshirn --- ndctl/lib/libndctl.c | 5 +++++ ndctl/lib/libndctl.sym | 1 + ndctl/libndctl.h | 1 + ndctl/monitor.c | 33 ++++++++++++++++++++++++++------- 4 files changed, 33 insertions(+), 7 deletions(-) diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c index 48bdb27..1186579 100644 --- a/ndctl/lib/libndctl.c +++ b/ndctl/lib/libndctl.c @@ -1550,6 +1550,11 @@ NDCTL_EXPORT struct ndctl_dimm *ndctl_dimm_get_next(struct ndctl_dimm *dimm) return list_next(&bus->dimms, dimm, list); } +NDCTL_EXPORT unsigned long ndctl_dimm_get_cmd_family(struct ndctl_dimm *dimm) +{ + return dimm->cmd_family; +} + NDCTL_EXPORT unsigned int ndctl_dimm_get_handle(struct ndctl_dimm *dimm) { return dimm->handle; diff --git a/ndctl/lib/libndctl.sym b/ndctl/lib/libndctl.sym index cb9f769..470e895 100644 --- a/ndctl/lib/libndctl.sym +++ b/ndctl/lib/libndctl.sym @@ -38,6 +38,7 @@ global: ndctl_bus_wait_probe; ndctl_dimm_get_first; ndctl_dimm_get_next; + ndctl_dimm_get_cmd_family; ndctl_dimm_get_handle; ndctl_dimm_get_phys_id; ndctl_dimm_get_vendor; diff --git a/ndctl/libndctl.h b/ndctl/libndctl.h index 0debdb6..cb5a8fc 100644 --- a/ndctl/libndctl.h +++ b/ndctl/libndctl.h @@ -145,6 +145,7 @@ struct ndctl_dimm *ndctl_dimm_get_next(struct ndctl_dimm *dimm); for (dimm = ndctl_dimm_get_first(bus); \ dimm != NULL; \ dimm = ndctl_dimm_get_next(dimm)) +unsigned long ndctl_dimm_get_cmd_family(struct ndctl_dimm *dimm); unsigned int ndctl_dimm_get_handle(struct ndctl_dimm *dimm); unsigned short ndctl_dimm_get_phys_id(struct ndctl_dimm *dimm); unsigned short ndctl_dimm_get_vendor(struct ndctl_dimm *dimm); diff --git a/ndctl/monitor.c b/ndctl/monitor.c index 43b2abe..6adc305 100644 --- a/ndctl/monitor.c +++ b/ndctl/monitor.c @@ -265,31 +265,50 @@ static bool filter_region(struct ndctl_region *region, return true; } -static void filter_dimm(struct ndctl_dimm *dimm, struct util_filter_ctx *fctx) +static bool ndctl_dimm_test_and_enable_notification(struct ndctl_dimm *dimm) { - struct monitor_dimm *mdimm; - struct monitor_filter_arg *mfa = fctx->monitor; const char *name = ndctl_dimm_get_devname(dimm); + /* + * Hyper-V Virtual NVDIMM doesn't use ND_CMD_SMART to get the health + * info. Instead, it uses ND_CMD_CALL, so the checking here can't + * apply, and it doesn't support threshold alarms. + */ + if (ndctl_dimm_get_cmd_family(dimm) == NVDIMM_FAMILY_HYPERV) + return true; + if (!ndctl_dimm_is_cmd_supported(dimm, ND_CMD_SMART)) { err(&monitor, "%s: no smart support\n", name); - return; + return false; } if (!ndctl_dimm_is_cmd_supported(dimm, ND_CMD_SMART_THRESHOLD)) { err(&monitor, "%s: no smart threshold support\n", name); - return; + return false; } if (!ndctl_dimm_is_flag_supported(dimm, ND_SMART_ALARM_VALID)) { err(&monitor, "%s: smart alarm invalid\n", name); - return; + return false; } if (enable_dimm_supported_threshold_alarms(dimm)) { err(&monitor, "%s: enable supported threshold alarms failed\n", name); - return; + return false; } + return true; +} + +static void filter_dimm(struct ndctl_dimm *dimm, struct util_filter_ctx *fctx) +{ + struct monitor_dimm *mdimm; + struct monitor_filter_arg *mfa = fctx->monitor; + const char *name = ndctl_dimm_get_devname(dimm); + + + if (!ndctl_dimm_test_and_enable_notification(dimm)) + return; + mdimm = calloc(1, sizeof(struct monitor_dimm)); if (!mdimm) { err(&monitor, "%s: calloc for monitor dimm failed\n", name);