Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp5242319imb; Thu, 7 Mar 2019 10:53:27 -0800 (PST) X-Google-Smtp-Source: APXvYqx2vzfrfoLQrADh1XpdF8Emuo2wBEJpGixc/53I5q/RfEYR2VmOyhehRgbfrFRVBLd6T3dU X-Received: by 2002:a62:138f:: with SMTP id 15mr14133923pft.219.1551984807723; Thu, 07 Mar 2019 10:53:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551984807; cv=none; d=google.com; s=arc-20160816; b=S/qM+yYqoruQmcMY4UsRTGKt+CWnwa2IdCBNYS+hVcOGAKVWicDIsoIwRJiBCtkeNH uKezdETKtSfXIgHGLn3LK8H+HlGveGw+IbTO0OvUhWqYksj59BgHrHzswC9XWH6nD1xw QGMCzGaqooZFATFnmUVnkIjaQ1E7dUgVxNQguswQYdQABLHpFbDFlfe1FtGZtAoiYTPe B8Lqybzw6AAwPJLjHKzNwzgBYrut29lgBx6hYcZVx6oep8IXLYTBR7+gj8DciSAzd1Wf QMQmpMmplK9taQ3ILWpdresspWfTCMuqWYVeYPhytPBYDqZXmE3CVdsIpa7WaYx5lqJI 7mMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:mime-version :message-id:date:dkim-signature; bh=vxPeICI1aFDlIKifVVs2OjTt1LL43ELKNS7JmYkNUFY=; b=pRoR+5JFZ5q3GV+Al0zKD/99fUBpQMSHVroAjMrPIRAS5WWI05AXav3Sy3nTcrotbT 0JvKIwrmKbUnr8dh9V0N6x7V7s7LBxIVWAa97V06yBYnj1mnHXrEE7YTMY4Yd5dWUlga Mhxxx5BKJ4JqUhJsFARwryzWBJJIyxqMwfAjEZqZfwlOF79rf/rMCVkp49xylMwlgQcy p+T+7C4W8upw1y2WsJzch/Ec6qWOMPlQlzmu5YgvQ/HbLTOEFfmeYr25qQyErd8Bdwyp JqNOzfLgZJRWYDopvvzzs6ERl/16Bdi4Z/ikmQz/AbfF3Wa0vxHScsGvTBBSlIML8UeK SWpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=cXprvTwn; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p186si4826516pfp.85.2019.03.07.10.53.11; Thu, 07 Mar 2019 10:53:27 -0800 (PST) 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; dkim=pass header.i=@google.com header.s=20161025 header.b=cXprvTwn; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726409AbfCGSwj (ORCPT + 99 others); Thu, 7 Mar 2019 13:52:39 -0500 Received: from mail-yw1-f73.google.com ([209.85.161.73]:52146 "EHLO mail-yw1-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726161AbfCGSwj (ORCPT ); Thu, 7 Mar 2019 13:52:39 -0500 Received: by mail-yw1-f73.google.com with SMTP id l11so24196974ywl.18 for ; Thu, 07 Mar 2019 10:52:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=vxPeICI1aFDlIKifVVs2OjTt1LL43ELKNS7JmYkNUFY=; b=cXprvTwnqq4q9FrocbFlL/yIf5EMxSO95QDCpJ3+LX+RkEz1ZqO2GPNonZFw0q+2VF KqMevdtZNqUDLVkweAJYG4H+KaUXqbLqGxnA3DVEbgR1ckQL29tc9xGBaWB49cupiJQQ Qs5bE5+h+NHZbyjj/bG6aquhKzwGJYiPPcq8ZiXkcJvJHUdHhZkV5Et2zzkWqVAFPoHM 8OoTChaUt1Qr6oiWnzmGNvUxDyRS1XK2ZY0CKg3EO6bSw1EX5nokGWYr+mrBUxDabUJ2 TPj4uMXb7no0cRrq6m2H22L8v1PSlPeGfBE0asCCitDCEe6Tx6MFM9VsHXOl2d4OaMCA pU9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=vxPeICI1aFDlIKifVVs2OjTt1LL43ELKNS7JmYkNUFY=; b=M5d2l4/3QKEjco3HHLakWQ4fJJhc9cmXeoE57JMffqFe60yKDNkY25AMWNhCIpxM4n mc6JCVcrzbkHnDGT5ff+oe7RjlL86v9CzPJJJh1LQ3aNO4/tbX0Qu86+Zq3TRYC3tuGu ox9QWvy5cmurFH1wYObRGji44pQDt+eztZGcd/v/NOOiAJGx29jNA5ptG97YVkzdOZCR h81VVdQoOwOt+RSB6cEt/18IJHLKnK9uMOLrm3IpmUCtSXi2in3XH+XdWmFtAwDqR3RB Btn4GnBHkAFSy9eDsC6LBRGJx/+Wb2Kc875ebQH7Oc4yEzPYBb+OFM5VSbK4Y1KJq2V2 1Oiw== X-Gm-Message-State: APjAAAXivWtvIKDPGM3WyzHiOTiLGJeN9zniRHvR4f/6hX4pnF26pYU/ io2I31MM0LUOna2M7j88l5pDa/kl9fadgByT2g+LsYOKvvcFitJy7ZuduItZrLJLN+TEsikWUEJ JOezuWquj18UgYzb9cSpOwnJC5/brZFoxJYw0zNtSz23X1X7GWG6MVsSgqm2sdQSDJBC1Rq6C X-Received: by 2002:a25:248b:: with SMTP id k133mr5362637ybk.79.1551984758025; Thu, 07 Mar 2019 10:52:38 -0800 (PST) Date: Thu, 7 Mar 2019 10:52:33 -0800 Message-Id: <20190307185233.225521-1-eranian@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.21.0.360.g471c308f928-goog Subject: [PATCH] perf/core: restore mmap record type correctly From: Stephane Eranian To: linux-kernel@vger.kernel.org Cc: ak@linux.intel.com, kan.liang@intel.com, peterz@infradead.org, mingo@elte.hu, acme@redhat.com, jolsa@redhat.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On mmap(), perf_events generates a RECORD_MMAP record and then checks which events are interested in this record. There are currently 2 versions of mmap records: RECORD_MMAP and RECORD_MMAP2. MMAP2 is larger. The event configuration controls which version the user level tool accepts. If the event->attr.mmap2=1 field then MMAP2 record is returned. The perf_event_mmap_output() takes care of this. It checks attr->mmap2 and corrects the record fields before putting it in the sampling buffer of the event. At the end the function restores the modified MMAP record fields. The problem is that the function restores the size but not the type. Thus, if a subsequent event only accepts MMAP type, then it would instead receive an MMAP2 record with a size of MMAP record. This patch fixes the problem by restoring the record type on exit. Signed-off-by: Stephane Eranian --- kernel/events/core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/events/core.c b/kernel/events/core.c index 5f59d848171e..f170cd12beed 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -7188,6 +7188,7 @@ static void perf_event_mmap_output(struct perf_event *event, struct perf_output_handle handle; struct perf_sample_data sample; int size = mmap_event->event_id.header.size; + u32 type = mmap_event->event_id.header.type; int ret; if (!perf_event_mmap_match(event, data)) @@ -7231,6 +7232,7 @@ static void perf_event_mmap_output(struct perf_event *event, perf_output_end(&handle); out: mmap_event->event_id.header.size = size; + mmap_event->event_id.header.type = type; } static void perf_event_mmap_event(struct perf_mmap_event *mmap_event) -- 2.21.0.360.g471c308f928-goog