Skip to content
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

CONFIG_HZ matters ? : BBR with LKL #265

Closed
thehajime opened this issue Nov 16, 2016 · 4 comments
Closed

CONFIG_HZ matters ? : BBR with LKL #265

thehajime opened this issue Nov 16, 2016 · 4 comments

Comments

@thehajime
Copy link
Member

I'm playing with Google's new TCP cc flavor, BBR, with LKL and saw some odd behavior if CONFIG_HZ is 100.

  • netperf TCP_STREAM test between an LKL-netperf and a pure Linux netserver.
cc hz tput
bbr HZ=100 456.43 Mbps
cubic HZ=100 9385.28 Mbps
bbr HZ=1000 6965.05 Mbps
cubic HZ=1000 9393.35 Mbps

(raw output: https://gist.github.com/thehajime/4efc5690bde1d1248087097a8635d31b)

though there is still more to investigate why this different number when HZ=1000, BBR seems to not be functioning if CONFIG_HZ=100.

I will separately check this BBR's number but was wondering if CONFIG_HZ=1000 makes sense to LKL or not.

tested with my tentative branch.
https://github.com/libos-nuse/lkl-linux/tree/bbr-linus-4.9-rc4

@thehajime
Copy link
Member Author

adding the following function to arch/lkl/kernel/time.c alleviates this issue.

unsigned long long sched_clock(void)
{
	return lkl_ops->time();
}

for more detail in https://github.com/lkl/linux/blob/master/Documentation/timers/timekeeping.txt#L107

This will introduce more frequent calls of lkl_ops->time() - I'm really worried about the performance degradation with this. @liuyuan10 @tavip it would be great if you could test the above patch (adding sched_clock) with a simple benchmark. I will also investigate this before making a PR.

btw, printk also shows different timestamps started with non-zero value.

[21848.144705] Linux version 4.9.0-rc4+ (tazaki@zakzak1) (gcc version 5.3.1 20160406 (Red Hat 5.3.1-6) (GCC) ) #35 Tue Nov 29 22:27:15 JST 2016
[21848.144716] bootmem address range: 0x7f2dd0000000 - 0x7f2dd3fff000
[21848.145589] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 16159
[21848.145589] Kernel command line:  virtio_mmio.device=268@0x1000000:1
[21848.145602] PID hash table entries: 256 (order: -1, 2048 bytes)
[21848.145655] Dentry cache hash table entries: 8192 (order: 4, 65536 bytes)

@liuyuan10
Copy link
Member

I can't observe any performance issue of it. According to the doc you refer to, sched_clock should start from 0?

@thehajime
Copy link
Member Author

I can't observe any performance issue of it.

thanks.

According to the doc you refer to, sched_clock should start from 0?

thanks too; it should be like the following where boot_time will be set during time_init().

unsigned long long sched_clock(void)
{
	if (!boot_time)
		return 0;

	return lkl_ops->time() - boot_time;
}

@thehajime
Copy link
Member Author

Fixed by #276.

boat0 pushed a commit to boat0/lkl-linux that referenced this issue May 18, 2018
syzbot reported one use-after-free in pfifo_fast_enqueue() [1]

Issue here is that we can not reuse skb after a successful skb_array_produce()
since another cpu might have consumed it already.

I believe a similar problem exists in try_bulk_dequeue_skb_slow()
in case we put an skb into qdisc_enqueue_skb_bad_txq() for lockless qdisc.

[1]
BUG: KASAN: use-after-free in qdisc_pkt_len include/net/sch_generic.h:610 [inline]
BUG: KASAN: use-after-free in qdisc_qstats_cpu_backlog_inc include/net/sch_generic.h:712 [inline]
BUG: KASAN: use-after-free in pfifo_fast_enqueue+0x4bc/0x5e0 net/sched/sch_generic.c:639
Read of size 4 at addr ffff8801cede37e8 by task syzkaller717588/5543

CPU: 1 PID: 5543 Comm: syzkaller717588 Not tainted 4.16.0-rc4+ lkl#265
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:17 [inline]
 dump_stack+0x194/0x24d lib/dump_stack.c:53
 print_address_description+0x73/0x250 mm/kasan/report.c:256
 kasan_report_error mm/kasan/report.c:354 [inline]
 kasan_report+0x23c/0x360 mm/kasan/report.c:412
 __asan_report_load4_noabort+0x14/0x20 mm/kasan/report.c:432
 qdisc_pkt_len include/net/sch_generic.h:610 [inline]
 qdisc_qstats_cpu_backlog_inc include/net/sch_generic.h:712 [inline]
 pfifo_fast_enqueue+0x4bc/0x5e0 net/sched/sch_generic.c:639
 __dev_xmit_skb net/core/dev.c:3216 [inline]

Fixes: c5ad119 ("net: sched: pfifo_fast use skb_array")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: syzbot+ed43b6903ab968b16f54@syzkaller.appspotmail.com
Cc: John Fastabend <john.fastabend@gmail.com>
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Cc:	Cong Wang <xiyou.wangcong@gmail.com>
Cc:	Jiri Pirko <jiri@resnulli.us>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
rodionov pushed a commit to rodionov/lkl that referenced this issue Jan 2, 2025
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>
rodionov pushed a commit to rodionov/lkl that referenced this issue Jan 2, 2025
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants