]> git.proxmox.com Git - mirror_lxcfs.git/log
mirror_lxcfs.git
4 years agobindings: ensure that opts is non NULL
Christian Brauner [Tue, 23 Jul 2019 14:57:28 +0000 (16:57 +0200)]
bindings: ensure that opts is non NULL

When the shared library is reloaded but the lxcfs binary itself will
likely not be replaced and even if will still be in-memory, i.e. the
fuse loop will not be restarted.
The code here introduced a new struct lxcfs_opts which is allocated and
gets stashed in the private_data member of the fuse file when the lxcfs
binary is first called. Now, in a scenario where the shared library is
reloaded the lxcfs binary itself won't be re-run. So now we have a
shared library that assumes there's always a valid struct lxcfs_opts
stashed in the private_data member. But there isnt'. This very likely
causes the segfaults we have seen.

Fix it by verifying a struct has been stashed.

Fixes: 7e60aa1b1540 ("option to disable swap in meminfo")
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoRelease LXCFS 3.1.1 lxcfs-3.1.1
Stéphane Graber [Mon, 22 Jul 2019 22:47:50 +0000 (18:47 -0400)]
Release LXCFS 3.1.1

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
4 years agoMakefile: Fix typo in file name
Stéphane Graber [Mon, 22 Jul 2019 22:47:20 +0000 (18:47 -0400)]
Makefile: Fix typo in file name

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
4 years agoRelease LXCFS 3.1.0 lxcfs-3.1.0
Stéphane Graber [Mon, 22 Jul 2019 22:43:16 +0000 (18:43 -0400)]
Release LXCFS 3.1.0

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
4 years agoMerge pull request #293 from brauner/2019-07-18/higher_precision_uptime
Stéphane Graber [Thu, 18 Jul 2019 19:44:14 +0000 (15:44 -0400)]
Merge pull request #293 from brauner/2019-07-18/higher_precision_uptime

bindings: enable higher precision uptime

4 years agobindings: enable higher precision uptime
Christian Brauner [Thu, 18 Jul 2019 13:44:06 +0000 (15:44 +0200)]
bindings: enable higher precision uptime

I don't know for what reason anyone but care but I guess ok.

Closes #292.
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoMerge pull request #290 from BurningXFlame/master
Christian Brauner [Wed, 17 Jul 2019 16:39:37 +0000 (18:39 +0200)]
Merge pull request #290 from BurningXFlame/master

CPU views based on quotas: several improvements

4 years agocpu: improve cpu info virtualization
Stephen Xiang [Fri, 14 Jun 2019 02:52:43 +0000 (10:52 +0800)]
cpu: improve cpu info virtualization

This commit introduces several improvements to CPU views based on
quotas:
- fall back to cpuacct.usage_percpu if cpuacct.usage_all not exists
- correct CPU usage
- correct CPU usage in partial CPU cases when quota/period doesn't yield
  an integer

Signed-off-by: Stephen Xiang <BurningXFlame@gmail.com>
[christian.brauner@ubuntu.com: squashed commits and fixed up commit message]
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
Abstract must_strcat from must_strcat_pid. Replace stringbuild with must_strcat.

Signed-off-by: Stephen Xiang <BurningXFlame@gmail.com>
5 years agoMerge pull request #282 from aither64/syscpus
Christian Brauner [Tue, 21 May 2019 14:19:48 +0000 (16:19 +0200)]
Merge pull request #282 from aither64/syscpus

mount hook: mount /sys/devices/system/cpu/online

5 years agomount hook: mount /sys/devices/system/cpu/online
Jakub Skokan [Tue, 21 May 2019 13:50:54 +0000 (15:50 +0200)]
mount hook: mount /sys/devices/system/cpu/online

Signed-off-by: Jakub Skokan <jakub.skokan@havefun.cz>
5 years agoMerge pull request #278 from wavezhang/master
Christian Brauner [Thu, 9 May 2019 10:14:38 +0000 (12:14 +0200)]
Merge pull request #278 from wavezhang/master

Support /sys/devices/system/cpu/online

5 years agoMerge pull request #280 from brauner/master
Stéphane Graber [Wed, 24 Apr 2019 12:50:09 +0000 (08:50 -0400)]
Merge pull request #280 from brauner/master

Revert "Merge pull request #272 from brauner/2019-02-19/compiler_base…

