Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp713685pxm; Fri, 25 Feb 2022 18:04:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJzJ0q3BNvRqAoqpjOYooJ5WpElnC9pPNjj7WiWfrqOY0y0azxnIigEgozLtm/xbu0SbNbB6 X-Received: by 2002:a17:902:ce91:b0:150:3f7:5096 with SMTP id f17-20020a170902ce9100b0015003f75096mr10007916plg.128.1645841066240; Fri, 25 Feb 2022 18:04:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645841066; cv=none; d=google.com; s=arc-20160816; b=B/6HBxbqyxFPy/prluBalE4HeaFHxfSMObkE3yZGWAaJCSCeqfVZ8iXHqpwfiUTSA8 pVWsXYzDRmfREMo/ZgkC4193wW9W9QOMVwIhtRnn/QFbcRvupmRlM+dCOnze8NC+m/Yy BFXyYhWqCxMxUKAhD8rviJUWYVT/5e8K3mKCLhWaWRdsrCrmZTHYyFkre2KKGqUap6H7 TozeeUdKS7rhyGyT8mxQndqcbv/wWrXy476l6/pJqC9d8YaINc/jcUbo+GSzExtmmYRY c8ws8BL9ob0Ne6CJcYNpwK7Ja1ZzOTcBk1QWGpakdPaRE++epgiIHCU6KHy747jYtM1w dCrw== 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:from:date:dkim-signature; bh=U4B0j/EqvoeBnl9wE+MT6sM3KFAaFuCUdeNZ1N0HCaE=; b=wmlQxC6I92fUklBhSPna02JroFbd5TmSmjyd3rLTvYOs+qGHlzH1VBQa0PYdFCUaaZ ri/J8duXctxpRp5Goa9L9aevXelT55FYrJfgSsCz4OfydttWozU6hnXp+6rM83Tw2yA0 nGuPAmJ4PQmia+4mXAqOpgT8z6SMy7zcpZMAag924kpfJvhLnig62ts9lB3K+Js4r/ZR CtIk6FDjEiOIiwr9MPZaNlIiYMZMOs/DO/JdBje0h5r5t5ZVkr5AiwdBM18sd2xdDj+q LJUL8ceF4AT8u9zJIDODNF4kd6BNdTuaABWfZHfbxsMlSeJ7rS2ut3dkyLg96LeVSw3T BphA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bgqJcWqv; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id i17-20020a63d451000000b0036fe3c1bf14si3010850pgj.176.2022.02.25.18.04.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Feb 2022 18:04:26 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=bgqJcWqv; 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=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 98CEB8930F; Fri, 25 Feb 2022 17:43:59 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241798AbiBYOdJ (ORCPT + 99 others); Fri, 25 Feb 2022 09:33:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241786AbiBYOci (ORCPT ); Fri, 25 Feb 2022 09:32:38 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A5C716F96F; Fri, 25 Feb 2022 06:32:06 -0800 (PST) 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 ams.source.kernel.org (Postfix) with ESMTPS id C5F87B831F8; Fri, 25 Feb 2022 14:32:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3A86AC340E7; Fri, 25 Feb 2022 14:32:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1645799523; bh=R7UNX1EqDtGkiEAz9dtDTaaeHOPhPEl39fh/58YEnQE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=bgqJcWqvGAoXF08p/LH3hYFTePdjznND7PCmsKaczhezQ+3/BhmYy/L6t1T3YP+Zh CP639+Wia/zVanM9JURiQcBx12XkW2vlkFuXE05vLd2RyQy9DqdvF7X0Cz/RPR4qT4 zbi2lRlOzacRqog1z/0kYCRGeIV0WEUh62DA6oU/HdJcCmL1cd/Np0LYwerbDkOcza c7Wa8DGFFTziPBEguzqM2Wc3MfN+gz3Tc49xqyiRGrTVLkHA31okY0nD4NuaBUjjWv GV4aykR+tloz1ZM4Spw82lY5Q/EVTEJXoHEdEH48Pr4Hw6pom6KqSo9WN+lD8kXqJt qEk2CvhgMWGeA== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 2C484403C8; Fri, 25 Feb 2022 11:32:00 -0300 (-03) Date: Fri, 25 Feb 2022 11:32:00 -0300 From: Arnaldo Carvalho de Melo To: Jiri Olsa Cc: Andrii Nakryiko , Jiri Olsa , Andrii Nakryiko , lkml , Peter Zijlstra , Ingo Molnar , Mark Rutland , Namhyung Kim , Alexander Shishkin , Ian Rogers , "linux-perf-use." , bpf Subject: Re: [PATCH 3/3] perf tools: Rework prologue generation code Message-ID: References: <20220217131916.50615-1-jolsa@kernel.org> <20220217131916.50615-4-jolsa@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Url: http://acmel.wordpress.com X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Em Fri, Feb 25, 2022 at 01:14:49PM +0100, Jiri Olsa escreveu: > On Wed, Feb 23, 2022 at 02:29:56PM -0800, Andrii Nakryiko wrote: > > SNIP > > > > and R3 is loaded in the prologue code (first 15 instructions) > > > and it also sets 'err' (R2) with the result of the reading: > > > > > > 0: (bf) r6 = r1 > > > 1: (79) r3 = *(u64 *)(r6 +96) > > > 2: (bf) r7 = r10 > > > 3: (07) r7 += -8 > > > 4: (7b) *(u64 *)(r10 -8) = r3 > > > 5: (b7) r2 = 8 > > > 6: (bf) r1 = r7 > > > 7: (85) call bpf_probe_read_user#-60848 > > > 8: (55) if r0 != 0x0 goto pc+2 > > > 9: (61) r3 = *(u32 *)(r10 -8) > > > 10: (05) goto pc+3 > > > 11: (b7) r2 = 1 > > > 12: (b7) r3 = 0 > > > 13: (05) goto pc+1 > > > 14: (b7) r2 = 0 > > > 15: (bf) r1 = r6 > > > > > > 16: (b7) r1 = 100 > > > 17: (6b) *(u16 *)(r10 -8) = r1 > > > 18: (18) r1 = 0x6c25203a6f697270 > > > 20: (7b) *(u64 *)(r10 -16) = r1 > > > 21: (bf) r1 = r10 > > > 22: (07) r1 += -16 > > > 23: (b7) r2 = 10 > > > 24: (85) call bpf_trace_printk#-54848 > > > 25: (b7) r0 = 1 > > > 26: (95) exit > > > > > > > > > I'm still scratching my head how to workaround this.. we do want maps > > > and all the other updates to the code, but verifier won't let it pass > > > without the prologue code > > > > ugh, perf cornered itself into supporting this crazy scheme and now > well, it just used the interface that was provided at the time At the time it was where experimentation was done with tooling for eBPF, Wangnan tried to provide a compact way to give access to parameters. The problem now is for libbpf to remove something that is used and that was documented to some extent in the perf tools examples so there _may_ be some usage of it, we just can't know. Its like Linux removing some syscall that is "crazy" and wait for somebody to complain of the breakage caused when they update to a new version. > > there is no good solution. I'm still questioning the value of > > supporting this going forward. Is there an evidence that anyone is > > using this functionality at all? Is it worth it trying to carry it on > > just because we have some example that exercises this feature? > yea we discussed this again and I think we can somehow mark this > feature in perf as deprecated and remove it after some time, > because even with the workaround below it'll be pita ;-) > > or people will come and scream and we will find some other solution :-\ if you have some "ugly" way to keep the feature, can't we go with it? > I already sent the rest of the changes (prog/map priv) separately > and will send some RFC for the deprecation I'll look at it now. Thanks for your work on this, Jiri. - Araldo > thanks, > jirka > > > > > Anyways, one way to solve this is to add bpf_program__set_insns() that > > could be called from prog_init_fn callback (which I just realized > > hasn't landed yet, I'll send v4 today) to prepend a simple preamble > > like this: > > > > r1 = 0; > > r2 = 0; > > r3 = 0; > > f4 = 0; > > r5 = 0; /* how many input arguments we support? */ > > > > This will make all input arguments initialized, libbpf will be able to > > adjust all the relocations and stuff. Once this "prototype program" is > > loaded, perf can grab final instructions and replace first X > > instructions with desired preamble. > > > > But... ugliness and horror, yeah :( > > > > > > > > > > jirka -- - Arnaldo