Received: by 2002:a05:7412:bb8d:b0:d7:7d3a:4fe2 with SMTP id js13csp363367rdb; Mon, 14 Aug 2023 21:15:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE17IrWJQQtms+3nvKJ+ExBJN0FsGXuM4gAsfjJ2BCVtT2OfNZdwzuUOhMoQJDRj7iJpgxF X-Received: by 2002:ac2:505a:0:b0:4fe:63cf:6048 with SMTP id a26-20020ac2505a000000b004fe63cf6048mr201337lfm.43.1692072921430; Mon, 14 Aug 2023 21:15:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692072921; cv=none; d=google.com; s=arc-20160816; b=05XQ2wlg0Oy07cm7+jb6c3uXTue1jlodzeWmIuF4yojUIfGX4g4njxiwyY3fpnVwP9 ezmbyGu2dYUyz1wRvVh5TEe3iz7o70yBLnMzxqi0D/UZUyAvdmriJ00Eqyq8+DOMvrlR TuUy9dLsWIuKgelhdAcf7mK1yF/jzMxEpwgK+wzZ9X81t/W/fqMi7I57d53ZnqQn+LQB 2pfX8JUE2hPexmc2rR5ZTipy1pQlD3NiHBrirKpzQ94lmQHVev3vn+sb5f/YFkOvbiG5 sDezjB51NwdTUZbNMLzR3OpV/jYccI4Vi/1Nt28bMuw7SFwd2DVxb44uMeedNanGLinr KTiw== 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=HGU97iw5oq/e3LBwfaWwJKeBPpMIqfE+4M/1ffzDFss=; fh=4+o1bXlEv0Qhz4r+7V/Li7FmhX/OdQNQxDXdRdcAm8k=; b=ZrQStITlgF5fgSVqg0VWN3pPViXDVaJzZ4dXxqa/+k+9NBFUFTyQ2CzYEzkC2SninW JbSQ9W58XjiSCkqKEU99IAq33CCqF7qSoUzPl3mgbMTiW3LcYyiMxI1j+HN2WF9EyCO0 Pepb9Qh+Mrtn9G2piJxsctvuARRrUSYuMHpfxt3v3DFeje/xXWK8FjGYBnHjSEXGezlk egzslFPLi2MpZiny48Xs71WTPxmQypyab+PzPsp3Jw0ojtET9DiW+aTkpejZ26RAHqBp th8SfE+C2Pvxo6KKKTRynVl7CL5xzi5rzcNlO/XJoNpkpDHwcbUAm7d3uPFYtDYAiGIq Ht5g== 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:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h6-20020a50ed86000000b005254c2bb872si4349000edr.10.2023.08.14.21.14.31; Mon, 14 Aug 2023 21:15:21 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233191AbjHOArw (ORCPT + 99 others); Mon, 14 Aug 2023 20:47:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233173AbjHOAr1 (ORCPT ); Mon, 14 Aug 2023 20:47:27 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 439D31710 for ; Mon, 14 Aug 2023 17:47:26 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D6E7A61DBA for ; Tue, 15 Aug 2023 00:47:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D5C6AC433C7; Tue, 15 Aug 2023 00:47:24 +0000 (UTC) Date: Mon, 14 Aug 2023 20:47:23 -0400 From: Steven Rostedt To: David Laight Cc: Sven Schnelle , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v2] tracing/synthetic: use union instead of casts Message-ID: <20230814204723.0fd326c0@gandalf.local.home> In-Reply-To: References: <20230809071459.2004931-1-svens@linux.ibm.com> <20230809085449.453b632a@gandalf.local.home> X-Mailer: Claws Mail 3.19.1 (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=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS 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 Mon, 14 Aug 2023 11:34:20 +0000 David Laight wrote: > > No need to create a structure around a single element union. Also, I would > > like to name it for what it is for. > > > > union trace_synth_field { > > u8 as_u8; > > u16 as_u16; > > u32 as_u32; > > u64 as_u64; > > struct trace_dynamic_info as_dynamic; > > }; > > > > Other than that, the patch looks good. Although I still need to test it. > > I was wondering if you need the u8 and u16 members at all? > Can't the values just be treated as 32bit? > Both char and short aren't really 'proper' arithmetic types. Not sure what you mean by "arithmatic types". If you do something like: ~# echo 's:skb u16 protocol; u64 delta;' >> /sys/kernel/tracing/dynamic_events ~# echo 'hist:keys=skbaddr:ts=common_timestamp.usecs' >> /sys/kernel/tracing/events/net/netif_receive_skb/trigger ~# echo 'hist:keys=skbaddr:delta=common_timestamp.usecs-$ts:onmatch(net.netif_receive_skb).trace(skb,protocol,$delta)' >> /sys/kernel/tracing/events/skb/kfree_skb/trigger Where it records the protocol as u16, I'm guessing that if we didn't use this union, it might break on BIG_ENDIAN machines. For reference, the kfree_skb event looks like: system: skb name: kfree_skb ID: 1735 format: field:unsigned short common_type; offset:0; size:2; signed:0; field:unsigned char common_flags; offset:2; size:1; signed:0; field:unsigned char common_preempt_count; offset:3; size:1; signed:0; field:int common_pid; offset:4; size:4; signed:1; field:void * skbaddr; offset:8; size:8; signed:0; field:void * location; offset:16; size:8; signed:0; field:unsigned short protocol; offset:24; size:2; signed:0; field:enum skb_drop_reason reason; offset:28; size:4; signed:0; -- Steve