CentOs7 vm.swappiness cannot be set on boot

General support questions
Post Reply
hunter86_bg
Posts: 2019
Joined: 2015/02/17 15:14:33
Location: Bulgaria
Contact:

CentOs7 vm.swappiness cannot be set on boot

Post by hunter86_bg » 2015/12/30 09:48:13

Hi guys,
I'm currently studying for the RHCE and one of the topics is system optimization. I'm trying to set "vm.swappiness" to a non-default setting.
First, I've created a swappiness.conf file in "/etc/sysctl.d" and removed the link pointing to the sysctl.conf file - on reboot it doesn't do it. (sysctl -p and systemctl restart systemd-sysctl works).
Then, I decided to revert all changes and enter vm.swappiness=<digit> in sysctl.conf file (with and without empty spaces around the "=") and after each reboot - swappiness was set to default.After a "systemctl restart systemd-sysctl or with "sysctl -p sysctl.conf" - everything seems to be ok.
I'm using CentOs 7.2 with kernel 3.10.0-327.3.1

I'm out of any ideas.
Thanks for your time reading this long post.

Best Regards,
Strahil Nikolov

hunter86_bg
Posts: 2019
Joined: 2015/02/17 15:14:33
Location: Bulgaria
Contact:

Re: CentOs7 vm.swappiness cannot be set on boot

Post by hunter86_bg » 2015/12/30 11:19:54

I've tried with net.ipv4.ip_forward = 1 and it worked. It seems that systemd-systemctl.service is started too early and it can't change the swappiness level.

hunter86_bg
Posts: 2019
Joined: 2015/02/17 15:14:33
Location: Bulgaria
Contact:

Re: CentOs7 vm.swappiness cannot be set on boot

Post by hunter86_bg » 2015/12/30 12:04:47

Update:
I've just tested the 2 tunables under Centos 7.0 and it worked.

hunter86_bg
Posts: 2019
Joined: 2015/02/17 15:14:33
Location: Bulgaria
Contact:

Re: CentOs7 vm.swappiness cannot be set on boot

Post by hunter86_bg » 2015/12/30 13:14:00

It looks like a bug and I've reported it as https://bugs.centos.org/view.php?id=10045.

User avatar
avij
Retired Moderator
Posts: 3046
Joined: 2010/12/01 19:25:52
Location: Helsinki, Finland
Contact:

Re: CentOs7 vm.swappiness cannot be set on boot

Post by avij » 2015/12/30 16:09:53

Works fine here via /etc/sysctl.conf. Perhaps there is something that sets swappiness back to the default after sysctl has set the custom value? grep -r swappiness /etc may give you some clues.

hunter86_bg
Posts: 2019
Joined: 2015/02/17 15:14:33
Location: Bulgaria
Contact:

Re: CentOs7 vm.swappiness cannot be set on boot

Post by hunter86_bg » 2015/12/30 22:51:12

I've tested it today.
In CentOs 7.0 - works fine, in 7.0 with latest kernel - still OK.
In CentOs7.0 updated to -> 7.2 - not working.
In CentOs7.2 from DVD with no updates - not working.

It just seems to be a bug. For kernel tunables only sysctl config files (located in /etc/sysctl.d/ folder , and /etc/sysctl.conf) should change these parameters. On 7.2 after restart of systemd-sysctl everything works fine.

hunter86_bg
Posts: 2019
Joined: 2015/02/17 15:14:33
Location: Bulgaria
Contact:

Re: CentOs7 vm.swappiness cannot be set on boot

Post by hunter86_bg » 2016/01/09 16:14:22

Ok,
here is the reson why the swappiness got changed. In my tune profile

Code: Select all

# tuned-adm active
there is a setting for vm.swappiness which overrides the sysctl setting.The settings for the different profiles are in /usr/lib/tuned.

Post Reply