[master] 15e2caa Move the remaining VSC's to The New World Order
Poul-Henning Kamp
phk at FreeBSD.org
Tue May 23 14:56:05 CEST 2017
commit 15e2caa6095d3563fb8d59761c813d607c84bba6
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Tue May 23 12:34:36 2017 +0000
Move the remaining VSC's to The New World Order
diff --git a/bin/varnishd/Makefile.am b/bin/varnishd/Makefile.am
index 9afd301..2b3220f 100644
--- a/bin/varnishd/Makefile.am
+++ b/bin/varnishd/Makefile.am
@@ -247,3 +247,48 @@ $(varnishd_OBJECTS): VSC_vbe.h
EXTRA_DIST += vbe.vsc
DISTCLEANFILES += VSC_vbe.c VSC_vbe.h
nodist_varnishd_SOURCES += VSC_vbe.c
+
+#######################################################################
+
+VSC_sma.c VSC_sma.h: $(srcdir)/sma.vsc $(top_builddir)/lib/libvcc/vsctool.py
+ $(PYTHON) $(top_srcdir)/lib/libvcc/vsctool.py $(srcdir)/sma.vsc
+
+$(varnishd_OBJECTS): VSC_sma.h
+
+EXTRA_DIST += sma.vsc
+DISTCLEANFILES += VSC_sma.c VSC_sma.h
+nodist_varnishd_SOURCES += VSC_sma.c
+
+#######################################################################
+
+VSC_smf.c VSC_smf.h: $(srcdir)/smf.vsc $(top_builddir)/lib/libvcc/vsctool.py
+ $(PYTHON) $(top_srcdir)/lib/libvcc/vsctool.py $(srcdir)/smf.vsc
+
+$(varnishd_OBJECTS): VSC_smf.h
+
+EXTRA_DIST += smf.vsc
+DISTCLEANFILES += VSC_smf.c VSC_smf.h
+nodist_varnishd_SOURCES += VSC_smf.c
+
+#######################################################################
+
+VSC_mempool.c VSC_mempool.h: $(srcdir)/mempool.vsc $(top_builddir)/lib/libvcc/vsctool.py
+ $(PYTHON) $(top_srcdir)/lib/libvcc/vsctool.py $(srcdir)/mempool.vsc
+
+$(varnishd_OBJECTS): VSC_mempool.h
+
+EXTRA_DIST += mempool.vsc
+DISTCLEANFILES += VSC_mempool.c VSC_mempool.h
+nodist_varnishd_SOURCES += VSC_mempool.c
+
+#######################################################################
+
+VSC_mgt.c VSC_mgt.h: $(srcdir)/mgt.vsc $(top_builddir)/lib/libvcc/vsctool.py
+ $(PYTHON) $(top_srcdir)/lib/libvcc/vsctool.py $(srcdir)/mgt.vsc
+
+$(varnishd_OBJECTS): VSC_mgt.h
+
+EXTRA_DIST += mgt.vsc
+DISTCLEANFILES += VSC_mgt.c VSC_mgt.h
+nodist_varnishd_SOURCES += VSC_mgt.c
+
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 5256c3f..6711c89 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -977,8 +977,6 @@ void SES_Set_String_Attr(struct sess *sp, enum sess_attr a, const char *src);
const char *SES_Get_String_Attr(const struct sess *sp, enum sess_attr a);
/* cache_shmlog.c */
-void *VSM_Alloc(unsigned size, const char *class, const char *type,
- const char *ident);
void VSM_Free(void *ptr);
#ifdef VSL_ENDMARKER
void VSLv(enum VSL_tag_e tag, uint32_t vxid, const char *fmt, va_list va);
diff --git a/bin/varnishd/cache/cache_mempool.c b/bin/varnishd/cache/cache_mempool.c
index 56edb20..b021150 100644
--- a/bin/varnishd/cache/cache_mempool.c
+++ b/bin/varnishd/cache/cache_mempool.c
@@ -38,6 +38,8 @@
#include "vtim.h"
+#include "VSC_mempool.h"
+
struct memitem {
unsigned magic;
#define MEMITEM_MAGIC 0x42e55401
@@ -58,7 +60,7 @@ struct mempool {
volatile struct poolparam *param;
volatile unsigned *cur_size;
uint64_t live;
- struct VSC_C_mempool *vsc;
+ struct VSC_mempool *vsc;
unsigned n_pool;
pthread_t thread;
double t_now;
@@ -236,8 +238,7 @@ MPL_New(const char *name,
VTAILQ_INIT(&mpl->surplus);
Lck_New(&mpl->mtx, lck_mempool);
/* XXX: prealloc min_pool */
- mpl->vsc = VSM_Alloc(sizeof *mpl->vsc,
- VSC_CLASS, VSC_type_mempool, mpl->name + 4);
+ mpl->vsc = VSC_mempool_New(mpl->name + 4);
AN(mpl->vsc);
AZ(pthread_create(&mpl->thread, NULL, mpl_guard, mpl));
AZ(pthread_detach(mpl->thread));
diff --git a/bin/varnishd/cache/cache_shmlog.c b/bin/varnishd/cache/cache_shmlog.c
index 5429a14..8ff321d 100644
--- a/bin/varnishd/cache/cache_shmlog.c
+++ b/bin/varnishd/cache/cache_shmlog.c
@@ -55,6 +55,9 @@ static ssize_t vsl_segsize;
struct VSC_main *VSC_C_main;
+static void *VSM_Alloc(unsigned size, const char *class, const char *type,
+ const char *ident);
+
static void
vsl_sanity(const struct vsl_log *vsl)
{
@@ -566,7 +569,7 @@ VSM_Init(void)
/*--------------------------------------------------------------------*/
-void *
+static void *
VSM_Alloc(unsigned size, const char *class, const char *type,
const char *ident)
{
diff --git a/bin/varnishd/mempool.vsc b/bin/varnishd/mempool.vsc
new file mode 100644
index 0000000..b947031
--- /dev/null
+++ b/bin/varnishd/mempool.vsc
@@ -0,0 +1,77 @@
+..
+ This is *NOT* a RST file but the syntax has been chosen so
+ that it may become an RST file at some later date.
+
+ XXX: For now this file must be kept in 100% agreement with
+ XXX: include/tbl/vsc_fields.h
+
+.. varnish_vsc_begin:: mempool
+ :oneliner: MEMORY POOL COUNTERS (MEMPOOL.*)
+
+.. varnish_vsc:: live
+ :type: gauge
+ :level: debug
+ :oneliner: In use
+
+
+.. varnish_vsc:: pool
+ :type: gauge
+ :level: debug
+ :oneliner: In Pool
+
+
+.. varnish_vsc:: sz_wanted
+ :type: gauge
+ :level: debug
+ :oneliner: Size requested
+
+
+.. varnish_vsc:: sz_actual
+ :type: gauge
+ :level: debug
+ :oneliner: Size allocated
+
+
+.. varnish_vsc:: allocs
+ :type: counter
+ :level: debug
+ :oneliner: Allocations
+
+
+.. varnish_vsc:: frees
+ :type: counter
+ :level: debug
+ :oneliner: Frees
+
+
+.. varnish_vsc:: recycle
+ :type: counter
+ :level: debug
+ :oneliner: Recycled from pool
+
+
+.. varnish_vsc:: timeout
+ :type: counter
+ :level: debug
+ :oneliner: Timed out from pool
+
+
+.. varnish_vsc:: toosmall
+ :type: counter
+ :level: debug
+ :oneliner: Too small to recycle
+
+
+.. varnish_vsc:: surplus
+ :type: counter
+ :level: debug
+ :oneliner: Too many for pool
+
+
+.. varnish_vsc:: randry
+ :type: counter
+ :level: debug
+ :oneliner: Pool ran dry
+
+
+.. varnish_vsc_end:: mempool
diff --git a/bin/varnishd/mgt.vsc b/bin/varnishd/mgt.vsc
new file mode 100644
index 0000000..d1d7984
--- /dev/null
+++ b/bin/varnishd/mgt.vsc
@@ -0,0 +1,61 @@
+..
+ This is *NOT* a RST file but the syntax has been chosen so
+ that it may become an RST file at some later date.
+
+ XXX: For now this file must be kept in 100% agreement with
+ XXX: include/tbl/vsc_fields.h
+
+.. varnish_vsc_begin:: mgt
+ :class: MGT
+ :oneliner: MANAGEMENT PROCESS COUNTERS (MGT.*)
+
+.. varnish_vsc:: uptime
+ :type: counter
+ :level: info
+ :oneliner: Management process uptime
+
+Uptime in seconds of the management process
+
+.. varnish_vsc:: child_start
+ :type: counter
+ :level: diag
+ :oneliner: Child process started
+
+Number of times the child process has been started
+
+.. varnish_vsc:: child_exit
+ :type: counter
+ :level: diag
+ :oneliner: Child process normal exit
+
+Number of times the child process has been cleanly stopped
+
+.. varnish_vsc:: child_stop
+ :type: counter
+ :level: diag
+ :oneliner: Child process unexpected exit
+
+Number of times the child process has exited with an unexpected return code
+
+.. varnish_vsc:: child_died
+ :type: counter
+ :level: diag
+ :oneliner: Child process died (signal)
+
+Number of times the child process has died due to signals
+
+.. varnish_vsc:: child_dump
+ :type: counter
+ :level: diag
+ :oneliner: Child process core dumped
+
+Number of times the child process has produced core dumps
+
+.. varnish_vsc:: child_panic
+ :type: counter
+ :level: diag
+ :oneliner: Child process panic
+
+Number of times the management process has caught a child panic
+
+.. varnish_vsc_end:: mgt
diff --git a/bin/varnishd/mgt/mgt.h b/bin/varnishd/mgt/mgt.h
index 3f8ff11..5d81642 100644
--- a/bin/varnishd/mgt/mgt.h
+++ b/bin/varnishd/mgt/mgt.h
@@ -38,6 +38,8 @@
#include "common/common.h"
#include "common/com_params.h"
+#include "VSC_mgt.h"
+
struct cli;
struct parspec;
struct vcc;
@@ -130,8 +132,8 @@ extern const struct jail_tech jail_tech_unix;
extern const struct jail_tech jail_tech_solaris;
/* mgt_main.c */
-extern struct VSC_C_mgt *VSC_C_mgt;
-extern struct VSC_C_mgt static_VSC_C_mgt;
+extern struct VSC_mgt *VSC_C_mgt;
+extern struct VSC_mgt static_VSC_C_mgt;
struct choice {
const char *name;
const void *ptr;
diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c
index 1a50c51..f0797a7 100644
--- a/bin/varnishd/mgt/mgt_main.c
+++ b/bin/varnishd/mgt/mgt_main.c
@@ -63,8 +63,8 @@ pid_t mgt_pid;
struct vev_base *mgt_evb;
int exit_status = 0;
struct vsb *vident;
-struct VSC_C_mgt static_VSC_C_mgt;
-struct VSC_C_mgt *VSC_C_mgt;
+struct VSC_mgt static_VSC_C_mgt;
+struct VSC_mgt *VSC_C_mgt;
static int I_fd = -1;
static char Cn_arg[] = "/tmp/varnishd_C_XXXXXXX";
diff --git a/bin/varnishd/mgt/mgt_shmem.c b/bin/varnishd/mgt/mgt_shmem.c
index 771080f..914a5ef 100644
--- a/bin/varnishd/mgt/mgt_shmem.c
+++ b/bin/varnishd/mgt/mgt_shmem.c
@@ -193,8 +193,7 @@ mgt_SHM_Create(void)
AN(heritage.panic_str);
/* Copy management counters to shm and update pointer */
- VSC_C_mgt = VSM_common_alloc(heritage.vsm,
- sizeof *VSC_C_mgt, VSC_CLASS, VSC_type_mgt, "");
+ VSC_C_mgt = VSC_mgt_New("");
AN(VSC_C_mgt);
*VSC_C_mgt = static_VSC_C_mgt;
diff --git a/bin/varnishd/sma.vsc b/bin/varnishd/sma.vsc
new file mode 100644
index 0000000..da4e18a
--- /dev/null
+++ b/bin/varnishd/sma.vsc
@@ -0,0 +1,60 @@
+..
+ This is *NOT* a RST file but the syntax has been chosen so
+ that it may become an RST file at some later date.
+
+ XXX: For now this file must be kept in 100% agreement with
+ XXX: include/tbl/vsc_fields.h
+
+.. varnish_vsc_begin:: sma
+ :oneliner: MALLOC STORAGE COUNTERS (SMA.*)
+
+.. varnish_vsc:: c_req
+ :type: counter
+ :level: info
+ :oneliner: Allocator requests
+
+Number of times the storage has been asked to provide a storage segment.
+
+.. varnish_vsc:: c_fail
+ :type: counter
+ :level: info
+ :oneliner: Allocator failures
+
+Number of times the storage has failed to provide a storage segment.
+
+.. varnish_vsc:: c_bytes
+ :type: counter
+ :level: info
+ :oneliner: Bytes allocated
+
+Number of total bytes allocated by this storage.
+
+.. varnish_vsc:: c_freed
+ :type: counter
+ :level: info
+ :oneliner: Bytes freed
+
+Number of total bytes returned to this storage.
+
+.. varnish_vsc:: g_alloc
+ :type: gauge
+ :level: info
+ :oneliner: Allocations outstanding
+
+Number of storage allocations outstanding.
+
+.. varnish_vsc:: g_bytes
+ :type: gauge
+ :level: info
+ :oneliner: Bytes outstanding
+
+Number of bytes allocated from the storage.
+
+.. varnish_vsc:: g_space
+ :type: gauge
+ :level: info
+ :oneliner: Bytes available
+
+Number of bytes left in the storage.
+
+.. varnish_vsc_end:: sma
diff --git a/bin/varnishd/smf.vsc b/bin/varnishd/smf.vsc
new file mode 100644
index 0000000..29f38d9
--- /dev/null
+++ b/bin/varnishd/smf.vsc
@@ -0,0 +1,78 @@
+..
+ This is *NOT* a RST file but the syntax has been chosen so
+ that it may become an RST file at some later date.
+
+ XXX: For now this file must be kept in 100% agreement with
+ XXX: include/tbl/vsc_fields.h
+
+.. varnish_vsc_begin:: smf
+ :oneliner: FILE STORAGE COUNTERS (SMF.*)
+
+.. varnish_vsc:: c_req
+ :type: counter
+ :level: info
+ :oneliner: Allocator requests
+
+Number of times the storage has been asked to provide a storage segment.
+
+.. varnish_vsc:: c_fail
+ :type: counter
+ :level: info
+ :oneliner: Allocator failures
+
+Number of times the storage has failed to provide a storage segment.
+
+.. varnish_vsc:: c_bytes
+ :type: counter
+ :level: info
+ :oneliner: Bytes allocated
+
+Number of total bytes allocated by this storage.
+
+.. varnish_vsc:: c_freed
+ :type: counter
+ :level: info
+ :oneliner: Bytes freed
+
+Number of total bytes returned to this storage.
+
+.. varnish_vsc:: g_alloc
+ :type: gauge
+ :level: info
+ :oneliner: Allocations outstanding
+
+Number of storage allocations outstanding.
+
+.. varnish_vsc:: g_bytes
+ :type: gauge
+ :level: info
+ :oneliner: Bytes outstanding
+
+Number of bytes allocated from the storage.
+
+.. varnish_vsc:: g_space
+ :type: gauge
+ :level: info
+ :oneliner: Bytes available
+
+Number of bytes left in the storage.
+
+.. varnish_vsc:: g_smf
+ :type: gauge
+ :level: info
+ :oneliner: N struct smf
+
+
+.. varnish_vsc:: g_smf_frag
+ :type: gauge
+ :level: info
+ :oneliner: N small free smf
+
+
+.. varnish_vsc:: g_smf_large
+ :type: gauge
+ :level: info
+ :oneliner: N large free smf
+
+
+.. varnish_vsc_end:: smf
diff --git a/bin/varnishd/storage/storage_file.c b/bin/varnishd/storage/storage_file.c
index 7de1a34..675bf62 100644
--- a/bin/varnishd/storage/storage_file.c
+++ b/bin/varnishd/storage/storage_file.c
@@ -45,6 +45,8 @@
#include "vnum.h"
#include "vfil.h"
+#include "VSC_smf.h"
+
#ifndef MAP_NOCORE
#define MAP_NOCORE 0 /* XXX Linux */
#endif
@@ -91,7 +93,7 @@ struct smf_sc {
unsigned magic;
#define SMF_SC_MAGIC 0x52962ee7
struct lock mtx;
- struct VSC_C_smf *stats;
+ struct VSC_smf *stats;
const char *filename;
int fd;
@@ -410,8 +412,7 @@ smf_open(struct stevedore *st)
if (lck_smf == NULL)
lck_smf = Lck_CreateClass("smf");
CAST_OBJ_NOTNULL(sc, st->priv, SMF_SC_MAGIC);
- sc->stats = VSM_Alloc(sizeof *sc->stats,
- VSC_CLASS, VSC_type_smf, st->ident);
+ sc->stats = VSC_smf_New(st->ident);
Lck_New(&sc->mtx, lck_smf);
Lck_Lock(&sc->mtx);
smf_open_chunk(sc, sc->filesize, 0, &fail, &sum);
diff --git a/bin/varnishd/storage/storage_malloc.c b/bin/varnishd/storage/storage_malloc.c
index 19a37ba..420b925 100644
--- a/bin/varnishd/storage/storage_malloc.c
+++ b/bin/varnishd/storage/storage_malloc.c
@@ -42,13 +42,15 @@
#include "vrt.h"
#include "vnum.h"
+#include "VSC_sma.h"
+
struct sma_sc {
unsigned magic;
#define SMA_SC_MAGIC 0x1ac8a345
struct lock sma_mtx;
size_t sma_max;
size_t sma_alloc;
- struct VSC_C_sma *stats;
+ struct VSC_sma *stats;
};
struct sma {
@@ -211,8 +213,7 @@ sma_open(struct stevedore *st)
lck_sma = Lck_CreateClass("sma");
CAST_OBJ_NOTNULL(sma_sc, st->priv, SMA_SC_MAGIC);
Lck_New(&sma_sc->sma_mtx, lck_sma);
- sma_sc->stats = VSM_Alloc(sizeof *sma_sc->stats,
- VSC_CLASS, VSC_type_sma, st->ident);
+ sma_sc->stats = VSC_sma_New(st->ident);
memset(sma_sc->stats, 0, sizeof *sma_sc->stats);
if (sma_sc->sma_max != SIZE_MAX)
sma_sc->stats->g_space = sma_sc->sma_max;
More information about the varnish-commit
mailing list