Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3450859imm; Tue, 29 May 2018 07:29:22 -0700 (PDT) X-Google-Smtp-Source: ADUXVKK/LngsHDBEMpGbOHxoQeixP3YShdD7yJX9ckjwWkhhHHBleoUNGLxf8dldr856GpJtoB6N X-Received: by 2002:a62:5004:: with SMTP id e4-v6mr5538155pfb.71.1527604162758; Tue, 29 May 2018 07:29:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527604162; cv=none; d=google.com; s=arc-20160816; b=PIIFTlpUB3GW7UqLnegEE/XaD5nQZR15mNruEavr1kk9gd3PM5s9jz2JYj0P74zLvE Xg3exDL4DfyI8rTN11YBRIlTalsawp6kiGI1+qs5TEhh5v5dIZnfMaqlMSlG+4QJEU/Q F/EmCRbln/JJEyA78ZIPlSaBW8qgWl+vLhyjldzFD8UVDwHm+B5zu76SUlrY7hLxVEHg h+BEy0J+PrtQeSqnA9jeStki49WiZb0yq3LKJD6V7WRjA+uA10kZp45ft88TnsrUTAig n0Ikx9l9Irk7yz+WgoW/LTCfD2PjehrFitgYHrGK2BTUvpMKWMuvvBLavyAp8E6d8jne AFnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=j1buwwYz2njjmuLon2rfy5kiGFAinzU7hQ5aDbiG5eo=; b=Cds5R1lSKOPVaqISIBN1Q+bmEQHbgd6dxUJZORhQoMgXnHMnZN//yHrTXVJSfHO7t5 IcHStsBsGTSaaB9o6sFXz85IvPNPV5cZpBicikohAIG4Yar5vdMvfm5S18aXSXWL3DiH 1KvuVRDoLtUiOMD4KKcASy2VDCg2yoqCwuBswK0ftCYhK/UWmJy5pqeSdAqwn5Ewpk3J qHlteBWGhDiNXoY9fyTtJjjkVzVub+M/yp2NNeOR5snl/aXv39v2SlvNOAE7fC7V63eM QRBbXugq5UiZKUc9BYniW76bEPR067W6OFT80JoU5Jc50phG7KKg6EpSSKZdgZDv8lch L+FA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p27-v6si32904211pfd.76.2018.05.29.07.29.08; Tue, 29 May 2018 07:29:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935092AbeE2O1R (ORCPT + 99 others); Tue, 29 May 2018 10:27:17 -0400 Received: from smtp4.ccs.ornl.gov ([160.91.203.40]:38208 "EHLO smtp4.ccs.ornl.gov" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935173AbeE2OWY (ORCPT ); Tue, 29 May 2018 10:22:24 -0400 Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id D9E9F10052C4; Tue, 29 May 2018 10:22:06 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id D751FBF; Tue, 29 May 2018 10:22:06 -0400 (EDT) From: James Simmons To: Greg Kroah-Hartman , devel@driverdev.osuosl.org, Andreas Dilger , Oleg Drokin , NeilBrown Cc: Linux Kernel Mailing List , Lustre Development List , Amir Shehata , James Simmons Subject: [PATCH v2 09/25] staging: lustre: libcfs: add cpu distance handling Date: Tue, 29 May 2018 10:21:49 -0400 Message-Id: <1527603725-30560-10-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1527603725-30560-1-git-send-email-jsimmons@infradead.org> References: <1527603725-30560-1-git-send-email-jsimmons@infradead.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Amir Shehata Add functionality to calculate the distance between two CPTs. Expose those distance in debugfs so people deploying a setup can debug what is being created for CPTs. Signed-off-by: Amir Shehata Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7734 Reviewed-on: http://review.whamcloud.com/18916 Reviewed-by: Olaf Weber Reviewed-by: Doug Oucharek Signed-off-by: James Simmons --- Changelog: v1) Initial patch v2) Rebased patch to handle recent libcfs changes .../lustre/include/linux/libcfs/libcfs_cpu.h | 31 +++++++++++ drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c | 61 ++++++++++++++++++++++ 2 files changed, 92 insertions(+) diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h index 487625d..d5237d0 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h @@ -87,6 +87,8 @@ struct cfs_cpu_partition { cpumask_var_t cpt_cpumask; /* nodes mask for this partition */ nodemask_t *cpt_nodemask; + /* NUMA distance between CPTs */ + unsigned int *cpt_distance; /* spread rotor for NUMA allocator */ unsigned int cpt_spread_rotor; }; @@ -97,6 +99,8 @@ struct cfs_cpt_table { #ifdef CONFIG_SMP /* spread rotor for NUMA allocator */ unsigned int ctb_spread_rotor; + /* maximum NUMA distance between all nodes in table */ + unsigned int ctb_distance; /* # of CPU partitions */ unsigned int ctb_nparts; /* partitions tables */ @@ -134,6 +138,10 @@ struct cfs_cpt_table { */ int cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len); /** + * print distance information of cpt-table + */ +int cfs_cpt_distance_print(struct cfs_cpt_table *cptab, char *buf, int len); +/** * return total number of CPU partitions in \a cptab */ int @@ -163,6 +171,10 @@ struct cfs_cpt_table { */ int cfs_cpt_of_node(struct cfs_cpt_table *cptab, int node); /** + * NUMA distance between \a cpt1 and \a cpt2 in \a cptab + */ +unsigned int cfs_cpt_distance(struct cfs_cpt_table *cptab, int cpt1, int cpt2); +/** * bind current thread on a CPU-partition \a cpt of \a cptab */ int cfs_cpt_bind(struct cfs_cpt_table *cptab, int cpt); @@ -257,6 +269,19 @@ static inline int cfs_cpt_table_print(struct cfs_cpt_table *cptab, return rc; } +static inline int cfs_cpt_distance_print(struct cfs_cpt_table *cptab, + char *buf, int len) +{ + int rc; + + rc = snprintf(buf, len, "0\t: 0:1\n"); + len -= rc; + if (len <= 0) + return -EFBIG; + + return rc; +} + static inline cpumask_var_t * cfs_cpt_cpumask(struct cfs_cpt_table *cptab, int cpt) { @@ -287,6 +312,12 @@ static inline int cfs_cpt_table_print(struct cfs_cpt_table *cptab, return &cptab->ctb_nodemask; } +static inline unsigned int cfs_cpt_distance(struct cfs_cpt_table *cptab, + int cpt1, int cpt2) +{ + return 1; +} + static inline int cfs_cpt_set_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu) { diff --git a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c index f616073..2a74e51 100644 --- a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c +++ b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c @@ -124,6 +124,15 @@ struct cfs_cpt_table * GFP_NOFS); if (!part->cpt_nodemask) goto failed_setting_ctb_parts; + + part->cpt_distance = kvmalloc_array(cptab->ctb_nparts, + sizeof(part->cpt_distance[0]), + GFP_KERNEL); + if (!part->cpt_distance) + goto failed_setting_ctb_parts; + + memset(part->cpt_distance, -1, + cptab->ctb_nparts * sizeof(part->cpt_distance[0])); } return cptab; @@ -134,6 +143,7 @@ struct cfs_cpt_table * kfree(part->cpt_nodemask); free_cpumask_var(part->cpt_cpumask); + kvfree(part->cpt_distance); } kvfree(cptab->ctb_parts); @@ -164,6 +174,7 @@ struct cfs_cpt_table * kfree(part->cpt_nodemask); free_cpumask_var(part->cpt_cpumask); + kvfree(part->cpt_distance); } kvfree(cptab->ctb_parts); @@ -218,6 +229,44 @@ struct cfs_cpt_table * } EXPORT_SYMBOL(cfs_cpt_table_print); +int cfs_cpt_distance_print(struct cfs_cpt_table *cptab, char *buf, int len) +{ + char *tmp = buf; + int rc; + int i; + int j; + + for (i = 0; i < cptab->ctb_nparts; i++) { + if (len <= 0) + goto err; + + rc = snprintf(tmp, len, "%d\t:", i); + len -= rc; + + if (len <= 0) + goto err; + + tmp += rc; + for (j = 0; j < cptab->ctb_nparts; j++) { + rc = snprintf(tmp, len, " %d:%d", j, + cptab->ctb_parts[i].cpt_distance[j]); + len -= rc; + if (len <= 0) + goto err; + tmp += rc; + } + + *tmp = '\n'; + tmp++; + len--; + } + + return tmp - buf; +err: + return -E2BIG; +} +EXPORT_SYMBOL(cfs_cpt_distance_print); + int cfs_cpt_number(struct cfs_cpt_table *cptab) { @@ -269,6 +318,18 @@ struct cfs_cpt_table * } EXPORT_SYMBOL(cfs_cpt_nodemask); +unsigned int cfs_cpt_distance(struct cfs_cpt_table *cptab, int cpt1, int cpt2) +{ + LASSERT(cpt1 == CFS_CPT_ANY || (cpt1 >= 0 && cpt1 < cptab->ctb_nparts)); + LASSERT(cpt2 == CFS_CPT_ANY || (cpt2 >= 0 && cpt2 < cptab->ctb_nparts)); + + if (cpt1 == CFS_CPT_ANY || cpt2 == CFS_CPT_ANY) + return cptab->ctb_distance; + + return cptab->ctb_parts[cpt1].cpt_distance[cpt2]; +} +EXPORT_SYMBOL(cfs_cpt_distance); + int cfs_cpt_set_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu) { -- 1.8.3.1