]> xenbits.xensource.com Git - xen.git/commitdiff
xenstored: Log when the write transaction rate limit bites
authorIan Jackson <ian.jackson@eu.citrix.com>
Sat, 18 Mar 2017 17:13:27 +0000 (17:13 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Wed, 5 Apr 2017 14:26:29 +0000 (15:26 +0100)
Reported-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
plus:

xenstore: dont increment bool variable
Instead of incrementing a bool variable just set it to true.

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/xenstore/xenstored_core.c
tools/xenstore/xenstored_domain.c
tools/xenstore/xenstored_domain.h

index beb630b2ed9ca12a9394a11a8b90f8187e6021fc..55d4b3b00e166d262edbd64172a289952a521bb1 100644 (file)
@@ -363,6 +363,7 @@ static void initialize_fds(int sock, int *p_sock_pollfd_idx,
                                        POLLIN|POLLPRI);
 
        wrl_gettime_now(&now);
+       wrl_log_periodic(now);
 
        list_for_each_entry(conn, &connections, list) {
                if (conn->domain) {
index 16c303e51645f991b1169518355289b61032e2cc..66d24546e635d698cd869afce42d75c307d7a623 100644 (file)
@@ -24,6 +24,7 @@
 #include <stdarg.h>
 #include <xenctrl.h>
 #include <time.h>
+#include <syslog.h>
 
 #include "utils.h"
 #include "talloc.h"
@@ -80,6 +81,7 @@ struct domain
        /* write rate limit */
        wrl_creditt wrl_credit; /* [ -wrl_config_writecost, +_dburst ] */
        struct wrl_timestampt wrl_timestamp;
+       bool wrl_delay_logged;
 };
 
 static LIST_HEAD(domains);
@@ -771,6 +773,7 @@ long wrl_ntransactions;
 
 static long wrl_ndomains;
 static wrl_creditt wrl_reserve; /* [-wrl_config_newdoms_dburst, +_gburst ] */
+static time_t wrl_log_last_warning; /* 0: no previous warning */
 
 void wrl_gettime_now(struct wrl_timestampt *now_wt)
 {
@@ -920,6 +923,9 @@ void wrl_check_timeout(struct domain *domain,
              wakeup);
 }
 
+#define WRL_LOG(now, ...) \
+       (syslog(LOG_WARNING, "write rate limit: " __VA_ARGS__))
+
 void wrl_apply_debit_actual(struct domain *domain)
 {
        struct wrl_timestampt now;
@@ -935,6 +941,26 @@ void wrl_apply_debit_actual(struct domain *domain)
        trace("wrl: domain %u credit=%ld (reserve=%ld)\n",
              domain->domid,
              (long)domain->wrl_credit, (long)wrl_reserve);
+
+       if (domain->wrl_credit < 0) {
+               if (!domain->wrl_delay_logged) {
+                       domain->wrl_delay_logged = true;
+                       WRL_LOG(now, "domain %ld is affected",
+                               (long)domain->domid);
+               } else if (!wrl_log_last_warning) {
+                       WRL_LOG(now, "rate limiting restarts");
+               }
+               wrl_log_last_warning = now.sec;
+       }
+}
+
+void wrl_log_periodic(struct wrl_timestampt now)
+{
+       if (wrl_log_last_warning &&
+           (now.sec - wrl_log_last_warning) > WRL_LOGEVERY) {
+               WRL_LOG(now, "not in force recently");
+               wrl_log_last_warning = 0;
+       }
 }
 
 void wrl_apply_debit_direct(struct connection *conn)
index a0085543cde505cf291341b67233de12470989d6..a9650ccb033d7164332ad9fdeb7809d5dfc31e62 100644 (file)
@@ -73,6 +73,7 @@ int domain_watch(struct connection *conn);
 #define WRL_DBURST     10
 #define WRL_GBURST   1000
 #define WRL_NEWDOMS     5
+#define WRL_LOGEVERY  120 /* seconds */
 
 struct wrl_timestampt {
        time_t sec;
@@ -88,6 +89,7 @@ void wrl_credit_update(struct domain *domain, struct wrl_timestampt now);
 void wrl_check_timeout(struct domain *domain,
                        struct wrl_timestampt now,
                        int *ptimeout);
+void wrl_log_periodic(struct wrl_timestampt now);
 void wrl_apply_debit_direct(struct connection *conn);
 void wrl_apply_debit_trans_commit(struct connection *conn);