Commit Graph

11 Commits

Author SHA1 Message Date
Waiman Long 8602ae629b cgroup/misc: Introduce misc.events.local
JIRA: https://issues.redhat.com/browse/RHEL-56023

commit 6a26f9c68901797261bc145975a02f85be0c1d8f
Author: Xiu Jianfeng <xiujianfeng@huawei.com>
Date:   Thu, 11 Jul 2024 10:14:57 +0000

    cgroup/misc: Introduce misc.events.local

    Currently the event counting provided by misc.events is hierarchical,
    it's not practical if user is only concerned with events of a
    specified cgroup. Therefore, introduce misc.events.local collect events
    specific to the given cgroup.

    This is analogous to memory.events.local and pids.events.local.

    Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
    Signed-off-by: Tejun Heo <tj@kernel.org>

Signed-off-by: Waiman Long <longman@redhat.com>
2024-09-30 09:47:02 -04:00
Waiman Long 7041d8c5e7 cgroup/misc: Introduce misc.peak
JIRA: https://issues.redhat.com/browse/RHEL-56023

commit 1028f391d5f9d4248e2f49193e6de2516ad630f8
Author: Xiu Jianfeng <xiujianfeng@huawei.com>
Date:   Wed, 3 Jul 2024 00:36:46 +0000

    cgroup/misc: Introduce misc.peak

    Introduce misc.peak to record the historical maximum usage of the
    resource, as in some scenarios the value of misc.max could be
    adjusted based on the peak usage of the resource.

    Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
    Signed-off-by: Tejun Heo <tj@kernel.org>

Signed-off-by: Waiman Long <longman@redhat.com>
2024-09-30 09:47:02 -04:00
Waiman Long 6d0328a7cf Revert "Revert "Merge: cgroup: Backport upstream cgroup commits up to v6.8""
JIRA: https://issues.redhat.com/browse/RHEL-36683
Upstream Status: RHEL only

This reverts commit 08637d76a2 which is a
revert of "Merge: cgroup: Backport upstream cgroup commits up to v6.8"

Signed-off-by: Waiman Long <longman@redhat.com>
2024-05-18 21:38:20 -04:00
Lucas Zampieri 08637d76a2 Revert "Merge: cgroup: Backport upstream cgroup commits up to v6.8"
This reverts merge request !4128
2024-05-16 15:26:41 +00:00
Waiman Long c1ee9d0859 cgroup/misc: Store atomic64_t reads to u64
JIRA: https://issues.redhat.com/browse/RHEL-34600

commit 714e08cc3ec564dc1717000f5a4c1f40ca8c8878
Author: Haitao Huang <haitao.huang@linux.intel.com>
Date:   Fri, 21 Jul 2023 05:02:31 -0700

    cgroup/misc: Store atomic64_t reads to u64

    Change 'new_usage' type to u64 so it can be compared with unsigned 'max'
    and 'capacity' properly even if the value crosses the signed boundary.

    Signed-off-by: Haitao Huang <haitao.huang@linux.intel.com>
    Signed-off-by: Tejun Heo <tj@kernel.org>

Signed-off-by: Waiman Long <longman@redhat.com>
2024-04-26 22:49:17 -04:00
Waiman Long 24d60e12e0 cgroup/misc: Change counters to be explicit 64bit types
JIRA: https://issues.redhat.com/browse/RHEL-34600

commit 32bf85c60ca3584a7ba3bef19da2779b73b2e7d6
Author: Haitao Huang <haitao.huang@linux.intel.com>
Date:   Mon, 17 Jul 2023 18:08:45 -0700

    cgroup/misc: Change counters to be explicit 64bit types

    So the variables can account for resources of huge quantities even on
    32-bit machines.

    Signed-off-by: Haitao Huang <haitao.huang@linux.intel.com>
    Signed-off-by: Tejun Heo <tj@kernel.org>

Signed-off-by: Waiman Long <longman@redhat.com>
2024-04-26 22:49:17 -04:00
Waiman Long e9c3c01bd6 cgroup/misc: Expose misc.current on cgroup v2 root
JIRA: https://issues.redhat.com/browse/RHEL-16027

commit e973dfe9299441ad263efedf094897fbb31e6a87
Author: LeiZhou-97 <lei.zhou@intel.com>
Date:   Tue, 13 Jun 2023 18:59:29 +0800

    cgroup/misc: Expose misc.current on cgroup v2 root

    Hello,

    This patch is to expose misc.current on cgroup v2 root for tracking
    how much of the resource has been consumed in total on the system.

    Most of the cloud infrastucture use cgroup to fetch the host
    information for scheduling purpose.

    Currently, the misc controller can be used by Intel TDX HKIDs and
    AMD SEV ASIDs, which are both used for creating encrypted VMs.
    Intel TDX and AMD SEV are mostly be used by the cloud providers
    for providing confidential VMs.

    In actual use of a server, these confidential VMs may be launched
    in different ways. For the cloud solution, there are kubvirt and
    coco (tracked by kubepods.slice); on host, they can be booted
    directly through qemu by end user (tracked by user.slice), etc.

    In this complex environment, when wanting to know how many resource
    is used in total it has to iterate through all existing slices to
    get the value of each misc.current and add them up to calculate
    the total number of consumed keys.

    So exposing misc.current to root cgroup tends to give much easier
    when calculates how much resource has been used in total, which
    helps to schedule and count resources for the cloud infrastucture.

    Signed-off-by: LeiZhou-97 <lei.zhou@intel.com>
    Signed-off-by: Tejun Heo <tj@kernel.org>

