cgroup: Implement cgroup_file_show()
Add cgroup_file_show() which allows toggling visibility of a cgroup file using the new kernfs_show(). This will be used to hide psi interface files on cgroups where it's disabled. Cc: Chengming Zhou <zhouchengming@bytedance.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Tested-by: Chengming Zhou <zhouchengming@bytedance.com> Reviewed-by: Chengming Zhou <zhouchengming@bytedance.com> Signed-off-by: Tejun Heo <tj@kernel.org> Link: https://lore.kernel.org/r/20220828050440.734579-10-tj@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
783bd07d09
commit
e2691f6b44
2 changed files with 21 additions and 0 deletions
|
|
@ -4339,6 +4339,26 @@ void cgroup_file_notify(struct cgroup_file *cfile)
|
|||
spin_unlock_irqrestore(&cgroup_file_kn_lock, flags);
|
||||
}
|
||||
|
||||
/**
|
||||
* cgroup_file_show - show or hide a hidden cgroup file
|
||||
* @cfile: target cgroup_file obtained by setting cftype->file_offset
|
||||
* @show: whether to show or hide
|
||||
*/
|
||||
void cgroup_file_show(struct cgroup_file *cfile, bool show)
|
||||
{
|
||||
struct kernfs_node *kn;
|
||||
|
||||
spin_lock_irq(&cgroup_file_kn_lock);
|
||||
kn = cfile->kn;
|
||||
kernfs_get(kn);
|
||||
spin_unlock_irq(&cgroup_file_kn_lock);
|
||||
|
||||
if (kn)
|
||||
kernfs_show(kn, show);
|
||||
|
||||
kernfs_put(kn);
|
||||
}
|
||||
|
||||
/**
|
||||
* css_next_child - find the next child of a given css
|
||||
* @pos: the current position (%NULL to initiate traversal)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue