Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp1106280rwo; Wed, 2 Aug 2023 08:48:33 -0700 (PDT) X-Google-Smtp-Source: APBJJlGTuT14GOWfXWfgjgSY7OJ5SQjbM86Syd4mVYMxN2aMGDV1/Ysc0nkLLGWatPsDgsRJA/JI X-Received: by 2002:a17:90a:2904:b0:263:5c6a:1956 with SMTP id g4-20020a17090a290400b002635c6a1956mr14768949pjd.25.1690991312652; Wed, 02 Aug 2023 08:48:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690991312; cv=none; d=google.com; s=arc-20160816; b=S/iYYo279szOYEzSXvfeixrp7KRlp9LvfvBPBZpvrLhu8VkCEZp86pokWyzeZw7vIQ nF/qqbFht5YDFNuDX5+Zz1GZM1fLnVH3DvWTnAkPGs9B831TWOgaZfBsKhjSCjOKC7J5 hlRjwnLKS+xm13EPFv3FnjSu80+uIY9eTD6+5HRjAda4hQEco+/VcUMNQXz905S/1KxU s3cqSTVuKsLCTBZv0Ad379tKCOFd9b0JVBAO+Fc8shLQFo62ihGPx9//1qOe87b/5BFq qgrQCyocWr2cMbyBcZ/AtkqxvgrdVtslgJeWBYYfTilgFvrkfgn5/R9G2VwGuMNiKX2f Odbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=sGrnYzd5HDo329ej7S9UGy2s8CEMFYkTaY0FnMVZHLY=; fh=3JZkHl2ukg7miGavQW0g2JmR/cZkT7HJHfkPx8E7A9s=; b=x3LDTaFxJdDU7m/xzfdRGmnzbwYzWt/8tfuazjel6SNbDcUnbOt0RY8PscfornJdpk kOwGw3o/9ooN3FOdIE1/tHYIdT65EIConLeInLub/ahIXQ2x7+1g2R1DD4xiC58Qy3aR rHAbpwD/XsXCQfuVC1GVBDIJeQM2+BlbUrsOz7yPzK2GC9/hlEe+I7D4UrnSZrOPLoeg GSWOEaaIup1C1afeyjeIuwMgqnDHI3TkctqszXDt4VpTxm6eDM2XPEavRK3O4z8m5z0a EFBEO8QfF9AtgOVXeZ2cBJE/nNci6jvq8yi53+0Si7iHgzqgSy3r5H2FrW/Mt2s00N65 Evcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=S7Zlx66n; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w4-20020a17090aad4400b0025653dc2881si1388070pjv.23.2023.08.02.08.48.20; Wed, 02 Aug 2023 08:48:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=S7Zlx66n; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233968AbjHBPJ4 (ORCPT + 99 others); Wed, 2 Aug 2023 11:09:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234094AbjHBPJp (ORCPT ); Wed, 2 Aug 2023 11:09:45 -0400 Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9181126BD for ; Wed, 2 Aug 2023 08:09:17 -0700 (PDT) Received: by mail-pg1-x52b.google.com with SMTP id 41be03b00d2f7-56481f2a148so341799a12.0 for ; Wed, 02 Aug 2023 08:09:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1690988950; x=1691593750; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=sGrnYzd5HDo329ej7S9UGy2s8CEMFYkTaY0FnMVZHLY=; b=S7Zlx66nt0XIGNLBNb0wRwefz585SdXOx7OtJCRv9BjsgPttexJzuDmcaaKyiIij4y bggyt9MI9nkv2Rc1mhFyyFzUNuDuXjjvu2zqf0i1lS/WQlbzjctF/rbLs5GhVdsNWP80 uf4Q3xP36leowau/xopRA+1zZ6s8m5VnVTCNo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690988950; x=1691593750; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sGrnYzd5HDo329ej7S9UGy2s8CEMFYkTaY0FnMVZHLY=; b=X/+J2/PxMr6c7u3gvm3gdMQUY/Idqy5dwEpp6tMk9jk80If/cgQJcf1zWUIYwQPjiN JHMkr76C/3W2BwYT1lFgv/iNL5ADCK9zLceX0I0BFmXtoIfc+04c5joWoaTLE1CwrK2Z 8/wXHbM0Stq/sJNC7qTO6jwE2RkpfOcOvKrN9bXFCsySU4T5lMCuIaRnCFT/sA4H79Xb 0DeMc3vjw3iVS+/og+4J6QSX3fLUQwba+Hsjek6IxM/357SMibrwK5vmC3Q4RfOvGFX2 KcG1L3jkl0nL8x7n70Ap4ooTZptFKMAgUaKj0pRJuBN7v0fJefN8xixnysbtVGN1Lv0H 3OyQ== X-Gm-Message-State: ABy/qLb1aYcWZYqxqPvdY0kMyQTlxqimeRUfFhGqs9MY7cCsbMi/Ydp9 2E6193nNG638ESZietgNQdl91egtvV+nm0nLKPhMfw== X-Received: by 2002:a17:90b:1e0b:b0:268:5919:a276 with SMTP id pg11-20020a17090b1e0b00b002685919a276mr13671658pjb.20.1690988950550; Wed, 02 Aug 2023 08:09:10 -0700 (PDT) MIME-Version: 1.0 References: <169078860386.173706.3091034523220945605.stgit@devnote2> <169078863449.173706.2322042687021909241.stgit@devnote2> <20230801085724.9bb07d2c82e5b6c6a6606848@kernel.org> <20230802000228.158f1bd605e497351611739e@kernel.org> <20230801112036.0d4ee60d@gandalf.local.home> <20230801113240.4e625020@gandalf.local.home> <20230801190920.7a1abfd5@gandalf.local.home> <20230802092146.9bda5e49528e6988ab97899c@kernel.org> <20230801204054.3884688e@rorschach.local.home> <20230801204407.7b284b00@rorschach.local.home> <20230802230738.2b22cef561feb5d498f22f49@kernel.org> In-Reply-To: <20230802230738.2b22cef561feb5d498f22f49@kernel.org> From: Florent Revest Date: Wed, 2 Aug 2023 17:08:58 +0200 Message-ID: Subject: Re: [PATCH v4 3/9] bpf/btf: Add a function to search a member of a struct/union To: Masami Hiramatsu Cc: Alexei Starovoitov , Steven Rostedt , linux-trace-kernel@vger.kernel.org, LKML , Martin KaFai Lau , bpf , Sven Schnelle , Alexei Starovoitov , Jiri Olsa , Arnaldo Carvalho de Melo , Daniel Borkmann , Alan Maguire , Mark Rutland , Peter Zijlstra , Thomas Gleixner Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham 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, Aug 2, 2023 at 4:07=E2=80=AFPM Masami Hiramatsu wrote: > > On Tue, 1 Aug 2023 19:22:01 -0700 > Alexei Starovoitov wrote: > > > On Tue, Aug 1, 2023 at 5:44=E2=80=AFPM Steven Rostedt wrote: > > > > > > On Tue, 1 Aug 2023 20:40:54 -0400 > > > Steven Rostedt wrote: > > > > > > > Maybe we can add a ftrace_partial_regs(fregs) that returns a > > > > partially filled pt_regs, and the caller that uses this obviously k= nows > > > > its partial (as it's in the name). But this doesn't quite help out = arm64 > > > > because unlike x86, struct ftrace_regs does not contain an address > > > > compatibility with pt_regs fields. It would need to do a copy. > > > > > > > > ftrace_partial_regs(fregs, ®s) ? > > > > > > Well, both would be pointers so you wouldn't need the "&", but it was > > > to stress that it would be copying one to the other. > > > > > > void ftrace_partial_regs(const struct ftrace_regs *fregs, struct pt= _regs regs); > > > > Copy works, but why did you pick a different layout? > > I think it is for minimize the stack consumption. pt_regs on arm64 will > consume 42*u64 =3D 336 bytes, on the other hand ftrace_regs will use > 14*unsigned long =3D 112 bytes. And most of the registers in pt_regs are = not > accessed usually. (as you may know RISC processors usually have many > registers - and x86 will be if we use APX in kernel. So pt_regs is big.) > > > Why not to use pt_regs ? if save of flags is slow, just skip that part > > and whatever else that is slow. You don't even need to zero out > > unsaved fields. Just ask the caller to zero out pt_regs before hand. > > Most users have per-cpu pt_regs that is being reused. > > So there will be one zero-out in the beginning and every partial > > save of regs will be fast. > > Then there won't be any need for copy-converter from ftrace_regs to pt_= regs. > > Maybe too much churn at this point. copy is fine. > > If there is no nested call, yeah, per-cpu pt_regs will work. BPF "multi_kprobe" programs (ugh, it's pretty awkward we called them that way given that kprobe is out of the picture and fprobe is subject to completely different constraints than kprobe) can't be nested, as checked here: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf.git/t= ree/kernel/trace/bpf_trace.c?id=3D4c9fbff54297471d4e2bbfe9c27e80067c722eae#= n2642 (this is probably the place where we'd be calling a "ftrace_partical_regs" anyway so that's cool)