5 years agoRevert "Merge pull request #272 from brauner/2019-02-19/compiler_based_housekeeping"
Christian Brauner [Wed, 24 Apr 2019 12:14:16 +0000 (14:14 +0200)]
Revert "Merge pull request #272 from brauner/2019-02-19/compiler_based_housekeeping"

This reverts commit ac98f00cd89278e82a4cffe9075792d2070abe69, reversing
changes made to d8addb023a0e96b7d42e253703ba909bbc81dd26.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agoMerge pull request #272 from brauner/2019-02-19/compiler_based_housekeeping
Serge Hallyn [Mon, 22 Apr 2019 04:25:58 +0000 (23:25 -0500)]
Merge pull request #272 from brauner/2019-02-19/compiler_based_housekeeping

lxcfs: coding style update

5 years agoremove unused function
Yafei Bao [Tue, 9 Apr 2019 02:37:29 +0000 (10:37 +0800)]
remove unused function

Signed-off-by: Yafei Bao <baoyafei@gmail.com>
5 years agosys dirs do not need to implement 'read' method
Yafei Bao [Mon, 8 Apr 2019 03:06:16 +0000 (11:06 +0800)]
sys dirs do not need to implement 'read' method

Signed-off-by: Yafei Bao <baoyafei@gmail.com>
5 years agosupport /sys/devices/system/cpu/online
Yafei Bao [Fri, 22 Mar 2019 07:58:21 +0000 (15:58 +0800)]
support /sys/devices/system/cpu/online

Signed-off-by: Yafei Bao <baoyafei@gmail.com>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agobindings: partially convert to cleanup macros
Christian Brauner [Tue, 19 Feb 2019 22:09:27 +0000 (23:09 +0100)]
bindings: partially convert to cleanup macros

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agolxcfs: use close cleanup attributes
Christian Brauner [Tue, 19 Feb 2019 21:44:48 +0000 (22:44 +0100)]
lxcfs: use close cleanup attributes

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agolxcfs: coding style update
Christian Brauner [Tue, 19 Feb 2019 21:17:40 +0000 (22:17 +0100)]
lxcfs: coding style update

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agoMerge pull request #271 from dmaj/master
Serge Hallyn [Tue, 19 Feb 2019 18:41:44 +0000 (12:41 -0600)]
Merge pull request #271 from dmaj/master

option to disable swap in meminfo

5 years agooption to disable swap in meminfo
dm@localhost [Mon, 18 Feb 2019 05:17:30 +0000 (06:17 +0100)]
option to disable swap in meminfo

Signed-off-by: Dieter Maier <dma@web.de>
5 years agoMerge pull request #269 from tomponline/tp-skipcgroupmount
Stéphane Graber [Thu, 7 Feb 2019 01:39:17 +0000 (20:39 -0500)]
Merge pull request #269 from tomponline/tp-skipcgroupmount

hooks: skip mounting lxcfs cgroup tree on centos 7 hosts

5 years agoconfig: Adds RPM spec file.
tomponline [Wed, 6 Feb 2019 19:51:22 +0000 (19:51 +0000)]
config: Adds RPM spec file.

On RHEL 7 distros the RPM spec file will run the lxc.mount.hook with the --skip-cgroup-mounts option.

Signed-off-by: tomponline <tomp@tomp.uk>
5 years agohooks: Adds --skip-cgroup-mounts flag to lxc.mount.hook script.
tomponline [Wed, 6 Feb 2019 19:49:11 +0000 (19:49 +0000)]
hooks: Adds --skip-cgroup-mounts flag to lxc.mount.hook script.

This can be used to avoid instability in LXCFS when running on RHEL 7 hosts.

Signed-off-by: tomponline <tomp@tomp.uk>
5 years agoMerge pull request #270 from tomponline/tp-reload
Christian Brauner [Wed, 23 Jan 2019 11:45:08 +0000 (12:45 +0100)]
Merge pull request #270 from tomponline/tp-reload

config: Adds reload mode to sysvinit and systemd scripts.

5 years agoMerge pull request #268 from tomponline/tp-lock
Christian Brauner [Wed, 23 Jan 2019 10:24:44 +0000 (11:24 +0100)]
Merge pull request #268 from tomponline/tp-lock

Revert "bindings: protect do_release_file_info() with mutex"

