1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
From 6a5b012157c3dbe4bb82f2aa3d950e20cb5bf9d6 Mon Sep 17 00:00:00 2001
From: Ian Jackson <ian.jackson@eu.citrix.com>
Date: Tue, 7 Mar 2017 16:09:13 +0000
Subject: [PATCH 02/15] xenstored: Log when the write transaction rate limit
bites
Reported-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
tools/xenstore/xenstored_core.c | 1 +
tools/xenstore/xenstored_domain.c | 25 +++++++++++++++++++++++++
tools/xenstore/xenstored_domain.h | 2 ++
3 files changed, 28 insertions(+)
diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_core.c
index d14f096..dc9a26f 100644
--- a/tools/xenstore/xenstored_core.c
+++ b/tools/xenstore/xenstored_core.c
@@ -379,6 +379,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 012dfe6..fd9ca39 100644
--- a/tools/xenstore/xenstored_domain.c
+++ b/tools/xenstore/xenstored_domain.c
@@ -22,6 +22,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);
@@ -774,6 +776,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)
{
@@ -923,6 +926,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;
@@ -938,6 +944,25 @@ 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++) {
+ 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 cec341e..561ab5d 100644
--- a/tools/xenstore/xenstored_domain.h
+++ b/tools/xenstore/xenstored_domain.h
@@ -72,6 +72,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;
@@ -87,6 +88,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);
--
2.1.4
|