Mercurial > illumos > illumos-gate
changeset 12934:c58988eacbb2
6959079 Need to improve how statistics are gathered in RDSv3
author | agiri <Giri.Adari@Sun.COM> |
---|---|
date | Tue, 27 Jul 2010 14:03:41 -0700 |
parents | 1d9a1ccf92e6 |
children | eb113dc3db0b |
files | usr/src/uts/common/io/ib/clients/rdsv3/ib.c usr/src/uts/common/io/ib/clients/rdsv3/ib_stats.c usr/src/uts/common/io/ib/clients/rdsv3/stats.c usr/src/uts/common/sys/ib/clients/rdsv3/ib.h usr/src/uts/common/sys/ib/clients/rdsv3/rdsv3.h usr/src/uts/common/sys/ib/clients/rdsv3/rdsv3_impl.h |
diffstat | 6 files changed, 40 insertions(+), 31 deletions(-) [+] |
line wrap: on
line diff
--- a/usr/src/uts/common/io/ib/clients/rdsv3/ib.c Tue Jul 27 12:42:15 2010 -0400 +++ b/usr/src/uts/common/io/ib/clients/rdsv3/ib.c Tue Jul 27 14:03:41 2010 -0700 @@ -385,6 +385,8 @@ rdsv3_ib_sysctl_exit(); rdsv3_ib_recv_exit(); rdsv3_trans_unregister(&rdsv3_ib_transport); + kmem_free(rdsv3_ib_stats, + nr_cpus * sizeof (struct rdsv3_ib_statistics)); mutex_destroy(&ib_nodev_conns_lock); list_destroy(&ib_nodev_conns); list_destroy(&rdsv3_ib_devices); @@ -435,6 +437,11 @@ offsetof(struct rdsv3_ib_connection, ib_node)); mutex_init(&ib_nodev_conns_lock, NULL, MUTEX_DRIVER, NULL); + /* allocate space for ib statistics */ + ASSERT(rdsv3_ib_stats == NULL); + rdsv3_ib_stats = kmem_zalloc(nr_cpus * + sizeof (struct rdsv3_ib_statistics), KM_SLEEP); + rdsv3_ib_client.dip = rdsv3_dev_info; ret = ib_register_client(&rdsv3_ib_client); if (ret) @@ -465,6 +472,8 @@ out_ibreg: ib_unregister_client(&rdsv3_ib_client); out: + kmem_free(rdsv3_ib_stats, + nr_cpus * sizeof (struct rdsv3_ib_statistics)); mutex_destroy(&ib_nodev_conns_lock); list_destroy(&ib_nodev_conns); list_destroy(&rdsv3_ib_devices);
--- a/usr/src/uts/common/io/ib/clients/rdsv3/ib_stats.c Tue Jul 27 12:42:15 2010 -0400 +++ b/usr/src/uts/common/io/ib/clients/rdsv3/ib_stats.c Tue Jul 27 14:03:41 2010 -0700 @@ -47,7 +47,7 @@ #include <sys/ib/clients/rdsv3/ib.h> #include <sys/ib/clients/rdsv3/rdsv3_debug.h> -RDSV3_DEFINE_PER_CPU(struct rdsv3_ib_statistics, rdsv3_ib_stats); +struct rdsv3_ib_statistics *rdsv3_ib_stats = NULL; static char *rdsv3_ib_stat_names[] = { "ib_connect_raced", @@ -95,7 +95,7 @@ if (avail < ARRAY_SIZE(rdsv3_ib_stat_names)) goto out; - for (cpu = 0; cpu < NR_CPUS; cpu++) { + for (cpu = 0; cpu < nr_cpus; cpu++) { src = (uint64_t *)&(rdsv3_per_cpu(rdsv3_ib_stats, cpu)); sum = (uint64_t *)&stats; for (i = 0; i < sizeof (stats) / sizeof (uint64_t); i++)
--- a/usr/src/uts/common/io/ib/clients/rdsv3/stats.c Tue Jul 27 12:42:15 2010 -0400 +++ b/usr/src/uts/common/io/ib/clients/rdsv3/stats.c Tue Jul 27 14:03:41 2010 -0700 @@ -45,7 +45,8 @@ #include <sys/ib/clients/rdsv3/rdsv3.h> -RDSV3_DEFINE_PER_CPU(struct rdsv3_statistics, rdsv3_stats); +struct rdsv3_statistics *rdsv3_stats = NULL; +uint_t nr_cpus; static char *rdsv3_stat_names[] = { "conn_reset", @@ -132,7 +133,7 @@ bzero(&stats, sizeof (struct rdsv3_statistics)); - for (cpu = 0; cpu < NR_CPUS; cpu++) { + for (cpu = 0; cpu < nr_cpus; cpu++) { src = (uint64_t *)&(rdsv3_per_cpu(rdsv3_stats, cpu)); sum = (uint64_t *)&stats; for (i = 0; @@ -155,11 +156,24 @@ rdsv3_stats_exit(void) { rdsv3_info_deregister_func(RDS_INFO_COUNTERS, rdsv3_stats_info); + + ASSERT(rdsv3_stats); + kmem_free(rdsv3_stats, + nr_cpus * sizeof (struct rdsv3_statistics)); + rdsv3_stats = NULL; } int rdsv3_stats_init(void) { + /* + * Note the max number of cpus that ths system can have at most. + */ + nr_cpus = max_ncpus; + ASSERT(rdsv3_stats == NULL); + rdsv3_stats = kmem_zalloc(nr_cpus * + sizeof (struct rdsv3_statistics), KM_SLEEP); + rdsv3_info_register_func(RDS_INFO_COUNTERS, rdsv3_stats_info); return (0); }
--- a/usr/src/uts/common/sys/ib/clients/rdsv3/ib.h Tue Jul 27 12:42:15 2010 -0400 +++ b/usr/src/uts/common/sys/ib/clients/rdsv3/ib.h Tue Jul 27 14:03:41 2010 -0700 @@ -362,8 +362,9 @@ uint32_t *adv_credits, int need_posted); /* ib_stats.c */ -RDSV3_DECLARE_PER_CPU(struct rdsv3_ib_statistics, rdsv3_ib_stats); -#define rdsv3_ib_stats_inc(member) rdsv3_stats_inc_which(rdsv3_ib_stats, member) +extern struct rdsv3_ib_statistics *rdsv3_ib_stats; +#define rdsv3_ib_stats_inc(member) \ + rdsv3_stats_add_which(rdsv3_ib_stats, member, 1) unsigned int rdsv3_ib_stats_info_copy(struct rdsv3_info_iterator *iter, unsigned int avail);
--- a/usr/src/uts/common/sys/ib/clients/rdsv3/rdsv3.h Tue Jul 27 12:42:15 2010 -0400 +++ b/usr/src/uts/common/sys/ib/clients/rdsv3/rdsv3.h Tue Jul 27 14:03:41 2010 -0700 @@ -38,6 +38,9 @@ #include <sys/ib/clients/rdsv3/rdsv3_impl.h> #include <sys/ib/clients/rdsv3/info.h> +#include <sys/cpuvar.h> +#include <sys/disp.h> + #define NIPQUAD(addr) \ (unsigned char)((ntohl(addr) >> 24) & 0xFF), \ (unsigned char)((ntohl(addr) >> 16) & 0xFF), \ @@ -67,17 +70,6 @@ #define RDSV3_REAPER_WAIT_SECS (5*60) #define RDSV3_REAPER_WAIT_JIFFIES SEC_TO_TICK(RDSV3_REAPER_WAIT_SECS) -/* - * This is the sad making. Some kernels have a bug in the per_cpu() api which - * makes DEFINE_PER_CPU trigger an oops on insmod because the per-cpu section - * in the module is not cacheline-aligned. As much as we'd like to tell users - * with older kernels to stuff it, that's not reasonable. We'll roll our own - * until this doesn't have to build against older kernels. - */ -#define RDSV3_DEFINE_PER_CPU(type, var) type var[NR_CPUS] -#define RDSV3_DECLARE_PER_CPU(type, var) extern type var[NR_CPUS] -#define rdsv3_per_cpu(var, cpu) var[cpu] - static inline ulong_t ceil(ulong_t x, ulong_t y) { @@ -655,16 +647,14 @@ struct rdsv3_message *rdsv3_cong_update_alloc(struct rdsv3_connection *conn); /* stats.c */ -RDSV3_DECLARE_PER_CPU(struct rdsv3_statistics, rdsv3_stats); -#define rdsv3_stats_inc_which(which, member) do { \ - rdsv3_per_cpu(which, get_cpu()).member++; \ - put_cpu(); \ +extern uint_t nr_cpus; +extern struct rdsv3_statistics *rdsv3_stats; +#define rdsv3_per_cpu(var, cpu) var[cpu] +#define rdsv3_stats_add_which(which, member, count) do { \ + rdsv3_per_cpu(which, CPU->cpu_seqid).member += count; \ } while (0) -#define rdsv3_stats_inc(member) rdsv3_stats_inc_which(rdsv3_stats, member) -#define rdsv3_stats_add_which(which, member, count) do { \ - rdsv3_per_cpu(which, get_cpu()).member += count; \ - put_cpu(); \ -} while (0) +#define rdsv3_stats_inc(member) \ + rdsv3_stats_add_which(rdsv3_stats, member, 1) #define rdsv3_stats_add(member, count) \ rdsv3_stats_add_which(rdsv3_stats, member, count) int rdsv3_stats_init(void);
--- a/usr/src/uts/common/sys/ib/clients/rdsv3/rdsv3_impl.h Tue Jul 27 12:42:15 2010 -0400 +++ b/usr/src/uts/common/sys/ib/clients/rdsv3/rdsv3_impl.h Tue Jul 27 14:03:41 2010 -0700 @@ -136,11 +136,6 @@ #define IS_ERR(ptr) (((uintptr_t)ptr) >= (uintptr_t)-MAX_ERRNO) #define PTR_ERR(ptr) (int)(uintptr_t)ptr -/* cpu */ -#define NR_CPUS 1 -#define put_cpu() -#define get_cpu() 0 - #define MAX_SCHEDULE_TIMEOUT (~0UL>>1) #define RDMA_CM_EVENT_ADDR_CHANGE 14