Project

General

Profile

Bug #1149 » WIP-linux-cgroup-tracepoints.patch

Loïc Gelle, 01/19/2018 11:45 AM

View differences:

include/trace/events/cgroup.h
TP_ARGS(dst_cgrp, task, threadgroup)
);
TRACE_EVENT(cgroup_file_write_fail,
TP_PROTO(struct cgroup *cgrp, struct cftype *cft, int ret),
TP_ARGS(cgrp, cft, ret),
TP_STRUCT__entry(
__field( int, root )
__field( int, id )
__string( ss_name, cft->ss->name )
__string( name, cft->name )
__field( int, ret )
),
TP_fast_assign(
__entry->root = cgrp->root->hierarchy_id;
__entry->id = cgrp->id;
__assign_str(ss_name, cft->ss->name);
__assign_str(name, cft->name);
__entry->ret = ret;
),
TP_printk("root=%d id=%d ss_name=%s name=%s ret=%d",
__entry->root, __entry->id, __get_str(ss_name),
__get_str(name), __entry->ret)
);
TRACE_EVENT(cgroup_file_write_u64,
TP_PROTO(struct cgroup *cgrp, struct cftype *cft,
u64 val, int ret),
TP_ARGS(cgrp, cft, val, ret),
TP_STRUCT__entry(
__field( int, root )
__field( int, id )
__string( ss_name, cft->ss->name )
__string( name, cft->name )
__field( u64, val )
__field( int, ret )
),
TP_fast_assign(
__entry->root = cgrp->root->hierarchy_id;
__entry->id = cgrp->id;
__assign_str(ss_name, cft->ss->name);
__assign_str(name, cft->name);
__entry->val = val;
__entry->ret = ret;
),
TP_printk("root=%d id=%d ss_name=%s name=%s val=%lld ret=%d",
__entry->root, __entry->id, __get_str(ss_name),
__get_str(name), __entry->val, __entry->ret)
);
TRACE_EVENT(cgroup_file_write_s64,
TP_PROTO(struct cgroup *cgrp, struct cftype *cft,
s64 val, int ret),
TP_ARGS(cgrp, cft, val, ret),
TP_STRUCT__entry(
__field( int, root )
__field( int, id )
__string( ss_name, cft->ss->name )
__string( name, cft->name )
__field( s64, val )
__field( int, ret )
),
TP_fast_assign(
__entry->root = cgrp->root->hierarchy_id;
__entry->id = cgrp->id;
__assign_str(ss_name, cft->ss->name);
__assign_str(name, cft->name);
__entry->val = val;
__entry->ret = ret;
),
TP_printk("root=%d id=%d ss_name=%s name=%s val=%lld ret=%d",
__entry->root, __entry->id, __get_str(ss_name),
__get_str(name), __entry->val, __entry->ret)
);
TRACE_EVENT(cgroup_file_write_str,
TP_PROTO(struct cgroup *cgrp, struct cftype *cft,
char *buf, int ret),
TP_ARGS(cgrp, cft, buf, ret),
TP_STRUCT__entry(
__field( int, root )
__field( int, id )
__string( ss_name, cft->ss->name )
__string( name, cft->name )
__string( str, buf )
__field( int, ret )
),
TP_fast_assign(
__entry->root = cgrp->root->hierarchy_id;
__entry->id = cgrp->id;
__assign_str(ss_name, cft->ss->name);
__assign_str(name, cft->name);
__assign_str(str, buf);
__entry->ret = ret;
),
TP_printk("root=%d id=%d ss_name=%s name=%s str=%s ret=%d",
__entry->root, __entry->id, __get_str(ss_name),
__get_str(name), __get_str(str), __entry->ret)
);
#endif /* _TRACE_CGROUP_H */
/* This part must be outside protection */
kernel/cgroup/cgroup.c
*/
if ((cgrp->root->flags & CGRP_ROOT_NS_DELEGATE) &&
!(cft->flags & CFTYPE_NS_DELEGATABLE) &&
ns != &init_cgroup_ns && ns->root_cset->dfl_cgrp == cgrp)
return -EPERM;
ns != &init_cgroup_ns && ns->root_cset->dfl_cgrp == cgrp) {
ret = -EPERM;
trace_cgroup_file_write_fail(cgrp, cft, ret);
return ret;
}
if (cft->write)
return cft->write(of, buf, nbytes, off);
if (cft->write) {
ret = cft->write(of, buf, nbytes, off);
if (ret)
trace_cgroup_file_write_fail(cgrp, cft, ret);
else
trace_cgroup_file_write_str(cgrp, cft, buf, ret);
return ret;
}
/*
* kernfs guarantees that a file isn't deleted with operations in
......
if (cft->write_u64) {
unsigned long long v;
ret = kstrtoull(buf, 0, &v);
if (!ret)
if (!ret) {
ret = cft->write_u64(css, cft, v);
trace_cgroup_file_write_u64(cgrp, cft, v, ret);
}
else
trace_cgroup_file_write_fail(cgrp, cft, ret);
} else if (cft->write_s64) {
long long v;
ret = kstrtoll(buf, 0, &v);
if (!ret)
if (!ret) {
ret = cft->write_s64(css, cft, v);
trace_cgroup_file_write_s64(cgrp, cft, v, ret);
}
else
trace_cgroup_file_write_fail(cgrp, cft, ret);
} else {
ret = -EINVAL;
trace_cgroup_file_write_fail(cgrp, cft, ret);
}
return ret ?: nbytes;
    (1-1/1)