Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2639585iof; Wed, 8 Jun 2022 09:01:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxQjS8y1FsNzJoUjI/XfxCHV/K4f+3T80dDtnBoX33LOZzUu/Zr270528z2CcQcxnq/YuQU X-Received: by 2002:a17:902:ccd0:b0:156:7ac2:5600 with SMTP id z16-20020a170902ccd000b001567ac25600mr34309991ple.156.1654704104290; Wed, 08 Jun 2022 09:01:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654704104; cv=none; d=google.com; s=arc-20160816; b=MRKqSw+bX+Uf03T79mYLtBwJ6JdKXEoo7Ac6TdgsOMT7apT28p/7xS8N6ff2464KG9 l27WARoGF6v9DPeHfNgoWwcEf8XCZKuwfhgoANx4XA9ayKmBP/DFXF9qovmdsQtQeUST fgACauehTqqrCs64/LZ5w25W0T2ry1Ddmj2KARlzPz6S7b1aTZNlzKk+AcEGsVsltoOB VWgDTYCgtUUtFHq6DqmEhSC1qdgeftLxcpSMMVCYvx+Oh6ZrLqzzSXAVIGp2W9jRwWCY fPcjfm9v5lHdekTb525IBtvjGguZph1tS4OoDuYNcRPXyl+TcC9Qq+IoJwMpud6Bknxl p+MQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:date:from:dkim-signature; bh=J4IcVQmCWbsMmkdxbOmYq0AW116qw3cDv81nRHPjJ3A=; b=ZSGQ4t7dMTD2ZPzwEkKOudwAPABVYQ5aiEEqSsxvf+YFrM4vmHZmm7N65GNyirS8g4 36hmWJShxA6XEUBGWWoIyKgudcEsONE0eMSMMTS5/ufII2mTlJhn0rkpxJNDi2vbUUms khthVBsLNRD+jcEgX8czcKVp+Ite1on1f66f9Lh8+/Io1jCa2fdrf+JENLrTXshFITM4 8NeliDDmu4kh0ruY3P5ivTLW5+/3CqRhgjbax5v2mirxa18uZWFuTON6au9Uchwmgh1I SeK8XqgRkQdyny5ONtYyNoCY2+nVW3J0bs2vX445K/8SXsIWQlhIuYSwfkeWOeAmGvHG gtGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=nAbUaLgY; 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 a11-20020a17090acb8b00b001e08bc5fab4si19768225pju.83.2022.06.08.09.01.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 09:01:44 -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=nAbUaLgY; 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 6C534403E3; Wed, 8 Jun 2022 08:33:19 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243930AbiFHPdK (ORCPT + 99 others); Wed, 8 Jun 2022 11:33:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242477AbiFHPdI (ORCPT ); Wed, 8 Jun 2022 11:33:08 -0400 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A355C7B; Wed, 8 Jun 2022 08:33:07 -0700 (PDT) Received: by mail-ej1-x630.google.com with SMTP id u12so42225536eja.8; Wed, 08 Jun 2022 08:33:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=J4IcVQmCWbsMmkdxbOmYq0AW116qw3cDv81nRHPjJ3A=; b=nAbUaLgYFng5Ob23XvU9j6AJ66VuiisUeEu7k2SypVaJxBLm2SauII2aAwjvMNaJ40 aOVlapNJdp+g3fOjyFqTXQTK4AiTW1CiTD3yXfBIwbFL1IQK4oqOkLzT1/zaeACtrexZ jCX+170X3D4kZ5S1bCwgnKx79WfqsC3ceLqjVukJKXhwRMSWgDHg9uMjAMJAMU5vP4hY HJZy4YmH0XlpyAm5hSk2OxOnDF3cxUHoT13NBXwzXLa0Y/PsUCWvRUp7TW4eUXfcloIY A62I297ZEYDmo4xBaX7jTjv8pdZxRCXvNUHyJhdJusBbTutov5rfRVBPorOEYN0TAAnJ RGpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=J4IcVQmCWbsMmkdxbOmYq0AW116qw3cDv81nRHPjJ3A=; b=FVjfvhakIgh1Wpj6KfrJagEhae49ATVB8nDr7XuGKdanuOJrwETfDP0WLRd9WHZQul cUNhduDdjeqjCgp0ipg6vqqGrz/1TxHFNs1wPu5e8dwy7oLlvIAw+ct0rjCmNoKekWzP yTDbZYdzTxwZ4jO2uwMGF9ZU27AleiO55WJE0xpFW86YzkuswuCwlgFTgfUOpHcCgeCv 2tjAtjLakHvsysb+5gl3tqpseGekMsY6yWaJY2TWM/BFgxDQSZmngg+7H9gn/H2kVBfo 6pLywR1sOod5qjRD6We/wDaTFABbcljclm5DqPOyUjIwS7B9ayXlkWBSCUG0co+lx2et 21aw== X-Gm-Message-State: AOAM530z32wT/ehpjHDe//RHKvOnO8gC/PaS+S3rU+JvC4Xfwm2N4Nx5 NIT0dYqROqkKNcuBuGE8OuE= X-Received: by 2002:a17:906:4787:b0:711:d085:88a3 with SMTP id cw7-20020a170906478700b00711d08588a3mr14311805ejc.118.1654702385752; Wed, 08 Jun 2022 08:33:05 -0700 (PDT) Received: from krava ([193.85.244.190]) by smtp.gmail.com with ESMTPSA id cn26-20020a0564020cba00b0042e0385e724sm11453742edb.40.2022.06.08.08.33.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 08:33:05 -0700 (PDT) From: Jiri Olsa X-Google-Original-From: Jiri Olsa Date: Wed, 8 Jun 2022 17:33:02 +0200 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 Subject: Re: [PATCHv2 bpf 3/3] bpf: Force cookies array to follow symbols sorting Message-ID: References: <20220606184731.437300-1-jolsa@kernel.org> <20220606184731.437300-4-jolsa@kernel.org> <20220608084023.4be8ffe2@gandalf.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220608084023.4be8ffe2@gandalf.local.home> 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 08, 2022 at 08:40:23AM -0400, 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. ok, we'll have to workaround that then thanks, jirka