[experimental-ims] ac85937 More argument strength reduction to reduce the spread of struct wrk

Geoff Simmons geoff at varnish-cache.org
Tue Feb 14 17:49:35 CET 2012


commit ac859374aac0c9b93c2b2975e280ea83d8f5105a
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue Feb 14 11:48:16 2012 +0000

    More argument strength reduction to reduce the spread of struct wrk

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 50d9541..42788c3 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -357,8 +357,8 @@ struct storage {
  * housekeeping fields parts of an object.
  */
 
-typedef struct object *getobj_f(struct worker *wrk, struct objcore *oc);
-typedef unsigned getxid_f(struct worker *wrk, struct objcore *oc);
+typedef struct object *getobj_f(struct dstat *ds, struct objcore *oc);
+typedef unsigned getxid_f(struct dstat *ds, struct objcore *oc);
 typedef void updatemeta_f(struct objcore *oc);
 typedef void freeobj_f(struct objcore *oc);
 typedef struct lru *getlru_f(const struct objcore *oc);
@@ -395,24 +395,24 @@ struct objcore {
 };
 
 static inline unsigned
-oc_getxid(struct worker *wrk, struct objcore *oc)
+oc_getxid(struct dstat *ds, struct objcore *oc)
 {
 	CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
 
 	AN(oc->methods);
 	AN(oc->methods->getxid);
-	return (oc->methods->getxid(wrk, oc));
+	return (oc->methods->getxid(ds, oc));
 }
 
 static inline struct object *
-oc_getobj(struct worker *wrk, struct objcore *oc)
+oc_getobj(struct dstat *ds, struct objcore *oc)
 {
 
 	CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
 	AZ(oc->flags & OC_F_BUSY);
 	AN(oc->methods);
 	AN(oc->methods->getobj);
-	return (oc->methods->getobj(wrk, oc));
+	return (oc->methods->getobj(ds, oc));
 }
 
 static inline void
@@ -1014,7 +1014,6 @@ void WS_Assert(const struct ws *ws);
 void WS_Reset(struct ws *ws, char *p);
 char *WS_Alloc(struct ws *ws, unsigned bytes);
 char *WS_Snapshot(struct ws *ws);
-unsigned WS_Free(const struct ws *ws);
 
 /* rfc2616.c */
 void RFC2616_Ttl(const struct sess *sp);
@@ -1092,11 +1091,11 @@ Tadd(txt *t, const char *p, int l)
 }
 
 static inline void
-AssertObjBusy(const struct object *o)
+AssertOCBusy(const struct objcore *oc)
 {
-	AN(o->objcore);
-	AN (o->objcore->flags & OC_F_BUSY);
-	AN(o->objcore->busyobj);
+	AN(oc);
+	AN (oc->flags & OC_F_BUSY);
+	AN(oc->busyobj);
 }
 
 static inline void
diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c
index b02e5f9..24a150e 100644
--- a/bin/varnishd/cache/cache_ban.c
+++ b/bin/varnishd/cache/cache_ban.c
@@ -891,7 +891,7 @@ ban_lurker_work(const struct sess *sp, unsigned pass)
 			/*
 			 * Get the object and check it against all relevant bans
 			 */
-			o = oc_getobj(sp->wrk, oc);
+			o = oc_getobj(&sp->wrk->stats, oc);
 			i = ban_check_object(o, sp, 0);
 			if (cache_param->diag_bitmap & 0x80000)
 				VSL(SLT_Debug, 0, "lurker got: %p %d",
diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c
index 61d1a94..0be9304 100644
--- a/bin/varnishd/cache/cache_center.c
+++ b/bin/varnishd/cache/cache_center.c
@@ -915,7 +915,8 @@ cnt_fetchbody(struct sess *sp, struct worker *wrk, struct req *req)
 		EXP_Insert(req->obj);
 		AN(req->obj->objcore);
 		AN(req->obj->objcore->ban);
-		HSH_Unbusy(wrk);
+		AZ(req->obj->ws_o->overflow);
+		HSH_Unbusy(req->obj->objcore);
 	}
 	VBO_DerefBusyObj(wrk, &wrk->busyobj);
 	wrk->acct_tmp.fetch++;
