"Devon push for Android 13" * tag 'MMI-T2SN33.73-22-3' of https://github.com/MotorolaMobilityLLC/kernel-msm: Revert "spi: spi-msm-geni: Keep device to suspend if PM call fails" BACKPORT: FROMGIT: binder: fix freeze race FROMGIT: binder: BINDER_GET_FROZEN_INFO ioctl binder: BINDER_FREEZE ioctl mm/rmap: Fix anon_vma->degree ambiguity leading to double-reuse techpack: add camera legacy support ANDROID: usb: f_accessory: Check buffer size when initialised via composite ALSA: pcm: Move rwsem lock inside snd_ctl_elem_read to prevent UAF video: fbdev: pxa3xx-gcu: Fix integer overflow in pxa3xx_gcu_write ext4: fix kernel infoleak via ext4_extent_header wifi: mac80211_hwsim: avoid mac80211 warning on bad rate fbcon: Disallow setting font bigger than screen size KVM: arm64: Allow SMCCC_ARCH_WORKAROUND_3 to be discovered and migrated arm64: Add Cortex-X2 CPU part definition arm64: Add Neoverse-N2, Cortex-A710 CPU part definition arm64: Add part number for Arm Cortex-A77 fget: check that the fd still exists after getting a ref to it fs: add fget_many() and fput_many() mm: fix misplaced unlock_page in do_wp_page() mm: do_wp_page() simplification mm/ksm: Remove reuse_ksm_page() mm: reuse only-pte-mapped KSM page in do_wp_page() Revert "mm:Fix conflict of speculative fault and MGLRU" mm:vmscan:Update the page scan prioritiy skip USB PHY reset on charger removal fuse:Porting fuse passthrough feature mm: mglru fix on qcom baseline mm:Clean page_io revert conflict Revert write back changes iio:add bc12 type read iio. [rhode]:Modify ldo driver voltage[2/2] configs:Enable multi generation LRU arm64: pgtable: Fix pte_accessible() mm: fix unexpected zeroed page mapping with zram swap mm:Fix conflict of speculative fault and MGLRU FROMLIST: mm: multi-gen LRU: design doc FROMLIST: mm: multi-gen LRU: admin guide FROMLIST: mm: multi-gen LRU: debugfs interface FROMLIST: mm: multi-gen LRU: thrashing prevention FROMLIST: mm: multi-gen LRU: kill switch FROMLIST: mm: multi-gen LRU: optimize multiple memcgs FROMLIST: mm: multi-gen LRU: support page table walks FROMLIST: mm: multi-gen LRU: exploit locality in rmap FROMLIST: mm: multi-gen LRU: minimal implementation FROMLIST: mm: multi-gen LRU: groundwork FROMLIST: mm: x86: add CONFIG_ARCH_HAS_NONLEAF_PMD_YOUNG FROMLIST: mm: x86, arm64: add arch_has_hw_pte_young() BACKPORT: include/linux/mm_inline.h: fold page_lru_base_type() into its sole caller UPSTREAM: mm: VM_BUG_ON lru page flags BACKPORT: mm: add __clear_page_lru_flags() to replace page_off_lru() BACKPORT: mm/swap.c: don't pass "enum lru_list" to del_page_from_lru_list() UPSTREAM: mm/swap.c: don't pass "enum lru_list" to trace_mm_lru_insertion() BACKPORT: mm: don't pass "enum lru_list" to lru list addition functions BACKPORT: include/linux/mm_inline.h: shuffle lru list addition and deletion functions BACKPORT: mm/vmscan.c: use add_page_to_lru_list() BACKPORT: mm: use self-explanatory macros rather than "2" BACKPORT: mm: remove superfluous __ClearPageActive() BACKPORT: mm/swapcache: support to handle the shadow entries UPSTREAM: mm/vmscan.c: use update_lru_size() in update_lru_sizes() UPSTREAM: arm64: cpufeature: introduce helper cpu_has_hw_af() UPSTREAM: mm: replace list_move_tail() with add_page_to_lru_list_tail() kernel: add PD VDM VERIFY IIO channel. Low flashlight brightness bugfix Hawaii+ OLED: sim1+sim2+sd fast plugging cause phone hang kernel/config: hawao: usb: sim1+sim2+sd fast plugging cause phone hang arm/config: devon: add CONFIG_CAM_SENSOR_PROBE_RETRY shmem becomes bigger and bigger when launch apps driver/power: Add debug logs Hawao: Fix NFC power consumption in sleep mode. devon:charger bring up kernel:add bc12 detect channel definition Revert "(CR): drm: mipi: Disable the MIPI DSI commands 0x2E and 0x3E" devon4g: camera flash bringup FROMGIT: binder: fix test regression due to sender_euid change UPSTREAM: binder: use cred instead of task for getsecid BACKPORT: binder: use cred instead of task for selinux checks UPSTREAM: binder: use euid from cred instead of using task arm64/defconfig: add devon extra configs hawao: devconfig: enable CHACHA20 crypto configs rhode: devconfig: enable CHACHA20 crypto configs regulator: Force shutdown all regulators when system power off. arm64: defconfig: Flash compatible TZ: Distinguishes encrypted and unencrypted TZ logs interfaces. TZ: Fix build err Hawaii+OLED:remove CONFIG_QCOM_FSA4480_I2C defconfig: Disable SLAB_MERGE. arm64/config:Enable Zram writeback on hawao Enable LZ4 on Rhode4G and Hawao dts: rhode: remove CONFIG_QCOM_FSA4480_I2C mm: zram: fix build error when zram wb disabled mm : zram fix swapcached issue on Zram Writeback fs:proc:abort reclaim once process goes to foreground ip_gre: add validation for csum_start arm64/config:Enable Zram writeback on Rhode kernel:add charger termination definition rhode:kernel: add wt6670 get firmware num node kernel/config:hawao:remove FTS TP config to use module kernel/input:hawao:update to use TP module ko kernel: remove wt6670 isp macro definition for user version kernel/config:hawao: add new FTS config to fix build error input/touchscreen: add ft3519 source config input/ft3519: hawao touch driver bringup Revert "(CR) hawaii OLED: visionox ft3519 touch drvier bringup" kernel: add wt6670 macro definition to control i2c nack QC3P:add iio channel definition Rhode: define CONFIG_CAMERA_FLASH_PWM display: Modify LDO driver initialization voltage compatibility Hawao: NFC Bringup(4) - driver hawaii OLED: visionox ft3519 touch drvier bringup kernel: qc3p wt6760 isp download function kernel:add ADC_GPIO3_DIV3 adc channel display/config: Add LDO driver config into the kernel. display: Load the regulator driver directly into the kernel. kernel: use orderly_poweroff when usb plugged out tty:diag:Move tty_flip_buffer_push out of spinlock Revert "tty:revert the tty update from qcom for moto tty_diag driver" kernel:dwc3 delay extcon module registeration ANDROID: xt_quota2: set usersize in xt_match registration object ANDROID: xt_quota2: clear quota2_log message before sending ANDROID: xt_quota2: remove trailing junk which might have a digit in it arm/defconfig: add hawao extra config usb:diag:revert the f_diag update from qcom for moto tty_diag driver tty:revert the tty update from qcom for moto tty_diag driver : Enable samsung NFC driver : integrate samsung RN4V NFC driver Rhode4G: wide camera bring up kernel: add charger gki kernel: change spi gpio for i2c gpio for charger : Remove gpio3 from reserve list for rhode4g arm/defconfig: add rhode extra config Revert "(CR) guamp: emmc add ffu" Removing debug config [PATCH] qseecom: Call INIT_WORK() before flush_work() guamp: emmc add ffu Caprip: modify the actuator noise reduction work flow. Caprip: modify the actuator noise reduction work flow. APP data lost after first R upgrade Porting of (CR) replace WARN with pr_debug for IPA api MOTODESK-2239 Make NCM driver compatible with windows disable CONFIG_SLUB_DEBUG for user builds disable CONFIG_DEBUG_PANIC_ON_OOM in userdebug builds Include inlinecrypt at config.gz to fix Q->R upgrade usb: add xhci-hw-lpm-disable dt property support kernel:ram overwritten by TZ logs to cause random panics caprip: Add start/stop vibrating notification to actuator. arm64: defconfig: Actuator noise reduction. kernel: driver/vibrator: diff vol for long/short vib skip ipa assert for debug build (patch 2) skip ipa assert for debug build limit ion cache size Revert "(CR) power: Add wakeup source in battery historian logging" power: print active wakeup source before suspend. alarmtimer: add debug to identify alarmtimers charger:driver:fix non power off issue for factory kill. arm64/defconfig: capri: open nfc driver for capri arm64/defconfig: disable debug fs on user build charger:support typec high 2A current at non-turbo product arm/defconfig: enable CONFIG_DEBUG_LIST on R soc: qcom: service-locator: enlarge timeout value arm/defconfig: caprip: init kernel deconfig arm/defconfig: capri: init kernel deconfig Revert "Revert "msm: media: uapi: Redefine NV12 format with different alignment"" Revert "msm: media: uapi: Redefine NV12 format with different alignment" clear SDAM for new battery profile loading. disable DEBUG_PANIC_ON_OOM on 3G ram device driver:qg:enale QG_DEBUG_SOC. Charge: fix slab out of bounds risk charge: qc2.0 adapter charge slow charge: Handle QC2.0 charger vbus rise 12V BCL: Enable charge bcl feature arm: setup: support mem= memory limit arm: call idle notifiers in CPU idle charger:improve micro-b input current to 1.9A per HW Capri bring up kernel:distinguish type-c and microb cdp input setting disable SPLIT_RSS_COUNTING to fix zero RSS issue charger:add battery test mode support for cebu. spi: disable_depth > 0 when pm runtime get sync driver/spi: spi driver suspend changes kernel: panel_notifier: Add new panel notify event type mmc:host:sdhci:Fix host->claimer NULL pointer problem Change ION fill mark from 100M to 16M to reduce the Lost RAM arm/defconfig: cebu: init kernel deconfig : NFC VEN pin startup and shutdown sequence disable watermark boost charge:Config DCP 2A charge current tune memory configs charger:limit typec high to medium when hvdcp disabled charger:support 2A dcp charger arm64/defconfig: enable external usb camera power: reset: Use warm reset for dload mode Update kernel config of userdebug on Guam/GuamP to improve performance charger:duplicated apsd detection at pmi632 expose ssr_reason to ss_ramdump SD: print SD interrupt log charger:SW_ICL do not used at moto charger:factory image charging soc over 75% usb audio: Let the usb sound card index from 1 kernel:USB DRP connect debug accessory test charge: config: config batt NTC for bornr NA Kernel: add sys node for panel supplier gpu/drm: Create panelRegDA sysfs to expose panel's reg pwrkey: change printk level to output to console Reboot: trigger warm reset when receive hw_warmreset cmd disable CONFIG_DEBUG_CONSOLE_UNHASHED_POINTERS for sts test Revert (CR): power: smb5: Clear HDC AICL arm/defconfig: borneo: init kernel deconfig guam serials: remove kernel config for PASR Revert "mm, vmstat: hide /proc/pagetypeinfo from normal users" arm/defconfig: guamna: init kernel deconfig arm/defconfig: add 32bit debug config defconfig.mk: add arch specific debug enable psi for guam guamp Revert "defconfig: disable MEMCG for bengal 32" Fix QC rebase issue for dual role sysfs access issue ion: display ion total size in debufs node ion: dmabuf improve debugfs kernel:support huawei p10 5A cable bengal:Enable dual role usb interface smb5:Add dual role class support in smb5 usb:Add dual role class support sdcardfs: don't depend on reserved_mb to check free space sdcardfs: check the free space before creating files sdcardfs: copy inode size while getting attributes : remove nfc function for guam charger:allow APSD re-run at factory usb detection CONFIG_FPR_FPC disable for rebase fingerprint fix defconfig.mk: Don't force make defconfig gitignore: ignore dts link guamp: arm64/dtsi enable regulator_fixed_voltage power: Add wakeup source in battery historian logging arm64/defconfig: enable softlockup panic for debug : arm64/defconfig : enable NFC kernel:add OCP charger current limitation guam: add touch module support Revert "(CR): config: disable CONFIG_PANIC_ON_REFCOUNT_ERROR" arm64/defconfig: disable debug config config: disable CONFIG_PANIC_ON_REFCOUNT_ERROR arm64/configs: sm4250: Enable USB console tty: msm_geni_serial: Support the match() callback printk: Keep boot console on if enabled arm64/config: support UAS of usb storage arm64/defconfig: enable usbnet drivers usb:configfs:Set udc_name NULL if attach failed usb/dwc3: msm: Enable all Debug Logs gadget: bcdUSB version back to 2.0 when not SuperSpeed usb: configfs: synchronize the secure and udc_name state usb: configfs: skip unregister gadget in secure usb: gadget: f_mtp: Return error if count is negative usb: gadget: storage: Support READ_TOC for MacOS usb: configfs: Implement secure attribute usb: configfs: Reset the use_os_desc flag usb: mass_storage: Add support for SC_REBOOT usb: f_mtp: Handle OS descriptors only when bound config:remove unused smb1355 config guam: input add touch class support arm64/config: enable DIAG_OVER_TTY drivers: tty: add tty diag module char: diag: add write done sync function panel_notify: add api for touch state guam: defconfig: enable panel notifications video: Add panel_notifier framework drm: mipi: disable Elvss dim of HBM for MIPI DSI Add new macro MIPI_DSI_MSG_READ gpu/drm: Create sysfs to expose panel vendor infor drm: mipi: Disable the MIPI DSI commands 0x2E and 0x3E drm/dsi: Implement DCS set disp brightness 2bytes guam: input add drm support defconfig: bengal: enable pstore power: Add function to show active wakelocks power: suspend: Save snapshot of gpio, vreg when suspend PM/Suspend: Print wall time at suspend entry and exit - Do not unload prov TZ app. add system restart warm and panic mode printk: increase log buffer size to 2k qpnp-power-on: Print system timestamp on Power key event regulator: core: Add sysfs node for debug pinctrl: msm: Add sysfs node for debug watchdog_v2: export watchdog trigger pinctrl: pinctrl-msm: do not dump unallocated GPIOs of: conditional status property arm64/dt add kpanic modules kernel:moto charger/battery driver enable config:battery 10k ntc enable guamp: input add touch support input add touch support kernel:JK50 NTC 10K report wrong temp arm/defconfig: update debug option defconfig: enable CONFIG_MEMCG config defconfig: bengal: Add moto defconfigs msm-poweroff: Store restart reason power: pmic-voter: Export Interfaces Do not build moto config while building MSI kernel/config: Add Moto ext_config feature soc: qcom: kconfig opt to build moto dtbs soc: qcom: socinfo: Add sku sysfs support soc: qcom: socinfo: Add revision 16 support in socinfo structure net: qrtr: fifo: Add bounds check on tx path msm: ADSPRPC: Restrict untrusted applications from attaching to GuestOS msm: kgsl: Zap performance counters across context switches msm: kgsl: Add a sysfs node to control performance counter reads tzlog: update struct to get normal and fatal diag logs firmware: qcom: Remove garbage characters from qsee log firmware: qcom: add enlarged qsee log support firmware: qcom: encrypted tz and qsee log support serial: msm_geni_serial: Reduce stale delay added in stop_rx_sequencer clk: qcom: debugcc: Remove the gcc_camss_camnoc clocks defconfig: Enable CONFIG_ION_SYSTEM_HEAP for bengal f2fs: fix the periodic wakeups of discard thread f2fs: allow to change discard policy based on cached discard cmds msm: adsprpc: Lock list before removing node clk: qcom: gpucc: Update the post div ops for GPUCC PLL for KHAJE clk: qcom: clk-alpha-pll: Update implementation for Zonda PLL msm: kgsl: Use pid struct to find the process to reclaim mm: process_reclaim: pass pid struct instead of tgid msm: kgsl: Change vma->vm_file to shmem file mm: process_reclaim: skip target_vma net: qrtr: Excessive logging casuing boot failure Revert "msm: kgsl: Add GPUCC register dumps to A6xx GPU snapshot" defconfig: msm: Enable CONFIG_STATIC_USERMODEHELPER for bengal_32 fdt: Update CRC check for rng-seed defconfig: Enable blk-crypto-fallback to handle sw crypto request md: dm-default-key: Use system sector size for SDHCI devices msm: mink: Fix copy_to_user issue fix corrupt merge serial: msm_geni_serial: Disable irq only for HSUART usecase msm_geni_serial: Correct the DMA RX interrupt logic Conflicts: .gitignore arch/arm/include/asm/spectre.h arch/arm64/include/asm/cpufeature.h arch/arm64/include/asm/cputype.h drivers/gpu/drm/drm_mipi_dsi.c drivers/soc/qcom/socinfo.c drivers/usb/gadget/function/f_ncm.c drivers/usb/gadget/function/u_ncm.h drivers/video/fbdev/core/fbcon.c fs/file.c fs/fuse/dev.c fs/fuse/file.c fs/fuse/fuse_i.h fs/fuse/passthrough.c include/drm/drm_mipi_dsi.h include/linux/page-flags-layout.h include/linux/rmap.h include/uapi/linux/dma-buf.h include/uapi/linux/fuse.h mm/page_io.c mm/rmap.c Change-Id: I284de7199b3bfc44db2cfc89b2cd00a51bebdb6d
962 lines
29 KiB
C
962 lines
29 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef _LINUX_CGROUP_H
|
|
#define _LINUX_CGROUP_H
|
|
/*
|
|
* cgroup interface
|
|
*
|
|
* Copyright (C) 2003 BULL SA
|
|
* Copyright (C) 2004-2006 Silicon Graphics, Inc.
|
|
*
|
|
*/
|
|
|
|
#include <linux/sched.h>
|
|
#include <linux/cpumask.h>
|
|
#include <linux/nodemask.h>
|
|
#include <linux/rculist.h>
|
|
#include <linux/cgroupstats.h>
|
|
#include <linux/fs.h>
|
|
#include <linux/seq_file.h>
|
|
#include <linux/kernfs.h>
|
|
#include <linux/jump_label.h>
|
|
#include <linux/types.h>
|
|
#include <linux/ns_common.h>
|
|
#include <linux/nsproxy.h>
|
|
#include <linux/user_namespace.h>
|
|
#include <linux/refcount.h>
|
|
#include <linux/kernel_stat.h>
|
|
|
|
#include <linux/cgroup-defs.h>
|
|
|
|
#ifdef CONFIG_CGROUPS
|
|
|
|
/*
|
|
* All weight knobs on the default hierarhcy should use the following min,
|
|
* default and max values. The default value is the logarithmic center of
|
|
* MIN and MAX and allows 100x to be expressed in both directions.
|
|
*/
|
|
#define CGROUP_WEIGHT_MIN 1
|
|
#define CGROUP_WEIGHT_DFL 100
|
|
#define CGROUP_WEIGHT_MAX 10000
|
|
|
|
/* walk only threadgroup leaders */
|
|
#define CSS_TASK_ITER_PROCS (1U << 0)
|
|
/* walk all threaded css_sets in the domain */
|
|
#define CSS_TASK_ITER_THREADED (1U << 1)
|
|
|
|
/* internal flags */
|
|
#define CSS_TASK_ITER_SKIPPED (1U << 16)
|
|
|
|
/* a css_task_iter should be treated as an opaque object */
|
|
struct css_task_iter {
|
|
struct cgroup_subsys *ss;
|
|
unsigned int flags;
|
|
|
|
struct list_head *cset_pos;
|
|
struct list_head *cset_head;
|
|
|
|
struct list_head *tcset_pos;
|
|
struct list_head *tcset_head;
|
|
|
|
struct list_head *task_pos;
|
|
struct list_head *tasks_head;
|
|
struct list_head *mg_tasks_head;
|
|
struct list_head *dying_tasks_head;
|
|
|
|
struct list_head *cur_tasks_head;
|
|
struct css_set *cur_cset;
|
|
struct css_set *cur_dcset;
|
|
struct task_struct *cur_task;
|
|
struct list_head iters_node; /* css_set->task_iters */
|
|
};
|
|
|
|
extern struct file_system_type cgroup_fs_type;
|
|
extern struct cgroup_root cgrp_dfl_root;
|
|
extern struct css_set init_css_set;
|
|
|
|
#define SUBSYS(_x) extern struct cgroup_subsys _x ## _cgrp_subsys;
|
|
#include <linux/cgroup_subsys.h>
|
|
#undef SUBSYS
|
|
|
|
#define SUBSYS(_x) \
|
|
extern struct static_key_true _x ## _cgrp_subsys_enabled_key; \
|
|
extern struct static_key_true _x ## _cgrp_subsys_on_dfl_key;
|
|
#include <linux/cgroup_subsys.h>
|
|
#undef SUBSYS
|
|
|
|
/**
|
|
* cgroup_subsys_enabled - fast test on whether a subsys is enabled
|
|
* @ss: subsystem in question
|
|
*/
|
|
#define cgroup_subsys_enabled(ss) \
|
|
static_branch_likely(&ss ## _enabled_key)
|
|
|
|
/**
|
|
* cgroup_subsys_on_dfl - fast test on whether a subsys is on default hierarchy
|
|
* @ss: subsystem in question
|
|
*/
|
|
#define cgroup_subsys_on_dfl(ss) \
|
|
static_branch_likely(&ss ## _on_dfl_key)
|
|
|
|
bool css_has_online_children(struct cgroup_subsys_state *css);
|
|
struct cgroup_subsys_state *css_from_id(int id, struct cgroup_subsys *ss);
|
|
struct cgroup_subsys_state *cgroup_get_e_css(struct cgroup *cgroup,
|
|
struct cgroup_subsys *ss);
|
|
struct cgroup_subsys_state *css_tryget_online_from_dir(struct dentry *dentry,
|
|
struct cgroup_subsys *ss);
|
|
|
|
struct cgroup *cgroup_get_from_path(const char *path);
|
|
struct cgroup *cgroup_get_from_fd(int fd);
|
|
|
|
int cgroup_attach_task_all(struct task_struct *from, struct task_struct *);
|
|
int cgroup_transfer_tasks(struct cgroup *to, struct cgroup *from);
|
|
|
|
int cgroup_add_dfl_cftypes(struct cgroup_subsys *ss, struct cftype *cfts);
|
|
int cgroup_add_legacy_cftypes(struct cgroup_subsys *ss, struct cftype *cfts);
|
|
int cgroup_rm_cftypes(struct cftype *cfts);
|
|
void cgroup_file_notify(struct cgroup_file *cfile);
|
|
|
|
int task_cgroup_path(struct task_struct *task, char *buf, size_t buflen);
|
|
int cgroupstats_build(struct cgroupstats *stats, struct dentry *dentry);
|
|
int proc_cgroup_show(struct seq_file *m, struct pid_namespace *ns,
|
|
struct pid *pid, struct task_struct *tsk);
|
|
|
|
void cgroup_fork(struct task_struct *p);
|
|
extern int cgroup_can_fork(struct task_struct *p);
|
|
extern void cgroup_cancel_fork(struct task_struct *p);
|
|
extern void cgroup_post_fork(struct task_struct *p);
|
|
void cgroup_exit(struct task_struct *p);
|
|
void cgroup_release(struct task_struct *p);
|
|
void cgroup_free(struct task_struct *p);
|
|
|
|
int cgroup_init_early(void);
|
|
int cgroup_init(void);
|
|
|
|
int cgroup_parse_float(const char *input, unsigned dec_shift, s64 *v);
|
|
|
|
/*
|
|
* Iteration helpers and macros.
|
|
*/
|
|
|
|
struct cgroup_subsys_state *css_next_child(struct cgroup_subsys_state *pos,
|
|
struct cgroup_subsys_state *parent);
|
|
struct cgroup_subsys_state *css_next_descendant_pre(struct cgroup_subsys_state *pos,
|
|
struct cgroup_subsys_state *css);
|
|
struct cgroup_subsys_state *css_rightmost_descendant(struct cgroup_subsys_state *pos);
|
|
struct cgroup_subsys_state *css_next_descendant_post(struct cgroup_subsys_state *pos,
|
|
struct cgroup_subsys_state *css);
|
|
|
|
struct task_struct *cgroup_taskset_first(struct cgroup_taskset *tset,
|
|
struct cgroup_subsys_state **dst_cssp);
|
|
struct task_struct *cgroup_taskset_next(struct cgroup_taskset *tset,
|
|
struct cgroup_subsys_state **dst_cssp);
|
|
|
|
void css_task_iter_start(struct cgroup_subsys_state *css, unsigned int flags,
|
|
struct css_task_iter *it);
|
|
struct task_struct *css_task_iter_next(struct css_task_iter *it);
|
|
void css_task_iter_end(struct css_task_iter *it);
|
|
|
|
/**
|
|
* css_for_each_child - iterate through children of a css
|
|
* @pos: the css * to use as the loop cursor
|
|
* @parent: css whose children to walk
|
|
*
|
|
* Walk @parent's children. Must be called under rcu_read_lock().
|
|
*
|
|
* If a subsystem synchronizes ->css_online() and the start of iteration, a
|
|
* css which finished ->css_online() is guaranteed to be visible in the
|
|
* future iterations and will stay visible until the last reference is put.
|
|
* A css which hasn't finished ->css_online() or already finished
|
|
* ->css_offline() may show up during traversal. It's each subsystem's
|
|
* responsibility to synchronize against on/offlining.
|
|
*
|
|
* It is allowed to temporarily drop RCU read lock during iteration. The
|
|
* caller is responsible for ensuring that @pos remains accessible until
|
|
* the start of the next iteration by, for example, bumping the css refcnt.
|
|
*/
|
|
#define css_for_each_child(pos, parent) \
|
|
for ((pos) = css_next_child(NULL, (parent)); (pos); \
|
|
(pos) = css_next_child((pos), (parent)))
|
|
|
|
/**
|
|
* css_for_each_descendant_pre - pre-order walk of a css's descendants
|
|
* @pos: the css * to use as the loop cursor
|
|
* @root: css whose descendants to walk
|
|
*
|
|
* Walk @root's descendants. @root is included in the iteration and the
|
|
* first node to be visited. Must be called under rcu_read_lock().
|
|
*
|
|
* If a subsystem synchronizes ->css_online() and the start of iteration, a
|
|
* css which finished ->css_online() is guaranteed to be visible in the
|
|
* future iterations and will stay visible until the last reference is put.
|
|
* A css which hasn't finished ->css_online() or already finished
|
|
* ->css_offline() may show up during traversal. It's each subsystem's
|
|
* responsibility to synchronize against on/offlining.
|
|
*
|
|
* For example, the following guarantees that a descendant can't escape
|
|
* state updates of its ancestors.
|
|
*
|
|
* my_online(@css)
|
|
* {
|
|
* Lock @css's parent and @css;
|
|
* Inherit state from the parent;
|
|
* Unlock both.
|
|
* }
|
|
*
|
|
* my_update_state(@css)
|
|
* {
|
|
* css_for_each_descendant_pre(@pos, @css) {
|
|
* Lock @pos;
|
|
* if (@pos == @css)
|
|
* Update @css's state;
|
|
* else
|
|
* Verify @pos is alive and inherit state from its parent;
|
|
* Unlock @pos;
|
|
* }
|
|
* }
|
|
*
|
|
* As long as the inheriting step, including checking the parent state, is
|
|
* enclosed inside @pos locking, double-locking the parent isn't necessary
|
|
* while inheriting. The state update to the parent is guaranteed to be
|
|
* visible by walking order and, as long as inheriting operations to the
|
|
* same @pos are atomic to each other, multiple updates racing each other
|
|
* still result in the correct state. It's guaranateed that at least one
|
|
* inheritance happens for any css after the latest update to its parent.
|
|
*
|
|
* If checking parent's state requires locking the parent, each inheriting
|
|
* iteration should lock and unlock both @pos->parent and @pos.
|
|
*
|
|
* Alternatively, a subsystem may choose to use a single global lock to
|
|
* synchronize ->css_online() and ->css_offline() against tree-walking
|
|
* operations.
|
|
*
|
|
* It is allowed to temporarily drop RCU read lock during iteration. The
|
|
* caller is responsible for ensuring that @pos remains accessible until
|
|
* the start of the next iteration by, for example, bumping the css refcnt.
|
|
*/
|
|
#define css_for_each_descendant_pre(pos, css) \
|
|
for ((pos) = css_next_descendant_pre(NULL, (css)); (pos); \
|
|
(pos) = css_next_descendant_pre((pos), (css)))
|
|
|
|
/**
|
|
* css_for_each_descendant_post - post-order walk of a css's descendants
|
|
* @pos: the css * to use as the loop cursor
|
|
* @css: css whose descendants to walk
|
|
*
|
|
* Similar to css_for_each_descendant_pre() but performs post-order
|
|
* traversal instead. @root is included in the iteration and the last
|
|
* node to be visited.
|
|
*
|
|
* If a subsystem synchronizes ->css_online() and the start of iteration, a
|
|
* css which finished ->css_online() is guaranteed to be visible in the
|
|
* future iterations and will stay visible until the last reference is put.
|
|
* A css which hasn't finished ->css_online() or already finished
|
|
* ->css_offline() may show up during traversal. It's each subsystem's
|
|
* responsibility to synchronize against on/offlining.
|
|
*
|
|
* Note that the walk visibility guarantee example described in pre-order
|
|
* walk doesn't apply the same to post-order walks.
|
|
*/
|
|
#define css_for_each_descendant_post(pos, css) \
|
|
for ((pos) = css_next_descendant_post(NULL, (css)); (pos); \
|
|
(pos) = css_next_descendant_post((pos), (css)))
|
|
|
|
/**
|
|
* cgroup_taskset_for_each - iterate cgroup_taskset
|
|
* @task: the loop cursor
|
|
* @dst_css: the destination css
|
|
* @tset: taskset to iterate
|
|
*
|
|
* @tset may contain multiple tasks and they may belong to multiple
|
|
* processes.
|
|
*
|
|
* On the v2 hierarchy, there may be tasks from multiple processes and they
|
|
* may not share the source or destination csses.
|
|
*
|
|
* On traditional hierarchies, when there are multiple tasks in @tset, if a
|
|
* task of a process is in @tset, all tasks of the process are in @tset.
|
|
* Also, all are guaranteed to share the same source and destination csses.
|
|
*
|
|
* Iteration is not in any specific order.
|
|
*/
|
|
#define cgroup_taskset_for_each(task, dst_css, tset) \
|
|
for ((task) = cgroup_taskset_first((tset), &(dst_css)); \
|
|
(task); \
|
|
(task) = cgroup_taskset_next((tset), &(dst_css)))
|
|
|
|
/**
|
|
* cgroup_taskset_for_each_leader - iterate group leaders in a cgroup_taskset
|
|
* @leader: the loop cursor
|
|
* @dst_css: the destination css
|
|
* @tset: taskset to iterate
|
|
*
|
|
* Iterate threadgroup leaders of @tset. For single-task migrations, @tset
|
|
* may not contain any.
|
|
*/
|
|
#define cgroup_taskset_for_each_leader(leader, dst_css, tset) \
|
|
for ((leader) = cgroup_taskset_first((tset), &(dst_css)); \
|
|
(leader); \
|
|
(leader) = cgroup_taskset_next((tset), &(dst_css))) \
|
|
if ((leader) != (leader)->group_leader) \
|
|
; \
|
|
else
|
|
|
|
/*
|
|
* Inline functions.
|
|
*/
|
|
|
|
/**
|
|
* css_get - obtain a reference on the specified css
|
|
* @css: target css
|
|
*
|
|
* The caller must already have a reference.
|
|
*/
|
|
static inline void css_get(struct cgroup_subsys_state *css)
|
|
{
|
|
if (!(css->flags & CSS_NO_REF))
|
|
percpu_ref_get(&css->refcnt);
|
|
}
|
|
|
|
/**
|
|
* css_get_many - obtain references on the specified css
|
|
* @css: target css
|
|
* @n: number of references to get
|
|
*
|
|
* The caller must already have a reference.
|
|
*/
|
|
static inline void css_get_many(struct cgroup_subsys_state *css, unsigned int n)
|
|
{
|
|
if (!(css->flags & CSS_NO_REF))
|
|
percpu_ref_get_many(&css->refcnt, n);
|
|
}
|
|
|
|
/**
|
|
* css_tryget - try to obtain a reference on the specified css
|
|
* @css: target css
|
|
*
|
|
* Obtain a reference on @css unless it already has reached zero and is
|
|
* being released. This function doesn't care whether @css is on or
|
|
* offline. The caller naturally needs to ensure that @css is accessible
|
|
* but doesn't have to be holding a reference on it - IOW, RCU protected
|
|
* access is good enough for this function. Returns %true if a reference
|
|
* count was successfully obtained; %false otherwise.
|
|
*/
|
|
static inline bool css_tryget(struct cgroup_subsys_state *css)
|
|
{
|
|
if (!(css->flags & CSS_NO_REF))
|
|
return percpu_ref_tryget(&css->refcnt);
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* css_tryget_online - try to obtain a reference on the specified css if online
|
|
* @css: target css
|
|
*
|
|
* Obtain a reference on @css if it's online. The caller naturally needs
|
|
* to ensure that @css is accessible but doesn't have to be holding a
|
|
* reference on it - IOW, RCU protected access is good enough for this
|
|
* function. Returns %true if a reference count was successfully obtained;
|
|
* %false otherwise.
|
|
*/
|
|
static inline bool css_tryget_online(struct cgroup_subsys_state *css)
|
|
{
|
|
if (!(css->flags & CSS_NO_REF))
|
|
return percpu_ref_tryget_live(&css->refcnt);
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* css_is_dying - test whether the specified css is dying
|
|
* @css: target css
|
|
*
|
|
* Test whether @css is in the process of offlining or already offline. In
|
|
* most cases, ->css_online() and ->css_offline() callbacks should be
|
|
* enough; however, the actual offline operations are RCU delayed and this
|
|
* test returns %true also when @css is scheduled to be offlined.
|
|
*
|
|
* This is useful, for example, when the use case requires synchronous
|
|
* behavior with respect to cgroup removal. cgroup removal schedules css
|
|
* offlining but the css can seem alive while the operation is being
|
|
* delayed. If the delay affects user visible semantics, this test can be
|
|
* used to resolve the situation.
|
|
*/
|
|
static inline bool css_is_dying(struct cgroup_subsys_state *css)
|
|
{
|
|
return !(css->flags & CSS_NO_REF) && percpu_ref_is_dying(&css->refcnt);
|
|
}
|
|
|
|
/**
|
|
* css_put - put a css reference
|
|
* @css: target css
|
|
*
|
|
* Put a reference obtained via css_get() and css_tryget_online().
|
|
*/
|
|
static inline void css_put(struct cgroup_subsys_state *css)
|
|
{
|
|
if (!(css->flags & CSS_NO_REF))
|
|
percpu_ref_put(&css->refcnt);
|
|
}
|
|
|
|
/**
|
|
* css_put_many - put css references
|
|
* @css: target css
|
|
* @n: number of references to put
|
|
*
|
|
* Put references obtained via css_get() and css_tryget_online().
|
|
*/
|
|
static inline void css_put_many(struct cgroup_subsys_state *css, unsigned int n)
|
|
{
|
|
if (!(css->flags & CSS_NO_REF))
|
|
percpu_ref_put_many(&css->refcnt, n);
|
|
}
|
|
|
|
static inline void cgroup_get(struct cgroup *cgrp)
|
|
{
|
|
css_get(&cgrp->self);
|
|
}
|
|
|
|
static inline bool cgroup_tryget(struct cgroup *cgrp)
|
|
{
|
|
return css_tryget(&cgrp->self);
|
|
}
|
|
|
|
static inline void cgroup_put(struct cgroup *cgrp)
|
|
{
|
|
css_put(&cgrp->self);
|
|
}
|
|
|
|
extern struct mutex cgroup_mutex;
|
|
|
|
static inline void cgroup_lock(void)
|
|
{
|
|
mutex_lock(&cgroup_mutex);
|
|
}
|
|
|
|
static inline void cgroup_unlock(void)
|
|
{
|
|
mutex_unlock(&cgroup_mutex);
|
|
}
|
|
|
|
/**
|
|
* task_css_set_check - obtain a task's css_set with extra access conditions
|
|
* @task: the task to obtain css_set for
|
|
* @__c: extra condition expression to be passed to rcu_dereference_check()
|
|
*
|
|
* A task's css_set is RCU protected, initialized and exited while holding
|
|
* task_lock(), and can only be modified while holding both cgroup_mutex
|
|
* and task_lock() while the task is alive. This macro verifies that the
|
|
* caller is inside proper critical section and returns @task's css_set.
|
|
*
|
|
* The caller can also specify additional allowed conditions via @__c, such
|
|
* as locks used during the cgroup_subsys::attach() methods.
|
|
*/
|
|
#ifdef CONFIG_PROVE_RCU
|
|
extern spinlock_t css_set_lock;
|
|
#define task_css_set_check(task, __c) \
|
|
rcu_dereference_check((task)->cgroups, \
|
|
lockdep_is_held(&cgroup_mutex) || \
|
|
lockdep_is_held(&css_set_lock) || \
|
|
((task)->flags & PF_EXITING) || (__c))
|
|
#else
|
|
#define task_css_set_check(task, __c) \
|
|
rcu_dereference((task)->cgroups)
|
|
#endif
|
|
|
|
/**
|
|
* task_css_check - obtain css for (task, subsys) w/ extra access conds
|
|
* @task: the target task
|
|
* @subsys_id: the target subsystem ID
|
|
* @__c: extra condition expression to be passed to rcu_dereference_check()
|
|
*
|
|
* Return the cgroup_subsys_state for the (@task, @subsys_id) pair. The
|
|
* synchronization rules are the same as task_css_set_check().
|
|
*/
|
|
#define task_css_check(task, subsys_id, __c) \
|
|
task_css_set_check((task), (__c))->subsys[(subsys_id)]
|
|
|
|
/**
|
|
* task_css_set - obtain a task's css_set
|
|
* @task: the task to obtain css_set for
|
|
*
|
|
* See task_css_set_check().
|
|
*/
|
|
static inline struct css_set *task_css_set(struct task_struct *task)
|
|
{
|
|
return task_css_set_check(task, false);
|
|
}
|
|
|
|
/**
|
|
* task_css - obtain css for (task, subsys)
|
|
* @task: the target task
|
|
* @subsys_id: the target subsystem ID
|
|
*
|
|
* See task_css_check().
|
|
*/
|
|
static inline struct cgroup_subsys_state *task_css(struct task_struct *task,
|
|
int subsys_id)
|
|
{
|
|
return task_css_check(task, subsys_id, false);
|
|
}
|
|
|
|
/**
|
|
* task_get_css - find and get the css for (task, subsys)
|
|
* @task: the target task
|
|
* @subsys_id: the target subsystem ID
|
|
*
|
|
* Find the css for the (@task, @subsys_id) combination, increment a
|
|
* reference on and return it. This function is guaranteed to return a
|
|
* valid css. The returned css may already have been offlined.
|
|
*/
|
|
static inline struct cgroup_subsys_state *
|
|
task_get_css(struct task_struct *task, int subsys_id)
|
|
{
|
|
struct cgroup_subsys_state *css;
|
|
|
|
rcu_read_lock();
|
|
while (true) {
|
|
css = task_css(task, subsys_id);
|
|
/*
|
|
* Can't use css_tryget_online() here. A task which has
|
|
* PF_EXITING set may stay associated with an offline css.
|
|
* If such task calls this function, css_tryget_online()
|
|
* will keep failing.
|
|
*/
|
|
if (likely(css_tryget(css)))
|
|
break;
|
|
cpu_relax();
|
|
}
|
|
rcu_read_unlock();
|
|
return css;
|
|
}
|
|
|
|
/**
|
|
* task_css_is_root - test whether a task belongs to the root css
|
|
* @task: the target task
|
|
* @subsys_id: the target subsystem ID
|
|
*
|
|
* Test whether @task belongs to the root css on the specified subsystem.
|
|
* May be invoked in any context.
|
|
*/
|
|
static inline bool task_css_is_root(struct task_struct *task, int subsys_id)
|
|
{
|
|
return task_css_check(task, subsys_id, true) ==
|
|
init_css_set.subsys[subsys_id];
|
|
}
|
|
|
|
static inline struct cgroup *task_cgroup(struct task_struct *task,
|
|
int subsys_id)
|
|
{
|
|
return task_css(task, subsys_id)->cgroup;
|
|
}
|
|
|
|
static inline struct cgroup *task_dfl_cgroup(struct task_struct *task)
|
|
{
|
|
return task_css_set(task)->dfl_cgrp;
|
|
}
|
|
|
|
static inline struct cgroup *cgroup_parent(struct cgroup *cgrp)
|
|
{
|
|
struct cgroup_subsys_state *parent_css = cgrp->self.parent;
|
|
|
|
if (parent_css)
|
|
return container_of(parent_css, struct cgroup, self);
|
|
return NULL;
|
|
}
|
|
|
|
/**
|
|
* cgroup_is_descendant - test ancestry
|
|
* @cgrp: the cgroup to be tested
|
|
* @ancestor: possible ancestor of @cgrp
|
|
*
|
|
* Test whether @cgrp is a descendant of @ancestor. It also returns %true
|
|
* if @cgrp == @ancestor. This function is safe to call as long as @cgrp
|
|
* and @ancestor are accessible.
|
|
*/
|
|
static inline bool cgroup_is_descendant(struct cgroup *cgrp,
|
|
struct cgroup *ancestor)
|
|
{
|
|
if (cgrp->root != ancestor->root || cgrp->level < ancestor->level)
|
|
return false;
|
|
return cgrp->ancestor_ids[ancestor->level] == ancestor->id;
|
|
}
|
|
|
|
/**
|
|
* cgroup_ancestor - find ancestor of cgroup
|
|
* @cgrp: cgroup to find ancestor of
|
|
* @ancestor_level: level of ancestor to find starting from root
|
|
*
|
|
* Find ancestor of cgroup at specified level starting from root if it exists
|
|
* and return pointer to it. Return NULL if @cgrp doesn't have ancestor at
|
|
* @ancestor_level.
|
|
*
|
|
* This function is safe to call as long as @cgrp is accessible.
|
|
*/
|
|
static inline struct cgroup *cgroup_ancestor(struct cgroup *cgrp,
|
|
int ancestor_level)
|
|
{
|
|
if (cgrp->level < ancestor_level)
|
|
return NULL;
|
|
while (cgrp && cgrp->level > ancestor_level)
|
|
cgrp = cgroup_parent(cgrp);
|
|
return cgrp;
|
|
}
|
|
|
|
/**
|
|
* task_under_cgroup_hierarchy - test task's membership of cgroup ancestry
|
|
* @task: the task to be tested
|
|
* @ancestor: possible ancestor of @task's cgroup
|
|
*
|
|
* Tests whether @task's default cgroup hierarchy is a descendant of @ancestor.
|
|
* It follows all the same rules as cgroup_is_descendant, and only applies
|
|
* to the default hierarchy.
|
|
*/
|
|
static inline bool task_under_cgroup_hierarchy(struct task_struct *task,
|
|
struct cgroup *ancestor)
|
|
{
|
|
struct css_set *cset = task_css_set(task);
|
|
|
|
return cgroup_is_descendant(cset->dfl_cgrp, ancestor);
|
|
}
|
|
|
|
/* no synchronization, the result can only be used as a hint */
|
|
static inline bool cgroup_is_populated(struct cgroup *cgrp)
|
|
{
|
|
return cgrp->nr_populated_csets + cgrp->nr_populated_domain_children +
|
|
cgrp->nr_populated_threaded_children;
|
|
}
|
|
|
|
/* returns ino associated with a cgroup */
|
|
static inline ino_t cgroup_ino(struct cgroup *cgrp)
|
|
{
|
|
return cgrp->kn->id.ino;
|
|
}
|
|
|
|
/* cft/css accessors for cftype->write() operation */
|
|
static inline struct cftype *of_cft(struct kernfs_open_file *of)
|
|
{
|
|
return of->kn->priv;
|
|
}
|
|
|
|
struct cgroup_subsys_state *of_css(struct kernfs_open_file *of);
|
|
|
|
/* cft/css accessors for cftype->seq_*() operations */
|
|
static inline struct cftype *seq_cft(struct seq_file *seq)
|
|
{
|
|
return of_cft(seq->private);
|
|
}
|
|
|
|
static inline struct cgroup_subsys_state *seq_css(struct seq_file *seq)
|
|
{
|
|
return of_css(seq->private);
|
|
}
|
|
|
|
/*
|
|
* Name / path handling functions. All are thin wrappers around the kernfs
|
|
* counterparts and can be called under any context.
|
|
*/
|
|
|
|
static inline int cgroup_name(struct cgroup *cgrp, char *buf, size_t buflen)
|
|
{
|
|
return kernfs_name(cgrp->kn, buf, buflen);
|
|
}
|
|
|
|
static inline int cgroup_path(struct cgroup *cgrp, char *buf, size_t buflen)
|
|
{
|
|
return kernfs_path(cgrp->kn, buf, buflen);
|
|
}
|
|
|
|
static inline void pr_cont_cgroup_name(struct cgroup *cgrp)
|
|
{
|
|
pr_cont_kernfs_name(cgrp->kn);
|
|
}
|
|
|
|
static inline void pr_cont_cgroup_path(struct cgroup *cgrp)
|
|
{
|
|
pr_cont_kernfs_path(cgrp->kn);
|
|
}
|
|
|
|
static inline struct psi_group *cgroup_psi(struct cgroup *cgrp)
|
|
{
|
|
return &cgrp->psi;
|
|
}
|
|
|
|
bool cgroup_psi_enabled(void);
|
|
|
|
static inline void cgroup_init_kthreadd(void)
|
|
{
|
|
/*
|
|
* kthreadd is inherited by all kthreads, keep it in the root so
|
|
* that the new kthreads are guaranteed to stay in the root until
|
|
* initialization is finished.
|
|
*/
|
|
current->no_cgroup_migration = 1;
|
|
}
|
|
|
|
static inline void cgroup_kthread_ready(void)
|
|
{
|
|
/*
|
|
* This kthread finished initialization. The creator should have
|
|
* set PF_NO_SETAFFINITY if this kthread should stay in the root.
|
|
*/
|
|
current->no_cgroup_migration = 0;
|
|
}
|
|
|
|
static inline union kernfs_node_id *cgroup_get_kernfs_id(struct cgroup *cgrp)
|
|
{
|
|
return &cgrp->kn->id;
|
|
}
|
|
|
|
void cgroup_path_from_kernfs_id(const union kernfs_node_id *id,
|
|
char *buf, size_t buflen);
|
|
#else /* !CONFIG_CGROUPS */
|
|
|
|
struct cgroup_subsys_state;
|
|
struct cgroup;
|
|
|
|
static inline void css_put(struct cgroup_subsys_state *css) {}
|
|
static inline void cgroup_lock(void) {}
|
|
static inline void cgroup_unlock(void) {}
|
|
static inline int cgroup_attach_task_all(struct task_struct *from,
|
|
struct task_struct *t) { return 0; }
|
|
static inline int cgroupstats_build(struct cgroupstats *stats,
|
|
struct dentry *dentry) { return -EINVAL; }
|
|
|
|
static inline void cgroup_fork(struct task_struct *p) {}
|
|
static inline int cgroup_can_fork(struct task_struct *p) { return 0; }
|
|
static inline void cgroup_cancel_fork(struct task_struct *p) {}
|
|
static inline void cgroup_post_fork(struct task_struct *p) {}
|
|
static inline void cgroup_exit(struct task_struct *p) {}
|
|
static inline void cgroup_release(struct task_struct *p) {}
|
|
static inline void cgroup_free(struct task_struct *p) {}
|
|
|
|
static inline int cgroup_init_early(void) { return 0; }
|
|
static inline int cgroup_init(void) { return 0; }
|
|
static inline void cgroup_init_kthreadd(void) {}
|
|
static inline void cgroup_kthread_ready(void) {}
|
|
static inline union kernfs_node_id *cgroup_get_kernfs_id(struct cgroup *cgrp)
|
|
{
|
|
return NULL;
|
|
}
|
|
|
|
static inline struct cgroup *cgroup_parent(struct cgroup *cgrp)
|
|
{
|
|
return NULL;
|
|
}
|
|
|
|
static inline struct psi_group *cgroup_psi(struct cgroup *cgrp)
|
|
{
|
|
return NULL;
|
|
}
|
|
|
|
static inline bool cgroup_psi_enabled(void)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
static inline bool task_under_cgroup_hierarchy(struct task_struct *task,
|
|
struct cgroup *ancestor)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
static inline void cgroup_path_from_kernfs_id(const union kernfs_node_id *id,
|
|
char *buf, size_t buflen) {}
|
|
#endif /* !CONFIG_CGROUPS */
|
|
|
|
#ifdef CONFIG_CGROUPS
|
|
/*
|
|
* cgroup scalable recursive statistics.
|
|
*/
|
|
void cgroup_rstat_updated(struct cgroup *cgrp, int cpu);
|
|
void cgroup_rstat_flush(struct cgroup *cgrp);
|
|
void cgroup_rstat_flush_irqsafe(struct cgroup *cgrp);
|
|
void cgroup_rstat_flush_hold(struct cgroup *cgrp);
|
|
void cgroup_rstat_flush_release(void);
|
|
|
|
/*
|
|
* Basic resource stats.
|
|
*/
|
|
#ifdef CONFIG_CGROUP_CPUACCT
|
|
void cpuacct_charge(struct task_struct *tsk, u64 cputime);
|
|
void cpuacct_account_field(struct task_struct *tsk, int index, u64 val);
|
|
#else
|
|
static inline void cpuacct_charge(struct task_struct *tsk, u64 cputime) {}
|
|
static inline void cpuacct_account_field(struct task_struct *tsk, int index,
|
|
u64 val) {}
|
|
#endif
|
|
|
|
void __cgroup_account_cputime(struct cgroup *cgrp, u64 delta_exec);
|
|
void __cgroup_account_cputime_field(struct cgroup *cgrp,
|
|
enum cpu_usage_stat index, u64 delta_exec);
|
|
|
|
static inline void cgroup_account_cputime(struct task_struct *task,
|
|
u64 delta_exec)
|
|
{
|
|
struct cgroup *cgrp;
|
|
|
|
cpuacct_charge(task, delta_exec);
|
|
|
|
rcu_read_lock();
|
|
cgrp = task_dfl_cgroup(task);
|
|
if (cgroup_parent(cgrp))
|
|
__cgroup_account_cputime(cgrp, delta_exec);
|
|
rcu_read_unlock();
|
|
}
|
|
|
|
static inline void cgroup_account_cputime_field(struct task_struct *task,
|
|
enum cpu_usage_stat index,
|
|
u64 delta_exec)
|
|
{
|
|
struct cgroup *cgrp;
|
|
|
|
cpuacct_account_field(task, index, delta_exec);
|
|
|
|
rcu_read_lock();
|
|
cgrp = task_dfl_cgroup(task);
|
|
if (cgroup_parent(cgrp))
|
|
__cgroup_account_cputime_field(cgrp, index, delta_exec);
|
|
rcu_read_unlock();
|
|
}
|
|
|
|
#else /* CONFIG_CGROUPS */
|
|
|
|
static inline void cgroup_account_cputime(struct task_struct *task,
|
|
u64 delta_exec) {}
|
|
static inline void cgroup_account_cputime_field(struct task_struct *task,
|
|
enum cpu_usage_stat index,
|
|
u64 delta_exec) {}
|
|
|
|
#endif /* CONFIG_CGROUPS */
|
|
|
|
/*
|
|
* sock->sk_cgrp_data handling. For more info, see sock_cgroup_data
|
|
* definition in cgroup-defs.h.
|
|
*/
|
|
#ifdef CONFIG_SOCK_CGROUP_DATA
|
|
|
|
#if defined(CONFIG_CGROUP_NET_PRIO) || defined(CONFIG_CGROUP_NET_CLASSID)
|
|
extern spinlock_t cgroup_sk_update_lock;
|
|
#endif
|
|
|
|
void cgroup_sk_alloc_disable(void);
|
|
void cgroup_sk_alloc(struct sock_cgroup_data *skcd);
|
|
void cgroup_sk_clone(struct sock_cgroup_data *skcd);
|
|
void cgroup_sk_free(struct sock_cgroup_data *skcd);
|
|
|
|
static inline struct cgroup *sock_cgroup_ptr(struct sock_cgroup_data *skcd)
|
|
{
|
|
#if defined(CONFIG_CGROUP_NET_PRIO) || defined(CONFIG_CGROUP_NET_CLASSID)
|
|
unsigned long v;
|
|
|
|
/*
|
|
* @skcd->val is 64bit but the following is safe on 32bit too as we
|
|
* just need the lower ulong to be written and read atomically.
|
|
*/
|
|
v = READ_ONCE(skcd->val);
|
|
|
|
if (v & 3)
|
|
return &cgrp_dfl_root.cgrp;
|
|
|
|
return (struct cgroup *)(unsigned long)v ?: &cgrp_dfl_root.cgrp;
|
|
#else
|
|
return (struct cgroup *)(unsigned long)skcd->val;
|
|
#endif
|
|
}
|
|
|
|
#else /* CONFIG_CGROUP_DATA */
|
|
|
|
static inline void cgroup_sk_alloc(struct sock_cgroup_data *skcd) {}
|
|
static inline void cgroup_sk_clone(struct sock_cgroup_data *skcd) {}
|
|
static inline void cgroup_sk_free(struct sock_cgroup_data *skcd) {}
|
|
|
|
#endif /* CONFIG_CGROUP_DATA */
|
|
|
|
struct cgroup_namespace {
|
|
refcount_t count;
|
|
struct ns_common ns;
|
|
struct user_namespace *user_ns;
|
|
struct ucounts *ucounts;
|
|
struct css_set *root_cset;
|
|
};
|
|
|
|
extern struct cgroup_namespace init_cgroup_ns;
|
|
|
|
#ifdef CONFIG_CGROUPS
|
|
|
|
void free_cgroup_ns(struct cgroup_namespace *ns);
|
|
|
|
struct cgroup_namespace *copy_cgroup_ns(unsigned long flags,
|
|
struct user_namespace *user_ns,
|
|
struct cgroup_namespace *old_ns);
|
|
|
|
int cgroup_path_ns(struct cgroup *cgrp, char *buf, size_t buflen,
|
|
struct cgroup_namespace *ns);
|
|
|
|
#else /* !CONFIG_CGROUPS */
|
|
|
|
static inline void free_cgroup_ns(struct cgroup_namespace *ns) { }
|
|
static inline struct cgroup_namespace *
|
|
copy_cgroup_ns(unsigned long flags, struct user_namespace *user_ns,
|
|
struct cgroup_namespace *old_ns)
|
|
{
|
|
return old_ns;
|
|
}
|
|
|
|
#endif /* !CONFIG_CGROUPS */
|
|
|
|
static inline void get_cgroup_ns(struct cgroup_namespace *ns)
|
|
{
|
|
if (ns)
|
|
refcount_inc(&ns->count);
|
|
}
|
|
|
|
static inline void put_cgroup_ns(struct cgroup_namespace *ns)
|
|
{
|
|
if (ns && refcount_dec_and_test(&ns->count))
|
|
free_cgroup_ns(ns);
|
|
}
|
|
|
|
#ifdef CONFIG_CGROUPS
|
|
|
|
void cgroup_enter_frozen(void);
|
|
void cgroup_leave_frozen(bool always_leave);
|
|
void cgroup_update_frozen(struct cgroup *cgrp);
|
|
void cgroup_freeze(struct cgroup *cgrp, bool freeze);
|
|
void cgroup_freezer_migrate_task(struct task_struct *task, struct cgroup *src,
|
|
struct cgroup *dst);
|
|
void cgroup_freezer_frozen_exit(struct task_struct *task);
|
|
static inline bool cgroup_task_freeze(struct task_struct *task)
|
|
{
|
|
bool ret;
|
|
|
|
if (task->flags & PF_KTHREAD)
|
|
return false;
|
|
|
|
rcu_read_lock();
|
|
ret = test_bit(CGRP_FREEZE, &task_dfl_cgroup(task)->flags);
|
|
rcu_read_unlock();
|
|
|
|
return ret;
|
|
}
|
|
|
|
static inline bool cgroup_task_frozen(struct task_struct *task)
|
|
{
|
|
return task->frozen;
|
|
}
|
|
|
|
#else /* !CONFIG_CGROUPS */
|
|
|
|
static inline void cgroup_enter_frozen(void) { }
|
|
static inline void cgroup_leave_frozen(bool always_leave) { }
|
|
static inline bool cgroup_task_freeze(struct task_struct *task)
|
|
{
|
|
return false;
|
|
}
|
|
static inline bool cgroup_task_frozen(struct task_struct *task)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
#endif /* !CONFIG_CGROUPS */
|
|
|
|
#endif /* _LINUX_CGROUP_H */
|