Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp242994pxb; Fri, 15 Jan 2021 11:51:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJzBAyEt9gwCZkZNQFcvTyx9koThsq9n851r6SI5Uyd60S+xx3tEwCcNMocOsHVJaNpjAAtK X-Received: by 2002:aa7:c88a:: with SMTP id p10mr9155568eds.204.1610740271064; Fri, 15 Jan 2021 11:51:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610740271; cv=none; d=google.com; s=arc-20160816; b=TMJLAFPpHWU+PcHfpmtfqu/gWoS2wXsmBoEK0qDCGYXO/WMYMAtVHgntu9kHZrNRJv CUAPSyoH/JizPkcSb2LzlSPWnljf27H2wh3xkK/blvpgwTB9pbdV1mdtbGVVTu4XRThl JEe4/Jk8gVain/nPhnoE/HPotcbKzNOSFhOfrmDzILYVTHZ/MeunQJZ/1N8EBZzU0bwF odk+e9oU7QkyusEuR0lclJkMIYR+B6ZqfHir/3NAyDw9d6Y0Xm8Au/O2/HUAGtMh5BMs UEcQkMo0KdM3uDMmzDIlIcPzPKVa8rD5sBu28OaNbHeIHJ792m6AOGiMHWyXXNg05Zyi oMOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=IIq7AZ7R/QMAAwVy6P899bIENqfYWVDCnClGldN5wxQ=; b=hmJn+YL3Qkh5N0dWyiuwdWOaEt998b8w9zC5LY8fhSzFp5uHNlcVn8sDcJeCqIk4zE psbEmFdYkVX8HQEQFwYpvfF/xVaN/LwYU6vdxfvfD/MmgQMM+X+tXGkG6igE8RM0C5hT 715QLhYMY+8CE3PEvY20MAOCToBoNIzjwCJTW7TLzcX/vE/wi5g1pSlrDqFLjD/MKf+Q ++gukKRo32HGIKbNZrEZ2+FilRHpkArcwHOofrtVUNd1urTO2hF0R6GPxmY6WgPp8aj5 Kz4sNM2bX/5/z1/tVynw5w+wekYrkzWecXXOjlNwgc7YmENPANW6ZedPEnDfcdzZbOQu EWJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lMyKbvIt; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id le10si1944067ejb.104.2021.01.15.11.50.46; Fri, 15 Jan 2021 11:51:11 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=lMyKbvIt; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388126AbhAOTsk (ORCPT + 99 others); Fri, 15 Jan 2021 14:48:40 -0500 Received: from mail.kernel.org ([198.145.29.99]:39592 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388013AbhAOTse (ORCPT ); Fri, 15 Jan 2021 14:48:34 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7780A235F8; Fri, 15 Jan 2021 19:47:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1610740073; bh=kqOX2A6clD03b+iOOz6xMw7OmOeGpcJteFQPhqT9lQE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=lMyKbvItthsILbBBWKw0oYrZpM/KH51mosprqBA/ZTujmQj85Mhwz7lWwlfWhV6zF nDb97DRlUGpsm6NlAMgg6lAExsL164P18GyGJFsJPma5jPLYpIryxxX4xGBWEQAJJJ E8fJ+T53DSuR3tyA+NM+RQxPOHMdXdOBfzt+wp7HSvDvsdofsHsn45xfjsa3c/A2k3 psF8Yz20GBOT/mwiPZePAwfhs2oxujQpu/L8J66Fcc0Nfj1wb4KzbJTS9h7MPXyhoU hnyray3pz011CjJDOZUozIqfssA4hdVr9m2TT5cR/tL4NZ9VbDStgztl5Tmcl1vVeg cwg07X7yPmL2A== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 7E05D40522; Fri, 15 Jan 2021 16:48:25 -0300 (-03) Date: Fri, 15 Jan 2021 16:48:25 -0300 From: Arnaldo Carvalho de Melo To: Jiri Olsa Cc: Denis Nikitin , linux-perf-users@vger.kernel.org, peterz@infradead.org, mingo@redhat.com, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, namhyung@kernel.org, al.grant@arm.com, al.grant@foss.arm.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH] perf inject: correct event attribute sizes Message-ID: <20210115194825.GL457607@kernel.org> References: <20201124195818.30603-1-al.grant@arm.com> <20201216065816.1840893-1-denik@chromium.org> <20201223221105.GA236568@krava> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201223221105.GA236568@krava> X-Url: http://acmel.wordpress.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Wed, Dec 23, 2020 at 11:11:05PM +0100, Jiri Olsa escreveu: > On Tue, Dec 15, 2020 at 10:58:16PM -0800, Denis Nikitin wrote: > > When perf inject reads a perf.data file from an older version of perf, > > it writes event attributes into the output with the original size field, > > but lays them out as if they had the size currently used. Readers see > > a corrupt file. Update the size field to match the layout. > > > > Signed-off-by: Al Grant > > Signed-off-by: Denis Nikitin > > --- > > tools/perf/util/header.c | 8 ++++++++ > > 1 file changed, 8 insertions(+) > > > > diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c > > index be850e9f8852..0d95981df8dd 100644 > > --- a/tools/perf/util/header.c > > +++ b/tools/perf/util/header.c > > @@ -3331,6 +3331,14 @@ int perf_session__write_header(struct perf_session *session, > > attr_offset = lseek(ff.fd, 0, SEEK_CUR); > > > > evlist__for_each_entry(evlist, evsel) { > > + if (evsel->core.attr.size < sizeof(evsel->core.attr)) { > > + /* > > + * We are likely in "perf inject" and have read > > + * from an older file. Update attr size so that > > + * reader gets the right offset to the ids. > > + */ > > + evsel->core.attr.size = sizeof(evsel->core.attr); > > + } > > seems ok, just wondering if it would be better > to fix it in perf_event__process_attr instead > > where we know where the data is coming from, > here we could cover for some unexpected case > of having different attr.size? > > anyway both would be probably equal, I'm ok > with either way > > Acked-by: Jiri Olsa Thanks, applied. - Arnaldo