From patchwork Wed Mar 6 01:34:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 10840305 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 7B0AD17E0 for ; Wed, 6 Mar 2019 01:46:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 58A792D07F for ; Wed, 6 Mar 2019 01:46:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4D0B92D0A0; Wed, 6 Mar 2019 01:46:52 +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.9 required=2.0 tests=BAYES_00,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 5285D2D07F for ; Wed, 6 Mar 2019 01:46:51 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 49903211D56BA; Tue, 5 Mar 2019 17:46:51 -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=192.55.52.136; helo=mga12.intel.com; envelope-from=dan.j.williams@intel.com; receiver=linux-nvdimm@lists.01.org Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 4C67A211D56AB for ; Tue, 5 Mar 2019 17:46:49 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Mar 2019 17:46:48 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,446,1544515200"; d="scan'208";a="122969478" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by orsmga008.jf.intel.com with ESMTP; 05 Mar 2019 17:46:48 -0800 Subject: [ndctl PATCH 2/5] ndctl/dimm: Minimize data-transfer for init-labels From: Dan Williams To: linux-nvdimm@lists.01.org Date: Tue, 05 Mar 2019 17:34:10 -0800 Message-ID: <155183605011.191625.7927964225736910065.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <155183603979.191625.11689546261255336448.stgit@dwillia2-desk3.amr.corp.intel.com> References: <155183603979.191625.11689546261255336448.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-2-gc94f MIME-Version: 1.0 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: , Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP Currently init-labels implementation reads the entire namespace-label capacity, initializes just the namespace index, and then writes the entire label capacity. It turns out that DIMM label-area access methods can be exceedingly slow. For example, the time to read the entire label area on a single dimm: 2s, but the time to just read the index block space: 45ms. Signed-off-by: Dan Williams --- ndctl/dimm.c | 2 +- ndctl/lib/dimm.c | 53 +++++++++++++++++++++++++++++++++++++++++++++--- ndctl/lib/libndctl.sym | 1 + ndctl/libndctl.h | 1 + 4 files changed, 53 insertions(+), 4 deletions(-) diff --git a/ndctl/dimm.c b/ndctl/dimm.c index 5ff730f42a45..5edada678c9c 100644 --- a/ndctl/dimm.c +++ b/ndctl/dimm.c @@ -974,7 +974,7 @@ static int __action_init(struct ndctl_dimm *dimm, struct ndctl_cmd *cmd_read; int rc; - cmd_read = ndctl_dimm_read_labels(dimm); + cmd_read = ndctl_dimm_read_label_index(dimm); if (!cmd_read) return -ENXIO; diff --git a/ndctl/lib/dimm.c b/ndctl/lib/dimm.c index 22cf4e10b56c..9c5a34e542c3 100644 --- a/ndctl/lib/dimm.c +++ b/ndctl/lib/dimm.c @@ -370,14 +370,15 @@ static struct namespace_label *label_base(struct nvdimm_data *ndd) return (struct namespace_label *) base; } -static void init_ndd(struct nvdimm_data *ndd, struct ndctl_cmd *cmd_read) +static void init_ndd(struct nvdimm_data *ndd, struct ndctl_cmd *cmd_read, + struct ndctl_cmd *cmd_size) { ndctl_cmd_unref(ndd->cmd_read); memset(ndd, 0, sizeof(*ndd)); ndd->cmd_read = cmd_read; ndctl_cmd_ref(cmd_read); ndd->data = cmd_read->iter.total_buf; - ndd->config_size = cmd_read->iter.total_xfer; + ndd->config_size = cmd_size->get_size->config_size; ndd->ns_current = -1; ndd->ns_next = -1; } @@ -490,6 +491,52 @@ NDCTL_EXPORT int ndctl_dimm_validate_labels(struct ndctl_dimm *dimm) return label_validate(&dimm->ndd); } +NDCTL_EXPORT struct ndctl_cmd *ndctl_dimm_read_label_index(struct ndctl_dimm *dimm) +{ + struct ndctl_bus *bus = ndctl_dimm_get_bus(dimm); + struct ndctl_cmd *cmd_size, *cmd_read; + struct nvdimm_data *ndd = &dimm->ndd; + int rc; + + rc = ndctl_bus_wait_probe(bus); + if (rc < 0) + return NULL; + + cmd_size = ndctl_dimm_cmd_new_cfg_size(dimm); + if (!cmd_size) + return NULL; + rc = ndctl_cmd_submit_xlat(cmd_size); + if (rc < 0) + goto out_size; + + cmd_read = ndctl_dimm_cmd_new_cfg_read(cmd_size); + if (!cmd_read) + goto out_size; + /* + * To calc the namespace index size use the minimum label + * size which corresponds to the maximum namespace index size. + */ + init_ndd(ndd, cmd_read, cmd_size); + ndd->nslabel_size = 128; + rc = ndctl_cmd_cfg_read_set_extent(cmd_read, + sizeof_namespace_index(ndd) * 2, 0); + if (rc < 0) + goto out_size; + + rc = ndctl_cmd_submit_xlat(cmd_read); + if (rc < 0) + goto out_read; + ndctl_cmd_unref(cmd_size); + + return cmd_read; + + out_read: + ndctl_cmd_unref(cmd_read); + out_size: + ndctl_cmd_unref(cmd_size); + return NULL; +} + NDCTL_EXPORT struct ndctl_cmd *ndctl_dimm_read_labels(struct ndctl_dimm *dimm) { struct ndctl_bus *bus = ndctl_dimm_get_bus(dimm); @@ -515,7 +562,7 @@ NDCTL_EXPORT struct ndctl_cmd *ndctl_dimm_read_labels(struct ndctl_dimm *dimm) goto out_read; ndctl_cmd_unref(cmd_size); - init_ndd(&dimm->ndd, cmd_read); + init_ndd(&dimm->ndd, cmd_read, cmd_size); return cmd_read; diff --git a/ndctl/lib/libndctl.sym b/ndctl/lib/libndctl.sym index e79b31c71ae6..3cd431a90e55 100644 --- a/ndctl/lib/libndctl.sym +++ b/ndctl/lib/libndctl.sym @@ -411,4 +411,5 @@ global: ndctl_bus_poll_scrub_completion; ndctl_cmd_cfg_read_set_extent; ndctl_cmd_cfg_write_set_extent; + ndctl_dimm_read_label_index; } LIBNDCTL_19; diff --git a/ndctl/libndctl.h b/ndctl/libndctl.h index 310814fe924c..8aa4b8bbe6c2 100644 --- a/ndctl/libndctl.h +++ b/ndctl/libndctl.h @@ -308,6 +308,7 @@ struct ndctl_cmd *ndctl_dimm_cmd_new_cfg_read(struct ndctl_cmd *cfg_size); struct ndctl_cmd *ndctl_dimm_cmd_new_cfg_write(struct ndctl_cmd *cfg_read); int ndctl_dimm_zero_labels(struct ndctl_dimm *dimm); struct ndctl_cmd *ndctl_dimm_read_labels(struct ndctl_dimm *dimm); +struct ndctl_cmd *ndctl_dimm_read_label_index(struct ndctl_dimm *dimm); int ndctl_dimm_validate_labels(struct ndctl_dimm *dimm); enum ndctl_namespace_version { NDCTL_NS_VERSION_1_1,