[master] f319ed5 Now that we have defined the unit of VSC to be 8 bytes, simplify.

Poul-Henning Kamp phk at FreeBSD.org
Fri Jun 9 11:04:05 CEST 2017


commit f319ed53b5f2bd39b3eb26d5b3e9da518e7e513c
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Fri Jun 9 09:03:08 2017 +0000

    Now that we have defined the unit of VSC to be 8 bytes, simplify.

diff --git a/bin/varnishstat/varnishstat_curses.c b/bin/varnishstat/varnishstat_curses.c
index 49df731..c517bc6 100644
--- a/bin/varnishstat/varnishstat_curses.c
+++ b/bin/varnishstat/varnishstat_curses.c
@@ -75,11 +75,7 @@ struct pt {
 
 	const struct VSC_point	*vpt;
 
-	char			*key;
 	char			*name;
-	int			semantics;
-	int			format;
-	const volatile uint64_t	*ptr;
 
 	char			seen;
 
@@ -287,8 +283,8 @@ build_pt_list_cb(void *priv, const struct VSC_point *vpt)
 
 	VTAILQ_FOREACH(pt, &ptlist, list) {
 		CHECK_OBJ_NOTNULL(pt, PT_MAGIC);
-		AN(pt->key);
-		if (strcmp(buf, pt->key))
+		AN(pt->name);
+		if (strcmp(buf, pt->name))
 			continue;
 		VTAILQ_REMOVE(&ptlist, pt, list);
 		AN(n_ptlist);
@@ -303,19 +299,12 @@ build_pt_list_cb(void *priv, const struct VSC_point *vpt)
 	ALLOC_OBJ(pt, PT_MAGIC);
 	AN(pt);
 
-	pt->key = strdup(buf);
-	AN(pt->key);
-
-	bprintf(buf, "%s.%s", vpt->section->ident, vpt->desc->name);
 	REPLACE(pt->name, buf);
 	AN(pt->name);
 
 	pt->vpt = vpt;
 
-	pt->ptr = vpt->ptr;
-	pt->last = *pt->ptr;
-	pt->semantics = vpt->desc->semantics;
-	pt->format = vpt->desc->format;
+	pt->last = *pt->vpt->ptr;
 
 	pt->ma_10.nmax = 10;
 	pt->ma_100.nmax = 100;
@@ -369,18 +358,20 @@ static void
 sample_points(void)
 {
 	struct pt *pt;
+	uint64_t v;
 
 	VTAILQ_FOREACH(pt, &ptlist, list) {
 		AN(pt->vpt);
-		AN(pt->ptr);
-		if (*pt->ptr == 0 && !pt->seen)
+		AN(pt->vpt->ptr);
+		v = *pt->vpt->ptr;
+		if (v == 0 && !pt->seen)
 			continue;
 		if (!pt->seen) {
 			pt->seen = 1;
 			rebuild = 1;
 		}
 		pt->last = pt->cur;
-		pt->cur = *pt->ptr;
+		pt->cur = v;
 		pt->t_last = pt->t_cur;
 		pt->t_cur = VTIM_mono();
 
@@ -388,12 +379,12 @@ sample_points(void)
 			pt->chg = ((int64_t)pt->cur - (int64_t)pt->last) /
 			    (pt->t_cur - pt->t_last);
 
-		if (pt->semantics == 'g') {
+		if (pt->vpt->desc->semantics == 'g') {
 			pt->avg = 0.;
 			update_ma(&pt->ma_10, (int64_t)pt->cur);
 			update_ma(&pt->ma_100, (int64_t)pt->cur);
 			update_ma(&pt->ma_1000, (int64_t)pt->cur);
-		} else if (pt->semantics == 'c') {
+		} else if (pt->vpt->desc->semantics == 'c') {
 			if (main_uptime != NULL && *main_uptime)
 				pt->avg = pt->cur / *main_uptime;
 			else
@@ -790,7 +781,7 @@ draw_line_bitmap(WINDOW *w, int y, int x, int X, const struct pt *pt)
 
 	AN(w);
 	AN(pt);
-	assert(pt->format == 'b');
+	assert(pt->vpt->desc->format == 'b');
 
 	col = 0;
 	while (col < COL_LAST) {
@@ -866,7 +857,7 @@ draw_line(WINDOW *w, int y, const struct pt *pt)
 		mvwprintw(w, y, x, "%.*s", colw_name, pt->name);
 	x += colw_name;
 
-	switch (pt->format) {
+	switch (pt->vpt->desc->format) {
 	case 'b':
 		draw_line_bitmap(w, y, x, X, pt);
 		break;
diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c
index e075120..7014b8a 100644
--- a/bin/varnishtest/vtc_varnish.c
+++ b/bin/varnishtest/vtc_varnish.c
@@ -822,7 +822,7 @@ do_stat_dump_cb(void *priv, const struct VSC_point * const pt)
 
 	if (strcmp(pt->desc->ctype, "uint64_t"))
 		return (0);
-	u = *(const volatile uint64_t*)pt->ptr;
+	u = *pt->ptr;
 
 	bprintf(buf, "%s.%s", pt->section->ident, pt->desc->name);
 
@@ -876,7 +876,7 @@ do_stat_cb(void *priv, const struct VSC_point * const pt)
 		return(0);
 
 	AZ(strcmp(pt->desc->ctype, "uint64_t"));
-	sp->val = *(const volatile uint64_t*)pt->ptr;
+	sp->val = *pt->ptr;
 	return (1);
 }
 
diff --git a/include/vapi/vsc.h b/include/vapi/vsc.h
index 3d74531..a3d847d 100644
--- a/include/vapi/vsc.h
+++ b/include/vapi/vsc.h
@@ -83,7 +83,7 @@ struct VSC_desc {
 
 struct VSC_point {
 	const struct VSC_desc *desc;	/* point description		*/
-	const volatile void *ptr;	/* field value			*/
+	const volatile uint64_t *ptr;	/* field value			*/
 	const struct VSC_section *section;
 };
 



More information about the varnish-commit mailing list