Re: [systemd-devel] [PATCH V1] Add L3 cache allocation settings in systemd

2018-07-13 Thread Lennart Poettering
On Sa, 30.06.18 09:44, Zhangyanfei (YF) (yanfei.zh...@huawei.com) wrote:

> Hello,
> 
> I am sorry I can only send the patches by using email because of some
> security reasons and the limit of my workspace.

While we are fine with accepting smaller patches by email for complex
stuff (and this qualifies as such) we really need submissions via
github. Reviewing is otherwise such a mess.

Sorry,

Lennart

-- 
Lennart Poettering, Red Hat
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH V1] Add L3 cache allocation settings in systemd

2018-06-29 Thread systemd github import bot
Patchset imported to github.
To create a pull request, one of the main developers has to initiate one via:


--
Generated by https://github.com/haraldh/mail2git
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH V1] Add L3 cache allocation settings in systemd

2018-06-29 Thread Zhangyanfei (YF)
Hello,

I am sorry I can only send the patches by using email because of some
security reasons and the limit of my workspace.


From 962eeb1869fb033d04074df0f992a6588e97164e Mon Sep 17 00:00:00 2001
From: Yanfei Zhang 
Date: Fri, 8 Jun 2018 03:00:53 -0400
Subject: [PATCH] Add L3 cache allocation settings in systemd

The patch tries to add L3 cache allocation settings in systemd.
L3 cache allocation control is supported by new intel cpu and
is exposed by a new filesystem named resctrl. For detail information,
please refer to https://www.kernel.org/doc/Documentation/x86/intel_rdt_ui.txt.

The patch adds the following things:
1. Mount resctrl when systemd starts.
2. Add two config items for L3 cache allocation control
   - L3CacheAllocationSize=XX
 L3CacheAllocationSize is used to indicates how many caches
 the group can use at most, but note the value will be round
 up to the N * min_granularity. For example, if L3 cache size
 is 30M and can be divided into 10 ways, so each way is 3M.
 L3CacheAllocationSize=10M means the group will have 4 ways
 (4 * 3M > 10M) of the cache.

   - L3CacheAllocationIds=XX
 L3CacheAllocationIds controls the cache id for this group.
 If we have two cpu sockets and we will have two L3 caches.
 We can use this setting to indicate which socket cache we
 want to control.
3. Create new directory in resctrl and initialize the schemata
   when systemd detects the above two configs in a unit. The directory
   name is the same as the unit.
4. The settings can be applied to all units just like cgroup setting.

Signed-off-by: Yanfei Zhang 
---
 src/basic/exit-status.h   |   1 +
 src/basic/parse-util.c|  22 +
 src/basic/parse-util.h|   6 +
 src/core/dbus-resctrl.c   |  70 +++
 src/core/dbus-resctrl.h   |  25 +
 src/core/dbus-slice.c |   6 +
 src/core/execute.c|  11 +
 src/core/load-fragment-gperf.gperf.m4 |  10 +
 src/core/load-fragment.c  |  43 ++
 src/core/load-fragment.h  |   1 +
 src/core/main.c   |   1 +
 src/core/meson.build  |   4 +
 src/core/mount-setup.c|   2 +
 src/core/mount.c  |   2 +
 src/core/mount.h  |   1 +
 src/core/resctrl.c| 743 ++
 src/core/resctrl.h|  90 
 src/core/scope.c  |   2 +
 src/core/scope.h  |   1 +
 src/core/service.c|   6 +-
 src/core/service.h|   1 +
 src/core/slice.c  |   3 +
 src/core/slice.h  |   1 +
 src/core/socket.c |   2 +
 src/core/socket.h |   1 +
 src/core/swap.c   |   2 +
 src/core/swap.h   |   1 +
 src/core/unit.c   |  25 +
 src/core/unit.h   |   6 +
 29 files changed, 1088 insertions(+), 1 deletion(-)
 create mode 100644 src/core/dbus-resctrl.c
 create mode 100644 src/core/dbus-resctrl.h
 create mode 100644 src/core/resctrl.c
 create mode 100644 src/core/resctrl.h

diff --git a/src/basic/exit-status.h b/src/basic/exit-status.h
index c41e8b8..fbd3fee 100644
--- a/src/basic/exit-status.h
+++ b/src/basic/exit-status.h
@@ -69,6 +69,7 @@ enum {
 EXIT_CACHE_DIRECTORY,
 EXIT_LOGS_DIRECTORY, /* 240 */
 EXIT_CONFIGURATION_DIRECTORY,
+EXIT_RESCTRL_WRITE_PID,
 };
 
 typedef enum ExitStatusLevel {
diff --git a/src/basic/parse-util.c b/src/basic/parse-util.c
index 6becf85..dd23ca3 100644
--- a/src/basic/parse-util.c
+++ b/src/basic/parse-util.c
@@ -453,6 +453,28 @@ int safe_atollu(const char *s, long long unsigned 
*ret_llu) {
 return 0;
 }
 
+int safe_atollx(const char *s, long long unsigned *ret_llx) {
+char *x = NULL;
+unsigned long long l;
+
+assert(s);
+assert(ret_llx);
+
+s += strspn(s, WHITESPACE);
+
+errno = 0;
+l = strtoull(s, , 16);
+if (errno > 0)
+return -errno;
+if (!x || x == s || *x != 0)
+return -EINVAL;
+if (*s == '-')
+return -ERANGE;
+
+*ret_llx = l;
+return 0;
+}
+
 int safe_atolli(const char *s, long long int *ret_lli) {
 char *x = NULL;
 long long l;
diff --git a/src/basic/parse-util.h b/src/basic/parse-util.h
index f3267f4..8ebed40 100644
--- a/src/basic/parse-util.h
+++ b/src/basic/parse-util.h
@@ -34,6 +34,7 @@ static inline int safe_atou(const char *s, unsigned *ret_u) {
 
 int safe_atoi(const char *s, int *ret_i);
 int safe_atollu(const char *s, unsigned long long *ret_u);
+int safe_atollx(const char *s, unsigned long long *ret_x);
 int safe_atolli(const char *s, long long int *ret_i);
 
 int safe_atou8(const char *s, uint8_t *ret);
@@ -65,6 +66,11 @@ static