5 years agoconfig: Adds reload mode to sysvinit and systemd scripts.
tomponline [Tue, 22 Jan 2019 14:23:05 +0000 (14:23 +0000)]
config: Adds reload mode to sysvinit and systemd scripts.

To to close down https://github.com/lxc/lxcfs/pull/188

Signed-off-by: tomponline <tomp@tomp.uk>
5 years agoRevert "bindings: protect do_release_file_info() with mutex"
tomponline [Tue, 22 Jan 2019 12:38:25 +0000 (12:38 +0000)]
Revert "bindings: protect do_release_file_info() with mutex"

This reverts commit 0108dc1cc6eab76392d228ee4ca844729096473d.

I am still experiencing hangs in lxcfs even with this patch.

Signed-off-by: tomponline <tomp@tomp.uk>
5 years agoMerge pull request #266 from tomponline/master
Christian Brauner [Fri, 18 Jan 2019 14:24:08 +0000 (16:24 +0200)]
Merge pull request #266 from tomponline/master

Adds mutex to do_release_file_info

5 years agobindings: protect do_release_file_info() with mutex
tomponline [Fri, 18 Jan 2019 13:05:09 +0000 (13:05 +0000)]
bindings: protect do_release_file_info() with mutex

Add a mutex to do_release_file_info to avoid lxcfs crash when stopping
multiple containers concurrently

Signed-off-by: tomponline <tomp@tomp.uk>
[christian.brauner@ubuntu.com: use correct commit message style]
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agoMerge pull request #262 from brauner/2018-12-12/cg_readdir
Wolfgang Bumiller [Wed, 12 Dec 2018 16:09:12 +0000 (17:09 +0100)]
Merge pull request #262 from brauner/2018-12-12/cg_readdir

bindings: prevent NULL pointer dereference

5 years agobindings: prevent NULL pointer dereference
Christian Brauner [Wed, 12 Dec 2018 11:49:16 +0000 (12:49 +0100)]
bindings: prevent NULL pointer dereference

Fixes: https://bugs.launchpad.net/ubuntu/+source/lxcfs/+bug/1807628
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agoMerge pull request #260 from aither64/cpu-views
Serge Hallyn [Sat, 8 Dec 2018 19:28:55 +0000 (13:28 -0600)]
Merge pull request #260 from aither64/cpu-views

CPU views based on quotas

5 years agostat: check for out of bound access to cpuacct usage data
Jakub Skokan [Wed, 24 Oct 2018 12:39:39 +0000 (14:39 +0200)]
stat: check for out of bound access to cpuacct usage data

Signed-off-by: Jakub Skokan <jakub.skokan@havefun.cz>
5 years agoCPU view: handle disabling/enabling of physical CPUs at runtime
Jakub Skokan [Sun, 21 Oct 2018 13:13:07 +0000 (15:13 +0200)]
CPU view: handle disabling/enabling of physical CPUs at runtime

Signed-off-by: Jakub Skokan <jakub.skokan@havefun.cz>
5 years agoCPU view: handle CPU hotplug at runtime
Jakub Skokan [Sun, 21 Oct 2018 07:04:12 +0000 (09:04 +0200)]
CPU view: handle CPU hotplug at runtime

Signed-off-by: Jakub Skokan <jakub.skokan@havefun.cz>
5 years agoCPU view: add mutexes
Jakub Skokan [Mon, 25 Jun 2018 16:24:14 +0000 (18:24 +0200)]
CPU view: add mutexes

Signed-off-by: Jakub Skokan <jakub.skokan@havefun.cz>
5 years agoCPU view: prune stale entries
Jakub Skokan [Mon, 25 Jun 2018 12:47:43 +0000 (14:47 +0200)]
CPU view: prune stale entries

Signed-off-by: Jakub Skokan <jakub.skokan@havefun.cz>
5 years agostat: use cpu views
Jakub Skokan [Mon, 25 Jun 2018 07:05:30 +0000 (09:05 +0200)]
stat: use cpu views

Signed-off-by: Jakub Skokan <jakub.skokan@havefun.cz>
5 years agocalc_hash(): do not apply modulo LOAD_SIZE
Jakub Skokan [Mon, 25 Jun 2018 06:55:23 +0000 (08:55 +0200)]
calc_hash(): do not apply modulo LOAD_SIZE

