From patchwork Sat May 7 12:57:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Olsa X-Patchwork-Id: 12841995 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C53CCC433F5 for ; Sat, 7 May 2022 12:57:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1446453AbiEGNBJ (ORCPT ); Sat, 7 May 2022 09:01:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1446548AbiEGNBD (ORCPT ); Sat, 7 May 2022 09:01:03 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58C62274; Sat, 7 May 2022 05:57:17 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id BCDEA611DD; Sat, 7 May 2022 12:57:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 61CEEC385A9; Sat, 7 May 2022 12:57:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1651928236; bh=NWsRoCfKG0cd6E6tm0v2OXLLe4vAnBaY6Bpc/4w9JUg=; h=From:To:Cc:Subject:Date:From; b=OIqqfb1c7rQDQKQfaciQY+ZUtDkRwaajH5AofXraMHnYIe69NRLlJKPN5GjR2wGB3 dHgWOGMB2zzhmnmeUvzbc6Xc4ufYAvtDEzxq2N5DQv8dVvyBDtFym7L8mMCw3Yy93b rWVS4BTJ5DJwJ1zWjzSdueeZecXZMrJlMk9NMM8RBKQ+dl+bC7d0ujnZKW8wsGRkXs ZYAjGA8YZVEB4zsvCieXJf3c0nZVDPArczMZ8H8tv0QoJUYnIuIlWLA6PaXkhYoXqY YCh40Kq/LwcpwK5KdhNMpyHcZdAnA3N3qbvocppqEJ8jI/RZJahGj+q2IQotS+/eCP YABBYvUYQvzCw== From: Jiri Olsa To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Masami Hiramatsu Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, lkml , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Steven Rostedt Subject: [PATCHv5 bpf-next 0/5] bpf: Speed up symbol resolving in kprobe multi link Date: Sat, 7 May 2022 14:57:06 +0200 Message-Id: <20220507125711.2022238-1-jolsa@kernel.org> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net hi, sending additional fix for symbol resolving in kprobe multi link requested by Alexei and Andrii [1]. This speeds up bpftrace kprobe attachment, when using pure symbols (3344 symbols) to attach: Before: # perf stat -r 5 -e cycles ./src/bpftrace -e 'kprobe:x* { } i:ms:1 { exit(); }' ... 6.5681 +- 0.0225 seconds time elapsed ( +- 0.34% ) After: # perf stat -r 5 -e cycles ./src/bpftrace -e 'kprobe:x* { } i:ms:1 { exit(); }' ... 0.5661 +- 0.0275 seconds time elapsed ( +- 4.85% ) v5 changes: - added acks [Masami] - workaround in selftest for RCU warning by filtering out several functions to attach v4 changes: - fix compile issue [kernel test robot] - added acks [Andrii] v3 changes: - renamed kallsyms_lookup_names to ftrace_lookup_symbols and moved it to ftrace.c [Masami] - added ack [Andrii] - couple small test fixes [Andrii] v2 changes (first version [2]): - removed the 2 seconds check [Alexei] - moving/forcing symbols sorting out of kallsyms_lookup_names function [Alexei] - skipping one array allocation and copy_from_user [Andrii] - several small fixes [Masami,Andrii] - build fix [kernel test robot] thanks, jirka [1] https://lore.kernel.org/bpf/CAEf4BzZtQaiUxQ-sm_hH2qKPRaqGHyOfEsW96DxtBHRaKLoL3Q@mail.gmail.com/ [2] https://lore.kernel.org/bpf/20220407125224.310255-1-jolsa@kernel.org/ --- Jiri Olsa (5): kallsyms: Fully export kallsyms_on_each_symbol function ftrace: Add ftrace_lookup_symbols function fprobe: Resolve symbols with ftrace_lookup_symbols bpf: Resolve symbols with ftrace_lookup_symbols for kprobe multi link selftests/bpf: Add attach bench test include/linux/ftrace.h | 6 ++++++ include/linux/kallsyms.h | 7 ++++++- kernel/kallsyms.c | 3 +-- kernel/trace/bpf_trace.c | 112 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------- kernel/trace/fprobe.c | 32 ++++++++++++-------------------- kernel/trace/ftrace.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ tools/testing/selftests/bpf/prog_tests/kprobe_multi_test.c | 143 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ tools/testing/selftests/bpf/progs/kprobe_multi_empty.c | 12 ++++++++++++ 8 files changed, 308 insertions(+), 69 deletions(-) create mode 100644 tools/testing/selftests/bpf/progs/kprobe_multi_empty.c