Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp884615yba; Thu, 18 Apr 2019 11:10:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqx4pm7KnC2YoeD+6gH6vr/0SpQocj7lGQCLVYootmCP57ZRS6x3yYAX5L9IfafHEXGBAkgE X-Received: by 2002:aa7:83d1:: with SMTP id j17mr98855043pfn.78.1555611047581; Thu, 18 Apr 2019 11:10:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555611047; cv=none; d=google.com; s=arc-20160816; b=jDS83Q7VriOpyJeeAE8N3gNOgVFE9bZx8PZnRj3OQ2dmsYAIDmy1aDoavXMgMK1lgt ezJ7760DfTHljmQ1BeJjWurGLWyFp6FTrInXpBleVSy45h6Lku49jtW035M+/3P8bFfs pHHuP7sHRr8ODjRk1wOU/wTbbD+8BOhruBtz0lHYn29Cgij+UukEw5hxzyOLo3A58Hag UaSJzXiD/FUJNUqizsheypxOP3bBv/Df3H6uPCZQC0fomkA5KfXR/YXOAEMN2itclQgr CuYy20Yd3ycGAnlExT8fvaseSslQw531Q3L5klUOnLwOmrQ14SupYu3iTFdmPdSX3WMT nF8A== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=1Owwc8Z+OIfEzphFDhExnZ0KmmZxB2QoA7Gt6X5QQTQ=; b=O779/9lORxZ89xW4RDXX1FD9VsP5sVYQJV1YKk5xVzE7Dp/IO0T4HcEiU72OsZg0dh qLGeKTTn1StUlT844hYDK8oEkA2vLC6RPzGrr4H3QGcS51Xn7Zdo3hu7x62eDw8ve/nJ 1VEmiVOtoWVL2AsoTSYlG3mUfsOsu+iC3j2HF6oCVdWRFcZnHhzMZspSLtD7SQ0HbyjW agLCyPQms/YkeSB4mJZw31Q/N//rUuJHpuWPl8OKtTgtBwv2rKDYx/pTDTswmTY+GKHu erKpAVCIO4JKLL28B2bgnIowcRfHj2+UXcFTKDjTV31ULB9kZqK0tylM+bi+gwrXEDmL gtMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=blMK9Xhk; 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 bc4si2651641plb.246.2019.04.18.11.10.33; Thu, 18 Apr 2019 11:10:47 -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; dkim=pass header.i=@kernel.org header.s=default header.b=blMK9Xhk; 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 S2391341AbfDRSHp (ORCPT + 99 others); Thu, 18 Apr 2019 14:07:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:38612 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390038AbfDRSHm (ORCPT ); Thu, 18 Apr 2019 14:07:42 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D356E218AF; Thu, 18 Apr 2019 18:07:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555610862; bh=0igPpzF5r32wZa+fH18mJRNNbdIctC8+SFq8MpPX1ng=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=blMK9XhkOkuhVgfR2E9shnir54d4Zt/zqbwCjN9nfdKGesJheo6p8mQ//JIoZz0tF URw0lIqXEBNF4raqz7cOGaI+FEAUr14mWjx6ulANk9Mvlx4MMSyXi1dIy5O/6qJTac hB+ZHT6iBmfpk2iNTHOcm6ZggYSh1Ie3eZDikLbg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stephane Eranian , "Peter Zijlstra (Intel)" , Andi Kleen , Jiri Olsa , Kan Liang , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 4.9 02/50] perf/core: Restore mmap record type correctly Date: Thu, 18 Apr 2019 19:57:13 +0200 Message-Id: <20190418160422.995613775@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190418160422.455656724@linuxfoundation.org> References: <20190418160422.455656724@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit d9c1bb2f6a2157b38e8eb63af437cb22701d31ee ] 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 Signed-off-by: Sasha Levin --- kernel/events/core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/events/core.c b/kernel/events/core.c index 5cbb2eda80b5..7929526e96e2 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -6616,6 +6616,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)) @@ -6659,6 +6660,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.19.1