@@ -961,7 +962,8 @@ cnt_streambody(struct sess *sp, struct worker *wrk, struct req *req)
 		EXP_Insert(req->obj);
 		AN(req->obj->objcore);
 		AN(req->obj->objcore->ban);
-		HSH_Unbusy(wrk);
+		AZ(req->obj->ws_o->overflow);
+		HSH_Unbusy(req->obj->objcore);
 	} else {
 		req->doclose = "Stream error";
 	}
@@ -1171,7 +1173,7 @@ cnt_lookup(struct sess *sp, struct worker *wrk, struct req *req)
 		return (0);
 	}
 
-	o = oc_getobj(wrk, oc);
+	o = oc_getobj(&wrk->stats, oc);
 	CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
 	req->obj = o;
 
diff --git a/bin/varnishd/cache/cache_expire.c b/bin/varnishd/cache/cache_expire.c
index 840e0b7..0d8ffe1 100644
--- a/bin/varnishd/cache/cache_expire.c
+++ b/bin/varnishd/cache/cache_expire.c
@@ -224,7 +224,7 @@ EXP_Insert(struct object *o)
 	CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
 	oc = o->objcore;
 	CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
-	AssertObjBusy(o);
+	AssertOCBusy(oc);
 	HSH_Ref(oc);
 
 	assert(o->exp.entered != 0 && !isnan(o->exp.entered));
@@ -399,9 +399,9 @@ exp_timer(struct sess *sp, void *priv)
 		VSC_C_main->n_expired++;
 
 		CHECK_OBJ_NOTNULL(oc->objhead, OBJHEAD_MAGIC);
-		o = oc_getobj(sp->wrk, oc);
+		o = oc_getobj(&sp->wrk->stats, oc);
 		WSL(sp->wrk->vsl, SLT_ExpKill, 0, "%u %.0f",
-		    oc_getxid(sp->wrk, oc), EXP_Ttl(NULL, o) - t);
+		    oc_getxid(&sp->wrk->stats, oc), EXP_Ttl(NULL, o) - t);
 		(void)HSH_Deref(&sp->wrk->stats, oc, NULL);
 	}
 	NEEDLESS_RETURN(NULL);
@@ -445,7 +445,7 @@ EXP_NukeOne(struct worker *wrk, struct lru *lru)
 		return (-1);
 
 	/* XXX: bad idea for -spersistent */
-	WSL(wrk->vsl, SLT_ExpKill, 0, "%u LRU", oc_getxid(wrk, oc));
+	WSL(wrk->vsl, SLT_ExpKill, 0, "%u LRU", oc_getxid(&wrk->stats, oc));
 	(void)HSH_Deref(&wrk->stats, oc, NULL);
 	return (1);
 }
diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c
index eebb999..7188ff4 100644
--- a/bin/varnishd/cache/cache_hash.c
+++ b/bin/varnishd/cache/cache_hash.c
@@ -353,7 +353,7 @@ HSH_Lookup(struct sess *sp, struct objhead **poh)
 			continue;
 		}
 
-		o = oc_getobj(sp->wrk, oc);
+		o = oc_getobj(&sp->wrk->stats, oc);
 		CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
 
 		if (o->exp.ttl <= 0.)
@@ -397,14 +397,14 @@ HSH_Lookup(struct sess *sp, struct objhead **poh)
 	    && (busy_oc != NULL		/* Somebody else is already busy */
 	    || !VDI_Healthy(sp->req->director, sp))) {
 					/* Or it is impossible to fetch */
-		o = oc_getobj(sp->wrk, grace_oc);
+		o = oc_getobj(&sp->wrk->stats, grace_oc);
 		CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
 		oc = grace_oc;
 	}
 	sp->req->objcore = NULL;
 
 	if (oc != NULL && !sp->req->hash_always_miss) {
-		o = oc_getobj(sp->wrk, oc);
+		o = oc_getobj(&sp->wrk->stats, oc);
 		CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
 		assert(oc->objhead == oh);
 
@@ -540,7 +540,7 @@ HSH_Purge(const struct sess *sp, struct objhead *oh, double ttl, double grace)
 			continue;
 		}
 
