From: Antony Deepak Thomas Date: Wed, 29 Sep 2021 04:07:42 +0000 (+0900) Subject: sysctl-util: minimize side-effects when running `systemd-sysctl` X-Git-Tag: v250-rc1~601^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ab14aa23aeecf62414a3468d19c797505ad2778d;p=thirdparty%2Fsystemd.git sysctl-util: minimize side-effects when running `systemd-sysctl` Currently `systemd-sysctl` binary is used in `systemd-sysctl.service` which is mostly configured as `oneshot`. There are situations where one would like to use systemd to maintain Sysctl configurations on a host, using a configuration managers such as Chef or Puppet, by apply configurations every X duration. The problem with using `systemd-sysctl` is that it writes all the Sysctl settings, even if the values for those settings have not changed. From experience, we have observed that some Sysctl settings cause actions in the kernel upon writing(like dropping caches) which in turn cause undesired side effects. This patch tries to minimize such side effects by comparing values before writing. --- diff --git a/src/basic/sysctl-util.c b/src/basic/sysctl-util.c index bb01d09696d..b66a6622ae7 100644 --- a/src/basic/sysctl-util.c +++ b/src/basic/sysctl-util.c @@ -58,7 +58,7 @@ int sysctl_write(const char *property, const char *value) { log_debug("Setting '%s' to '%s'", p, value); - return write_string_file(p, value, WRITE_STRING_FILE_VERIFY_ON_FAILURE | WRITE_STRING_FILE_DISABLE_BUFFER); + return write_string_file(p, value, WRITE_STRING_FILE_VERIFY_ON_FAILURE | WRITE_STRING_FILE_DISABLE_BUFFER | WRITE_STRING_FILE_SUPPRESS_REDUNDANT_VIRTUAL); } int sysctl_writef(const char *property, const char *format, ...) {