Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2259391pxb; Thu, 11 Feb 2021 08:07:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJyektVOFisAEWTV7iE9ZHYbxw4t17WU/GhNmHQPNl2MZEs/scWMjCmrZPC/CtKNZa+FGl9m X-Received: by 2002:a17:906:503:: with SMTP id j3mr9152882eja.172.1613059653416; Thu, 11 Feb 2021 08:07:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613059653; cv=none; d=google.com; s=arc-20160816; b=Ta01eC6ySTA6MWKPAxqLp8gcDs7doi3UtByZ8kxG/jtj9zaBY4zhk48qI7crULkP9N 7E9eyo9PmbwAhRsPzSL1/4/AXkBge33mwQqZ/QVtiHzo/7ZInu97DZx67a+fKMLcTORF nMnErWpPYkVy9HxzEss+IzCr8my0ndgemNij1BMhPIktjKMy8ChWVJW9Hn/f+TXjwv4C kNxmav51GLznsypW6gKpmjFYXYMmPcPOKaWHjd4vL4Xvc+/+VTwdU3B9HBQuc4f+wqPs qLSw2Fl1tgnyMl2SRdG6tHVBwb1G2uQINPf9Mn+DK/dZ2/FztFgilZwryiUoJoNoHid5 wvKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=gKAjhCwiBoAlUxUk30lGvl/BTPOds4MRiNq31eKTan4=; b=ZuYZr6+eoakqGWDtHIlk3TrcuHl6QmU8BucrWf9f85OUqgWxxcyohHLCW4M/nY9gZw jhaZF4wAff9U6x/TbQNfi/DtLSQjhoV6U96nbSsQTXF6UqDUuTdHTMonbq84dKH1t5ft gAL9r4gHeWz/9OsHrW+/d2QXQcZpAXx5K1r1W5CfR2Yiuw8ErdEWi4qn08N1VWV/AZ14 Inkr6yGKSw8e8B8d6MAkfc2JKHKrsjg7UMyXsbhLHPBitEaBKDkxndy0yB9LQERK/Y4y yP3mOjq9DDbWC5azcBmFvVVg4lk6R5fwnFO5l278GAhyRC19s+WlFZg8s0J/FmXmEall FH0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=aEoOwA44; 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=pass (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 k7si3869379ejb.442.2021.02.11.08.07.07; Thu, 11 Feb 2021 08:07:33 -0800 (PST) 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=@linuxfoundation.org header.s=korg header.b=aEoOwA44; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230295AbhBKQEz (ORCPT + 99 others); Thu, 11 Feb 2021 11:04:55 -0500 Received: from mail.kernel.org ([198.145.29.99]:52628 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229623AbhBKPUq (ORCPT ); Thu, 11 Feb 2021 10:20:46 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7700664F30; Thu, 11 Feb 2021 15:07:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1613056026; bh=2/71MJlEV2yQgVTkYl4oNdU3wbyu25jp7ArwNz2UvEM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aEoOwA44XDpU7O90qL12mSQH0yAweH9PGKjXFOJKXmHOJX7bcpspG3f97ndY628YD Ugn42HHItKu/Pn00nwzu3ZhmFfN+W54gbqDPxzPTc5d7VvptilexmwY5slA1dszXB4 wUdtuH9Ud3T4d1JAWuAUB7Z7LZ+lMw0ooSDr303o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, pierre.gondois@arm.com, "Steven Rostedt (VMware)" Subject: [PATCH 4.19 03/24] fgraph: Initialize tracing_graph_pause at task creation Date: Thu, 11 Feb 2021 16:02:37 +0100 Message-Id: <20210211150147.902688534@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210211150147.743660073@linuxfoundation.org> References: <20210211150147.743660073@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Steven Rostedt (VMware) commit 7e0a9220467dbcfdc5bc62825724f3e52e50ab31 upstream. On some archs, the idle task can call into cpu_suspend(). The cpu_suspend() will disable or pause function graph tracing, as there's some paths in bringing down the CPU that can have issues with its return address being modified. The task_struct structure has a "tracing_graph_pause" atomic counter, that when set to something other than zero, the function graph tracer will not modify the return address. The problem is that the tracing_graph_pause counter is initialized when the function graph tracer is enabled. This can corrupt the counter for the idle task if it is suspended in these architectures. CPU 1 CPU 2 ----- ----- do_idle() cpu_suspend() pause_graph_tracing() task_struct->tracing_graph_pause++ (0 -> 1) start_graph_tracing() for_each_online_cpu(cpu) { ftrace_graph_init_idle_task(cpu) task-struct->tracing_graph_pause = 0 (1 -> 0) unpause_graph_tracing() task_struct->tracing_graph_pause-- (0 -> -1) The above should have gone from 1 to zero, and enabled function graph tracing again. But instead, it is set to -1, which keeps it disabled. There's no reason that the field tracing_graph_pause on the task_struct can not be initialized at boot up. Cc: stable@vger.kernel.org Fixes: 380c4b1411ccd ("tracing/function-graph-tracer: append the tracing_graph_flag") Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=211339 Reported-by: pierre.gondois@arm.com Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Greg Kroah-Hartman --- init/init_task.c | 3 ++- kernel/trace/ftrace.c | 2 -- 2 files changed, 2 insertions(+), 3 deletions(-) --- a/init/init_task.c +++ b/init/init_task.c @@ -168,7 +168,8 @@ struct task_struct init_task .lockdep_recursion = 0, #endif #ifdef CONFIG_FUNCTION_GRAPH_TRACER - .ret_stack = NULL, + .ret_stack = NULL, + .tracing_graph_pause = ATOMIC_INIT(0), #endif #if defined(CONFIG_TRACING) && defined(CONFIG_PREEMPT) .trace_recursion = 0, --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -6875,7 +6875,6 @@ static int alloc_retstack_tasklist(struc } if (t->ret_stack == NULL) { - atomic_set(&t->tracing_graph_pause, 0); atomic_set(&t->trace_overrun, 0); t->curr_ret_stack = -1; t->curr_ret_depth = -1; @@ -7088,7 +7087,6 @@ static DEFINE_PER_CPU(struct ftrace_ret_ static void graph_init_task(struct task_struct *t, struct ftrace_ret_stack *ret_stack) { - atomic_set(&t->tracing_graph_pause, 0); atomic_set(&t->trace_overrun, 0); t->ftrace_timestamp = 0; /* make curr_ret_stack visible before we add the ret_stack */