Received: by 2002:a05:6a10:83d0:0:0:0:0 with SMTP id o16csp60891pxh; Thu, 7 Apr 2022 14:00:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx5rRR4iKn6Ut+eEXC+I1l2Bjf4UrrzGWhNFoQCWDralsFNC1+W8V5cOHtTrKQXrPxy0PDE X-Received: by 2002:a17:903:11c7:b0:151:9769:3505 with SMTP id q7-20020a17090311c700b0015197693505mr15660833plh.72.1649365220159; Thu, 07 Apr 2022 14:00:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649365220; cv=none; d=google.com; s=arc-20160816; b=0Y2X9tpFUbEB4QmhUBjKOXx6nGohCpix1jGCsc02N0PkKbzcv5OxWQUE+xqo7JZGBM EY+ipg/kn8ipzd/aAr5wX4Prrn5apD8F9WU5aGXSrGskr02GFtp8Fg8sFrKsRSCYl7UM WQw7XTnMKhHuRzOKhihcpKCMM7VESH3KwvKYMuKeGBGPUFnppm2B+bsak4eXlB1kDq4u 0feo+UNB9SwgIb+2a+9Y1N8d9fwH3hwLqd8r4i/SWwFLUIFS8kwkraxAhamtgz7Ab0tD IUkAG5XXr8nS6BQZ4SAuZRYpOAyIXgUaqgEtw2u3P8Q5w+n3WZ3iARmq+o3IQvF2gLTl Z0aA== 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=GjttDxxWzhtmq2hDOTzdIk4bjYnug+XvcXnW5egnPX0=; b=rBo2r54J9FnvODdzUPd91gEMJ7GgtASDm+PCeoKq1BL9fm1NJ27hvy9RNOw6Zmz+zw HwlvDCvUxEKR0up93PYftDUFv6D6JLTypPOd/I2y1+W6zGnLaLPLvkZ/Gm97WyrT1Q8d 11+ZoIALRC6UmCcT9/QUkO6BoIyQmqdWoLomkfGhsmkwGX7pqlrbRLfLGhH4VjWGaiu+ JVxmnyXIM2DJxswHSSwL7DCZikpUJM+fNReyz7iUqPT5DCsUUpnN1uGHitjdv7GdjrYu Juy7JcWY4L/TKr+gBeXmvj+vQqJem7EACA3hG8sDFvj0J/1C2m6YHJOwG9RacxQlVEHM sClQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OQ92ngDF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id m14-20020a637d4e000000b003816043ef93si19210130pgn.392.2022.04.07.14.00.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 14:00:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OQ92ngDF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1BE2743F1C7; Thu, 7 Apr 2022 13:04:27 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245472AbiDGMyl (ORCPT + 99 others); Thu, 7 Apr 2022 08:54:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233916AbiDGMyk (ORCPT ); Thu, 7 Apr 2022 08:54:40 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E8E4259B41; Thu, 7 Apr 2022 05:52:40 -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 15C6060F8A; Thu, 7 Apr 2022 12:52:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6B977C385A4; Thu, 7 Apr 2022 12:52:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1649335959; bh=Efh9KZBTUFq/nJ++UsePBAQq4hIBUOTLc1DIbRgJ1Bg=; h=From:To:Cc:Subject:Date:From; b=OQ92ngDFwY+aYn6FxBtIm3WlGnTxQJAc8YV4jSbGv6OdA3IALRgCBdntcUUEIjY2s bt1XeMemV/OdaAyhGIBncslMeP32mOk2qWL3fD2ULF4Ar0kqbgzfZjuL+2h8s37Lsr hzk8Z9y4g9MYBZI0IRh4E2RHCrsJ7gGW5tVWq9Hb1JxFhuPNvfAWIWv/PlZ2MHABNH X6p3P78PlYtq6q0cLtWpKmmbFK5n7COGi6x6Wod4ykpnXUcfjKfLKRdUlnCMq4/Z6L 7s8s15WHa61b6FpAy1WFyFuXLDz5NR7ub3xulKG01RYZG1qc9iJMxDOhpggYpoDiwS QwHuuNMudRMyA== 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 Subject: [RFC bpf-next 0/4] bpf: Speed up symbol resolving in kprobe multi link Date: Thu, 7 Apr 2022 14:52:20 +0200 Message-Id: <20220407125224.310255-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=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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% ) There are 2 reasons I'm sending this as RFC though.. - I added test that meassures attachment speed on all possible functions from available_filter_functions, which is 48712 functions on my setup. The attach/detach speed for that is under 2 seconds and the test will fail if it's bigger than that.. which might fail on different setups or loaded machine.. I'm not sure what's the best solution yet, separate bench application perhaps? - copy_user_syms function potentially allocates lot of memory (~6MB in my tests with attaching ~48k functions). I haven't seen this to fail yet, but it might need to be changed to allocate memory gradually if needed, do we care? ;-) thanks, jirka [1] https://lore.kernel.org/bpf/CAEf4BzZtQaiUxQ-sm_hH2qKPRaqGHyOfEsW96DxtBHRaKLoL3Q@mail.gmail.com/ --- Jiri Olsa (4): kallsyms: Add kallsyms_lookup_names function fprobe: Resolve symbols with kallsyms_lookup_names bpf: Resolve symbols with kallsyms_lookup_names for kprobe multi link selftests/bpf: Add attach bench test include/linux/kallsyms.h | 6 ++++ kernel/kallsyms.c | 50 ++++++++++++++++++++++++++++++++- kernel/trace/bpf_trace.c | 123 +++++++++++++++++++++++++++++++++++++++++++++++--------------------------------- kernel/trace/fprobe.c | 23 ++------------- tools/testing/selftests/bpf/prog_tests/kprobe_multi_test.c | 141 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ tools/testing/selftests/bpf/progs/kprobe_multi_empty.c | 12 ++++++++ 6 files changed, 283 insertions(+), 72 deletions(-) create mode 100644 tools/testing/selftests/bpf/progs/kprobe_multi_empty.c