Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp2830174rwb; Fri, 20 Jan 2023 07:55:13 -0800 (PST) X-Google-Smtp-Source: AMrXdXsP34et5uxkyjoVj0to/cBI/gd1zdBairWXsQ4GBHrqi3xcgtJXgLZ+qYAU6rgNJtbTehwB X-Received: by 2002:aa7:c917:0:b0:483:5e56:7bc5 with SMTP id b23-20020aa7c917000000b004835e567bc5mr14874504edt.40.1674230113140; Fri, 20 Jan 2023 07:55:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674230113; cv=none; d=google.com; s=arc-20160816; b=lsmRWKe49pnKXuR3TG+QCRBbGWDakpY/rOuZrKoDnQ8swtTlGy4BnVtjDE998ZgPpN QXi2ukfqNP3SIYtr8Yq0vjXTViJe4c9n0Pq7JES6Dv9xRCjTHRpIyOcZ+Y2G7XQXw6hp LIM9cPTRVVmaJwn0RlTweDoIrk+GARiB2+M89oruaX3svh7BaYyXYLf4T4WivRlchlSl OjcFkW4Iz1hvZ3FZ9gFlfNRfxLhexMBIShpi514Qe18nKaMNhZuPrIWUDNq0W++tADBC h4Clr6cOrpe3Y4yRykv8z3QHzH32NEKO0M3CBgWsVTMFPGIStiCoeae29jwiizjW0o6A ZtgA== 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 :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=6iRsFgdyFm9aCh9hJwwja26lzouAKLjx2fwTp+CTHC4=; b=doBIysoVfqoY68Sx6N8UNeeXjzSX9C/fMfqdJKZHjjN/bbQnb5g5nos0MeGCaX4VE6 UFxusQXaR51r0eCHdAAz9lmXTABHMMYnPuYlnsbIVcHDUxrGAZ7x1qj74CgLb4ZDMOB8 8FoscgIvGdiKuZnFyc23kmNVx8MSttqpR7MlMgLCEWjDw5XxNwhdQRt6D3kAPfYEmpYM 4KxWi0j0JisFf2Ppyd/3kpLPRNADcbw0s1UqgALS19qMqEXuhtrnUhbm+M9TIj3uclsv /mx7b/2dPRNHC0XtRh1j0qKyk7CRR50xyYdgoIVvBridgrshK8UCm+qYAo/72Oj+cC5e ASIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NeBGpfJu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ey6-20020a0564022a0600b0049e34ecef51si12927970edb.517.2023.01.20.07.55.00; Fri, 20 Jan 2023 07:55:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NeBGpfJu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231278AbjATPE2 (ORCPT + 49 others); Fri, 20 Jan 2023 10:04:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230024AbjATPEW (ORCPT ); Fri, 20 Jan 2023 10:04:22 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47F0D7CCC1 for ; Fri, 20 Jan 2023 07:03:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1674227013; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6iRsFgdyFm9aCh9hJwwja26lzouAKLjx2fwTp+CTHC4=; b=NeBGpfJuLOkvMoRl6iRI/RQzWMebyjXrhuvP/kniEbjccQ0kxvmIiEPg5Van3hOi73TXky r74zGYPbgeIbjTC6Oq0sYQjJ9DtLtGg4nOXVvrKB36mbQ/yQRzU6U+ghvUeBVVeJmhElgN WJLn1hZL1rYbn7qflw1SbAbP40s6nsU= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-133-0x9ArX0hPPaHNE5UgIfsEQ-1; Fri, 20 Jan 2023 10:03:26 -0500 X-MC-Unique: 0x9ArX0hPPaHNE5UgIfsEQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id ACE998588E7; Fri, 20 Jan 2023 15:03:25 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.32.187]) by smtp.corp.redhat.com (Postfix) with ESMTP id A5AA8492B03; Fri, 20 Jan 2023 15:03:20 +0000 (UTC) From: Wander Lairson Costa To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , "Eric W. Biederman" , Geert Uytterhoeven , Andrew Morton , Catalin Marinas , Kefeng Wang , Wander Lairson Costa , Oleg Nesterov , Thomas Gleixner , Sebastian Andrzej Siewior , Andy Lutomirski , "Liam R. Howlett" , Fenghua Yu , Andrei Vagin , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2 2/4] sched/deadline: fix inactive_task_timer splat Date: Fri, 20 Jan 2023 12:02:40 -0300 Message-Id: <20230120150246.20797-3-wander@redhat.com> In-Reply-To: <20230120150246.20797-1-wander@redhat.com> References: <20230120150246.20797-1-wander@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org inactive_task_timer() executes in interrupt (atomic) context. It calls put_task_struct(), which indirectly acquires sleeping locks under PREEMPT_RT. Below is an example of a splat that happened in a test environment: CPU: 1 PID: 2848 Comm: life Kdump: loaded Tainted: G W --------- Hardware name: HP ProLiant DL388p Gen8, BIOS P70 07/15/2012 Call Trace: dump_stack_lvl+0x57/0x7d mark_lock_irq.cold+0x33/0xba ? stack_trace_save+0x4b/0x70 ? save_trace+0x55/0x150 mark_lock+0x1e7/0x400 mark_usage+0x11d/0x140 __lock_acquire+0x30d/0x930 lock_acquire.part.0+0x9c/0x210 ? refill_obj_stock+0x3d/0x3a0 ? rcu_read_lock_sched_held+0x3f/0x70 ? trace_lock_acquire+0x38/0x140 ? lock_acquire+0x30/0x80 ? refill_obj_stock+0x3d/0x3a0 rt_spin_lock+0x27/0xe0 ? refill_obj_stock+0x3d/0x3a0 refill_obj_stock+0x3d/0x3a0 ? inactive_task_timer+0x1ad/0x340 kmem_cache_free+0x357/0x560 inactive_task_timer+0x1ad/0x340 ? switched_from_dl+0x2d0/0x2d0 __run_hrtimer+0x8a/0x1a0 __hrtimer_run_queues+0x91/0x130 hrtimer_interrupt+0x10f/0x220 __sysvec_apic_timer_interrupt+0x7b/0xd0 sysvec_apic_timer_interrupt+0x4f/0xd0 ? asm_sysvec_apic_timer_interrupt+0xa/0x20 asm_sysvec_apic_timer_interrupt+0x12/0x20 RIP: 0033:0x7fff196bf6f5 Use put_task_struct_atomic_safe() instead. Signed-off-by: Wander Lairson Costa Cc: Thomas Gleixner --- kernel/sched/deadline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index 0d97d54276cc..03400c61a994 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -1442,7 +1442,7 @@ static enum hrtimer_restart inactive_task_timer(struct hrtimer *timer) dl_se->dl_non_contending = 0; unlock: task_rq_unlock(rq, p, &rf); - put_task_struct(p); + put_task_struct_atomic_safe(p); return HRTIMER_NORESTART; } -- 2.39.0