[systemd-commits] 2 commits - man/systemd-system.conf.xml man/systemd.resource-control.xml src/core src/libsystemd src/shared src/timesync

Lennart Poettering lennart at kemper.freedesktop.org
Wed May 21 19:54:37 PDT 2014


 man/systemd-system.conf.xml           |   12 ------
 man/systemd.resource-control.xml      |   27 ++-------------
 src/core/cgroup.c                     |   47 +++-----------------------
 src/core/cgroup.h                     |    5 --
 src/core/dbus-cgroup.c                |   61 ----------------------------------
 src/core/load-fragment-gperf.gperf.m4 |    3 -
 src/core/load-fragment.c              |   28 +++++----------
 src/core/main.c                       |    3 -
 src/core/manager.c                    |    1 
 src/core/manager.h                    |    1 
 src/core/system.conf                  |    1 
 src/core/unit.c                       |    1 
 src/libsystemd/sd-bus/bus-util.c      |   32 -----------------
 src/shared/logs-show.c                |    6 +--
 src/shared/time-util.c                |   24 ++++++-------
 src/shared/time-util.h                |   38 ++++++++++-----------
 src/timesync/timesyncd.c              |    8 ++--
 17 files changed, 63 insertions(+), 235 deletions(-)

New commits:
commit 9a0549093332880df47c4218209ce126b8586835
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu May 22 11:53:12 2014 +0900

    cgroups: simplify CPUQuota= logic
    
    Only accept cpu quota values in percentages, get rid of period
    definition.
    
    It's not clear whether the CFS period controllable per-cgroup even has a
    future in the kernel, hence let's simplify all this, hardcode the period
    to 100ms and only accept percentage based quota values.

diff --git a/man/systemd-system.conf.xml b/man/systemd-system.conf.xml
index 3814bd2..e2b2bd8 100644
--- a/man/systemd-system.conf.xml
+++ b/man/systemd-system.conf.xml
@@ -302,18 +302,6 @@
                         </varlistentry>
 
                         <varlistentry>
-                                <term><varname>DefaultCPUQuotaPeriodSec=</varname></term>
-
-                                <listitem><para>Sets the default CPU
-                                quota period. Defaults to 100ms. This
-                                controls th global default for the
-                                <varname>CPUQuotaPeriodSec=</varname>
-                                setting of units, see
-                                <citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>
-                                for details.</para></listitem>
-                        </varlistentry>
-
-                        <varlistentry>
                                 <term><varname>DefaultTimeoutStartSec=</varname></term>
                                 <term><varname>DefaultTimeoutStopSec=</varname></term>
                                 <term><varname>DefaultRestartSec=</varname></term>
diff --git a/man/systemd.resource-control.xml b/man/systemd.resource-control.xml
index a1f63dd..e0e49db 100644
--- a/man/systemd.resource-control.xml
+++ b/man/systemd.resource-control.xml
@@ -143,14 +143,11 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>.
 
         <listitem>
           <para>Assign the specified CPU time quota to the processes
-          executed. Takes a percentage value (suffixed with "%") or an
-          absolute time (suffixed by one of the common time units, us,
-          ms, s, ...). The percentage specifies how much CPU time the
-          unit shall get at maximum, relative to the total CPU time
-          available on one CPU. Use values > 100% for alloting CPU
-          time on more than one CPU. If an absolute time is specified
-          the processes of this unit will get this much absolute time
-          within each quota period, at maximum. This controls the
+          executed. Takes a percentage value, suffixed with "%". The
+          percentage specifies how much CPU time the unit shall get at
+          maximum, relative to the total CPU time available on one
+          CPU. Use values > 100% for alloting CPU time on more than
+          one CPU. This controls the
           <literal>cpu.cfs_quota_us</literal> control group
           attribute. For details about this control group attribute,
           see <ulink
@@ -165,20 +162,6 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>.
       </varlistentry>
 
       <varlistentry>
-        <term><varname>CPUQuotaPeriodSec=</varname></term>
-
-        <listitem>
-          <para>Specify the CPU quota period to use. Defaults to
-          100ms. This controls the <literal>cpu.cfs_period_us</literal>
-          control group attribute. For details about this control
-          group attribute, see <ulink
-          url="https://www.kernel.org/doc/Documentation/scheduler/sched-design-CFS.txt">sched-design-CFS.txt</ulink>.</para>
-
-          <para>Implies <literal>CPUAccounting=true</literal>.</para>
-        </listitem>
-      </varlistentry>
-
-      <varlistentry>
         <term><varname>MemoryAccounting=</varname></term>
 
         <listitem>
diff --git a/src/core/cgroup.c b/src/core/cgroup.c
index 36e9f53..cd67963 100644
--- a/src/core/cgroup.c
+++ b/src/core/cgroup.c
@@ -27,6 +27,8 @@
 #include "cgroup-util.h"
 #include "cgroup.h"
 
