Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp1067391img; Fri, 22 Mar 2019 15:00:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqyocfA2fAknHw5DLm6yHHZDdF0dGkrO2WMFa1HEutl7VRx0WsFeJz9e63+Ox+DNyP++8Cju X-Received: by 2002:a63:2a8f:: with SMTP id q137mr11041867pgq.31.1553292055274; Fri, 22 Mar 2019 15:00:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553292055; cv=none; d=google.com; s=arc-20160816; b=ffRM51xLuyAt0+YcpmhKsomwao5WdyvDXTLL6uGNhAVAG2HlRoe1VSfKZg0LNCZvQc 5hLX3EU7ZvWW3sf5r8Vs808MI8qYLf9Sc+4Z6DyGMx0OfHTZr4O+CJKJxnfmZgtGuHo/ BPhJR0w4bkaJeOI8LyB9XX1XZcrZlLi3GmuuSjwr3+Nt1KecYg7wdKgnA8qjq0VFvOm7 ZGrowOMIbIz1uGy/b2JbKmz8H92CPm7BnGXxeYSx9pI5d+KrTGPyDyKKfUnMAOAsscOO mwzFvW4m5HKX52iZuQDY+sEYevNfzwOucL7riILMVXXLwH9ERB6ZsyerjmQimNeA/2Ta R46A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date; bh=+0k/zzNBqd/iP3+967D5MVA1swyQwG581CYvtURvKLQ=; b=V2FRfsSkHd2wsnko/7tDpTAIEN5YGptJfuHbfAKuhzAmhi5L8GZh25Vm0dXk6/6low rH0cgm/c3ffbuPUd+hd+DgPJwhkNcwigdUX3n/bt8szjMOuwB5woa31sIZRcmRV2plIE Cj6yqiZLEz10qc3hmfl/nw3PIqym+p7FAyjflr8+PyEVikFqL2rDMt4sUlIecrtGOYLo qLrjhSQYt1m6O3P54JByVbZLYVmdSdfjgQzHfqZo5AA510LMKPfZkP/bhFQIo7dnyj4H WMpuru4Y5bx2pWMekPH6vRO7zz1GsQWGkqYL9946RDOSnXu06Ovmqo+WrWGpsl1vfhor OKuw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a21si7345877pgw.395.2019.03.22.15.00.39; Fri, 22 Mar 2019 15:00:55 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727823AbfCVV7w (ORCPT + 99 others); Fri, 22 Mar 2019 17:59:52 -0400 Received: from terminus.zytor.com ([198.137.202.136]:46011 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727440AbfCVV7v (ORCPT ); Fri, 22 Mar 2019 17:59:51 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id x2MLwItI744765 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Fri, 22 Mar 2019 14:58:18 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id x2MLwHbT744762; Fri, 22 Mar 2019 14:58:17 -0700 Date: Fri, 22 Mar 2019 14:58:17 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Stephane Eranian Message-ID: Cc: eranian@google.com, tglx@linutronix.de, linux-kernel@vger.kernel.org, ak@linux.intel.com, kan.liang@linux.intel.com, mingo@kernel.org, hpa@zytor.com, acme@redhat.com, peterz@infradead.org, jolsa@redhat.com Reply-To: kan.liang@linux.intel.com, acme@redhat.com, mingo@kernel.org, hpa@zytor.com, peterz@infradead.org, jolsa@redhat.com, eranian@google.com, linux-kernel@vger.kernel.org, ak@linux.intel.com, tglx@linutronix.de In-Reply-To: <20190307185233.225521-1-eranian@google.com> References: <20190307185233.225521-1-eranian@google.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/urgent] perf/core: Restore mmap record type correctly Git-Commit-ID: d9c1bb2f6a2157b38e8eb63af437cb22701d31ee X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, T_DATE_IN_FUTURE_96_Q autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: d9c1bb2f6a2157b38e8eb63af437cb22701d31ee Gitweb: https://git.kernel.org/tip/d9c1bb2f6a2157b38e8eb63af437cb22701d31ee Author: Stephane Eranian AuthorDate: Thu, 7 Mar 2019 10:52:33 -0800 Committer: Arnaldo Carvalho de Melo CommitDate: Mon, 11 Mar 2019 11:56:02 -0300 perf/core: Restore mmap record type correctly 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 Acked-by: Peter Zijlstra (Intel) Cc: Andi Kleen Cc: Jiri Olsa Cc: Kan Liang Fixes: 13d7a2410fa6 ("perf: Add attr->mmap2 attribute to an event") Link: http://lkml.kernel.org/r/20190307185233.225521-1-eranian@google.com Signed-off-by: Arnaldo Carvalho de Melo --- kernel/events/core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/events/core.c b/kernel/events/core.c index 6fb27b564730..514b8e014a2d 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -7189,6 +7189,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)) @@ -7232,6 +7233,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)