Received: by 2002:ac0:8845:0:0:0:0:0 with SMTP id g63csp359841img; Thu, 28 Feb 2019 00:15:14 -0800 (PST) X-Google-Smtp-Source: AHgI3IYgqMxUcFq02xcjS4mRRwAsfJ0SvT4fVqCeJeXbN10FRxh9a6Uo/EcFeWH0fnD3IVgJ8c8m X-Received: by 2002:a63:31c8:: with SMTP id x191mr6700412pgx.99.1551341714562; Thu, 28 Feb 2019 00:15:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551341714; cv=none; d=google.com; s=arc-20160816; b=IOPU1ihU7NZwi2AUYFKe0agvXRN/K/yYtnNKP+UnCWA1Bt2LAY1npQn95nC7v9lb5+ JobSYmkkfOgNZpa2s1DSvsbyWnNavxIodrJg2Q3XSToWdeisMz5uOZn+s+CVlS7+p9S2 0Wpw0FAmjz/EhQcNLCLa1FccQACv26nb8bdZeeVr+QlceGB7+kFHjLdeb3wsLVxyKUus pMgxyYsNQNacLgkPzAsiIkzMnRQ7YN1hiYFqHchWuiW+UzRRaJjEgqtGGPzJuS9vLIfM EPyHNhICPb4kLRbuWTJfv0tDU6TI88qpqj9Ov1SUW4TcRu/dMI6oKkzCpPjFb9xBd9PU wQ1A== 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=UXhHmIJjdDxBQHPZrwSlaEfg9cl6vr+8KzVvVo8vGWI=; b=p8bhjsWoBUrc3yC5raJgt54KD+7GHAs5b/o7woyTw9Fe004ku7QYoV0ArfabZYr4CF Mg52Y1CrLk3zLuTCLZVI948ToQQgI6TiGu3Lgt9rsZwod/cGNJQq7K+UtSHQX4+t0Qqm KqEMpEmheo+Gux1cGzvhcAswVOjDG/5k6Si8A++S5GYSQzmA4ie51gG1vtIj0Cfw1CrT NTA3X9w68zOwhdBKkDCtGKOflvwlrWjdPVVZYwRN8ajyQJrOGrihoc037mzmmzSTXKhW PufGtL23tFqY6O7zs+oMiHgUfsndLsZHjTw0B8L/oU0oYUTE7AYSpHT6OAJvaJvTvLsz G9xw== 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 r8si16525650plo.118.2019.02.28.00.14.58; Thu, 28 Feb 2019 00:15:14 -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; 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 S1731069AbfB1H6v (ORCPT + 99 others); Thu, 28 Feb 2019 02:58:51 -0500 Received: from terminus.zytor.com ([198.137.202.136]:37597 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730399AbfB1H6u (ORCPT ); Thu, 28 Feb 2019 02:58:50 -0500 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id x1S7vbDW2952079 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 27 Feb 2019 23:57:37 -0800 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id x1S7vaRB2952076; Wed, 27 Feb 2019 23:57:36 -0800 Date: Wed, 27 Feb 2019 23:57:36 -0800 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Alexander Shishkin Message-ID: Cc: mingo@kernel.org, jolsa@redhat.com, alexander.shishkin@linux.intel.com, peterz@infradead.org, malharthi9@gatech.edu, mathieu.poirier@linaro.org, acme@redhat.com, linux-kernel@vger.kernel.org, tglx@linutronix.de, hpa@zytor.com Reply-To: linux-kernel@vger.kernel.org, hpa@zytor.com, tglx@linutronix.de, mingo@kernel.org, alexander.shishkin@linux.intel.com, jolsa@redhat.com, acme@redhat.com, mathieu.poirier@linaro.org, malharthi9@gatech.edu, peterz@infradead.org In-Reply-To: <20190215115655.63469-2-alexander.shishkin@linux.intel.com> References: <20190215115655.63469-2-alexander.shishkin@linux.intel.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf: Copy parent's address filter offsets on clone Git-Commit-ID: 18736eef12137c59f60cc9f56dc5bea05c92e0eb 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: 18736eef12137c59f60cc9f56dc5bea05c92e0eb Gitweb: https://git.kernel.org/tip/18736eef12137c59f60cc9f56dc5bea05c92e0eb Author: Alexander Shishkin AuthorDate: Fri, 15 Feb 2019 13:56:54 +0200 Committer: Arnaldo Carvalho de Melo CommitDate: Fri, 22 Feb 2019 16:52:07 -0300 perf: Copy parent's address filter offsets on clone When a child event is allocated in the inherit_event() path, the VMA based filter offsets are not copied from the parent, even though the address space mapping of the new task remains the same, which leads to no trace for the new task until exec. Reported-by: Mansour Alharthi Signed-off-by: Alexander Shishkin Tested-by: Mathieu Poirier Acked-by: Peter Zijlstra Cc: Jiri Olsa Fixes: 375637bc5249 ("perf/core: Introduce address range filtering") Link: http://lkml.kernel.org/r/20190215115655.63469-2-alexander.shishkin@linux.intel.com Signed-off-by: Arnaldo Carvalho de Melo --- kernel/events/core.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/kernel/events/core.c b/kernel/events/core.c index 5aeb4c74fb99..2d89efc0a3e0 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -1255,6 +1255,7 @@ static void put_ctx(struct perf_event_context *ctx) * perf_event_context::lock * perf_event::mmap_mutex * mmap_sem + * perf_addr_filters_head::lock * * cpu_hotplug_lock * pmus_lock @@ -10312,6 +10313,20 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu, goto err_per_task; } + /* + * Clone the parent's vma offsets: they are valid until exec() + * even if the mm is not shared with the parent. + */ + if (event->parent) { + struct perf_addr_filters_head *ifh = perf_event_addr_filters(event); + + raw_spin_lock_irq(&ifh->lock); + memcpy(event->addr_filters_offs, + event->parent->addr_filters_offs, + pmu->nr_addr_filters * sizeof(unsigned long)); + raw_spin_unlock_irq(&ifh->lock); + } + /* force hw sync on the address filters */ event->addr_filters_gen = 1; }