Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1253915pxa; Thu, 20 Aug 2020 06:51:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxOSPpljAe5UFgSLHM47rh7XLSgxCqxcAyuHszj/UTgODlIf1R8jxMGxEbG4uqxpkijeXPp X-Received: by 2002:a17:906:1f88:: with SMTP id t8mr3330702ejr.241.1597931507291; Thu, 20 Aug 2020 06:51:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597931507; cv=none; d=google.com; s=arc-20160816; b=EWMEwA6kyvgA4MorBNsiw8eP8DZaN+iFm9OclEIzcLFo4QDm13OEDTPm7Ig8+MegEL 52XKHMG6ZQU1JzZ4Nnx4u8WvxkgoR36zTxgD1OIs+kRE2ZgSSAyqQ03fnTMGjw/wigoD 0HIb1kY6olnGEdNocqNXHf6q5Om8PWMkSyfUZkGVGxMqPfpqlE4ItqonUnoXwZ850Ymz 7ByCcUbc+kpOjnCRQbVHqanmZRFri4hr4qjVkT9vSs3uBluuQon9ZFc1XO54QLLBMrMB vuV8wNpdI2Gq5vQWszAMkEnSSjzjZhWqKiqvC4OSoL2nX7XszBDd6uSBL+OpSdyGG3Lk kT9A== 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=5w8Ngg/s+0WSYrQ8UQxzYNUatgi+iJYDLQ26N/LLTUg=; b=BPMp30AMAe/xLTeQa9fE08dCKUWMig5kC2kht2qU/27y9cedONcEul31GFdX21SimW M7x19ao/A1v6l9ON5AuqCgJ4dgxOTSGzGe/16nfXiQAJ9SDBvlDkviRXQleKkuEoZHqN 20eLARCFfvm2Uelc23PMtKAGlVAzDjZXpr93gXOtstCQB1Be4i7ZMiDGtCBWO+neg903 3h6i61fyF580J7bCSjtNLKAoQ2q1qQOHa+Dqucqf2wJFdcgk+kbjyLp/aqvbByC94CAY KehL3uVjwttjkTnkjFjF6h1nRbZpXZ5mD1LtFchCGm/h8Ii6P5blG2ZuxAq3Qq9bxqG2 H1Ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Ivv8TNVG; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dk2si1372138edb.542.2020.08.20.06.51.23; Thu, 20 Aug 2020 06:51:47 -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; dkim=pass header.i=@kernel.org header.s=default header.b=Ivv8TNVG; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730689AbgHTNmm (ORCPT + 99 others); Thu, 20 Aug 2020 09:42:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:40126 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728082AbgHTJ3i (ORCPT ); Thu, 20 Aug 2020 05:29:38 -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 A67F922D00; Thu, 20 Aug 2020 09:29:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597915777; bh=m/pOPloSaYdwhN/rKdqLfvawP/Ad664Qe3L31mMTvLE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ivv8TNVGp0dtt16Y36a4MA/oWCzvGkUn4rmSIbF552kfR5HmgrvDuB3vsl7GNd5xD Uew0jfaV/0vD9Kf4i4XXoFTg6jDBCQknqh78FQFcy5Ttrwpk/QbrT5XlBMJO93W9QE 6leqUqL87SDAsGcDMKUFgmqiQVXRXbVaH12NRf0U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Namhyung Kim , "Steven Rostedt (VMware)" Subject: [PATCH 5.8 091/232] tracing: Use trace_sched_process_free() instead of exit() for pid tracing Date: Thu, 20 Aug 2020 11:19:02 +0200 Message-Id: <20200820091617.243792188@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200820091612.692383444@linuxfoundation.org> References: <20200820091612.692383444@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 From: Steven Rostedt (VMware) commit afcab636657421f7ebfa0783a91f90256bba0091 upstream. On exit, if a process is preempted after the trace_sched_process_exit() tracepoint but before the process is done exiting, then when it gets scheduled in, the function tracers will not filter it properly against the function tracing pid filters. That is because the function tracing pid filters hooks to the sched_process_exit() tracepoint to remove the exiting task's pid from the filter list. Because the filtering happens at the sched_switch tracepoint, when the exiting task schedules back in to finish up the exit, it will no longer be in the function pid filtering tables. This was noticeable in the notrace self tests on a preemptable kernel, as the tests would fail as it exits and preempted after being taken off the notrace filter table and on scheduling back in it would not be in the notrace list, and then the ending of the exit function would trace. The test detected this and would fail. Cc: stable@vger.kernel.org Cc: Namhyung Kim Fixes: 1e10486ffee0a ("ftrace: Add 'function-fork' trace option") Fixes: c37775d57830a ("tracing: Add infrastructure to allow set_event_pid to follow children" Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Greg Kroah-Hartman --- kernel/trace/ftrace.c | 4 ++-- kernel/trace/trace_events.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -6969,12 +6969,12 @@ void ftrace_pid_follow_fork(struct trace if (enable) { register_trace_sched_process_fork(ftrace_pid_follow_sched_process_fork, tr); - register_trace_sched_process_exit(ftrace_pid_follow_sched_process_exit, + register_trace_sched_process_free(ftrace_pid_follow_sched_process_exit, tr); } else { unregister_trace_sched_process_fork(ftrace_pid_follow_sched_process_fork, tr); - unregister_trace_sched_process_exit(ftrace_pid_follow_sched_process_exit, + unregister_trace_sched_process_free(ftrace_pid_follow_sched_process_exit, tr); } } --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -538,12 +538,12 @@ void trace_event_follow_fork(struct trac if (enable) { register_trace_prio_sched_process_fork(event_filter_pid_sched_process_fork, tr, INT_MIN); - register_trace_prio_sched_process_exit(event_filter_pid_sched_process_exit, + register_trace_prio_sched_process_free(event_filter_pid_sched_process_exit, tr, INT_MAX); } else { unregister_trace_sched_process_fork(event_filter_pid_sched_process_fork, tr); - unregister_trace_sched_process_exit(event_filter_pid_sched_process_exit, + unregister_trace_sched_process_free(event_filter_pid_sched_process_exit, tr); } }