From nobody Mon Nov 25 17:46:44 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D81F51D967F for ; Fri, 25 Oct 2024 10:18:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729851539; cv=none; b=q+8XjppZeNh3jhUcexaF0VcWN/xrW89amELQwWcIBUZ7LxjGr+5fQ+h/3zyaO5iBbX4gIQJT505K55MT9L/vuKm55t3HEdfaqZI0tnvKYO19Xet7rqbmKGbozxJi4sv2abZuT2UgcZytN6VvFsNYYpHmUTp+NbWltt08BJgKPZI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729851539; c=relaxed/simple; bh=rLeO8mNI41AATF8hlKv+eh5i2L/e3kjoAfalXsBhtcY=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=LNpUoOZ0H8C4gQ6XOjsGhwHhjfNlmGqmgnjs8rySDxbt3P51pMqYjONLM8OqCPTrLnG7A0M6BVWItSpefNcKuK2P0MI5aBNMkD5wbPmRZseJxSqJWN87GtwvtnBEqjaJCG3TO8jAQceLfSUqx9eKVSoauyWdZaHXw1dtyH5nqmc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 97E78C4AF09; Fri, 25 Oct 2024 10:18:59 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.98) (envelope-from ) id 1t4HPx-00000004rfV-2kfd; Fri, 25 Oct 2024 06:19:41 -0400 Message-ID: <20241025101941.516467026@goodmis.org> User-Agent: quilt/0.68 Date: Fri, 25 Oct 2024 06:19:11 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , kernel test robot , Dan Carpenter , Li Huafei Subject: [for-linus][PATCH 1/2] fgraph: Fix missing unlock in register_ftrace_graph() References: <20241025101910.054222333@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Li Huafei Use guard(mutex)() to acquire and automatically release ftrace_lock, fixing the issue of not unlocking when calling cpuhp_setup_state() fails. Fixes smatch warning: kernel/trace/fgraph.c:1317 register_ftrace_graph() warn: inconsistent retur= ns '&ftrace_lock'. Link: https://lore.kernel.org/20241024155917.1019580-1-lihuafei1@huawei.com Fixes: 2c02f7375e65 ("fgraph: Use CPU hotplug mechanism to initialize idle = shadow stacks") Reported-by: kernel test robot Reported-by: Dan Carpenter Closes: https://lore.kernel.org/r/202410220121.wxg0olfd-lkp@intel.com/ Suggested-by: Steven Rostedt Signed-off-by: Li Huafei Acked-by: Masami Hiramatsu (Google) Signed-off-by: Steven Rostedt (Google) --- kernel/trace/fgraph.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/kernel/trace/fgraph.c b/kernel/trace/fgraph.c index 41e7a15dcb50..cd1c2946018c 100644 --- a/kernel/trace/fgraph.c +++ b/kernel/trace/fgraph.c @@ -1252,7 +1252,7 @@ int register_ftrace_graph(struct fgraph_ops *gops) int ret =3D 0; int i =3D -1; =20 - mutex_lock(&ftrace_lock); + guard(mutex)(&ftrace_lock); =20 if (!fgraph_initialized) { ret =3D cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "fgraph_idle_init", @@ -1273,10 +1273,8 @@ int register_ftrace_graph(struct fgraph_ops *gops) } =20 i =3D fgraph_lru_alloc_index(); - if (i < 0 || WARN_ON_ONCE(fgraph_array[i] !=3D &fgraph_stub)) { - ret =3D -ENOSPC; - goto out; - } + if (i < 0 || WARN_ON_ONCE(fgraph_array[i] !=3D &fgraph_stub)) + return -ENOSPC; gops->idx =3D i; =20 ftrace_graph_active++; @@ -1313,8 +1311,6 @@ int register_ftrace_graph(struct fgraph_ops *gops) gops->saved_func =3D NULL; fgraph_lru_release_index(i); } -out: - mutex_unlock(&ftrace_lock); return ret; } =20 --=20 2.45.2 From nobody Mon Nov 25 17:46:44 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D813E1D8DF8 for ; Fri, 25 Oct 2024 10:18:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729851539; cv=none; b=PSKst+wWMRn8NLSEM5lhdX+xpD1FHLidxird6wNkn6jQtG3cqlzUpgtscsMbFbMgl90H/8fhYj7uhwdX5ZdpJW2oSUvrbFpsbs8SDUX2kDiIcvmwo0G0f+cNK6yt8M6uIDOVG9FSFI4HAhlXLIvNyqF5s10K2UfJ4Q0SjFUoh5Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729851539; c=relaxed/simple; bh=d3uJcPwMcfeTjJjRl96boF6hbfwnXQhKDRY8RJd7uvs=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=KwvQSQYNtuftJNbnJyN2FZnkMqtuY3nISR/4G60+Z4rmevDz/36Ehfhs+GrpIOp1m/TR9oOd91XjcsTRxWmxIg1PRag/kS9Voencpw2VoQYjYulDVpNh627GwwjQHdrUtlmG/Y/BSIp3RffyDsAaA4BbqPgyNxh+OQRahi2eXuw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 97CF6C4CEC3; Fri, 25 Oct 2024 10:18:59 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.98) (envelope-from ) id 1t4HPx-00000004rfz-3NzE; Fri, 25 Oct 2024 06:19:41 -0400 Message-ID: <20241025101941.675760393@goodmis.org> User-Agent: quilt/0.68 Date: Fri, 25 Oct 2024 06:19:12 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Thomas Gleixner Subject: [for-linus][PATCH 2/2] fgraph: Change the name of cpuhp state to "fgraph:online" References: <20241025101910.054222333@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Steven Rostedt The cpuhp state name given to cpuhp_setup_state() is "fgraph_idle_init" which doesn't really conform to the names that are used for cpu hotplug setups. Instead rename it to "fgraph:online" to be in line with other states. Cc: Mark Rutland Cc: Mathieu Desnoyers Cc: Thomas Gleixner Link: https://lore.kernel.org/20241024222944.473d88c5@rorschach.local.home Suggested-by: Masami Hiramatsu Fixes: 2c02f7375e658 ("fgraph: Use CPU hotplug mechanism to initialize idle= shadow stacks") Signed-off-by: Steven Rostedt (Google) --- kernel/trace/fgraph.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/trace/fgraph.c b/kernel/trace/fgraph.c index cd1c2946018c..69e226a48daa 100644 --- a/kernel/trace/fgraph.c +++ b/kernel/trace/fgraph.c @@ -1255,7 +1255,7 @@ int register_ftrace_graph(struct fgraph_ops *gops) guard(mutex)(&ftrace_lock); =20 if (!fgraph_initialized) { - ret =3D cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "fgraph_idle_init", + ret =3D cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "fgraph:online", fgraph_cpu_init, NULL); if (ret < 0) { pr_warn("fgraph: Error to init cpu hotplug support\n"); --=20 2.45.2