This will allow `calc_hash()` to be used for other purposes than
the loadavg implementation.

Signed-off-by: Jakub Skokan <jakub.skokan@havefun.cz>
5 years agocpuinfo: use cpu view based on cpu quotas
Jakub Skokan [Mon, 25 Jun 2018 06:54:15 +0000 (08:54 +0200)]
cpuinfo: use cpu view based on cpu quotas

Signed-off-by: Jakub Skokan <jakub.skokan@havefun.cz>
5 years agoMerge pull request #255 from brauner/2018-08-26/fix_makedev
Stéphane Graber [Sun, 26 Aug 2018 20:09:35 +0000 (16:09 -0400)]
Merge pull request #255 from brauner/2018-08-26/fix_makedev

tests: include missing sys/sysmacros.h header

5 years agotests: include missing sys/sysmacros.h header
Christian Brauner [Sun, 26 Aug 2018 10:23:31 +0000 (12:23 +0200)]
tests: include missing sys/sysmacros.h header

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agoMerge pull request #253 from brauner/2018-08-17/prevent_double_free
Stéphane Graber [Fri, 17 Aug 2018 16:00:00 +0000 (12:00 -0400)]
Merge pull request #253 from brauner/2018-08-17/prevent_double_free

bindings: prevent double free

5 years agobindings: prevent double free
Christian Brauner [Fri, 17 Aug 2018 15:33:22 +0000 (17:33 +0200)]
bindings: prevent double free

Closes #252.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agoMerge pull request #250 from brauner/2018-07-30/improve_error_message
Stéphane Graber [Mon, 30 Jul 2018 21:47:32 +0000 (17:47 -0400)]
Merge pull request #250 from brauner/2018-07-30/improve_error_message

bindings: better logging for write_string()

5 years agobindings: better logging for write_string()
Christian Brauner [Mon, 30 Jul 2018 08:53:19 +0000 (10:53 +0200)]
bindings: better logging for write_string()

Closes #249.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agoMerge pull request #248 from aither64/meminfo
Christian Brauner [Wed, 4 Jul 2018 16:26:09 +0000 (18:26 +0200)]
Merge pull request #248 from aither64/meminfo

meminfo: read shmem from memory cgroup

5 years agomeminfo: set ShmemHugePages and ShmemPmdMapped to zero
Jakub Skokan [Wed, 4 Jul 2018 15:50:30 +0000 (17:50 +0200)]
meminfo: set ShmemHugePages and ShmemPmdMapped to zero

Signed-off-by: Jakub Skokan <jakub.skokan@havefun.cz>
5 years agomeminfo: read shmem from cgroup parameter memory.stat
Jakub Skokan [Wed, 4 Jul 2018 15:48:52 +0000 (17:48 +0200)]
meminfo: read shmem from cgroup parameter memory.stat

Shmem was passed as-is from the host, but other fields weren't (such as
Cached and SReclaimed), which has caused htop to show incorrect memory usage.
If `total_shmem` is found in `memory.stat`, it is used, otherwise `Shmem`
is reported as zero.

Signed-off-by: Jakub Skokan <jakub.skokan@havefun.cz>
5 years agoMerge pull request #245 from aither64/loadavg-leak
Christian Brauner [Thu, 21 Jun 2018 07:58:45 +0000 (09:58 +0200)]
Merge pull request #245 from aither64/loadavg-leak

bindings: fix memory leak in calc_pid()

5 years agobindings: fix memory leak in calc_pid()
Jakub Skokan [Wed, 20 Jun 2018 18:24:28 +0000 (20:24 +0200)]
bindings: fix memory leak in calc_pid()

Signed-off-by: Jakub Skokan <jakub.skokan@havefun.cz>
5 years agotravis: fix .travis.yml
Christian Brauner [Wed, 20 Jun 2018 13:45:09 +0000 (15:45 +0200)]
travis: fix .travis.yml

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agotravis: add coverity support
Christian Brauner [Wed, 20 Jun 2018 10:54:10 +0000 (12:54 +0200)]
travis: add coverity support

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agoMerge pull request #244 from aither64/perct-cpu-usage
Christian Brauner [Wed, 20 Jun 2018 10:44:12 +0000 (12:44 +0200)]
Merge pull request #244 from aither64/perct-cpu-usage

Per-container CPU usage in /proc/stat

