From patchwork Wed Jun 14 22:27:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 105600 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp512193qgd; Wed, 14 Jun 2017 15:28:09 -0700 (PDT) X-Received: by 10.84.231.134 with SMTP id g6mr2504417plk.86.1497479288963; Wed, 14 Jun 2017 15:28:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497479288; cv=none; d=google.com; s=arc-20160816; b=MgIAhzgEAccsItGJ0ugA0jQcQtZ6poGGXOl440ai0pF8+sWANlo9aMNjDGsWHmbwr0 xIAaYd1MCJBeHAM8uU7viNtLo6CmQfzgustBgq5Svmf/QHOFl6VvkF5wRVCx89dw/f77 JNOvs9KHRMxPB2E3TDnt5a1/lN7Ebws0K2LR50t59Y03vzQ3AEmgsdHFMBDwVbq97gIy CsU06+xKg524iettoU8rA49XcOIG7fRFTEpyPGzEXfq7znez/61Br7rujyE+f0mOeeSf FEPSajG+cdfimuOCuqvqRBruhpS6y+L5U8e4j3zV3RwFR6CCqp3ngZT6tW9LAtAzJeax 1vxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=pviJS4FN39ENaGUiIetOSwNB2DA9OOiwvpKC1MNjcbw=; b=yvIGqb57vKq9ZCrYVnBEnd42FnGcmjRKRUmRZk5l0aN9bTAu3ZV5AvFf6cCcCBsDl5 +tZG5X61s1TY6/HcG/7YZrQ0oiZGr9aGwDauzEyu4WZFCGTyIVByprBpgkc/2cOOc3QA wa5oBhjeQDsAmHI7AdqMKJcJPryWkisrYcrErMHXzA3ewSSlP+lDzLojxQXkR3pLGJkJ Nil+/OHKo4la0PzbqVIxP4+ddQjaR0osmehY4HdA3/TmxegHQ8GRQ9mh8u0hGjpeoStn LLK6kltgufrvSPrvIsOuQ8EI3CUOfRBQT5C+x5Tc3o9ZYDYNJRtc2wSxDH41hQ1tSdq1 l8+w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q63si844114pfk.166.2017.06.14.15.28.08; Wed, 14 Jun 2017 15:28:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752831AbdFNW14 (ORCPT + 25 others); Wed, 14 Jun 2017 18:27:56 -0400 Received: from foss.arm.com ([217.140.101.70]:39702 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752771AbdFNW1m (ORCPT ); Wed, 14 Jun 2017 18:27:42 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B09681993; Wed, 14 Jun 2017 15:27:36 -0700 (PDT) Received: from beelzebub.ast.arm.com (beelzebub.austin.arm.com [10.118.12.119]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 284823F3E1; Wed, 14 Jun 2017 15:27:36 -0700 (PDT) From: Jeremy Linton To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, rostedt@goodmis.org, mingo@redhat.com, rusty@rustcorp.com.au, jeyu@redhat.com, kirill.shutemov@linux.intel.com, christoffer.dall@linaro.org, marc.zyngier@arm.com, jcm@jonmasters.org, clemens@ladisch.de, perex@perex.cz Subject: [PATCH v2 10/13] tracing: Update sample file to describe the new macro Date: Wed, 14 Jun 2017 17:27:26 -0500 Message-Id: <20170614222729.16521-11-jeremy.linton@arm.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170614222729.16521-1-jeremy.linton@arm.com> References: <20170614222729.16521-1-jeremy.linton@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a blurb in the trace sample file to describe the macro used to add sizeof to value conversions. Signed-off-by: Jeremy Linton --- samples/trace_events/trace-events-sample.h | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) -- 2.9.4 diff --git a/samples/trace_events/trace-events-sample.h b/samples/trace_events/trace-events-sample.h index 76a75ab..a7431d4 100644 --- a/samples/trace_events/trace-events-sample.h +++ b/samples/trace_events/trace-events-sample.h @@ -225,26 +225,36 @@ TRACE_DEFINE_ENUM(TRACE_SAMPLE_FOO); TRACE_DEFINE_ENUM(TRACE_SAMPLE_BAR); TRACE_DEFINE_ENUM(TRACE_SAMPLE_ZOO); +/* + * The same problem as above applies to sizeof(), so there is also + * a macro to solve that problem. In the case show below foo_bar/format + * contains a string "__print_array(...,sizeof(phys_addr_t))" for which + * the sizeof() result varies depending on the kernel. Adding the following + * macro decodes the size before transferring it to userspace. + */ + +TRACE_DEFINE_SIZEOF(phys_addr_t); + TRACE_EVENT(foo_bar, - TP_PROTO(const char *foo, int bar, const int *lst, + TP_PROTO(const char *foo, int bar, const phys_addr_t *lst, const char *string, const struct cpumask *mask), TP_ARGS(foo, bar, lst, string, mask), TP_STRUCT__entry( - __array( char, foo, 10 ) - __field( int, bar ) - __dynamic_array(int, list, __length_of(lst)) - __string( str, string ) - __bitmask( cpus, num_possible_cpus() ) + __array( char, foo, 10 ) + __field( int, bar ) + __dynamic_array(phys_addr_t, list, __length_of(lst) ) + __string( str, string ) + __bitmask( cpus, num_possible_cpus() ) ), TP_fast_assign( strlcpy(__entry->foo, foo, 10); __entry->bar = bar; memcpy(__get_dynamic_array(list), lst, - __length_of(lst) * sizeof(int)); + __length_of(lst) * sizeof(phys_addr_t)); __assign_str(str, string); __assign_bitmask(cpus, cpumask_bits(mask), num_possible_cpus()); ), @@ -291,8 +301,8 @@ TRACE_EVENT(foo_bar, * This prints out the array that is defined by __array in a nice format. */ __print_array(__get_dynamic_array(list), - __get_dynamic_array_len(list) / sizeof(int), - sizeof(int)), + __get_dynamic_array_len(list) / sizeof(phys_addr_t), + sizeof(phys_addr_t)), __get_str(str), __get_bitmask(cpus)) );