Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp55309pxa; Wed, 26 Aug 2020 04:46:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxBERtEGltqqOlivLzLvipeMxO7qRr5c8ePgLLVrU/qMaNje+wDydIAarIBLsry5bpxCiiH X-Received: by 2002:a50:a2e6:: with SMTP id 93mr14009867edm.147.1598442416246; Wed, 26 Aug 2020 04:46:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598442416; cv=none; d=google.com; s=arc-20160816; b=jGQndHmWX4cicsmy7s57gDCILX8Stk61z873RUgjPDE7wktnxZTCR9CdUacJQ6+FY3 ukTA0MSYfeoYZ5lkWiRiATTtILWSbniPnP6U7CoZ/V90dutDoY4BUnVPFM/QqwhHWnYX vdKtbz5etyBmIdH0/l09rtDbM9Qn7+wP/p3XKBkoHyIO3hpMkkBNfDtk3nS1KY3KW59x 40r/0XOZbrnylmikxV4Jt2WoPcr/W+Frc6mIFTr9zuR59LfX5pO7G4xk59v2WERHjGp8 ZQKdK6pTEYy8x4fXTLz323vS82OzKdbmxk9OZPCKhONIKlu5sU6r66LaH7orapG/uPuS 6y6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=noOi/4eRnD90foQVcjB4EqwnSAlQ03ioYVr2LdFsp5c=; b=jYHUuH9udHOYhNF9dWKcb8lMDpAbTseBXr37q/oya7l0sljrf7FHhtevoTzEPfAKUQ G4YK9EoEgDiY/3FSx5N/hlNbdKPgysajBLkHF7bmZHOWZGoxsByP5Uy90xZ1k+/d6P9c BJcUcJbPecvWXpssuHnXCJ2DL5rh0Kj6XcUFWxevQB5K7OgsENMt79CrGqvbGJePd1tt ar946g0JzfI//qTgmR7h1nym0TqopxJA2bItZxPshmeUFEYi8qvp8rH3M7CeW6oshd6O xVcl8eBQMIzWcONjQ5Cpp874tEwYt4mRxfv5VXsbiyHvmqyU3WQw9MLfc7RDAlQaztA4 cKHQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b3si1236835edv.572.2020.08.26.04.46.32; Wed, 26 Aug 2020 04:46:56 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729049AbgHZLlR (ORCPT + 99 others); Wed, 26 Aug 2020 07:41:17 -0400 Received: from foss.arm.com ([217.140.110.172]:44634 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729011AbgHZLjV (ORCPT ); Wed, 26 Aug 2020 07:39:21 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E6FF51045; Wed, 26 Aug 2020 04:27:49 -0700 (PDT) Received: from C02TD0UTHF1T.local (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 919993F71F; Wed, 26 Aug 2020 04:27:48 -0700 (PDT) Date: Wed, 26 Aug 2020 12:27:45 +0100 From: Mark Rutland To: Al Grant Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, acme@redhat.com, Denis Nikitin Subject: Re: [PATCH] perf inject: correct event attribute sizes Message-ID: <20200826112745.GB43491@C02TD0UTHF1T.local> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 26, 2020 at 10:42:04AM +0100, Al Grant 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. > > From: Denis Nikitin > Signed-off-by: Al Grant Did Denis write this patch? If so, we need an S-o-B line from them. Mark. > 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 9cf4efdcbbbd..762eb94bd532 100644 > --- a/tools/perf/util/header.c > +++ b/tools/perf/util/header.c > @@ -3326,6 +3326,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); > + } > f_attr = (struct perf_file_attr){ > .attr = evsel->core.attr, > .ids = {