Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp2821035pxb; Mon, 18 Apr 2022 08:56:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwDKtt2Y9BJSOM6YwU48JeOQCzWUUqv/6Ny5DdvuvHQyJPIrP5qL3Uc4ftwkNbb4kZYUsPB X-Received: by 2002:a05:6a00:1897:b0:50a:5c7d:e003 with SMTP id x23-20020a056a00189700b0050a5c7de003mr10135717pfh.28.1650297401937; Mon, 18 Apr 2022 08:56:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650297401; cv=none; d=google.com; s=arc-20160816; b=bJPqgc5WwMQaCi7c5GoI3p7xLKJ3xEPaCz3+UtljYs4npDPs6b2aH4nKaxU9ezTcj1 VvUDuzWO7tZEmMpch4J9bgcbePQ6kJcL8xWT36De0HoM+dTf3jMP41uhhfDFsiqqBUwG wkR7nL1O5LSdlPZalV05zOrpKGIpy5nyWpa1KAs/KZPt0j5xnRqwUEPsp3ti6QCEBlIJ unBc557gAfMwbHTvALwCCkNVdlEEduMhtQP8NFU3WWrach1TIVM2CIU4AcMNENidbgRM BdRatUUwE6BI1ucVU4qmnNzGasMdj7zy5LZnDb6k9CVSLolTHPAvlJKAQkAeglxbX42Z IMFA== 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=SOWaSMEQnqs706h2DatFgjjSoFNl0BhFPzETSzI58eM=; b=jIyKOlWwIDMofGFb840eCvaKojWTGx9E6psvGwPZt61M4PbBe5vEk8VjYtITjTLWMg W3LJ8jVHFgHfp7ZITjnBXpBRhCaDZHxFNfmKxe2KI/rTNQoN6a0u+C+4IAhGA+UPK/Rw XBCW8uDU57Uqkkt6+dINsMMgXsPEOvUX17qxq9qG2A2/YsjSG3HSdqRX3WITCu7Gz+hR DIDdsJC16d5wgIQ6cF4YxyEPSBqx8jVTPz25KJT4Nq5h1t3K3IZL4ON8ff94O1MW3NpW hTASeE6ynyDF+5AJZoL+pbnb8dCz91fQ1aLkUsDlDBQo+LINgU0uuptLiYYJvM/PvfrL cZEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NRsrd2MA; 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 d9-20020a17090ad3c900b001c6f8b9aea5si5890145pjw.42.2022.04.18.08.56.25; Mon, 18 Apr 2022 08:56:41 -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=NRsrd2MA; 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 S241235AbiDRNe6 (ORCPT + 99 others); Mon, 18 Apr 2022 09:34:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242500AbiDRNJL (ORCPT ); Mon, 18 Apr 2022 09:09:11 -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 523D435AB1; Mon, 18 Apr 2022 05:48: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 72DBA6124E; Mon, 18 Apr 2022 12:48:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4A156C385A8; Mon, 18 Apr 2022 12:48:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1650286118; bh=KmajxESK8s8AkUiyXrriHM2As/5Rutgyy3pyGp7Dfpw=; h=From:To:Cc:Subject:Date:From; b=NRsrd2MA/OPrNtCaN+Nj/Bu+3wODoyvLAxJ+zaLF/8NcxUDef7pTSFIgE4be2rXXg y4EbE9eyWlpwSQ7sqnxqTZRfGK2eIeu2kVGrvfab5QoTSXbtjBblSv7YAqWz8dMza0 zWzanoEqFmj3c/OiRfr/7WjPgOiW9yTQRxQ38e/szi+JmLz9DACybkVXnMKc6WK/vR fqYNZxJQrm6pVyYlXgtygDJwtJg1IHAMIw+6ul5M8GmhbGKBtT2F6TovMgXzUD/Gsz zGFvNOraEsj7x6fkgHP414atkl7797eFH0V4VN6sSB/WG871Ge8D4IdUwKzHFhMG20 P4nkrT2Uo2tOw== 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: [PATCHv2 bpf-next 0/4] bpf: Speed up symbol resolving in kprobe multi link Date: Mon, 18 Apr 2022 14:48:30 +0200 Message-Id: <20220418124834.829064-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,T_SCC_BODY_TEXT_LINE 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% ) 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 (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 | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- kernel/trace/bpf_trace.c | 113 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------- kernel/trace/fprobe.c | 32 ++++++++++++-------------------- tools/testing/selftests/bpf/prog_tests/kprobe_multi_test.c | 136 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ tools/testing/selftests/bpf/progs/kprobe_multi_empty.c | 12 ++++++++++++ 6 files changed, 302 insertions(+), 67 deletions(-) create mode 100644 tools/testing/selftests/bpf/progs/kprobe_multi_empty.c