Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2663344iof; Wed, 8 Jun 2022 09:27:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwxcmxI77EAhMcDh8Yj4/1Kq1/ocNmA2+0hAwcylYrpvSSekq2LpUlkOQ12xNJp9r+/C8xy X-Received: by 2002:a17:90b:3909:b0:1e8:4669:ce47 with SMTP id ob9-20020a17090b390900b001e84669ce47mr32559pjb.124.1654705624755; Wed, 08 Jun 2022 09:27:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654705624; cv=none; d=google.com; s=arc-20160816; b=fprwrkLBx9IQokqASdqkXM2lzeBFzarNkDmCDxfkbPKtTvuIWb435qlWcs3fGIgYOc wOmLnKQkavStd2q4TRw19DIoWpKrhEKnceMHy8ygWPtRVIa/ZuVyHDCXZd46coJ1rS3J zauD+jCjpJ/LKhPd9nGhTPOmHlksGkzlTA96lK6A+hDMjTOBEKmAjQLLnqUDYscnEI/L aWkIVzCwY6SEa0oDdb4XMQKXck5N895ntBNaSzY5SXfjDIVH2iPKbgV7Svfea12sEUX0 iupjmgNDgg2/Fgy8XZvX+xp2wGn56BG5DNW0d8gJZzulgo5gnWgbgkTSLEA8lD9rp5g3 6dJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=DVfFcL/p/g9l6zNNgj4xtypcOyIqNfaVEjGSvMr4y54=; b=w2vEFEvczThSKHcX0mKLZjdQfu/cYftzPxiz5HIdkNTVawfbqcpb1H552jHuGrsOQW SD56M77UIJJ+x/meaXfX70WhMtTrWNOMX2VdJVatSwkgQ6yHXy31ZcgBF+Lh8nOxZMzO voP17TC63OhzgYsC1TTHyYeGY5Ge0sCiJ0zBemxAG2Xbb3QRUyGl1kVGQ0SMrWTM+PJz qTcgHAmD4gBoBjBYvf6Kah6BX1RNu1D5Ud8p7s3f56DudkqSWYs+lYWBZXs5Maf8joTU HC5cSm/l6YL+ieEu3DREJc+dtTectLn5adQh23VQUw6Rf+mM91aBUUEgthSwhx9C/w5Q 6+vA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=N7MBfuKt; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id v12-20020a170902b7cc00b00161571fd712si27895746plz.450.2022.06.08.09.27.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 09:27:04 -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=@gmail.com header.s=20210112 header.b=N7MBfuKt; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C3C79CE21; Wed, 8 Jun 2022 09:00:24 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244556AbiFHQAM (ORCPT + 99 others); Wed, 8 Jun 2022 12:00:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233355AbiFHQAH (ORCPT ); Wed, 8 Jun 2022 12:00:07 -0400 Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D70BEB4BE; Wed, 8 Jun 2022 09:00:03 -0700 (PDT) Received: by mail-lf1-x131.google.com with SMTP id s6so33875856lfo.13; Wed, 08 Jun 2022 09:00:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=DVfFcL/p/g9l6zNNgj4xtypcOyIqNfaVEjGSvMr4y54=; b=N7MBfuKtagUgEl6p+oPmZKgOjBSalyJpusCN5hjwdigSnU03UfLSDkAOJOZM9QzFUC 3I/mesO2LyjmsbYPbys34/kmqy+7INcEfD4eYRWJK1mjo05A5D8jLlbtRvGHp8njHTNK It9Ht5B59s/MY1bFKv4+0C9F8hF+9ruR0jEip9PEwsH0Aw/tq8QpOdvM3p0JnrAq/3QU N35dcZdFM6nLV+s70o2dHDpZWSM6wSYPEmXbIF0REf6ODJppV7uBmCVGvmbTeMld15fN I8GUpuW4jbZOK14bDI9NUrqsG8WLuUnWTsVU4t5PAdOKKRV9HDRrfX6lZD3fhW3QfETi nTpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=DVfFcL/p/g9l6zNNgj4xtypcOyIqNfaVEjGSvMr4y54=; b=BMouYea0upDDovtWSYLbCZuOFn7FH3OzNdzBlG3rVMjI6pOcG1/msMeS801XKyldMX 6DPJNL9cCrYcVcPjXa+bMGAnCHAPSlKwPZu7Lc4NEurmLrs/DcW0m8yqVJ1fMBXLNxyv 5r7JV67X13aGjvrCJGpZ7ljTyMnZhloVhYu6RISiNqg55m16CLVoDVaYjbOSMUe6yiGQ 97YCGFlfunI9A5L/P4tfhNemLPnpz442DNx4RQ3FS76I0tem3zBVmjr1GYGVqLZMJTK0 sIKZ1tzpgEX5RSPPQTBr0SkXUfYxse2B6EPgrQu8UDp8K5408CL8/sIcNxoJTGJFLiIS L9FA== X-Gm-Message-State: AOAM532vG9GWWw8NRPE14xJG/ynCwnb7f99VU78T+Ljz211Sm//atQjU g+29laIjgVyzeOQWr+jCYTbvwIj1I02yPVm3YRo= X-Received: by 2002:a05:6512:1398:b0:448:bda0:99f2 with SMTP id p24-20020a056512139800b00448bda099f2mr68744850lfa.681.1654704001946; Wed, 08 Jun 2022 09:00:01 -0700 (PDT) MIME-Version: 1.0 References: <20220606184731.437300-1-jolsa@kernel.org> <20220606184731.437300-4-jolsa@kernel.org> <20220608084023.4be8ffe2@gandalf.local.home> In-Reply-To: <20220608084023.4be8ffe2@gandalf.local.home> From: Andrii Nakryiko Date: Wed, 8 Jun 2022 08:59:50 -0700 Message-ID: Subject: Re: [PATCHv2 bpf 3/3] bpf: Force cookies array to follow symbols sorting To: Steven Rostedt Cc: Jiri Olsa , Alexei Starovoitov , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Network Development , bpf , lkml , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Masami Hiramatsu Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 On Wed, Jun 8, 2022 at 5:40 AM Steven Rostedt wrote: > > On Wed, 8 Jun 2022 11:57:48 +0200 > Jiri Olsa wrote: > > > Steven, > > is there a reason to show '__ftrace_invalid_address___*' symbols in > > available_filter_functions? it seems more like debug message to me > > > > Yes, because set_ftrace_filter may be set by index. That is, if schedule is > the 43,245th entry in available_filter_functions, then you can do: > > # echo 43245 > set_ftrace_filter > # cat set_ftrace_filter > schedule > > That index must match the array index of the entries in the function list > internally. The reason for this is that entering a name is an O(n) > operation, where n is the number of functions in > available_filter_functions. If you want to enable half of those functions, > then it takes O(n^2) to do so. > > I first implemented this trick to help with bisecting bad functions. That > is, every so often a function that should be annotated with notrace, isn't > and if it gets traced it cause the machine to reboot. To bisect this, I > would enable half the functions at a time and enable tracing to see if it > reboots or not, and if it does, I know that one of the half I enabled is > the culprit, if not, it's in the other half. It would take over 5 minutes > to enable half the functions. Where as the number trick took one second, > not only was it O(1) per function, but it did not need to do kallsym > lookups either. It simply enabled the function at the index. > > Later, libtracefs (used by trace-cmd and others) would allow regex(3) > enabling of functions. That is, it would search available_filter_functions > in user space, match them via normal regex, create an index of the > functions to know where they are, and then write in those numbers to enable > them. It's much faster than writing in strings. > > My original fix was to simply ignore those functions, but then it would > make the index no longer match what got set. I noticed this while writing > my slides for Kernel Recipes, and then fixed it. > > The commit you mention above even states this: > > __ftrace_invalid_address___ > > (showing the offset that caused it to be invalid). > > This is required for tools that use libtracefs (like trace-cmd does) that > scan the available_filter_functions and enable set_ftrace_filter and > set_ftrace_notrace using indexes of the function listed in the file (this > is a speedup, as enabling thousands of files via names is an O(n^2) > operation and can take minutes to complete, where the indexing takes less > than a second). > > In other words, having a placeholder is required to keep from breaking user > space. Would it be possible to preprocess ftrace_pages to remove such invalid records (so that by the time we have to report available_filter_functions there are no invalid records)? Or that data is read-only when kernel is running? > > -- Steve > >