Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp961698iob; Thu, 28 Apr 2022 15:02:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwTlDmMw3TxNo4cdJYaxGdS1h6XKyOVQ6nG4ZESlwBG5dYcByJDsNFmU3Sk6zDa0Si33V7h X-Received: by 2002:a17:90b:1291:b0:1db:eab7:f165 with SMTP id fw17-20020a17090b129100b001dbeab7f165mr426579pjb.74.1651183375187; Thu, 28 Apr 2022 15:02:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651183375; cv=none; d=google.com; s=arc-20160816; b=sv4lBR77/cIHy1yLBRBz84pMf01YIaAUXH7kZjmgpx1y17yy6M9A+whIsrGa0S3ZaN Veg5i3mhTo2H4vsgZRRZd2Mf3+lJS9620ysu/lM7TtQwby874+/HFr9ldBkPUCwir+dK 4Ao5jUWo3t/+9ZTcqC+8kgYDayrwLC6Pd+i9K4rG3yzDi9zKxcMN5g3BqN0EFo9esHby b2kI/Wuceuh5ZeIjmnphrVQsiMHVuF4YSeD6B0Vre7e46+KbrYaq9bvAfrnHEbyEiEde puOUaq5sOrOmWXX8nTBM7mIJu8cFwpRholc9yDctPHxDbxVhoxT3Isvdjy8+JwaWJd4g eWLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=M1Xis2jS/dCvd5egVQ+LxrRriEvf69H7yQSXXzsI8BM=; b=bu5vH4//FD0Wp8nW3GLTgcnddhhmvefJK4fOREzZmp5VweWZMzIFWdC6I+OKQozDNX XAhShV62zWm0W0Vs2QvAYBpP/TOd8ZK44Wk0ESZGiVgJZuT20Ut5KJsPpp3SwOO9VbVU F1S3dzgzzUgsVtT1gRmFNm6dM3tCioq5ebp5DodUMPHb5zezrwXZOW/85lLIVhYO/IZN 1zsVaaRUv19o64wjd63X30Bhm2yFws1FpPlSF+OTvcmbbcpFcmfKwHawNqfWmNrojF5O o7BgsmB97Gatkt4K4NPhrSlEtYZ4WJXO15krTrpB7cEeSXxuzgL3WDJV448UCbdycYYd ydFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rZYfMZAN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q25-20020a637519000000b003ab8efcc84asi5746307pgc.603.2022.04.28.15.02.33; Thu, 28 Apr 2022 15:02:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rZYfMZAN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232384AbiD0VHJ (ORCPT + 99 others); Wed, 27 Apr 2022 17:07:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229965AbiD0VHH (ORCPT ); Wed, 27 Apr 2022 17:07:07 -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 652DD38B9; Wed, 27 Apr 2022 14:03:51 -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 7908E61D92; Wed, 27 Apr 2022 21:03:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E6353C385A7; Wed, 27 Apr 2022 21:03:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1651093430; bh=EXkPPwFcpeWT8TP+jJ4voP6uahjnNmfSRZbq7nYktMs=; h=From:To:Cc:Subject:Date:From; b=rZYfMZANmHJjQ3LiJ8AucJyHp82yFWe6DOKSEf/M1URkUYhpSki5NKq3QvJuqk9/s NlFFgZtwU6W736FaniaBF4XQeiS/ajAftKXBDeEPAIJYcQiszAaCZSzqFAHSlU7a8l zGz1GLlgTqj8eOAqZbKQH3W0wwjqWnyTZtIqVCJwAkA8xm/rfyctInH2hIpbUpZ1bs dInMcvfCVSGuuHFQRSVSX0AYgPLF5cu15nA9q23di+vBADhyUKcX9r9P+m5SDSgLNQ 505yK4Lr5VQhCWPMoCo6yjHev8M1/KPidTIgP/5d6vt5XSf8d+nCkRdC5p1teKskv6 E9yjKYMG15k2w== 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: [PATCHv3 bpf-next 0/5] bpf: Speed up symbol resolving in kprobe multi link Date: Wed, 27 Apr 2022 23:03:40 +0200 Message-Id: <20220427210345.455611-1-jolsa@kernel.org> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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% ) 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 | 5 +++++ 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 | 133 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ tools/testing/selftests/bpf/progs/kprobe_multi_empty.c | 12 ++++++++++++ 8 files changed, 297 insertions(+), 68 deletions(-) create mode 100644 tools/testing/selftests/bpf/progs/kprobe_multi_empty.c