Ema has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/349965 )

Change subject: 4.1.5-1wm2: add 0006-exp-thread-realtime.patch
......................................................................

4.1.5-1wm2: add 0006-exp-thread-realtime.patch

Use a realtime scheduling policy (SCHED_FIFO) for the mailbox expiry
thread and bump priority.

Bug: T145661
Change-Id: Id194574f91de015ac4955e4b585b29524eccd4b4
---
M debian/changelog
A debian/patches/0006-exp-thread-realtime.patch
M debian/patches/series
3 files changed, 101 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/debs/varnish4 
refs/changes/65/349965/1

diff --git a/debian/changelog b/debian/changelog
index bf300c6..bcdbeec 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+varnish (4.1.5-1wm2) jessie-wikimedia; urgency=medium
+
+  * Add 0006-exp-thread-realtime.patch: pick a realtime scheduling policy
+    (SCHED_FIFO) for the mailbox expiry thread and bump priority.
+    Bug: #T145661.
+
+ -- Emanuele Rocca <[email protected]>  Sat, 22 Apr 2017 13:36:08 +0200
+
 varnish (4.1.5-1wm1) jessie-wikimedia; urgency=medium
 
   * New upstream release
diff --git a/debian/patches/0006-exp-thread-realtime.patch 
b/debian/patches/0006-exp-thread-realtime.patch
new file mode 100644
index 0000000..8b5d445
--- /dev/null
+++ b/debian/patches/0006-exp-thread-realtime.patch
@@ -0,0 +1,92 @@
+diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
+index c03570389..da9ba22aa 100644
+--- a/bin/varnishd/cache/cache.h
++++ b/bin/varnishd/cache/cache.h
+@@ -824,14 +824,15 @@ extern pthread_key_t witness_key;
+ void Lck__Lock(struct lock *lck, const char *p,  int l);
+ void Lck__Unlock(struct lock *lck, const char *p,  int l);
+ int Lck__Trylock(struct lock *lck, const char *p,  int l);
+-void Lck__New(struct lock *lck, struct VSC_C_lck *, const char *);
++void Lck__New(struct lock *lck, struct VSC_C_lck *, const char *, int 
protocol);
+ void Lck__Assert(const struct lock *lck, int held);
+ 
+ /* public interface: */
+ void Lck_Delete(struct lock *lck);
+ int Lck_CondWait(pthread_cond_t *cond, struct lock *lck, double);
+ 
+-#define Lck_New(a, b) Lck__New(a, b, #b)
++#define Lck_New(a, b) Lck__New(a, b, #b, PTHREAD_PRIO_NONE)
++#define Lck_New_Inherit(a, b) Lck__New(a, b, #b, PTHREAD_PRIO_INHERIT)
+ #define Lck_Lock(a) Lck__Lock(a, __func__, __LINE__)
+ #define Lck_Unlock(a) Lck__Unlock(a, __func__, __LINE__)
+ #define Lck_Trylock(a) Lck__Trylock(a, __func__, __LINE__)
+diff --git a/bin/varnishd/cache/cache_expire.c 
b/bin/varnishd/cache/cache_expire.c
+index 5c27d0741..2827ae3c5 100644
+--- a/bin/varnishd/cache/cache_expire.c
++++ b/bin/varnishd/cache/cache_expire.c
+@@ -33,6 +33,7 @@
+ #include "config.h"
+ 
+ #include <stdlib.h>
++#include <stdio.h>
+ 
+ #include "cache.h"
+ 
+@@ -575,12 +576,23 @@ exp_thread(struct worker *wrk, void *priv)
+       struct objcore *oc;
+       double t = 0, tnext = 0;
+       struct exp_priv *ep;
++      struct sched_param param;
++      int s;
+ 
+       CAST_OBJ_NOTNULL(ep, priv, EXP_PRIV_MAGIC);
+       ep->wrk = wrk;
+       VSL_Setup(&ep->vsl, NULL, 0);
+       ep->heap = binheap_new(NULL, object_cmp, object_update);
+       AN(ep->heap);
++
++      // Pick a realtime policy scheduling (SCHED_FIFO) and bump prio
++      param.sched_priority = 1;
++      s = pthread_setschedparam(pthread_self(), SCHED_FIFO, &param);
++      if (s != 0) {
++              perror("pthread_getschedparam");
++              exit(EXIT_FAILURE);
++      }
++
+       while (1) {
+ 
+               Lck_Lock(&ep->mtx);
+@@ -617,7 +629,8 @@ EXP_Init(void)
+       ALLOC_OBJ(ep, EXP_PRIV_MAGIC);
+       AN(ep);
+ 
+-      Lck_New(&ep->mtx, lck_exp);
++      Lck_New_Inherit(&ep->mtx, lck_exp);
++
+       AZ(pthread_cond_init(&ep->condvar, NULL));
+       VTAILQ_INIT(&ep->inbox);
+       AZ(pthread_rwlock_init(&ep->cb_rwl, NULL));
+diff --git a/bin/varnishd/cache/cache_lck.c b/bin/varnishd/cache/cache_lck.c
+index 90190dcea..8078b3194 100644
+--- a/bin/varnishd/cache/cache_lck.c
++++ b/bin/varnishd/cache/cache_lck.c
+@@ -209,7 +209,7 @@ Lck_CondWait(pthread_cond_t *cond, struct lock *lck, 
double when)
+ }
+ 
+ void
+-Lck__New(struct lock *lck, struct VSC_C_lck *st, const char *w)
++Lck__New(struct lock *lck, struct VSC_C_lck *st, const char *w, int protocol)
+ {
+       struct ilck *ilck;
+ 
+@@ -221,6 +221,10 @@ Lck__New(struct lock *lck, struct VSC_C_lck *st, const 
char *w)
+       ilck->w = w;
+       ilck->stat = st;
+       ilck->stat->creat++;
++
++      // Valid values: PTHREAD_PRIO_NONE, PTHREAD_PRIO_INHERIT, 
PTHREAD_PRIO_PROTECT
++      pthread_mutexattr_setprotocol(&attr, protocol);
++
+       AZ(pthread_mutex_init(&ilck->mtx, &attr));
+       lck->priv = ilck;
+ }
diff --git a/debian/patches/series b/debian/patches/series
index 44fc4a0..4965e07 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -2,3 +2,4 @@
 0002-varnishd-persistent-fallocate.patch
 0004-varnishd-persistent-mmap-exit.patch
 0005-gethdr_extrachance.patch
+0006-exp-thread-realtime.patch

-- 
To view, visit https://gerrit.wikimedia.org/r/349965
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id194574f91de015ac4955e4b585b29524eccd4b4
Gerrit-PatchSet: 1
Gerrit-Project: operations/debs/varnish4
Gerrit-Branch: debian-wmf
Gerrit-Owner: Ema <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to