From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CD73FC4363A for ; Wed, 28 Oct 2020 22:41:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 747DE207CD for ; Wed, 28 Oct 2020 22:41:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="noS8dvS1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389102AbgJ1WlA (ORCPT ); Wed, 28 Oct 2020 18:41:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730725AbgJ1Wk6 (ORCPT ); Wed, 28 Oct 2020 18:40:58 -0400 Received: from mail-yb1-xb42.google.com (mail-yb1-xb42.google.com [IPv6:2607:f8b0:4864:20::b42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D610C0613CF; Wed, 28 Oct 2020 15:40:58 -0700 (PDT) Received: by mail-yb1-xb42.google.com with SMTP id b138so542324yba.5; Wed, 28 Oct 2020 15:40:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=jg45dpTkIStnq7FH8sB1G6csIoi0LJaAOaqWI/KVCvI=; b=noS8dvS1P9698Fp6wHJWJPKA+/s9WfOrs3eI0eKM7tXYQIY+jDH6Ivu06+vFjdr6tR m82s7srotwXwMAhUpxBzkw9o/OMYtJra6MkONeYOdQZMK8DZ5nh9f0DuuUpXSzx9xjC/ Is5X+0B55s4egZElRcBoYkhwSx5z+lbt43kRaGUeEyTJqn0EmwZZyr79GyLfJXIJZxyx mDGGiIO+maiihAloxafvli/rpUTQy8IoP/1sn9Hk4DEK+WFy0R4/7jpVFFzRfotzH8sR 45ToxSia4MLemgUbQ9+HCYWdSwPzcwEC5U97K78w1YtRk5q3bBSM8687/prdUbe6YM1c rzsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=jg45dpTkIStnq7FH8sB1G6csIoi0LJaAOaqWI/KVCvI=; b=bNP0xXFHnzBit1JPYBlxKg1ev4E86bZ0uwAQeCaNgXE2lzN81q1T3oA3rSnJVr0/Hf lLlJZpX+0rwBwJlSEbhtO/9YXS42useXwywouY2N/6lqypr+XaHZPnh0KWmz9vAgs9rI 5TCic22NNSVYMSkJ5b3gr+YjB2Abs264l/pDdP5pp2OjBw0eTC9U4oO7ryY0budz4a2E gKUAKyQCbWAXaUXQWfyDjNZe9abAhnaS6zpNpAnyQ+YyZpEWH8fxvCD0NWYzu3keLe5M nkHNSh9WQ+L9lLX+5g9QkxY45eC47rutejmM50+XLONjyuNE2N9fk6zYW23ZatQ2P/kk HfAw== X-Gm-Message-State: AOAM532UOVWIJ6bUXLP1SxN9a2QHnwq9wCy0ZvpOIjuL1tWLJ5j+GXpC 6wOigaEvulvjtLuRJ5yMPCzA6y2R22Y7VsY1qYQ= X-Google-Smtp-Source: ABdhPJzjR9v72td9M8NZQP+eitD1eMiz3OsKtziYoQQJVouthGxKy6BQyiXpmiZ9+bPbeYxIQSPgdVC+fQkcTwS6lm4= X-Received: by 2002:a25:c001:: with SMTP id c1mr1976005ybf.27.1603924857840; Wed, 28 Oct 2020 15:40:57 -0700 (PDT) MIME-Version: 1.0 References: <20201022082138.2322434-1-jolsa@kernel.org> <20201022082138.2322434-8-jolsa@kernel.org> <20201028182534.GS2900849@krava> In-Reply-To: <20201028182534.GS2900849@krava> From: Andrii Nakryiko Date: Wed, 28 Oct 2020 15:40:46 -0700 Message-ID: Subject: Re: [RFC bpf-next 07/16] kallsyms: Use rb tree for kallsyms name search To: Jiri Olsa Cc: Jiri Olsa , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Networking , bpf , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Daniel Xu , Steven Rostedt , Jesper Brouer , =?UTF-8?B?VG9rZSBIw7hpbGFuZC1Kw7hyZ2Vuc2Vu?= , Viktor Malik Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Wed, Oct 28, 2020 at 3:29 PM Jiri Olsa wrote: > > On Thu, Oct 22, 2020 at 10:21:29AM +0200, Jiri Olsa wrote: > > The kallsyms_expand_symbol function showed in several bpf related > > profiles, because it's doing linear search. > > > > Before: > > > > Performance counter stats for './src/bpftrace -ve kfunc:__x64_sys_s* \ > > { printf("test\n"); } i:ms:10 { printf("exit\n"); exit();}' (5 runs): > > > > 2,535,458,767 cycles:k ( +- 0.55% ) > > 940,046,382 cycles:u ( +- 0.27% ) > > > > 33.60 +- 3.27 seconds time elapsed ( +- 9.73% ) > > > > Loading all the vmlinux symbols in rbtree and and switch to rbtree > > search in kallsyms_lookup_name function to save few cycles and time. > > > > After: > > > > Performance counter stats for './src/bpftrace -ve kfunc:__x64_sys_s* \ > > { printf("test\n"); } i:ms:10 { printf("exit\n"); exit();}' (5 runs): > > > > 2,199,433,771 cycles:k ( +- 0.55% ) > > 936,105,469 cycles:u ( +- 0.37% ) > > > > 26.48 +- 3.57 seconds time elapsed ( +- 13.49% ) > > > > Each symbol takes 160 bytes, so for my .config I've got about 18 MBs > > used for 115285 symbols. > > > > Signed-off-by: Jiri Olsa > > FYI there's init_kprobes dependency on kallsyms_lookup_name in early > init call, so this won't work as it is :-\ will address this in v2 > > also I'll switch to sorted array and bsearch, because kallsyms is not > dynamically updated what about kernel modules then? > > jirka > > > --- > > kernel/kallsyms.c | 95 ++++++++++++++++++++++++++++++++++++++++++----- > > 1 file changed, 86 insertions(+), 9 deletions(-) > > [...]