Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp5121286rwb; Mon, 31 Jul 2023 19:04:05 -0700 (PDT) X-Google-Smtp-Source: APBJJlHiQG+HvO4/Z5/laLDexvP0hZG4McWvGeMR0XRwHUbxWXsorosQup4SGefZ8jJtwRPQ8gFP X-Received: by 2002:a05:6870:f14f:b0:1be:dab4:308b with SMTP id l15-20020a056870f14f00b001bedab4308bmr5824433oac.55.1690855445153; Mon, 31 Jul 2023 19:04:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690855445; cv=none; d=google.com; s=arc-20160816; b=rcoL+pEOXWGoD69rBs8LIPKj8a9hFotKRk19P4oerJx1dePnd5e936Bfw9N8ZK9iWg FMOs8JxblCyVIqkiOtOfGOh9vd07e1n4+Nc2B/spQLSeEB8aRjIO1oHLkA6rOavLiuo2 745EGjaCfPqradXvrCosQHkDXWVFlds48Ztw9UE5iqT0pxHhHUZmvVIDI2qgZc6FW4OH vvRovd2yWHKisbW08JN82iceda8st7yelgWQNWJ00WTGdGQ13+iMdbvgO5AMi3L/fbr0 DVb5dy/wNNyzaQmLjyrhQi+mg4ILKpDgiQwpShKOIn7GvG0mW4Cl7Hpd5/57GoUfhcpa 8BNQ== 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=kTN64aQK1aLiDWyd71+xyKuSM4NGn6Hr4yVjOFLrX4Y=; fh=RPaymWcWdpuCqECJSI3zyIgg6cBA5CRNntumQh+rM18=; b=07q/YdHzh7lkCApMATCSheQGeXnRBu6FqToDAHVqCCZtITIUVtUAsPOZfEgwlOq+Dc 3iQwXhIiaGS9zMbYgTE1/wqHgNJWluyk1YtdCGf7QWV8boGeE8p7+dqbj749ywd0OERx S65uQL1wyvAWJezf5fyn3bpCLIY2Mp5e2koPhl/XAs5Or0IVQLIkLGZ3rpaAe96sl2+R KWKlgYvrLmJNSQjpdlCcaTF4ojFJDemPPvt68dEtXMBzM6lc8Q8jQoTiwXTuvGfugUGY W1KPmKeNZMWXR+J+68HbPP0CdK2lzic2N0+FjpsQFhlRlThBepn6bQdSgbzit/wruZrE 5DLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=BuEGdnqV; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q24-20020a637518000000b005644f022c68si2368896pgc.159.2023.07.31.19.03.52; Mon, 31 Jul 2023 19:04:05 -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=@gmail.com header.s=20221208 header.b=BuEGdnqV; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231838AbjHABgO (ORCPT + 99 others); Mon, 31 Jul 2023 21:36:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229585AbjHABgM (ORCPT ); Mon, 31 Jul 2023 21:36:12 -0400 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78970114; Mon, 31 Jul 2023 18:36:11 -0700 (PDT) Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-4fe21e7f3d1so5528197e87.3; Mon, 31 Jul 2023 18:36:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690853770; x=1691458570; 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=kTN64aQK1aLiDWyd71+xyKuSM4NGn6Hr4yVjOFLrX4Y=; b=BuEGdnqVDsbrkk14K1tG6Ztj9Mi2l4o012+wxn8qUuWF0/XG7f/mKSUanj8c8KVPPf 6c5p6ZdK9XObNVdd0SjD0+yQJir6m0pDPmYWZBLefbuHr2UjoHWhVzZGPrETjphG4xOc 3NPHCL24vfW4MvA2R/fv2Z3/htkPcP/8fPYgPpKpkbLqaA08n0kZ5OpTGzMw0zIrdE/E Yf6ZFuBvkTfRedDlshcL5co95VoGSev45ZEKi2Um0w7rMnxFRbaoSdZTYsZmtyYVS0gC t5iHTKAthad36u9khz/tzFXDvBov+NEi6rfAEEOzqMSfg1rQu7GcnLm4G+Eo53jcTRSX 224w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690853770; x=1691458570; 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=kTN64aQK1aLiDWyd71+xyKuSM4NGn6Hr4yVjOFLrX4Y=; b=NPU1y/oAyQxcN/331Wni/S02qgx6pUf+9ziAzTf34tyZrNAuBUCq7qxXUZYrNfmOTn Z+XA+dYSFejPszspq0+wA3GkYzmjYF1y6skZfMLjbLAnxFMaFAqVVX1iWoZZYZw7FHTv HOJR49nnlpppra/okM7RY9BusiaqEFraQd5ouvhkWfwAeH4fTxzMhMnbfmM2gqwVg2of aFprrLb7zhduJP6nXRiK29ruFc9FyJ5kJ8wR5DmCfKZKXBfGA1xiRoyVWE1yw06Ehxfs p6YEW5whC1It43cwDfz3D59kZWsKBKbByWyersqvM7V6YE0IyEm2RwkQ0c8SYsS4BbNG HWCA== X-Gm-Message-State: ABy/qLbkYzeKEuWg4754aUKpho4dtjPGpIzQqGZOm/ey+y9Onvn+a/kZ a/VW6oTUx06NIZv26gcbfmB5Rt206vqC0xsBN3E= X-Received: by 2002:ac2:4d97:0:b0:4f9:5404:af5 with SMTP id g23-20020ac24d97000000b004f954040af5mr991330lfe.46.1690853769397; Mon, 31 Jul 2023 18:36:09 -0700 (PDT) MIME-Version: 1.0 References: <20230726121618.19198-1-zegao@tencent.com> <20230726121618.19198-2-zegao@tencent.com> <20230731113807.1a4a455c@gandalf.local.home> In-Reply-To: <20230731113807.1a4a455c@gandalf.local.home> From: Ze Gao Date: Tue, 1 Aug 2023 09:35:58 +0800 Message-ID: Subject: Re: [RFC PATCH v2 1/3] sched, tracing: add to report task state in symbolic chars To: Steven Rostedt Cc: Peter Zijlstra , Namhyung Kim , Adrian Hunter , Alexander Shishkin , Arnaldo Carvalho de Melo , Ian Rogers , Ingo Molnar , Jiri Olsa , Mark Rutland , Masami Hiramatsu , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-trace-devel@vger.kernel.org, Ze Gao Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 Thanks Steven, Indeed this did not consider the struct alignment. I left the field order i= ntact because I was not sure whether the order here matters for reporting or pars= ing. Now I will fix this and send a v3, and again thanks for pointing it out. Thanks, Ze On Mon, Jul 31, 2023 at 11:38=E2=80=AFPM Steven Rostedt wrote: > > On Wed, 26 Jul 2023 20:16:16 +0800 > Ze Gao wrote: > > > @@ -231,41 +253,29 @@ TRACE_EVENT(sched_switch, > > TP_STRUCT__entry( > > __array( char, prev_comm, TASK_COMM_LEN ) > > __field( pid_t, prev_pid ) > > - __field( int, prev_prio ) > > - __field( long, prev_state ) > > + __field( short, prev_prio ) > > + __field( int, prev_state ) > > + __field( char, prev_state_char ) > > __array( char, next_comm, TASK_COMM_LEN ) > > __field( pid_t, next_pid ) > > - __field( int, next_prio ) > > + __field( short, next_prio ) > > ), > > The above adds a bunch of holes. This needs to be reordered to condense t= he > event, we don't want to increase it. libtraceevent will handle reordering= . > > The above produces: > > struct { > char prev_comm[16]; > pid_t prev_pid; > short prev_prio; <-- 2 character padding > int prev_state; > char prev_state_char; > char next_comm[16]; <- 3 character padding > pid_t next_pid; > short next_prio; <- 2 char padding > }; > > (all events are at least 4 byte aligned, and are multiple of 4 bytes in > size, thus that last short of next_prio did nothing) > > The above is a total of 56 bytes (note, that is the same as the current > sched_switch event size); > > What the above should be: > > TP_STRUCT__entry( > __field( pid_t, prev_pid ) > __field( pid_t, next_pid ) > __field( short, prev_prio ) > __field( short, next_prio ) > __field( int, prev_state ) > __array( char, prev_comm, TASK_COMM_LEN ) > __array( char, next_comm, TASK_COMM_LEN ) > __field( char, prev_state_char ) > ), > > > Which would be: > > struct { > pid_t prev_pid; > pid_t next_pid; > short prev_prio; > short next_prio; > int prev_state; > char prev_comm[16]; > char next_comm[16]; > char prev_stat_char; <-- 3 characters of padding > } > > which would be 52 byte. Saving us 4 bytes per event. Which is a big deal! > > -- Steve >