5 years agoPer-container CPU usage in /proc/stat
Jakub Skokan [Mon, 18 Jun 2018 08:50:02 +0000 (10:50 +0200)]
Per-container CPU usage in /proc/stat

Containers can see utilization of all available CPUs, even if the CPU
is utilized by other containers or by the host. The contents
of `/proc/stat` is shared across the system, except for hiding CPUs
excluded by cpuset. This commit attempts to fix that, but at a cost.
CPU usage is read from cpuacct cgroup, but that accounts only for
`user` and `system` fields from `/proc/stat`. Idle time can be
calculated, but other fields cannot, thus are always set to 0.
Additionally, idle time is based on values from the host, so even
a freshly started container has large initial idle time.

If the cpuacct cgroup is not present, or reading from it fails, LXCFS
will return CPU usage stats from the host as before.

Signed-off-by: Jakub Skokan <jakub.skokan@havefun.cz>
5 years agoMerge pull request #242 from aither64/loadavg-reload
Christian Brauner [Thu, 14 Jun 2018 07:39:36 +0000 (09:39 +0200)]
Merge pull request #242 from aither64/loadavg-reload

loadavg: restart thread on library reload

6 years agoloadavg: restart thread on library reload
Jakub Skokan [Mon, 11 Jun 2018 13:05:14 +0000 (15:05 +0200)]
loadavg: restart thread on library reload

Signed-off-by: Jakub Skokan <jakub.skokan@havefun.cz>
6 years agoMerge pull request #241 from aither64/loadavg-leak
Christian Brauner [Wed, 13 Jun 2018 09:00:41 +0000 (11:00 +0200)]
Merge pull request #241 from aither64/loadavg-leak

bindings: fix memory leak in proc_loadavg_read()

6 years agobindings: fix memory leak in proc_loadavg_read()
Jakub Skokan [Mon, 11 Jun 2018 13:12:22 +0000 (15:12 +0200)]
bindings: fix memory leak in proc_loadavg_read()

Signed-off-by: Jakub Skokan <jakub.skokan@havefun.cz>
6 years agoMerge pull request #237 from zhang2639/master
Christian Brauner [Thu, 24 May 2018 14:58:18 +0000 (16:58 +0200)]
Merge pull request #237 from zhang2639/master

loadavg

6 years agoClaim and use load_free() to free hash table.
zhang2639 [Thu, 24 May 2018 10:46:53 +0000 (18:46 +0800)]
Claim and use load_free() to free hash table.

Signed-off-by: zhang2639 <zhangshiqiang@hust.edu.cn>
Signed-off-by: yuwang <yuwang@linux.alibaba.com>
6 years agoCalculate and read the average load.
zhang2639 [Thu, 24 May 2018 10:42:37 +0000 (18:42 +0800)]
Calculate and read the average load.

Use load daemon to calculate the loadavg and use proc_loadavg_read() to read the loadavg.
calc_pid : find the process pid from cgroup path of a container.
calc_load : calculate the loadavg of a container.
refresh_load : refresh the loadavg of a container.
load_begin : traverse the hash table and update it.

Signed-off-by: zhang2639 <zhangshiqiang@hust.edu.cn>
Signed-off-by: yuwang <yuwang@linux.alibaba.com>
6 years agoUse hash table to store load information
zhang2639 [Thu, 24 May 2018 10:27:34 +0000 (18:27 +0800)]
Use hash table to store load information

struct load_head{} contains three locks for thread synchronization
and a pointer to the hash list.
struct load_node{} contains special information of container and
pointers to the hash node.
static struct load_head *load_hash[LOAD_SIZE] is hash table.
calc_hash : get the hash of a special container.
init_load : initialize hash table.
insert_node : insert a container node to the hash table.
locate_node : find the specital container node.
del_node : delete a specital container node and return the next node
of it.

Signed-off-by: zhang2639 <zhangshiqiang@hust.edu.cn>
Signed-off-by: yuwang <yuwang@linux.alibaba.com>
6 years agoNecessary instructions for loadavg
zhang2639 [Thu, 3 May 2018 03:14:47 +0000 (11:14 +0800)]
Necessary instructions for loadavg

