Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp119859pxa; Wed, 26 Aug 2020 06:26:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvPDb5Drn5m+5IyBc0k56kDBlxB9RFtWal+fkEUDnYgrL7oNIfJLIwSkSHgWOqWUv1UsRQ X-Received: by 2002:a05:6402:1545:: with SMTP id p5mr14381668edx.388.1598448360390; Wed, 26 Aug 2020 06:26:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598448360; cv=none; d=google.com; s=arc-20160816; b=p2MC+TfosB6Z74PKcILnxGCd/xZC45SaGHarGOu9V5ev5GgnsR5N37TBEM+0O+U7QW YHQuH8SIM18uhZzmBdGqbIwKS9zH7/LM4gagz7unO0MVhpoVBe2oRQ45HhGHI01X+TBW 3Nm26Ig8jccdKoi2axsxwYc5blviAo2Z+P5qy18Wb7qP1XewxcHYYSUDjsc57vxie5Rt 06rpKsCW2/6Yl8RDhbqw5jSWEpJ/4WCDt6OVHUNKBgory9N7UHcMKDgJksWd9yC8Iz9T Hyj8pvVbAIQ0r/ujiDwd8Us5o+6exzIf4g1vp+usBIoJE/K6352f3JnawpKpG4NwfHo5 DN7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=Q3E19r02aKCkLCOrZp7VFaV4C3hsQlQqXoFzlfhJ+lQ=; b=QR5xO3x0zXYn35GTuJ5fRsg0tVb5uScGXFLSGfRHci1gHp9Ci7DMf8B1/SHnDzc1ui FhWcIoILlWYxCh6kQOKFVp28AOKpdQDjAfUKY3rcHxBIrVK1dyRqTWMOASBobMCqO95T W8rXxT79Yzz0hGcpAuNcNMAXwA73ixSjZ9in7gOiAHu54ayIT+adtUY+0n75RhK/sQ7f 7j6Y+Yb682b3DswKlNPAfD9V7UA1XROp9fMigqNweU7Wf4XvhDs26h2/MJ7ExQKc52as E1iINsDd/8nu4ghAuSXEvU768SAv7YLE+gMJxc9By0auTzd0RjKFsVRyCtwg7Fk2L6Lz sCFQ== 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 n16si1501934ejj.284.2020.08.26.06.25.36; Wed, 26 Aug 2020 06:26:00 -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 S1730214AbgHZNYD (ORCPT + 99 others); Wed, 26 Aug 2020 09:24:03 -0400 Received: from foss.arm.com ([217.140.110.172]:46302 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728132AbgHZNYB (ORCPT ); Wed, 26 Aug 2020 09:24:01 -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 1BE35101E; Wed, 26 Aug 2020 06:24:01 -0700 (PDT) Received: from [10.57.5.66] (unknown [10.57.5.66]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 1E74D3F68F; Wed, 26 Aug 2020 06:23:59 -0700 (PDT) Subject: Re: [PATCH] perf inject: correct event attribute sizes To: Mark Rutland Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, acme@redhat.com, Denis Nikitin References: <20200826112745.GB43491@C02TD0UTHF1T.local> From: Al Grant Message-ID: <9a48bd74-42ad-4498-7f38-aed560031c4e@foss.arm.com> Date: Wed, 26 Aug 2020 14:23:59 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.0.1 MIME-Version: 1.0 In-Reply-To: <20200826112745.GB43491@C02TD0UTHF1T.local> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 26/08/2020 12:27, Mark Rutland wrote: > 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? Joint work - I fixed the sizes in the event attributes section, but Denis noticed that the copies in HEADER_EVENT_DESC also need fixing, so the final text is his. > If so, we need an S-o-B line from them. I have his approval to upstream this, so: Signed-off-by: Denis Nikitin Al > > 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 = {