Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 18B70C54E94 for ; Wed, 25 Jan 2023 00:16:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234037AbjAYAQb (ORCPT ); Tue, 24 Jan 2023 19:16:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230015AbjAYAQ3 (ORCPT ); Tue, 24 Jan 2023 19:16:29 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C573349969 for ; Tue, 24 Jan 2023 16:16:27 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3BA5861301 for ; Wed, 25 Jan 2023 00:16:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 52D35C4339B; Wed, 25 Jan 2023 00:16:24 +0000 (UTC) Date: Tue, 24 Jan 2023 19:16:22 -0500 From: Steven Rostedt To: Wander Lairson Costa Cc: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , "Eric W. Biederman" , Stafford Horne , Guo Ren , Kefeng Wang , Oleg Nesterov , Andrew Morton , Thomas Gleixner , Sebastian Andrzej Siewior , Andy Lutomirski , "Liam R. Howlett" , Fenghua Yu , Andrei Vagin , linux-kernel@vger.kernel.org (open list) Subject: Re: [PATCH v2 3/4] sched/rt: use put_task_struct_atomic_safe() to avoid potential splat Message-ID: <20230124191622.6d0b8680@gandalf.local.home> In-Reply-To: <20230120150246.20797-4-wander@redhat.com> References: <20230120150246.20797-1-wander@redhat.com> <20230120150246.20797-4-wander@redhat.com> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 20 Jan 2023 12:02:41 -0300 Wander Lairson Costa wrote: > rto_push_irq_work_func() is called in hardirq context, and it calls > push_rt_task(), which calls put_task_struct(). > > If the kernel is compiled with PREEMPT_RT and put_task_struct() reaches > zero usage count, it triggers a splat because __put_task_struct() > indirectly acquires sleeping locks. > > The put_task_struct() call pairs with an earlier get_task_struct(), > which makes the probability of the usage count reaches zero pretty > low. In any case, let's play safe and use the atomic safe version. > > Signed-off-by: Wander Lairson Costa > Cc: Thomas Gleixner > --- > kernel/sched/rt.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > For what it's worth: Reviewed-by: Steven Rostedt (Google) -- Steve > diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c > index ed2a47e4ddae..30a4e9607bec 100644 > --- a/kernel/sched/rt.c > +++ b/kernel/sched/rt.c > @@ -2147,7 +2147,7 @@ static int push_rt_task(struct rq *rq, bool pull) > /* > * Something has shifted, try again. > */ > - put_task_struct(next_task); > + put_task_struct_atomic_safe(next_task); > next_task = task; > goto retry; > } > @@ -2160,7 +2160,7 @@ static int push_rt_task(struct rq *rq, bool pull) > > double_unlock_balance(rq, lowest_rq); > out: > - put_task_struct(next_task); > + put_task_struct_atomic_safe(next_task); > > return ret; > }