[master] fe0382d Integrate EXP_Touch() into sml_touch()
Poul-Henning Kamp
phk at FreeBSD.org
Wed Dec 16 12:35:48 CET 2015
commit fe0382d73f68c7aec468e7d1481a85fcee1c3486
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Wed Dec 16 11:35:27 2015 +0000
Integrate EXP_Touch() into sml_touch()
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index fe1f37e..f9350ec 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -690,7 +690,6 @@ void EXP_Insert(struct worker *wrk, struct objcore *oc);
void EXP_Inject(struct worker *wrk, struct objcore *oc, struct lru *lru);
void EXP_Rearm(struct objcore *, double now, double ttl, double grace,
double keep);
-void EXP_Touch(struct objcore *oc, double now);
int EXP_NukeOne(struct worker *wrk, struct lru *lru);
enum exp_event_e {
diff --git a/bin/varnishd/cache/cache_expire.c b/bin/varnishd/cache/cache_expire.c
index a01ca0a..119f521 100644
--- a/bin/varnishd/cache/cache_expire.c
+++ b/bin/varnishd/cache/cache_expire.c
@@ -217,45 +217,6 @@ EXP_Insert(struct worker *wrk, struct objcore *oc)
}
/*--------------------------------------------------------------------
- * Object was used, move to tail of LRU list.
- *
- * To avoid the exphdl->mtx becoming a hotspot, we only attempt to move
- * objects if they have not been moved recently and if the lock is available.
- * This optimization obviously leaves the LRU list imperfectly sorted.
- */
-
-void
-EXP_Touch(struct objcore *oc, double now)
-{
- struct lru *lru;
-
- CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
-
- if (oc->flags & OC_F_INCOMPLETE)
- return;
-
- if (now - oc->last_lru < cache_param->lru_interval)
- return;
-
- lru = ObjGetLRU(oc);
- CHECK_OBJ_NOTNULL(lru, LRU_MAGIC);
-
- if (Lck_Trylock(&lru->mtx))
- return;
-
- AN(oc->exp_flags & OC_EF_EXP);
-
- if (!(oc->exp_flags & OC_EF_OFFLRU)) {
- /* Can only touch it while it's actually on the LRU list */
- VTAILQ_REMOVE(&lru->lru_head, oc, lru_list);
- VTAILQ_INSERT_TAIL(&lru->lru_head, oc, lru_list);
- VSC_C_main->n_lru_moved++;
- }
- oc->last_lru = now;
- Lck_Unlock(&lru->mtx);
-}
-
-/*--------------------------------------------------------------------
* We have changed one or more of the object timers, tell the exp_thread
*
*/
diff --git a/bin/varnishd/storage/storage_simple.c b/bin/varnishd/storage/storage_simple.c
index 168e7ff..6ce07c6 100644
--- a/bin/varnishd/storage/storage_simple.c
+++ b/bin/varnishd/storage/storage_simple.c
@@ -560,10 +560,40 @@ sml_setattr(struct worker *wrk, struct objcore *oc, enum obj_attr attr,
static void __match_proto__(objtouch_f)
sml_touch(struct worker *wrk, struct objcore *oc, double now)
{
+ struct lru *lru;
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
- EXP_Touch(oc, now);
+
+ /*
+ * To avoid the exphdl->mtx becoming a hotspot, we only
+ * attempt to move objects if they have not been moved
+ * recently and if the lock is available. This optimization
+ * obviously leaves the LRU list imperfectly sorted.
+ */
+
+ if (oc->flags & OC_F_INCOMPLETE)
+ return;
+
+ if (now - oc->last_lru < cache_param->lru_interval)
+ return;
+
+ lru = ObjGetLRU(oc);
+ CHECK_OBJ_NOTNULL(lru, LRU_MAGIC);
+
+ if (Lck_Trylock(&lru->mtx))
+ return;
+
+ AN(oc->exp_flags & OC_EF_EXP);
+
+ if (!(oc->exp_flags & OC_EF_OFFLRU)) {
+ /* Can only touch it while it's actually on the LRU list */
+ VTAILQ_REMOVE(&lru->lru_head, oc, lru_list);
+ VTAILQ_INSERT_TAIL(&lru->lru_head, oc, lru_list);
+ VSC_C_main->n_lru_moved++;
+ }
+ oc->last_lru = now;
+ Lck_Unlock(&lru->mtx);
}
const struct obj_methods SML_methods = {
More information about the varnish-commit
mailing list