Signed-off-by: zhang2639 <zhangshiqiang@hust.edu.cn>
Signed-off-by: yuwang <yuwang@linux.alibaba.com>
6 years agoMerge pull request #236 from geaaru/nonempty-opt
Christian Brauner [Wed, 2 May 2018 15:08:53 +0000 (17:08 +0200)]
Merge pull request #236 from geaaru/nonempty-opt

Add support to nonempty option

6 years agoAdd support to nonempty option
Geaaru [Tue, 24 Apr 2018 22:01:03 +0000 (00:01 +0200)]
Add support to nonempty option

Signed-off-by: Geaaru <geaaru@gmail.com>
6 years agoRelease LXCFS 3.0.0 lxcfs-3.0.0
Stéphane Graber [Tue, 27 Mar 2018 03:17:37 +0000 (23:17 -0400)]
Release LXCFS 3.0.0

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
6 years agoMerge pull request #234 from stgraber/master
Christian Brauner [Fri, 2 Mar 2018 22:16:00 +0000 (23:16 +0100)]
Merge pull request #234 from stgraber/master

Fix test_proc on s390x

6 years agoFix test_proc on s390x
Stéphane Graber [Fri, 2 Mar 2018 22:13:47 +0000 (17:13 -0500)]
Fix test_proc on s390x

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
6 years agoRelease LXCFS 3.0.0.beta1 lxcfs-3.0.0.beta1
Stéphane Graber [Thu, 1 Mar 2018 18:46:21 +0000 (13:46 -0500)]
Release LXCFS 3.0.0.beta1

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
6 years agoMerge pull request #233 from brauner/2018-02-26/remove_pam_cgfs
Stéphane Graber [Mon, 26 Feb 2018 17:11:39 +0000 (12:11 -0500)]
Merge pull request #233 from brauner/2018-02-26/remove_pam_cgfs

pam: remove from LXCFS (is now in LXC)

6 years agopam: remove from LXCFS (is now in LXC)
Christian Brauner [Mon, 26 Feb 2018 16:40:46 +0000 (17:40 +0100)]
pam: remove from LXCFS (is now in LXC)

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
6 years agoMerge pull request #228 from asokoloski/fix-175-c
Christian Brauner [Mon, 4 Dec 2017 20:04:10 +0000 (21:04 +0100)]
Merge pull request #228 from asokoloski/fix-175-c

Change MemAvailable figure in /proc/meminfo to include cache memory -- Fixes #175 I think.

6 years agoChange MemAvailable figure in /proc/meminfo to include cache memory -- Fixes #175...
Aaron Sokoloski [Mon, 4 Dec 2017 18:30:37 +0000 (12:30 -0600)]
Change MemAvailable figure in /proc/meminfo to include cache memory -- Fixes #175 I think.

MemAvailable represents roughly how much more memory we can use before
we start swapping.  Page cache memory can be reclaimed if it's needed
for something else, so it should count as available memory.  This
change should also fix the "available" column of the "free" command,
as well as the "avail Mem" value in "top", both of which come from
MemAvailable.

Note that this isn't perfectly accurate.  On a physical machine, the
value for MemAvailable is the result of a calculation that takes into
account that when memory gets low (but before it's completely
exhausted), kswapd wakes up and starts paging things out.  See:

https://github.com/torvalds/linux/blob/a0908a1b7d68706ee52ed4a039756e70c8e956e9/mm/page_alloc.c#L4553
(si_mem_available function)

I tried to think of a way to be more exact, but this calculation
includes figures that we don't have available for a given cgroup
hierarchy, such as reclaimable slab memory and the low watermark for
zones.  So it's not really feasible to reproduce it exactly.

Anyway, since the kernel calculation itself is just an estimation, it
doesn't seem too bad that we're a little bit off.  Adding in the
amount of memory used for page cache seems much better than what we
were doing before (just copying the free memory figure), because that
can be wrong by gigabytes.

For a more detailed understanding of how MemAvailable comes about one
should look at 34e431b0ae398fc54ea69ff85ec700722c9da773 in the Linux
kernel tree.

Signed-off-by: Aaron Sokoloski <asokoloski@gmail.com>
6 years agoMerge pull request #225 from asokoloski/master
Christian Brauner [Sat, 2 Dec 2017 19:15:43 +0000 (20:15 +0100)]
Merge pull request #225 from asokoloski/master

Fix inaccurate values in /proc/meminfo for containers with child cgroups

