-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lkl: Fix lkl_sys_halt and memory leak of TIF_HOST_THREAD #262
Conversation
Signed-off-by: Yuan Liu <liuyuan@google.com>
@@ -112,7 +112,8 @@ void machine_restart(char *unused) | |||
long lkl_sys_halt(void) | |||
{ | |||
long err; | |||
long params[6] = { 0, }; | |||
long params[6] = {LINUX_REBOOT_MAGIC1, | |||
LINUX_REBOOT_MAGIC2, LINUX_REBOOT_CMD_RESTART, }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a big deal, but we probably want to use LINUX_REBOOT_CMD_HALT instead, just to match the API name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the kernel/reboot.c, LINUX_REBOOT_CMD_HALT will call do_exit which is not what we want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point.
Now the TIF_HOST_THREAD threads are not properly killed. Signed-off-by: Yuan Liu <liuyuan@google.com>
Added another fix for memory leak of TIF_HOST_THREAD on top of this PR |
@@ -112,7 +112,8 @@ void machine_restart(char *unused) | |||
long lkl_sys_halt(void) | |||
{ | |||
long err; | |||
long params[6] = { 0, }; | |||
long params[6] = {LINUX_REBOOT_MAGIC1, | |||
LINUX_REBOOT_MAGIC2, LINUX_REBOOT_CMD_RESTART, }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point.
Fengguang is running into a warning from the buddy allocator: > swapper/0: page allocation failure: order:9, mode:0x14040c0(GFP_KERNEL|__GFP_COMP), nodemask=(null) > CPU: 1 PID: 1 Comm: swapper/0 Not tainted 4.17.0-rc1 lkl#262 > Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1 04/01/2014 > Call Trace: ... > __kmalloc+0x14b/0x180: ____cache_alloc at mm/slab.c:3127 > stm_register_device+0xf3/0x5c0: stm_register_device at drivers/hwtracing/stm/core.c:695 ... Which is basically a result of the stm class trying to allocate ~512kB for the dummy_stm with its default parameters. There's no reason, however, for it not to be vmalloc()ed instead, which is what this patch does. Reported-by: Fengguang Wu <fengguang.wu@intel.com> Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com> CC: stable@vger.kernel.org # v4.4+ Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Add a new test case which performs double query of the bpf_mprog through libbpf API, but also via raw bpf(2) syscall. This is testing to gather first the count and then in a subsequent probe the full information with the program array without clearing passed structs in between. # ./vmtest.sh -- ./test_progs -t tc_opts [...] ./test_progs -t tc_opts [ 1.398818] tsc: Refined TSC clocksource calibration: 3407.999 MHz [ 1.400263] clocksource: tsc: mask: 0xffffffffffffffff max_cycles: 0x311fd336761, max_idle_ns: 440795243819 ns [ 1.402734] clocksource: Switched to clocksource tsc [ 1.426639] bpf_testmod: loading out-of-tree module taints kernel. [ 1.428112] bpf_testmod: module verification failed: signature and/or required key missing - tainting kernel lkl#252 tc_opts_after:OK lkl#253 tc_opts_append:OK lkl#254 tc_opts_basic:OK lkl#255 tc_opts_before:OK lkl#256 tc_opts_chain_classic:OK lkl#257 tc_opts_chain_mixed:OK lkl#258 tc_opts_delete_empty:OK lkl#259 tc_opts_demixed:OK lkl#260 tc_opts_detach:OK lkl#261 tc_opts_detach_after:OK lkl#262 tc_opts_detach_before:OK lkl#263 tc_opts_dev_cleanup:OK lkl#264 tc_opts_invalid:OK lkl#265 tc_opts_max:OK lkl#266 tc_opts_mixed:OK lkl#267 tc_opts_prepend:OK lkl#268 tc_opts_query:OK <--- (new test) lkl#269 tc_opts_replace:OK lkl#270 tc_opts_revision:OK Summary: 19/0 PASSED, 0 SKIPPED, 0 FAILED Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/r/20231006220655.1653-4-daniel@iogearbox.net Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Add a new test case to query on an empty bpf_mprog and pass the revision directly into expected_revision for attachment to assert that this does succeed. ./test_progs -t tc_opts [ 1.406778] tsc: Refined TSC clocksource calibration: 3407.990 MHz [ 1.408863] clocksource: tsc: mask: 0xffffffffffffffff max_cycles: 0x311fcaf6eb0, max_idle_ns: 440795321766 ns [ 1.412419] clocksource: Switched to clocksource tsc [ 1.428671] bpf_testmod: loading out-of-tree module taints kernel. [ 1.430260] bpf_testmod: module verification failed: signature and/or required key missing - tainting kernel lkl#252 tc_opts_after:OK lkl#253 tc_opts_append:OK lkl#254 tc_opts_basic:OK lkl#255 tc_opts_before:OK lkl#256 tc_opts_chain_classic:OK lkl#257 tc_opts_chain_mixed:OK lkl#258 tc_opts_delete_empty:OK lkl#259 tc_opts_demixed:OK lkl#260 tc_opts_detach:OK lkl#261 tc_opts_detach_after:OK lkl#262 tc_opts_detach_before:OK lkl#263 tc_opts_dev_cleanup:OK lkl#264 tc_opts_invalid:OK lkl#265 tc_opts_max:OK lkl#266 tc_opts_mixed:OK lkl#267 tc_opts_prepend:OK lkl#268 tc_opts_query:OK lkl#269 tc_opts_query_attach:OK <--- (new test) lkl#270 tc_opts_replace:OK lkl#271 tc_opts_revision:OK Summary: 20/0 PASSED, 0 SKIPPED, 0 FAILED Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/r/20231006220655.1653-6-daniel@iogearbox.net Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Signed-off-by: Yuan Liu liuyuan@google.com
This change is![Reviewable](https://camo.githubusercontent.com/1541c4039185914e83657d3683ec25920c672c6c5c7ab4240ee7bff601adec0b/68747470733a2f2f72657669657761626c652e696f2f7265766965775f627574746f6e2e737667)