[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen stable-4.5] xenstored: Log when the write transaction rate limit bites



commit b820c31b4047316dc5fe57743a48bd303b78f5c4
Author:     Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
AuthorDate: Thu Mar 23 17:05:11 2017 +0000
Commit:     Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
CommitDate: Wed Apr 5 15:22:21 2017 +0100

    xenstored: Log when the write transaction rate limit bites
    
    Reported-by: Juergen Gross <jgross@xxxxxxxx>
    Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
    
    plus:
    
    xenstore: dont increment bool variable
    Instead of incrementing a bool variable just set it to true.
    
    Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
    Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
 tools/xenstore/xenstored_core.c   |  1 +
 tools/xenstore/xenstored_domain.c | 26 ++++++++++++++++++++++++++
 tools/xenstore/xenstored_domain.h |  2 ++
 3 files changed, 29 insertions(+)

diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_core.c
index 069160a..07ca98e 100644
--- a/tools/xenstore/xenstored_core.c
+++ b/tools/xenstore/xenstored_core.c
@@ -374,6 +374,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) {
diff --git a/tools/xenstore/xenstored_domain.c 
b/tools/xenstore/xenstored_domain.c
index 85fa658..b818edc 100644
--- a/tools/xenstore/xenstored_domain.c
+++ b/tools/xenstore/xenstored_domain.c
@@ -23,6 +23,7 @@
 #include <stdlib.h>
 #include <stdarg.h>
 #include <time.h>
+#include <syslog.h>
 
 #include "utils.h"
 #include "talloc.h"
@@ -79,6 +80,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);
@@ -770,6 +772,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)
 {
@@ -919,6 +922,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;
@@ -934,6 +940,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)
diff --git a/tools/xenstore/xenstored_domain.h 
b/tools/xenstore/xenstored_domain.h
index a008554..a9650cc 100644
--- a/tools/xenstore/xenstored_domain.h
+++ b/tools/xenstore/xenstored_domain.h
@@ -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);
 
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.5

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.