6 years agoFix inaccurate values in /proc/meminfo for containers with child cgroups
Aaron Sokoloski [Sat, 2 Dec 2017 18:43:06 +0000 (12:43 -0600)]
Fix inaccurate values in /proc/meminfo for containers with child cgroups

The values for Cached, Active, Inactive, Active(anon), Inactive(anon),
Active(file), Inactive(file), and Unevictable are derived/computed
from these values in the relevant meminfo.stat:

cache
active_anon
inactive_anon
active_file
inactive_file
unevictable

However, these value apply only to the cgroup of the lxc container
itself.  If your container uses memory cgroups internally, and thus
the container cgroup has children, their memory is not counted.

In order to take the memory usage of child cgroups into account, we
need to look at the "total_" prefixed versions of these values.

Signed-off-by: Aaron Sokoloski <asokoloski@gmail.com>
6 years agoMerge pull request #221 from brauner/2017-11-02/cgroup_v2_fixes
Serge Hallyn [Sat, 11 Nov 2017 00:55:31 +0000 (18:55 -0600)]
Merge pull request #221 from brauner/2017-11-02/cgroup_v2_fixes

pam: cgroup v2 fixes

6 years agopam: adapt to changed cgroup v2 layout
Christian Brauner [Thu, 2 Nov 2017 12:30:13 +0000 (13:30 +0100)]
pam: adapt to changed cgroup v2 layout

In order to enable proper unprivileged cgroup delegation on newer kernels we not
just need delegate the "cgroup.procs" file to the user but also to
"cgroup.threads". But don't report an error in case it doesn't exist.
Also delegate "cgroup.subtree_control" to enable users to hand over controllers
to descendant cgroups.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
6 years agobindings: remove unused function
Christian Brauner [Thu, 2 Nov 2017 12:30:03 +0000 (13:30 +0100)]
bindings: remove unused function

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
6 years agobindings: record mount namespace
Christian Brauner [Thu, 2 Nov 2017 12:26:36 +0000 (13:26 +0100)]
bindings: record mount namespace

This will allows us to attach to the mount namespace in case we need to debug or
perform some action on update.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
6 years agoMerge pull request #220 from yuwang888/master
Serge Hallyn [Sat, 21 Oct 2017 17:02:46 +0000 (13:02 -0400)]
Merge pull request #220 from yuwang888/master

Fix wrong calc of swaptoal and swapfree

6 years agoFix wrong calc of swaptoal and swapfree
yuwang.yuwang [Fri, 20 Oct 2017 06:28:03 +0000 (14:28 +0800)]
Fix wrong calc of swaptoal and swapfree

it make the value of (memswlimit - memlimit) to be swaptotal,
it is wrong, because swapsize in cgroup/container can up to
[0,memswlimit], sometimes if the memsize(unless swap) of all tasks in
cgroup/container is very small, the swaptoal can to be memswlimit
so make the swaptotal to be min(host swtoal,memswlimit)

Signed-off-by: yuwang.yuwang <yuwang.yuwang@alibaba-inc.com>
6 years agoMerge pull request #216 from nagarathnam200/master
Serge Hallyn [Mon, 2 Oct 2017 19:06:10 +0000 (14:06 -0500)]
Merge pull request #216 from nagarathnam200/master

Fix the installation directory for liblxcfs to ${libdir}/lxcfs

6 years agoFix the installation directory for liblxcfs to ${libdir}/lxcfs
Nagarathnam Muthusamy [Tue, 26 Sep 2017 00:32:09 +0000 (17:32 -0700)]
Fix the installation directory for liblxcfs to ${libdir}/lxcfs

Signed-off-by: Nagarathnam Muthusamy <nagarathnam.muthusamy@oracle.com>
6 years agoMerge pull request #211 from cyphar/pam_cgfs-all-option
Christian Brauner [Fri, 15 Sep 2017 01:35:29 +0000 (18:35 -0700)]
Merge pull request #211 from cyphar/pam_cgfs-all-option

pam_cgfs: add an 'all' option for -c

6 years agopam_cgfs: add an 'all' option for -c
Aleksa Sarai [Fri, 15 Sep 2017 01:05:40 +0000 (11:05 +1000)]
pam_cgfs: add an 'all' option for -c

In order to not require a user to manually list all cgroup controllers
in their PAM configuration, add an "all" option that effectively just
sets all controllers as read-write.