+#define CGROUP_CPU_QUOTA_PERIOD_USEC ((usec_t) 100 * USEC_PER_MSEC)
+
 void cgroup_context_init(CGroupContext *c) {
         assert(c);
 
@@ -40,8 +42,6 @@ void cgroup_context_init(CGroupContext *c) {
         c->startup_blockio_weight = (unsigned long) -1;
 
         c->cpu_quota_per_sec_usec = (usec_t) -1;
-        c->cpu_quota_usec = (usec_t) -1;
-        c->cpu_quota_period_usec = 100*USEC_PER_MSEC;
 }
 
 void cgroup_context_free_device_allow(CGroupContext *c, CGroupDeviceAllow *a) {
@@ -84,37 +84,11 @@ void cgroup_context_done(CGroupContext *c) {
                 cgroup_context_free_device_allow(c, c->device_allow);
 }
 
-usec_t cgroup_context_get_cpu_quota_usec(CGroupContext *c) {
-        assert(c);
-
-        /* Returns the absolute CPU quota */
-
-        if (c->cpu_quota_usec != (usec_t) -1)
-                return c->cpu_quota_usec;
-        else if (c->cpu_quota_per_sec_usec != (usec_t) -1)
-                return c->cpu_quota_per_sec_usec*c->cpu_quota_period_usec/USEC_PER_SEC;
-        else
-                return (usec_t) -1;
-}
-
-usec_t cgroup_context_get_cpu_quota_per_sec_usec(CGroupContext *c) {
-        assert(c);
-
-        /* Returns the CPU quota relative to 1s */
-
-        if (c->cpu_quota_usec != (usec_t) -1)
-                return c->cpu_quota_usec*USEC_PER_SEC/c->cpu_quota_period_usec;
-        else if (c->cpu_quota_per_sec_usec != (usec_t) -1)
-                return c->cpu_quota_per_sec_usec;
-        else
-                return (usec_t) -1;
-}
-
 void cgroup_context_dump(CGroupContext *c, FILE* f, const char *prefix) {
         CGroupBlockIODeviceBandwidth *b;
         CGroupBlockIODeviceWeight *w;
         CGroupDeviceAllow *a;
-        char t[FORMAT_TIMESPAN_MAX], s[FORMAT_TIMESPAN_MAX], u[FORMAT_TIMESPAN_MAX];
+        char u[FORMAT_TIMESPAN_MAX];
 
         assert(c);
         assert(f);
@@ -127,9 +101,7 @@ void cgroup_context_dump(CGroupContext *c, FILE* f, const char *prefix) {
                 "%sMemoryAccounting=%s\n"
                 "%sCPUShares=%lu\n"
                 "%sStartupCPUShares=%lu\n"
-                "%sCPUQuota=%s\n"
                 "%sCPUQuotaPerSecSec=%s\n"
-                "%sCPUQuotaPeriodSec=%s\n"
                 "%sBlockIOWeight=%lu\n"
                 "%sStartupBlockIOWeight=%lu\n"
                 "%sMemoryLimit=%" PRIu64 "\n"
@@ -139,9 +111,7 @@ void cgroup_context_dump(CGroupContext *c, FILE* f, const char *prefix) {
                 prefix, yes_no(c->memory_accounting),
                 prefix, c->cpu_shares,
                 prefix, c->startup_cpu_shares,
-                prefix, strna(format_timespan(u, sizeof(u), cgroup_context_get_cpu_quota_usec(c), 1)),
-                prefix, strna(format_timespan(t, sizeof(t), cgroup_context_get_cpu_quota_per_sec_usec(c), 1)),
-                prefix, strna(format_timespan(s, sizeof(s), c->cpu_quota_period_usec, 1)),
+                prefix, strna(format_timespan(u, sizeof(u), c->cpu_quota_per_sec_usec, 1)),
                 prefix, c->blockio_weight,
                 prefix, c->startup_blockio_weight,
                 prefix, c->memory_limit,
@@ -328,7 +298,6 @@ void cgroup_context_apply(CGroupContext *c, CGroupControllerMask mask, const cha
 
         if ((mask & CGROUP_CPU) && !is_root) {
                 char buf[MAX(DECIMAL_STR_MAX(unsigned long), DECIMAL_STR_MAX(usec_t)) + 1];
-                usec_t q;
 
                 sprintf(buf, "%lu\n",
                         state == MANAGER_STARTING && c->startup_cpu_shares != (unsigned long) -1 ? c->startup_cpu_shares :
@@ -337,14 +306,13 @@ void cgroup_context_apply(CGroupContext *c, CGroupControllerMask mask, const cha
                 if (r < 0)
                         log_warning("Failed to set cpu.shares on %s: %s", path, strerror(-r));
 
-                sprintf(buf, USEC_FMT "\n", c->cpu_quota_period_usec);
+                sprintf(buf, USEC_FMT "\n", CGROUP_CPU_QUOTA_PERIOD_USEC);
                 r = cg_set_attribute("cpu", path, "cpu.cfs_period_us", buf);
                 if (r < 0)
                         log_warning("Failed to set cpu.cfs_period_us on %s: %s", path, strerror(-r));
 
-                q = cgroup_context_get_cpu_quota_usec(c);
-                if (q != (usec_t) -1) {
-                        sprintf(buf, USEC_FMT "\n", q);
+                if (c->cpu_quota_per_sec_usec != (usec_t) -1) {
+                        sprintf(buf, USEC_FMT "\n", c->cpu_quota_per_sec_usec * CGROUP_CPU_QUOTA_PERIOD_USEC / USEC_PER_SEC);
                         r = cg_set_attribute("cpu", path, "cpu.cfs_quota_us", buf);
                 } else
                         r = cg_set_attribute("cpu", path, "cpu.cfs_quota_us", "-1");
@@ -479,7 +447,6 @@ CGroupControllerMask cgroup_context_get_mask(CGroupContext *c) {
         if (c->cpu_accounting ||
             c->cpu_shares != (unsigned long) -1 ||
             c->startup_cpu_shares != (unsigned long) -1 ||
-            c->cpu_quota_usec != (usec_t) -1 ||
             c->cpu_quota_per_sec_usec != (usec_t) -1)
                 mask |= CGROUP_CPUACCT | CGROUP_CPU;
 
diff --git a/src/core/cgroup.h b/src/core/cgroup.h
index 44482c5..d299872 100644
--- a/src/core/cgroup.h
+++ b/src/core/cgroup.h
@@ -73,8 +73,6 @@ struct CGroupContext {
         unsigned long cpu_shares;
         unsigned long startup_cpu_shares;
         usec_t cpu_quota_per_sec_usec;
-        usec_t cpu_quota_usec;
-        usec_t cpu_quota_period_usec;
 
         unsigned long blockio_weight;
         unsigned long startup_blockio_weight;
@@ -102,9 +100,6 @@ void cgroup_context_free_device_allow(CGroupContext *c, CGroupDeviceAllow *a);
 void cgroup_context_free_blockio_device_weight(CGroupContext *c, CGroupBlockIODeviceWeight *w);
 void cgroup_context_free_blockio_device_bandwidth(CGroupContext *c, CGroupBlockIODeviceBandwidth *b);
 
-usec_t cgroup_context_get_cpu_quota_usec(CGroupContext *c);
-usec_t cgroup_context_get_cpu_quota_per_sec_usec(CGroupContext *c);
-
 CGroupControllerMask unit_get_cgroup_mask(Unit *u);
 CGroupControllerMask unit_get_siblings_mask(Unit *u);
 CGroupControllerMask unit_get_members_mask(Unit *u);
diff --git a/src/core/dbus-cgroup.c b/src/core/dbus-cgroup.c
index ce7e55c..eb7c2b9 100644
--- a/src/core/dbus-cgroup.c
+++ b/src/core/dbus-cgroup.c
@@ -133,24 +133,6 @@ static int property_get_device_allow(
         return sd_bus_message_close_container(reply);
 }
 
-static int property_get_cpu_quota_usec(
-                sd_bus *bus,
-                const char *path,
-                const char *interface,
-                const char *property,
-                sd_bus_message *reply,
-                void *userdata,
-                sd_bus_error *error) {
-
-        CGroupContext *c = userdata;
-
-        assert(bus);
-        assert(reply);
-        assert(c);
-
-        return sd_bus_message_append(reply, "t", cgroup_context_get_cpu_quota_usec(c));
-}
-
 static int property_get_cpu_quota_per_sec_usec(
                 sd_bus *bus,
                 const char *path,
@@ -166,7 +148,7 @@ static int property_get_cpu_quota_per_sec_usec(
         assert(reply);
         assert(c);
 
-        return sd_bus_message_append(reply, "t", cgroup_context_get_cpu_quota_per_sec_usec(c));
+        return sd_bus_message_append(reply, "t", c->cpu_quota_per_sec_usec);
 }
 
 static int property_get_ulong_as_u64(
@@ -193,8 +175,6 @@ const sd_bus_vtable bus_cgroup_vtable[] = {
         SD_BUS_PROPERTY("CPUShares", "t", property_get_ulong_as_u64, offsetof(CGroupContext, cpu_shares), 0),
         SD_BUS_PROPERTY("StartupCPUShares", "t", property_get_ulong_as_u64, offsetof(CGroupContext, startup_cpu_shares), 0),
         SD_BUS_PROPERTY("CPUQuotaPerSecUSec", "t", property_get_cpu_quota_per_sec_usec, 0, 0),
-        SD_BUS_PROPERTY("CPUQuotaUSec", "t", property_get_cpu_quota_usec, 0, 0),
-        SD_BUS_PROPERTY("CPUQuotaPeriodUSec", "t", bus_property_get_usec, offsetof(CGroupContext, cpu_quota_period_usec), 0),
         SD_BUS_PROPERTY("BlockIOAccounting", "b", bus_property_get_bool, offsetof(CGroupContext, blockio_accounting), 0),
         SD_BUS_PROPERTY("BlockIOWeight", "t", property_get_ulong_as_u64, offsetof(CGroupContext, blockio_weight), 0),
         SD_BUS_PROPERTY("StartupBlockIOWeight", "t", property_get_ulong_as_u64, offsetof(CGroupContext, startup_blockio_weight), 0),
@@ -298,51 +278,12 @@ int bus_cgroup_set_property(
 
                 if (mode != UNIT_CHECK) {
                         c->cpu_quota_per_sec_usec = u64;
-                        c->cpu_quota_usec = (uint64_t) -1;
                         u->cgroup_realized_mask &= ~CGROUP_CPU;
                         unit_write_drop_in_private_format(u, mode, "CPUQuota", "CPUQuota=%0.f%%", (double) (c->cpu_quota_per_sec_usec / 10000));
                 }
 
                 return 1;
 
-        } else if (streq(name, "CPUQuotaUSec")) {
-                uint64_t u64;
-
-                r = sd_bus_message_read(message, "t", &u64);
-                if (r < 0)
-                        return r;
-
-                if (u64 <= 0)
-                        return sd_bus_error_set_errnof(error, EINVAL, "CPUQuotaUSec value out of range");
-
-                if (mode != UNIT_CHECK) {
-                        c->cpu_quota_usec = u64;
-                        c->cpu_quota_per_sec_usec = (uint64_t) -1;
-                        u->cgroup_realized_mask &= ~CGROUP_CPU;
-                        unit_write_drop_in_private_format(u, mode, "CPUQuota", "CPUQuota=%" PRIu64 "us", u64);
-                }
-
-                return 1;
-
-        } else if (streq(name, "CPUQuotaPeriodUSec")) {
-
-                uint64_t u64;
-
-                r = sd_bus_message_read(message, "t", &u64);
-                if (r < 0)
-                        return r;
-
-                if (u64 <= 0 || u64 >= (usec_t) -1)
-                        return sd_bus_error_set_errnof(error, EINVAL, "CPUQuotaPeriodUSec value out of range");
-
-                if (mode != UNIT_CHECK) {
-                        c->cpu_quota_period_usec = u64;
-                        u->cgroup_realized_mask &= ~CGROUP_CPU;
-                        unit_write_drop_in_private_format(u, mode, name, "CPUQuotaPeriodSec=%" PRIu64 "us", c->cpu_quota_period_usec);
-                }
-
-                return 1;
-
         } else if (streq(name, "BlockIOAccounting")) {
                 int b;
 
diff --git a/src/core/load-fragment-gperf.gperf.m4 b/src/core/load-fragment-gperf.gperf.m4
index 524e5c7..4c066a8 100644
--- a/src/core/load-fragment-gperf.gperf.m4
+++ b/src/core/load-fragment-gperf.gperf.m4
@@ -108,14 +108,13 @@ $1.CPUAccounting,                config_parse_bool,                  0,
 $1.CPUShares,                    config_parse_cpu_shares,            0,                             offsetof($1, cgroup_context.cpu_shares)
 $1.StartupCPUShares,             config_parse_cpu_shares,            0,                             offsetof($1, cgroup_context.startup_cpu_shares)
 $1.CPUQuota,                     config_parse_cpu_quota,             0,                             offsetof($1, cgroup_context)
-$1.CPUQuotaPeriodSec,            config_parse_sec,                   0,                             offsetof($1, cgroup_context.cpu_quota_period_usec)
 $1.MemoryAccounting,             config_parse_bool,                  0,                             offsetof($1, cgroup_context.memory_accounting)
 $1.MemoryLimit,                  config_parse_memory_limit,          0,                             offsetof($1, cgroup_context)
 $1.DeviceAllow,                  config_parse_device_allow,          0,                             offsetof($1, cgroup_context)
 $1.DevicePolicy,                 config_parse_device_policy,         0,                             offsetof($1, cgroup_context.device_policy)
 $1.BlockIOAccounting,            config_parse_bool,                  0,                             offsetof($1, cgroup_context.blockio_accounting)
 $1.BlockIOWeight,                config_parse_blockio_weight,        0,                             offsetof($1, cgroup_context.blockio_weight)
-$1.StartupBlockIOWeight,         config_parse_blockio_weight,        0,                            offsetof($1, cgroup_context.startup_blockio_weight)
+$1.StartupBlockIOWeight,         config_parse_blockio_weight,        0,                             offsetof($1, cgroup_context.startup_blockio_weight)
 $1.BlockIODeviceWeight,          config_parse_blockio_device_weight, 0,                             offsetof($1, cgroup_context)
 $1.BlockIOReadBandwidth,         config_parse_blockio_bandwidth,     0,                             offsetof($1, cgroup_context)
 $1.BlockIOWriteBandwidth,        config_parse_blockio_bandwidth,     0,                             offsetof($1, cgroup_context)'
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
index 7c5b49c..6403e41 100644
--- a/src/core/load-fragment.c
+++ b/src/core/load-fragment.c
@@ -2465,7 +2465,7 @@ int config_parse_cpu_quota(
                 void *userdata) {
 
         CGroupContext *c = data;
-        int r;
+        double percent;
 
         assert(filename);
         assert(lvalue);
@@ -2473,30 +2473,22 @@ int config_parse_cpu_quota(
 
         if (isempty(rvalue)) {
                 c->cpu_quota_per_sec_usec = (usec_t) -1;
-                c->cpu_quota_usec = (usec_t) -1;
                 return 0;
         }
 
-        if (endswith(rvalue, "%")) {
-                double percent;
-
-                if (sscanf(rvalue, "%lf%%", &percent) != 1 || percent <= 0) {
-                        log_syntax(unit, LOG_ERR, filename, line, EINVAL, "CPU quota '%s' invalid. Ignoring.", rvalue);
-                        return 0;
-                }
+        if (!endswith(rvalue, "%")) {
 
-                c->cpu_quota_per_sec_usec = (usec_t) (percent * USEC_PER_SEC / 100);
-                c->cpu_quota_usec = (usec_t) -1;
-        } else {
-                r = parse_sec(rvalue, &c->cpu_quota_usec);
-                if (r < 0) {
-                        log_syntax(unit, LOG_ERR, filename, line, EINVAL, "CPU quota '%s' invalid. Ignoring.", rvalue);
-                        return 0;
-                }
+                log_syntax(unit, LOG_ERR, filename, line, EINVAL, "CPU quota '%s' not ending in '%%'. Ignoring.", rvalue);
+                return 0;
+        }
 
-                c->cpu_quota_per_sec_usec = (usec_t) -1;
+        if (sscanf(rvalue, "%lf%%", &percent) != 1 || percent <= 0) {
+                log_syntax(unit, LOG_ERR, filename, line, EINVAL, "CPU quota '%s' invalid. Ignoring.", rvalue);
+                return 0;
         }
 
+        c->cpu_quota_per_sec_usec = (usec_t) (percent * USEC_PER_SEC / 100);
+
         return 0;
 }
 
diff --git a/src/core/main.c b/src/core/main.c
index c1b0ffd..74c50f5 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -109,7 +109,6 @@ static struct rlimit *arg_default_rlimit[_RLIMIT_MAX] = {};
 static uint64_t arg_capability_bounding_set_drop = 0;
 static nsec_t arg_timer_slack_nsec = (nsec_t) -1;
 static usec_t arg_default_timer_accuracy_usec = 1 * USEC_PER_MINUTE;
-static usec_t arg_default_cpu_quota_period_usec = 100 * USEC_PER_MSEC;
 static Set* arg_syscall_archs = NULL;
 static FILE* arg_serialization = NULL;
 static bool arg_default_cpu_accounting = false;
@@ -684,7 +683,6 @@ static int parse_config_file(void) {
 #endif
                 { "Manager", "TimerSlackNSec",            config_parse_nsec,             0, &arg_timer_slack_nsec                  },
                 { "Manager", "DefaultTimerAccuracySec",   config_parse_sec,              0, &arg_default_timer_accuracy_usec       },
-                { "Manager", "DefaultCPUQuotaPeriodSec",  config_parse_sec,              0, &arg_default_cpu_quota_period_usec     },
                 { "Manager", "DefaultStandardOutput",     config_parse_output,           0, &arg_default_std_output                },
                 { "Manager", "DefaultStandardError",      config_parse_output,           0, &arg_default_std_error                 },
                 { "Manager", "DefaultTimeoutStartSec",    config_parse_sec,              0, &arg_default_timeout_start_usec        },
@@ -1619,7 +1617,6 @@ int main(int argc, char *argv[]) {
 
         m->confirm_spawn = arg_confirm_spawn;
         m->default_timer_accuracy_usec = arg_default_timer_accuracy_usec;
-        m->default_cpu_quota_period_usec = arg_default_cpu_quota_period_usec;
         m->default_std_output = arg_default_std_output;
         m->default_std_error = arg_default_std_error;
         m->default_restart_usec = arg_default_restart_usec;
diff --git a/src/core/manager.c b/src/core/manager.c
index 2975746..0cb2044 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -429,7 +429,6 @@ int manager_new(SystemdRunningAs running_as, Manager **_m) {
         m->running_as = running_as;
         m->exit_code = _MANAGER_EXIT_CODE_INVALID;
         m->default_timer_accuracy_usec = USEC_PER_MINUTE;
-        m->default_cpu_quota_period_usec = 100 * USEC_PER_MSEC;
 
         m->idle_pipe[0] = m->idle_pipe[1] = m->idle_pipe[2] = m->idle_pipe[3] = -1;
 
diff --git a/src/core/manager.h b/src/core/manager.h
index ab4cafc..f2c1b0d 100644
--- a/src/core/manager.h
+++ b/src/core/manager.h
@@ -243,7 +243,6 @@ struct Manager {
         bool default_cpu_accounting;
         bool default_memory_accounting;
         bool default_blockio_accounting;
-        usec_t default_cpu_quota_period_usec;
 
         usec_t default_timer_accuracy_usec;
 
diff --git a/src/core/system.conf b/src/core/system.conf
index 4d775fa..65a35a0 100644
--- a/src/core/system.conf
+++ b/src/core/system.conf
@@ -24,7 +24,6 @@
 #SystemCallArchitectures=
 #TimerSlackNSec=
 #DefaultTimerAccuracySec=1min
-#DefaultCPUQuotaPeriodSec=100ms
 #DefaultStandardOutput=journal
 #DefaultStandardError=inherit
 #DefaultTimeoutStartSec=90s
diff --git a/src/core/unit.c b/src/core/unit.c
index 99ee709..3f862aa 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -121,7 +121,6 @@ static void unit_init(Unit *u) {
                 cc->cpu_accounting = u->manager->default_cpu_accounting;
                 cc->blockio_accounting = u->manager->default_blockio_accounting;
                 cc->memory_accounting = u->manager->default_memory_accounting;
-                cc->cpu_quota_period_usec = u->manager->default_cpu_quota_period_usec;
         }
 
         ec = unit_get_exec_context(u);
diff --git a/src/libsystemd/sd-bus/bus-util.c b/src/libsystemd/sd-bus/bus-util.c
index 6220934..6c9548f 100644
--- a/src/libsystemd/sd-bus/bus-util.c
+++ b/src/libsystemd/sd-bus/bus-util.c
@@ -1274,40 +1274,10 @@ int bus_append_unit_property_assignment(sd_bus_message *m, const char *assignmen
 
                         r = sd_bus_message_append(m, "v", "t", (usec_t) percent * USEC_PER_SEC / 100);
                 } else {
-                        usec_t us;
-
-                        r = parse_sec(eq, &us);
-                        if (r < 0) {
-                                log_error("CPU quota '%s' invalid.", eq);
-                                return -EINVAL;
-                        }
-
-                        r = sd_bus_message_append_basic(m, SD_BUS_TYPE_STRING, "CPUQuotaUSec");
-                        if (r < 0)
-                                return bus_log_create_error(r);
-
-                        r = sd_bus_message_append(m, "v", "t", us);
-                }
-
-                if (r < 0)
-                        return bus_log_create_error(r);
-
-                return 0;
-
-        } else if (streq(field, "CPUQuotaPeriodSec")) {
-                usec_t us;
-
-                r = parse_sec(eq, &us);
-                if (r < 0) {
-                        log_error("CPU period '%s' invalid.", eq);
+                        log_error("CPU quota needs to be in percent.");
                         return -EINVAL;
                 }
 
-                r = sd_bus_message_append_basic(m, SD_BUS_TYPE_STRING, "CPUQuotaPeriodUSec");
-                if (r < 0)
-                        return bus_log_create_error(r);
-
-                r = sd_bus_message_append(m, "v", "t", us);
                 if (r < 0)
                         return bus_log_create_error(r);
 

commit 609e002e78e79ef2bf9d6a6ea22bda215abbbb14
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu May 22 11:44:03 2014 +0900

    time-util: make sure USEC_PER_SEC and friends are actually of type usec_t

diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c
index c3578ac..8edf408 100644
--- a/src/shared/logs-show.c
+++ b/src/shared/logs-show.c
@@ -301,8 +301,8 @@ static int output_short(
                 }
 
                 fprintf(f, "[%5llu.%06llu]",
-                        t / USEC_PER_SEC,
-                        t % USEC_PER_SEC);
+                        (unsigned long long) (t / USEC_PER_SEC),
+                        (unsigned long long) (t % USEC_PER_SEC));
 
                 n += 1 + 5 + 1 + 6 + 1;
 
@@ -335,7 +335,7 @@ static int output_short(
                         r = strftime(buf, sizeof(buf), "%b %d %H:%M:%S", localtime_r(&t, &tm));
                         if (r > 0) {
                                 snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),
-                                         ".%06llu", x % USEC_PER_SEC);
+                                         ".%06llu", (unsigned long long) (x % USEC_PER_SEC));
                         }
                         break;
                 default:
diff --git a/src/shared/time-util.c b/src/shared/time-util.c
index c667638..8e5de77 100644
--- a/src/shared/time-util.c
+++ b/src/shared/time-util.c
@@ -183,7 +183,7 @@ char *format_timestamp_us(char *buf, size_t l, usec_t t) {
 
         if (strftime(buf, l, "%a %Y-%m-%d %H:%M:%S", &tm) <= 0)
                 return NULL;
-        snprintf(buf + strlen(buf), l - strlen(buf), ".%06llu", t % USEC_PER_SEC);
+        snprintf(buf + strlen(buf), l - strlen(buf), ".%06llu", (unsigned long long) (t % USEC_PER_SEC));
         if (strftime(buf + strlen(buf), l - strlen(buf), " %Z", &tm) <= 0)
                 return NULL;
 
@@ -208,41 +208,41 @@ char *format_timestamp_relative(char *buf, size_t l, usec_t t) {
         }
 
         if (d >= USEC_PER_YEAR)
-                snprintf(buf, l, "%llu years %llu months %s",
+                snprintf(buf, l, USEC_FMT " years " USEC_FMT " months %s",
                          d / USEC_PER_YEAR,
                          (d % USEC_PER_YEAR) / USEC_PER_MONTH, s);
         else if (d >= USEC_PER_MONTH)
-                snprintf(buf, l, "%llu months %llu days %s",
+                snprintf(buf, l, USEC_FMT " months " USEC_FMT " days %s",
                          d / USEC_PER_MONTH,
                          (d % USEC_PER_MONTH) / USEC_PER_DAY, s);
         else if (d >= USEC_PER_WEEK)
-                snprintf(buf, l, "%llu weeks %llu days %s",
+                snprintf(buf, l, USEC_FMT " weeks " USEC_FMT " days %s",
                          d / USEC_PER_WEEK,
                          (d % USEC_PER_WEEK) / USEC_PER_DAY, s);
         else if (d >= 2*USEC_PER_DAY)
-                snprintf(buf, l, "%llu days %s", d / USEC_PER_DAY, s);
+                snprintf(buf, l, USEC_FMT " days %s", d / USEC_PER_DAY, s);
         else if (d >= 25*USEC_PER_HOUR)
-                snprintf(buf, l, "1 day %lluh %s",
+                snprintf(buf, l, "1 day " USEC_FMT "h %s",
                          (d - USEC_PER_DAY) / USEC_PER_HOUR, s);
         else if (d >= 6*USEC_PER_HOUR)
-                snprintf(buf, l, "%lluh %s",
+                snprintf(buf, l, USEC_FMT "h %s",
                          d / USEC_PER_HOUR, s);
         else if (d >= USEC_PER_HOUR)
-                snprintf(buf, l, "%lluh %llumin %s",
+                snprintf(buf, l, USEC_FMT "h " USEC_FMT "min %s",
                          d / USEC_PER_HOUR,
                          (d % USEC_PER_HOUR) / USEC_PER_MINUTE, s);
         else if (d >= 5*USEC_PER_MINUTE)
-                snprintf(buf, l, "%llumin %s",
+                snprintf(buf, l, USEC_FMT "min %s",
                          d / USEC_PER_MINUTE, s);
         else if (d >= USEC_PER_MINUTE)
-                snprintf(buf, l, "%llumin %llus %s",
+                snprintf(buf, l, USEC_FMT "min " USEC_FMT "s %s",
                          d / USEC_PER_MINUTE,
                          (d % USEC_PER_MINUTE) / USEC_PER_SEC, s);
         else if (d >= USEC_PER_SEC)
-                snprintf(buf, l, "%llus %s",
+                snprintf(buf, l, USEC_FMT "s %s",
                          d / USEC_PER_SEC, s);
         else if (d >= USEC_PER_MSEC)
-                snprintf(buf, l, "%llums %s",
+                snprintf(buf, l, USEC_FMT "ms %s",
                          d / USEC_PER_MSEC, s);
         else if (d > 0)
                 snprintf(buf, l, USEC_FMT"us %s",
diff --git a/src/shared/time-util.h b/src/shared/time-util.h
index 96f2ec8..f68c095 100644
--- a/src/shared/time-util.h
+++ b/src/shared/time-util.h
@@ -37,25 +37,25 @@ typedef struct dual_timestamp {
         usec_t monotonic;
 } dual_timestamp;
 
-#define MSEC_PER_SEC  1000ULL
-#define USEC_PER_SEC  1000000ULL
-#define USEC_PER_MSEC 1000ULL
-#define NSEC_PER_SEC  1000000000ULL
-#define NSEC_PER_MSEC 1000000ULL
-#define NSEC_PER_USEC 1000ULL
-
-#define USEC_PER_MINUTE (60ULL*USEC_PER_SEC)
-#define NSEC_PER_MINUTE (60ULL*NSEC_PER_SEC)
-#define USEC_PER_HOUR (60ULL*USEC_PER_MINUTE)
-#define NSEC_PER_HOUR (60ULL*NSEC_PER_MINUTE)
-#define USEC_PER_DAY (24ULL*USEC_PER_HOUR)
-#define NSEC_PER_DAY (24ULL*NSEC_PER_HOUR)
-#define USEC_PER_WEEK (7ULL*USEC_PER_DAY)
-#define NSEC_PER_WEEK (7ULL*NSEC_PER_DAY)
-#define USEC_PER_MONTH (2629800ULL*USEC_PER_SEC)
-#define NSEC_PER_MONTH (2629800ULL*NSEC_PER_SEC)
-#define USEC_PER_YEAR (31557600ULL*USEC_PER_SEC)
-#define NSEC_PER_YEAR (31557600ULL*NSEC_PER_SEC)
+#define MSEC_PER_SEC  ((usec_t) 1000ULL)
+#define USEC_PER_SEC  ((usec_t) 1000000ULL)
+#define USEC_PER_MSEC ((usec_t) 1000ULL)
+#define NSEC_PER_SEC  ((usec_t) 1000000000ULL)
+#define NSEC_PER_MSEC ((usec_t) 1000000ULL)
+#define NSEC_PER_USEC ((usec_t) 1000ULL)
+
+#define USEC_PER_MINUTE ((usec_t) (60ULL*USEC_PER_SEC))
+#define NSEC_PER_MINUTE ((usec_t) (60ULL*NSEC_PER_SEC))
+#define USEC_PER_HOUR ((usec_t) (60ULL*USEC_PER_MINUTE))
+#define NSEC_PER_HOUR ((usec_t) (60ULL*NSEC_PER_MINUTE))
+#define USEC_PER_DAY ((usec_t) (24ULL*USEC_PER_HOUR))
+#define NSEC_PER_DAY ((usec_t) (24ULL*NSEC_PER_HOUR))
+#define USEC_PER_WEEK ((usec_t) (7ULL*USEC_PER_DAY))
+#define NSEC_PER_WEEK ((usec_t) (7ULL*NSEC_PER_DAY))
+#define USEC_PER_MONTH ((usec_t) (2629800ULL*USEC_PER_SEC))
+#define NSEC_PER_MONTH ((usec_t) (2629800ULL*NSEC_PER_SEC))
+#define USEC_PER_YEAR ((usec_t) (31557600ULL*USEC_PER_SEC))
+#define NSEC_PER_YEAR ((usec_t) (31557600ULL*NSEC_PER_SEC))
 
 #define FORMAT_TIMESTAMP_MAX ((4*4+1)+11+9+4+1) /* weekdays can be unicode */
 #define FORMAT_TIMESTAMP_RELATIVE_MAX 256
diff --git a/src/timesync/timesyncd.c b/src/timesync/timesyncd.c
index 54da88b..13cdef7 100644
--- a/src/timesync/timesyncd.c
+++ b/src/timesync/timesyncd.c
@@ -455,12 +455,12 @@ static int manager_adjust_clock(Manager *m, double offset, int leap_sec) {
         m->drift_ppm = tmx.freq / 65536;
 
         log_debug("  status       : %04i %s\n"
-                  "  time now     : %li.%03lli\n"
+                  "  time now     : %li.%03llu\n"
                   "  constant     : %li\n"
                   "  offset       : %+.3f sec\n"
                   "  freq offset  : %+li (%i ppm)\n",
                   tmx.status, tmx.status & STA_UNSYNC ? "" : "sync",
-                  tmx.time.tv_sec, tmx.time.tv_usec / NSEC_PER_MSEC,
+                  tmx.time.tv_sec, (unsigned long long) (tmx.time.tv_usec / NSEC_PER_MSEC),
                   tmx.constant,
                   (double)tmx.offset / NSEC_PER_SEC,
                   tmx.freq, m->drift_ppm);
@@ -727,7 +727,7 @@ static int manager_receive_response(sd_event_source *source, int fd, uint32_t re
                   "  delay        : %+.3f sec\n"
                   "  packet count : %"PRIu64"\n"
                   "  jitter       : %.3f%s\n"
-                  "  poll interval: %llu\n",
+                  "  poll interval: " USEC_FMT "\n",
                   NTP_FIELD_LEAP(ntpmsg.field),
                   NTP_FIELD_VERSION(ntpmsg.field),
                   NTP_FIELD_MODE(ntpmsg.field),
@@ -749,7 +749,7 @@ static int manager_receive_response(sd_event_source *source, int fd, uint32_t re
                         log_error("Failed to call clock_adjtime(): %m");
         }
 
-        log_info("interval/delta/delay/jitter/drift %llus/%+.3fs/%.3fs/%.3fs/%+ippm%s",
+        log_info("interval/delta/delay/jitter/drift " USEC_FMT "s/%+.3fs/%.3fs/%.3fs/%+ippm%s",
                  m->poll_interval_usec / USEC_PER_SEC, offset, delay, m->samples_jitter, m->drift_ppm,
                  spike ? " (ignored)" : "");
 



More information about the systemd-commits mailing list