Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935426AbcKWUMI (ORCPT ); Wed, 23 Nov 2016 15:12:08 -0500 Received: from merlin.infradead.org ([205.233.59.134]:43594 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933325AbcKWUMH (ORCPT ); Wed, 23 Nov 2016 15:12:07 -0500 Date: Wed, 23 Nov 2016 21:11:05 +0100 From: Peter Zijlstra To: kan.liang@intel.com Cc: mingo@redhat.com, acme@kernel.org, linux-kernel@vger.kernel.org, alexander.shishkin@linux.intel.com, tglx@linutronix.de, namhyung@kernel.org, jolsa@kernel.org, adrian.hunter@intel.com, wangnan0@huawei.com, mark.rutland@arm.com, andi@firstfloor.org Subject: Re: [PATCH 01/14] perf/x86: Introduce PERF_RECORD_OVERHEAD Message-ID: <20161123201105.GA3092@twins.programming.kicks-ass.net> References: <1479894292-16277-1-git-send-email-kan.liang@intel.com> <1479894292-16277-2-git-send-email-kan.liang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1479894292-16277-2-git-send-email-kan.liang@intel.com> User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1212 Lines: 49 On Wed, Nov 23, 2016 at 04:44:39AM -0500, kan.liang@intel.com wrote: > +struct perf_overhead_entry { > + __u32 cpu; > + __u64 nr; > + __u64 time; > +}; > +void perf_log_overhead(struct perf_event *event, u32 type, > + struct perf_overhead_entry *entry) > +{ > + struct perf_output_handle handle; > + struct perf_sample_data sample; > + int ret; > + > + struct { > + struct perf_event_header header; > + u32 type; There's two u32 sized holes here. > + struct perf_overhead_entry overhead; > + } overhead_event = { > + .header = { > + .type = PERF_RECORD_OVERHEAD, > + .misc = 0, > + .size = sizeof(overhead_event), > + }, .type = type, .overhead = *event, > + }; > + overhead_event.type = type; > + memcpy(&overhead_event.overhead, entry, sizeof(overhead_event.overhead)); Do the above named initialization instead. > + > + perf_event_header__init_id(&overhead_event.header, &sample, event); > + ret = perf_output_begin(&handle, event, overhead_event.header.size); > + > + if (ret) > + return; > + > + perf_output_put(&handle, overhead_event); > + perf_event__output_id_sample(event, &handle, &sample); > + > + perf_output_end(&handle); > + memset(entry, 0, sizeof(*entry)); > +}