Skip to content

Commit e2691f6

Browse files
htejungregkh
authored andcommitted
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 <[email protected]> Cc: Johannes Weiner <[email protected]> Tested-by: Chengming Zhou <[email protected]> Reviewed-by: Chengming Zhou <[email protected]> Signed-off-by: Tejun Heo <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 783bd07 commit e2691f6

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

include/linux/cgroup.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ int cgroup_add_dfl_cftypes(struct cgroup_subsys *ss, struct cftype *cfts);
114114
int cgroup_add_legacy_cftypes(struct cgroup_subsys *ss, struct cftype *cfts);
115115
int cgroup_rm_cftypes(struct cftype *cfts);
116116
void cgroup_file_notify(struct cgroup_file *cfile);
117+
void cgroup_file_show(struct cgroup_file *cfile, bool show);
117118

118119
int task_cgroup_path(struct task_struct *task, char *buf, size_t buflen);
119120
int cgroupstats_build(struct cgroupstats *stats, struct dentry *dentry);

kernel/cgroup/cgroup.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4339,6 +4339,26 @@ void cgroup_file_notify(struct cgroup_file *cfile)
43394339
spin_unlock_irqrestore(&cgroup_file_kn_lock, flags);
43404340
}
43414341

4342+
/**
4343+
* cgroup_file_show - show or hide a hidden cgroup file
4344+
* @cfile: target cgroup_file obtained by setting cftype->file_offset
4345+
* @show: whether to show or hide
4346+
*/
4347+
void cgroup_file_show(struct cgroup_file *cfile, bool show)
4348+
{
4349+
struct kernfs_node *kn;
4350+
4351+
spin_lock_irq(&cgroup_file_kn_lock);
4352+
kn = cfile->kn;
4353+
kernfs_get(kn);
4354+
spin_unlock_irq(&cgroup_file_kn_lock);
4355+
4356+
if (kn)
4357+
kernfs_show(kn, show);
4358+
4359+
kernfs_put(kn);
4360+
}
4361+
43424362
/**
43434363
* css_next_child - find the next child of a given css
43444364
* @pos: the current position (%NULL to initiate traversal)

0 commit comments

Comments
 (0)