mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-28 15:13:55 +08:00
15bed2742a
The 'parent_tidptr', 'child_tidptr' and 'tls' arguments to the 'clone' syscall are only used when certain flags are set in 'flags', suppress them when those aren't there. E.g: 9886.919 (0.236 ms): fetchmail/19298 clone(flags: CHILD_CLEARTID|CHILD_SETTID|0x11, child_stack: 0, child_tidptr: 0x7fe43f468590) = 19608 (fetchmail) 12876.052 (0.249 ms): qemu-system-x8/21238 clone(flags: VM|FS|FILES|SIGHAND|THREAD|SYSVSEM|SETTLS|PARENT_SETTID|CHILD_CLEARTID, child_stack: 0x7f48117fc770, parent_tidptr: 0x7f48117ff9d0, child_tidptr: 0x7f48117ff9d0, tls: 0x7f48117ff700) = 19611 (qemu-system-x86) 12876.555 (0.048 ms): worker/19611 clone(flags: VM|FS|FILES|SIGHAND|THREAD|SYSVSEM|SETTLS|PARENT_SETTID|CHILD_CLEARTID, child_stack: 0x7f480f7f8770, parent_tidptr: 0x7f480f7fb9d0, child_tidptr: 0x7f480f7fb9d0, tls: 0x7f480f7fb700) = 19612 (worker) 16575.240 (0.469 ms): fetchmail/19298 clone(flags: CHILD_CLEARTID|CHILD_SETTID|0x11, child_stack: 0, child_tidptr: 0x7fe43f468590) = 19613 (fetchmail) 20797.270 (0.335 ms): fetchmail/19298 clone(flags: CHILD_CLEARTID|CHILD_SETTID|0x11, child_stack: 0, child_tidptr: 0x7fe43f468590) = 19614 (fetchmail) 21228.585 (0.501 ms): vim/19519 clone(flags: CHILD_CLEARTID|CHILD_SETTID|0x11, child_stack: 0, child_tidptr: 0x7fbad6ac27d0) = 19615 (vim) 21232.193 (0.137 ms): bash/19615 clone(flags: CHILD_CLEARTID|CHILD_SETTID|0x11, child_stack: 0, child_tidptr: 0x7fad8bff49d0) = 19616 (bash) Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/n/tip-0um93djul9knf239gwa5mpcb@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
76 lines
1.6 KiB
C
76 lines
1.6 KiB
C
/*
|
|
* trace/beauty/cone.c
|
|
*
|
|
* Copyright (C) 2017, Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com>
|
|
*
|
|
* Released under the GPL v2. (and only v2, not any later version)
|
|
*/
|
|
|
|
#include "trace/beauty/beauty.h"
|
|
#include <linux/kernel.h>
|
|
#include <sys/types.h>
|
|
#include <uapi/linux/sched.h>
|
|
|
|
static size_t clone__scnprintf_flags(unsigned long flags, char *bf, size_t size)
|
|
{
|
|
int printed = 0;
|
|
|
|
#define P_FLAG(n) \
|
|
if (flags & CLONE_##n) { \
|
|
printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \
|
|
flags &= ~CLONE_##n; \
|
|
}
|
|
|
|
P_FLAG(VM);
|
|
P_FLAG(FS);
|
|
P_FLAG(FILES);
|
|
P_FLAG(SIGHAND);
|
|
P_FLAG(PTRACE);
|
|
P_FLAG(VFORK);
|
|
P_FLAG(PARENT);
|
|
P_FLAG(THREAD);
|
|
P_FLAG(NEWNS);
|
|
P_FLAG(SYSVSEM);
|
|
P_FLAG(SETTLS);
|
|
P_FLAG(PARENT_SETTID);
|
|
P_FLAG(CHILD_CLEARTID);
|
|
P_FLAG(DETACHED);
|
|
P_FLAG(UNTRACED);
|
|
P_FLAG(CHILD_SETTID);
|
|
P_FLAG(NEWCGROUP);
|
|
P_FLAG(NEWUTS);
|
|
P_FLAG(NEWIPC);
|
|
P_FLAG(NEWUSER);
|
|
P_FLAG(NEWPID);
|
|
P_FLAG(NEWNET);
|
|
P_FLAG(IO);
|
|
#undef P_FLAG
|
|
|
|
if (flags)
|
|
printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", flags);
|
|
|
|
return printed;
|
|
}
|
|
|
|
size_t syscall_arg__scnprintf_clone_flags(char *bf, size_t size, struct syscall_arg *arg)
|
|
{
|
|
unsigned long flags = arg->val;
|
|
enum syscall_clone_args {
|
|
SCC_FLAGS = (1 << 0),
|
|
SCC_CHILD_STACK = (1 << 1),
|
|
SCC_PARENT_TIDPTR = (1 << 2),
|
|
SCC_CHILD_TIDPTR = (1 << 3),
|
|
SCC_TLS = (1 << 4),
|
|
};
|
|
if (!(flags & CLONE_PARENT_SETTID))
|
|
arg->mask |= SCC_PARENT_TIDPTR;
|
|
|
|
if (!(flags & (CLONE_CHILD_SETTID | CLONE_CHILD_CLEARTID)))
|
|
arg->mask |= SCC_CHILD_TIDPTR;
|
|
|
|
if (!(flags & CLONE_SETTLS))
|
|
arg->mask |= SCC_TLS;
|
|
|
|
return clone__scnprintf_flags(flags, bf, size);
|
|
}
|