Signed-off-by: Aleksa Sarai <asarai@suse.de>
6 years agoMerge pull request #205 from bmiklautz/uptime_read
Christian Brauner [Thu, 3 Aug 2017 13:01:33 +0000 (09:01 -0400)]
Merge pull request #205 from bmiklautz/uptime_read

uptime: fix a problem with subsequent reads.

6 years agouptime: fix a problem with subsequent reads.
Bernhard Miklautz [Thu, 3 Aug 2017 11:37:37 +0000 (13:37 +0200)]
uptime: fix a problem with subsequent reads.

When doing subsequent reads of uptime on an open file handle
in the form:

read
lseek 0L, SEEK_SET
read

the second (and later) reads cause that the error
"failed to write to cache" was printed. This
happens for example with "top". top would print the error:

bad data in /proc/uptime

To fix this problem use the whole size of the buffer instead of the d->size
because this is set on the first read.

This behavior was introduced with commit 0ecddf023a4caf8e8d2fe7e9125d777a06c5ec12.

Signed-off-by: Bernhard Miklautz <bernhard.miklautz@shacknet.at>
6 years agoMerge pull request #198 from elianka/elianka-dev
Serge Hallyn [Tue, 4 Jul 2017 15:46:54 +0000 (10:46 -0500)]
Merge pull request #198 from elianka/elianka-dev

add common fallback dlopen for liblxcfs.so

6 years agoadd common fallback dlopen for liblxcfs.so
Daniel Kang [Sat, 1 Jul 2017 16:23:44 +0000 (00:23 +0800)]
add common fallback dlopen for liblxcfs.so

Signed-off-by: Daniel Kang <kangliang424@gmail.com>
6 years agoMerge pull request #196 from elianka/elianka-dev
Christian Brauner [Wed, 28 Jun 2017 11:55:59 +0000 (13:55 +0200)]
Merge pull request #196 from elianka/elianka-dev

enable debug option

6 years agoenable debug option
Daniel Kang [Wed, 28 Jun 2017 11:40:50 +0000 (19:40 +0800)]
enable debug option

Signed-off-by: Daniel Kang <kangliang424@gmail.com>
6 years agoMerge pull request #195 from evgeni/should-start-after-cgroupfs-mount
Christian Brauner [Thu, 22 Jun 2017 09:35:52 +0000 (11:35 +0200)]
Merge pull request #195 from evgeni/should-start-after-cgroupfs-mount

add cgroupfs-mount to Should-Start/Stop sysvinit LSB headers

6 years agoadd cgroupfs-mount to Should-Start/Stop sysvinit LSB headers
Evgeni Golov [Thu, 22 Jun 2017 06:22:07 +0000 (08:22 +0200)]
add cgroupfs-mount to Should-Start/Stop sysvinit LSB headers

otherwise init might try to start lxcfs before cgroupfs was mounted,
which will result in an empty /var/lib/lxcfs/cgroup and weird issues.

Debian-Bug: https://bugs.debian.org/859219
Signed-off-by: Evgeni Golov <evgeni@debian.org>
6 years agoMerge pull request #194 from brauner/2017-06-19/update_readme
Stéphane Graber [Mon, 19 Jun 2017 16:25:18 +0000 (12:25 -0400)]
Merge pull request #194 from brauner/2017-06-19/update_readme

README: update

6 years agoREADME: update
Christian Brauner [Mon, 19 Jun 2017 08:29:34 +0000 (10:29 +0200)]
README: update

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
6 years agoMerge pull request #192 from hallyn/revert-btime
Christian Brauner [Sun, 18 Jun 2017 20:53:10 +0000 (22:53 +0200)]
Merge pull request #192 from hallyn/revert-btime

(temporarily?) revert the virtualization of btime field in /proc/stat

6 years ago(temporarily?) revert the virtualization of btime field in /proc/stat
Serge Hallyn [Sun, 18 Jun 2017 19:43:22 +0000 (14:43 -0500)]
(temporarily?) revert the virtualization of btime field in /proc/stat

Closes #189

This seems to be responsible for corrupting STIME on processlist
inside containers.  Hopefully we can find a reasonable way to fix
both, but compared to unvirtualized btime field, bogus STIME field
is the greater evil here.

Signed-off-by: Serge Hallyn <serge@hallyn.com>