-		(void)oc_getobj(sp->wrk, oc); /* XXX: still needed ? */
+		(void)oc_getobj(&sp->wrk->stats, oc); /* XXX: still needed ? */
 
 		xxxassert(spc >= sizeof *ocp);
 		oc->refcnt++;
@@ -557,7 +557,7 @@ HSH_Purge(const struct sess *sp, struct objhead *oh, double ttl, double grace)
 	for (n = 0; n < nobj; n++) {
 		oc = ocp[n];
 		CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
-		o = oc_getobj(sp->wrk, oc);
+		o = oc_getobj(&sp->wrk->stats, oc);
 		if (o == NULL)
 			continue;
 		CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
@@ -587,34 +587,23 @@ HSH_Drop(struct worker *wrk)
 	AssertObjCorePassOrBusy(o->objcore);
 	o->exp.ttl = -1.;
 	if (o->objcore != NULL)		/* Pass has no objcore */
-		HSH_Unbusy(wrk);
+		HSH_Unbusy(o->objcore);
 	(void)HSH_Deref(&wrk->stats, NULL, &wrk->sp->req->obj);
 }
 
 void
-HSH_Unbusy(struct worker *wrk)
+HSH_Unbusy(struct objcore *oc)
 {
-	struct object *o;
 	struct objhead *oh;
-	struct objcore *oc;
 
-	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
-	o = wrk->sp->req->obj;
-	CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
-	oc = o->objcore;
 	CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
 	oh = oc->objhead;
 	CHECK_OBJ(oh, OBJHEAD_MAGIC);
 
-	AssertObjBusy(o);
+	AssertOCBusy(oc);
 	AN(oc->ban);
 	assert(oc->refcnt > 0);
 	assert(oh->refcnt > 0);
-	if (o->ws_o->overflow)
-		wrk->stats.n_objoverflow++;
-	if (cache_param->diag_bitmap & 0x40)
-		WSL(wrk->vsl, SLT_Debug, 0,
-		    "Object %u workspace free %u", o->xid, WS_Free(o->ws_o));
 
 	/* XXX: pretouch neighbors on oh->objcs to prevent page-on under mtx */
 	Lck_Lock(&oh->mtx);
@@ -628,7 +617,6 @@ HSH_Unbusy(struct worker *wrk)
 		hsh_rush(oh);
 	AN(oc->ban);
 	Lck_Unlock(&oh->mtx);
-	assert(oc_getobj(wrk, oc) == o);
 }
 
 void
diff --git a/bin/varnishd/cache/cache_ws.c b/bin/varnishd/cache/cache_ws.c
index be38496..d84e937 100644
--- a/bin/varnishd/cache/cache_ws.c
+++ b/bin/varnishd/cache/cache_ws.c
@@ -116,14 +116,6 @@ WS_Alloc(struct ws *ws, unsigned bytes)
 	return (r);
 }
 
