Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2488755iof; Wed, 8 Jun 2022 06:07:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz1fwUPy/skidrlOdPDe/Jk8XHsl415rq6HSoyTNkWzKyeZ/BSLSWKoXtMK4JsglqTPldsj X-Received: by 2002:a17:902:7c0e:b0:161:f9f6:be5b with SMTP id x14-20020a1709027c0e00b00161f9f6be5bmr33446494pll.156.1654693627401; Wed, 08 Jun 2022 06:07:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654693627; cv=none; d=google.com; s=arc-20160816; b=Q7tyAdDRbgi7GSQhjogi79niu7ytX6y7sH/Imr2Os9as+uMZIa705hU40EvFCITBpK /n4IU1Eeco9M4Ly+R5wvxHvHY7nvE5+S5WfjujMFJfrm/zfzFjHXNJuSy0pGjYEH/Pm/ tY5Ev3d7TS0+Hc2RDnt9V7u5/54+ycY6NYch39fvsPzPnjxF0/qTtdU+0Fv57TYmcZCb ozHPFMcC2dSmeYl9qeTIr5uoKAutjb0kXoKCJHgogFMhy7max+t/FyX3uxghU10f2UKR Qre2XMQtAZGhMM/kh+UjspNSc2nZ2mwVS9ofA28XbiXyjr629xQEzA1a5lR7v7a7pxcB nsXA== 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 :references:in-reply-to:message-id:subject:cc:to:from:date; bh=Rd/ovWGwj6cI3ykbM2Q7gOUa/67vpE54uuOwm7aSgMA=; b=CBuc1IK+wVrRtzDfYuOSu5s4b0ZPZH7RsFfNQIwzkBSW71io9t7CxJ8NYoEMMemIk1 4okPsufD91LXiUyqxo4zXRFPS8pMqys49hE1Yuq6szvGQGoEpD5UyXDo/Ax+L1064JiG OpXojg7DsAvdPdBJeUxJ+z/7GY8njglTW7VEvv4TIfuWG7Y6LjJqhWOTYMCQVmQa49El F8X0kDcR5GDgsMlSrWXnBEhm+sHgL8xswDVt98oPgthgWWkNC54fdDVCEtJNV+ekzdDj +czHSTcMZOJ2ZeXL+AgNoPu3Q69Epup4ede0pGeyFPy5GjCmXwx1c1xkxqUVLhaAuQvi dCjA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id u4-20020a17090341c400b00163b1bb13e4si30437647ple.113.2022.06.08.06.07.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 06:07:07 -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; 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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8725B2FAC21; Wed, 8 Jun 2022 05:40:41 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239788AbiFHMkc (ORCPT + 99 others); Wed, 8 Jun 2022 08:40:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239512AbiFHMka (ORCPT ); Wed, 8 Jun 2022 08:40:30 -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 B19EC2D80A9; Wed, 8 Jun 2022 05:40:27 -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 2BFE061975; Wed, 8 Jun 2022 12:40:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1F377C34116; Wed, 8 Jun 2022 12:40:25 +0000 (UTC) Date: Wed, 8 Jun 2022 08:40:23 -0400 From: Steven Rostedt To: Jiri Olsa Cc: 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: <20220608084023.4be8ffe2@gandalf.local.home> In-Reply-To: References: <20220606184731.437300-1-jolsa@kernel.org> <20220606184731.437300-4-jolsa@kernel.org> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, 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, 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. -- Steve