Signed-off-by: Waiman Long <longman@redhat.com>
2023-11-08 14:47:38 -05:00
Waiman Long 9172944c99 misc_cgroup: remove error log to avoid log flood
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2190004

commit b03357528fd9516600ff358ab5d4b887b8cb80e8
Author: Chunguang Xu <brookxu@tencent.com>
Date:   Fri, 17 Sep 2021 20:44:15 +0800

    misc_cgroup: remove error log to avoid log flood

    In scenarios where containers are frequently created and deleted,
    a large number of error logs maybe generated. The logs only show
    which node is about to go over the max limit, not the node which
    resource request failed. As misc.events has provided relevant
    information, maybe we can remove this log.

    Signed-off-by: Chunguang Xu <brookxu@tencent.com>
    Reviewed-by: Michal Koutný <mkoutny@suse.com>
    Signed-off-by: Tejun Heo <tj@kernel.org>

Signed-off-by: Waiman Long <longman@redhat.com>
2023-07-14 10:42:48 -04:00
Waiman Long 2153a6202b misc_cgroup: introduce misc.events to count failures
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2190004

commit f279294b329363eb6ada568e494d609ef78e3e8e
Author: Chunguang Xu <brookxu@tencent.com>
Date:   Fri, 17 Sep 2021 20:44:14 +0800

    misc_cgroup: introduce misc.events to count failures

    Introduce misc.events to make it easier for us to understand
    the pressure of resources. Currently only the 'max' event is
    implemented, which indicates the times the resource is about
    to exceeds the max limit.

    Signed-off-by: Chunguang Xu <brookxu@tencent.com>
    Reviewed-by: Vipin Sharma <vipinsh@google.com>
    Reviewed-by: Michal Koutný <mkoutny@suse.com>
    Signed-off-by: Tejun Heo <tj@kernel.org>

Signed-off-by: Waiman Long <longman@redhat.com>
2023-07-14 10:42:48 -04:00
Vipin Sharma 7aef27f0b2 svm/sev: Register SEV and SEV-ES ASIDs to the misc controller
Secure Encrypted Virtualization (SEV) and Secure Encrypted
Virtualization - Encrypted State (SEV-ES) ASIDs are used to encrypt KVMs
on AMD platform. These ASIDs are available in the limited quantities on
a host.

Register their capacity and usage to the misc controller for tracking
via cgroups.

Signed-off-by: Vipin Sharma <vipinsh@google.com>
Reviewed-by: David Rientjes <rientjes@google.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
2021-04-04 13:34:46 -04:00
Vipin Sharma a72232eabd cgroup: Add misc cgroup controller
The Miscellaneous cgroup provides the resource limiting and tracking
mechanism for the scalar resources which cannot be abstracted like the
other cgroup resources. Controller is enabled by the CONFIG_CGROUP_MISC
config option.

A resource can be added to the controller via enum misc_res_type{} in
the include/linux/misc_cgroup.h file and the corresponding name via
misc_res_name[] in the kernel/cgroup/misc.c file. Provider of the
resource must set its capacity prior to using the resource by calling
misc_cg_set_capacity().

Once a capacity is set then the resource usage can be updated using
charge and uncharge APIs. All of the APIs to interact with misc
controller are in include/linux/misc_cgroup.h.

Miscellaneous controller provides 3 interface files. If two misc
resources (res_a and res_b) are registered then:

misc.capacity
A read-only flat-keyed file shown only in the root cgroup.  It shows
miscellaneous scalar resources available on the platform along with
their quantities::

    $ cat misc.capacity
    res_a 50
    res_b 10

misc.current
A read-only flat-keyed file shown in the non-root cgroups.  It shows
the current usage of the resources in the cgroup and its children::

    $ cat misc.current
    res_a 3
    res_b 0

misc.max
A read-write flat-keyed file shown in the non root cgroups. Allowed
maximum usage of the resources in the cgroup and its children.::

    $ cat misc.max
    res_a max
    res_b 4

Limit can be set by::

    # echo res_a 1 > misc.max

Limit can be set to max by::

    # echo res_a max > misc.max

Limits can be set more than the capacity value in the misc.capacity
file.

Signed-off-by: Vipin Sharma <vipinsh@google.com>
Reviewed-by: David Rientjes <rientjes@google.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
2021-04-04 13:34:46 -04:00