Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp789379pxk; Wed, 23 Sep 2020 16:44:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzIxGY+Kf3f1INBdJoUbcyvmvMX9dBg4kmCvCMcljaJITuCTYwp8cf+ZgtpEcFbxR85VSqV X-Received: by 2002:a50:fb15:: with SMTP id d21mr1914270edq.150.1600904679446; Wed, 23 Sep 2020 16:44:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600904679; cv=none; d=google.com; s=arc-20160816; b=GT5yWFjc1KZrubov/AHtIDX0IWvAAb9TNC4KBFAJUt2rBwOj5NPI9L+N3OM6qAsLDg zKZRHghBbmRK6q0aqI/fSe615VToQoHtRMA4YzWU35gKO0vdGDJ/iy4S3axCjbdgJ188 Qgy3Use9USn11nE25mblvSTW4SaI6Q8/5BXi26G17SYhXcBr7epnUXNcMaORjKYrVKQE 7he2nRdDFvPud0H6pEIN2rtGTGgUVRGp8EVvOS0acTrpG/DGJHaA7h6Xb2JZNKBztYjm Tm/hBQLMrZPoIpNA4qbbTw8PP4OWL3t4bKPj+ZyCF7KbdeKv/+zmtCXGk5+lvlwtDuGN 4jYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=gTCQ6FmbtqXr2lWYi2SA92VBSqB0+yg7rI8urwU4EPQ=; b=Cs0fws2JrNbD0oR0IhMFpfx0IYKpqb8sjxT6hAwUe4MefSyB50+3OGXGyumhaTltR6 GzP647p94G4AHABP/UI9i41t9dfIyeZiepkgTIzUXcK9x6MpNyPxDBHssp4nHoWXXlrC TpBZQxWzOq8qjoZHMY4dMTgHNJe5SqfAgtKcxi1HxxqVL6i9dymtEdZrtLm7FTag34Bl y+Sdjy5ATCc2taB8gtd7HYMVWnSAi6Kwpd1DqJkNg5BJNulYCoKrllOtxTUE09CFBNsR hV+B8ny2HqOeDfZ94TqAfVJ78dkS2aprz3DFKYODuE+FfIefMh11FT1vQv8LSywo2K2D Wdlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=GIuAB5Gf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d10si928340edv.145.2020.09.23.16.44.15; Wed, 23 Sep 2020 16:44:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=GIuAB5Gf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1726562AbgIWXnN (ORCPT + 99 others); Wed, 23 Sep 2020 19:43:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726265AbgIWXnM (ORCPT ); Wed, 23 Sep 2020 19:43:12 -0400 Received: from mail-ej1-x644.google.com (mail-ej1-x644.google.com [IPv6:2a00:1450:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C8E2C0613CE; Wed, 23 Sep 2020 16:43:12 -0700 (PDT) Received: by mail-ej1-x644.google.com with SMTP id nw23so1961656ejb.4; Wed, 23 Sep 2020 16:43:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=gTCQ6FmbtqXr2lWYi2SA92VBSqB0+yg7rI8urwU4EPQ=; b=GIuAB5Gf+EQXOBC+oUffPLM/u/Ny+yaZHgdkRxzMUIYycsGcIRBgEz6S6H32yT5SG/ 3y0daOEPOh0ZdPkEYg+qpA5IJ2AzUPaMl2kJabgSid7hPCi04pb/fTIa/RNHyjOX8N/B zTPujNrL3fYTeJ6Pyl+J3PpyDRWs0J7r/wPG2NwARq4hHV1D8S6QcSzc19at3t04ubZe ZysCzDVzvPMbFSwHZ6kUFDVzWVkNRjzPxe72i8xDynUG2OL4fqS2gXCkrU4uUPy5x03z YOranh+9jwvCWccxq354q/SJiFub/8j3DwYgLXFA2FbAKFW/Un9VA6O6LMYR45pgDDZE u7Qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=gTCQ6FmbtqXr2lWYi2SA92VBSqB0+yg7rI8urwU4EPQ=; b=bU0NChSPDeOQL/yQY4NLu4/kDVF94vM6Y+1eghb8HQjZ2bYoDXIt9GUt6Frdygb0/J XXp2DXVXCRKdzc95brtxYynafv/KxiAUn5/dunv/nm2Ov4qCghEym+VBASeGZbOQyK2w 1RSdCnqz0XwcRNl/VXo3+WnNPpV5kU1gTqOgKYPcBDUMZtavmeeEacZjyWXPdKRFQoDe NZIT2L9hPNUrmVF6nSK6wXG8fgh44mf7/1WMUPuXoFLsk0fk6l4OZ3xcoYv4rtgzYmbJ iEJ/PTdxYaoqOMAmKJ6wPq173dFyx4hnlYuUmLK5202UWy60UEc57CeC8/a8EET/kZ+x yA7A== X-Gm-Message-State: AOAM532dM78A8kLuHeACvXyuldUUHGPQ9Mm3P4jSyV6ohQIrd6MZjSaF d++hKjoLyO5Eo5Ou7poa71E= X-Received: by 2002:a17:906:7fcc:: with SMTP id r12mr2022196ejs.360.1600904590831; Wed, 23 Sep 2020 16:43:10 -0700 (PDT) Received: from [192.168.2.202] (pd9e5a9df.dip0.t-ipconnect.de. [217.229.169.223]) by smtp.gmail.com with ESMTPSA id e25sm999772edj.43.2020.09.23.16.43.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 23 Sep 2020 16:43:10 -0700 (PDT) Subject: Re: [RFC PATCH 4/9] surface_aggregator: Add trace points To: Steven Rostedt Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, Arnd Bergmann , Greg Kroah-Hartman , Rob Herring , Jiri Slaby , =?UTF-8?Q?Bla=c5=be_Hrastnik?= , Dorian Stoll References: <20200923151511.3842150-1-luzmaximilian@gmail.com> <20200923151511.3842150-5-luzmaximilian@gmail.com> <20200923160757.51e773a0@oasis.local.home> From: Maximilian Luz Message-ID: Date: Thu, 24 Sep 2020 01:43:08 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20200923160757.51e773a0@oasis.local.home> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/23/20 10:07 PM, Steven Rostedt wrote: > On Wed, 23 Sep 2020 17:15:06 +0200 > Maximilian Luz wrote: > >> Add trace points to the Surface Aggregator subsystem core. These trace >> points can be used to track packets, requests, and allocations. They are >> further intended for debugging and testing/validation, specifically in >> combination with the error injection capabilities introduced in the >> subsequent commit. > > I'm impressed! This uses some of the advanced features of the tracing > infrastructure. But I still have some comments to make about the layout > of the TP_STRUCT__entry() fields. Thanks! [...] >> +DECLARE_EVENT_CLASS(ssam_packet_class, >> + TP_PROTO(const struct ssh_packet *packet), >> + >> + TP_ARGS(packet), >> + >> + TP_STRUCT__entry( >> + __array(char, uid, SSAM_PTR_UID_LEN) >> + __field(u8, priority) >> + __field(u16, length) >> + __field(unsigned long, state) >> + __field(u16, seq) > > > Order matters above to keep the events as compact as possible. The more > compact they are, the more events you can store without loss. > > Now with SSAM_PTR_UID_LEN = 9, the above is (on a 64 bit system); > > 9 bytes; > 1 byte; > 2 bytes; > 8 bytes; > 2 bytes; > > The ftrace ring buffer is 4 byte aligned. As words and long words are > also 4 byte aligned, there's not much different to change. But it is > possible that the compiler might add 4 byte padding between the long > word "length" and "priority". Note, these are not packed structures. > > Testing this out with the following code: > > $ cat << EOF > test.c > struct test { > unsigned char array[9]; > unsigned char priority; > unsigned short length; > unsigned long state; > unsigned short seq; > }; > > static struct test x; > > void receive_x(struct test *p) > { > p = &x; > } > EOF > > $ gcc -g -c -o test.o test.c > $ pahole test.o > struct test { > unsigned char array[9]; /* 0 9 */ > unsigned char priority; /* 9 1 */ > short unsigned int length; /* 10 2 */ > > /* XXX 4 bytes hole, try to pack */ > > long unsigned int state; /* 16 8 */ > short unsigned int seq; /* 24 2 */ > > /* size: 32, cachelines: 1, members: 5 */ > /* sum members: 22, holes: 1, sum holes: 4 */ > /* padding: 6 */ > /* last cacheline: 32 bytes */ > }; > > You do see a hole between length and state. Now if we were to move this > around a little. > > $ cat < test2.c > struct test { > unsigned long state; > unsigned char array[9]; > unsigned char priority; > unsigned short length; > unsigned short seq; > }; > > static struct test x; > > void receive_x(struct test *p) > { > p = &x; > } > EOF > > $ gcc -g -c -o test2 test2.c > $ pahole test2.o > struct test { > long unsigned int state; /* 0 8 */ > unsigned char array[9]; /* 8 9 */ > unsigned char priority; /* 17 1 */ > short unsigned int length; /* 18 2 */ > short unsigned int seq; /* 20 2 */ > > /* size: 24, cachelines: 1, members: 5 */ > /* padding: 2 */ > /* last cacheline: 24 bytes */ > }; > > > We get a more compact structure with: > > TP_STRUCT__entry( > __field(unsigned long, state) > __array(char, uid, SSAM_PTR_UID_LEN) > __field(u8, priority) > __field(u16, length) > __field(u16, seq) > ), > > > Note, you can find pahole here: > > https://git.kernel.org/pub/scm/devel/pahole/pahole.git > > >> + ), Thank you for that detailed write-up! As you have clearly noticed, I have not really looked at the struct layouts. I will fix this for v2, include your changes, and have a look at pahole. [...] Thanks, Max