-unsigned
-WS_Free(const struct ws *ws)
-{
-
-	WS_Assert(ws);
-	return(ws->e - ws->f);
-}
-
 char *
 WS_Snapshot(struct ws *ws)
 {
diff --git a/bin/varnishd/hash/hash_slinger.h b/bin/varnishd/hash/hash_slinger.h
index 1bc08b1..ac8ce7e 100644
--- a/bin/varnishd/hash/hash_slinger.h
+++ b/bin/varnishd/hash/hash_slinger.h
@@ -54,7 +54,7 @@ struct hash_slinger {
 void HSH_Prealloc(const struct sess *sp);
 void HSH_Cleanup(struct worker *w);
 struct objcore *HSH_Lookup(struct sess *sp, struct objhead **poh);
-void HSH_Unbusy(struct worker *wrk);
+void HSH_Unbusy(struct objcore *);
 void HSH_Ref(struct objcore *o);
 void HSH_Drop(struct worker *wrk);
 void HSH_Init(const struct hash_slinger *slinger);
diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c
index 5c44c98..ae71f6e 100644
--- a/bin/varnishd/storage/stevedore.c
+++ b/bin/varnishd/storage/stevedore.c
@@ -49,20 +49,20 @@ static const struct stevedore * volatile stv_next;
  */
 
 static unsigned __match_proto__(getxid_f)
-default_oc_getxid(struct worker *wrk, struct objcore *oc)
+default_oc_getxid(struct dstat *ds, struct objcore *oc)
 {
 	struct object *o;
 
-	o = oc_getobj(wrk, oc);
+	o = oc_getobj(ds, oc);
 	return (o->xid);
 }
 
 static struct object * __match_proto__(getobj_f)
-default_oc_getobj(struct worker *wrk, struct objcore *oc)
+default_oc_getobj(struct dstat *ds, struct objcore *oc)
 {
 	struct object *o;
 
-	(void)wrk;
+	(void)ds;
 	if (oc->priv == NULL)
 		return (NULL);
 	CAST_OBJ_NOTNULL(o, oc->priv, OBJECT_MAGIC);
diff --git a/bin/varnishd/storage/storage_persistent_silo.c b/bin/varnishd/storage/storage_persistent_silo.c
index 7cafe4f..a6a02e6 100644
--- a/bin/varnishd/storage/storage_persistent_silo.c
+++ b/bin/varnishd/storage/storage_persistent_silo.c
@@ -370,13 +370,13 @@ smp_loaded_st(const struct smp_sc *sc, const struct smp_seg *sg,
  */
 
 static unsigned __match_proto__(getxid_f)
-smp_oc_getxid(struct worker *wrk, struct objcore *oc)
+smp_oc_getxid(struct dstat *ds, struct objcore *oc)
 {
 	struct object *o;
 	struct smp_seg *sg;
 	struct smp_object *so;
 
-	(void)wrk;
+	(void)ds;
 	CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
 
 	CAST_OBJ_NOTNULL(sg, oc->priv, SMP_SEG_MAGIC);
@@ -399,7 +399,7 @@ smp_oc_getxid(struct worker *wrk, struct objcore *oc)
  */
 
 static struct object *
-smp_oc_getobj(struct worker *wrk, struct objcore *oc)
+smp_oc_getobj(struct dstat *ds, struct objcore *oc)
 {
 	struct object *o;
 	struct smp_seg *sg;
@@ -412,7 +412,7 @@ smp_oc_getobj(struct worker *wrk, struct objcore *oc)
 	assert(oc->methods->getobj == smp_oc_getobj);
 
 	CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
-	if (wrk == NULL)
+	if (ds == NULL)
 		AZ(oc->flags & OC_F_NEEDFIXUP);
 
 	CAST_OBJ_NOTNULL(sg, oc->priv, SMP_SEG_MAGIC);
@@ -435,7 +435,7 @@ smp_oc_getobj(struct worker *wrk, struct objcore *oc)
 	if (!(oc->flags & OC_F_NEEDFIXUP))
 		return (o);
 
-	AN(wrk);
+	AN(ds);
 	Lck_Lock(&sg->sc->mtx);
 	/* Check again, we might have raced. */
 	if (oc->flags & OC_F_NEEDFIXUP) {
@@ -459,8 +459,8 @@ smp_oc_getobj(struct worker *wrk, struct objcore *oc)
 		}
 
 		sg->nfixed++;
-		wrk->stats.n_object++;
-		wrk->stats.n_vampireobject--;
+		ds->n_object++;
+		ds->n_vampireobject--;
 		oc->flags &= ~OC_F_NEEDFIXUP;
 	}
 	Lck_Unlock(&sg->sc->mtx);



More information about the varnish-commit mailing list