From patchwork Fri Jan 20 15:02:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wander Lairson Costa X-Patchwork-Id: 4320 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp256939wrn; Fri, 20 Jan 2023 07:18:18 -0800 (PST) X-Google-Smtp-Source: AMrXdXseoCMt6FPzgTO+85eH0w4niHGMhMCx0dFrv1naYs7vt+cCn8HCUL3FHzf5D5Qp2lEhmFmJ X-Received: by 2002:a17:907:ca85:b0:86f:ae1f:9234 with SMTP id ul5-20020a170907ca8500b0086fae1f9234mr16928675ejc.7.1674227898176; Fri, 20 Jan 2023 07:18:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674227898; cv=none; d=google.com; s=arc-20160816; b=Msv9EI4EKOYLZGyEHao5v3iUrDtECfwp700xNyOalcW16kiXAAcayF0irjh5AueunR YPQvUoXqsR6XA1re8I4gaXPaNPWq+e37PZ4qHv+pYSiBZAtEasAOnI+ZR1LytaVH8zXe kJ0kp1UCwk8IvDMUbzuJsc4IKOeW8omKNKjzic/CO5mPXiLPAIf0Im183mBFRRqEX5QY 1C2e/RhEQ4q/6jyFyHPsc8/YixFTXzfr7TENUOr9R6B0CRTbVFJrJlrVo5oEUWVNfn0o HJzSPLBC7UgMrl2QquHJu4Qayqm2DOybX41OM8jkbuCs4FCfcpucX6mPPeN12sHen3js /jmQ== 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 :message-id:date:subject:to:from:dkim-signature; bh=TLOWCWdvP7Mw76tPsWEdql+JcbZ7sGhlRjsTCSJjmvg=; b=JdqN8zaop3sqnv7ZHqUOTU8E6vfXouVa9Rgjw9EFt9t5ShMaUlu1dJBjwBlmrinZhI aggLd62RJf/OTDXUG2B/dt1LywBwUCqtOePv/CofEI0nqm7A6zhsKhqmX2rN/5l5mNa6 VNCg8S11D+mAFm0BTN4QyEMFxO8eC8hELhcTzCD060owQ1ujDoq4Xtsg+yxgy3PgQybC FNd8NSArcvNlnQWjQYA3r4AQq19hExm+HCkJo6Z645gseHQTIuqJwP4sR7j3R15wA1zi jrKg3SMK7wxu7DCQu9GUmTzqaASSRQN1j3ZFvvNXx+00UzSe7KbOhOVRQqzm2MahcaHi YyfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LmO3mcUN; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id xi5-20020a170906dac500b007ae1874c142si12221354ejb.446.2023.01.20.07.17.52; Fri, 20 Jan 2023 07:18:18 -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=LmO3mcUN; 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 S231189AbjATPDw (ORCPT + 99 others); Fri, 20 Jan 2023 10:03:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229590AbjATPDr (ORCPT ); Fri, 20 Jan 2023 10:03:47 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2DC6F10415 for ; Fri, 20 Jan 2023 07:03:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1674226983; 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; bh=TLOWCWdvP7Mw76tPsWEdql+JcbZ7sGhlRjsTCSJjmvg=; b=LmO3mcUNVwkmHPMiaZus5+7zCqkDxiEvaKcrS6HADfWztLdA4xDoYvFKK9+9ZeiCkRZoYU 6chljr8Ooshh5Jr1kWwm8f6f2SBVEgWdDgCCJ1wgf6ypen96oajxljHS79vCAE9Z0FGn8m tovnZ9TOdfXMQFrub6g/uKLG9jNMds4= 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-64-1g2HogO0Psi3wtB4CLFcVA-1; Fri, 20 Jan 2023 10:02:59 -0500 X-MC-Unique: 1g2HogO0Psi3wtB4CLFcVA-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 8BF1B8030D0; Fri, 20 Jan 2023 15:02:58 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.32.187]) by smtp.corp.redhat.com (Postfix) with ESMTP id C83CC492B03; Fri, 20 Jan 2023 15:02:52 +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 , "Russell King (Oracle)" , Catalin Marinas , Wander Lairson Costa , Oleg Nesterov , Kefeng Wang , Andrew Morton , Thomas Gleixner , Sebastian Andrzej Siewior , Andy Lutomirski , "Liam R. Howlett" , Fenghua Yu , Andrei Vagin , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2 0/4] Fix put_task_struct() calls under PREEMPT_RT Date: Fri, 20 Jan 2023 12:02:38 -0300 Message-Id: <20230120150246.20797-1-wander@redhat.com> MIME-Version: 1.0 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755555192486571789?= X-GMAIL-MSGID: =?utf-8?q?1755555192486571789?= put_task_struct() decrements a usage counter and calls __put_task_struct() if the counter reaches zero. __put_task_struct() indirectly acquires a spinlock, which is a sleeping lock under PREEMPT_RT. Therefore, we can't call put_task_struct() in an atomic context in RT kernels. This patch series introduces put_task_struct_atomic_safe(), which defers the call to __put_task_struct() to a process context when compiled with PREEMPT_RT. It also fixes known problematic call sites. Changelog: ========== v2: * Add the put_task_struct_atomic_safe() function that is responsible for handling the conditions to call put_task_struct(). * Replace put_task_struct() by put_task_struct_atomic_safe() in known atomic call sites. Wander Lairson Costa (4): sched/task: Add the put_task_struct_atomic_safe function sched/deadline: fix inactive_task_timer splat sched/rt: use put_task_struct_atomic_safe() to avoid potential splat sched/core: use put_task_struct_atomic_safe() to avoid potential splat include/linux/sched/task.h | 21 +++++++++++++++++++++ kernel/fork.c | 8 ++++++++ kernel/sched/core.c | 2 +- kernel/sched/deadline.c | 2 +- kernel/sched/rt.c | 4 ++-- 5 files changed, 33 insertions(+), 4 deletions(-)