Skip to content

Commit d447ea2

Browse files
xemultorvalds
authored andcommitted
cgroups: add the trigger callback to struct cftype
Trigger callback can be used to receive a kick-up from the user space. The string written is ignored. The cftype->private is used for multiplexing events. Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Acked-by: Paul Menage <menage@google.com> Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: Balbir Singh <balbir@in.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 46ae220 commit d447ea2

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

‎include/linux/cgroup.h‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,14 @@ struct cftype {
243243
*/
244244
int (*write_s64) (struct cgroup *cgrp, struct cftype *cft, s64 val);
245245

246+
/*
247+
* trigger() callback can be used to get some kick from the
248+
* userspace, when the actual string written is not important
249+
* at all. The private field can be used to determine the
250+
* kick type for multiplexing.
251+
*/
252+
int (*trigger)(struct cgroup *cgrp, unsigned int event);
253+
246254
int (*release) (struct inode *inode, struct file *file);
247255
};
248256

‎kernel/cgroup.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,6 +1410,10 @@ static ssize_t cgroup_file_write(struct file *file, const char __user *buf,
14101410
return cft->write(cgrp, cft, file, buf, nbytes, ppos);
14111411
if (cft->write_u64 || cft->write_s64)
14121412
return cgroup_write_X64(cgrp, cft, file, buf, nbytes, ppos);
1413+
if (cft->trigger) {
1414+
int ret = cft->trigger(cgrp, (unsigned int)cft->private);
1415+
return ret ? ret : nbytes;
1416+
}
14131417
return -EINVAL;
14141418
}
14151419

0 commit comments

Comments
 (0)