From patchwork Tue Sep 19 20:16:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 142125 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp3753879vqi; Tue, 19 Sep 2023 16:42:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHOn8KZFkME1uAZDCE0U2i+x38xLxqPIMaRTyD4OjQG9uI3qusdl03q0R/2Ob57av+CBe1g X-Received: by 2002:a05:6a21:3296:b0:13d:2f80:cf1c with SMTP id yt22-20020a056a21329600b0013d2f80cf1cmr1200431pzb.17.1695166947410; Tue, 19 Sep 2023 16:42:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695166947; cv=none; d=google.com; s=arc-20160816; b=mhEsA4o7PJ7g6cyXU9GD4NtgOJ03xoT3vPcnzTmJGhvd0IYh/qeup0I5IkO03RBwKW D1bI1DRM7k6SCr29qCUDl6MpS7ebS0x1yiUw0SRnC6N9oPgeR+QjgZeyB5K6vuXAokUe Ca9tjtNQOWgBcezf7CS9paEnbnY5D1lhypl7BJatTYFicffIEb+QJyYrKAdmOW8FIVcn pL5l8YpoDp6ucHOGdqgqAKevCkpiK76+xMjjYTJhdEg265swFeb9DDt0MqTDH2lr1Ncc bu5VimcQIQdeknxdiZiWBfxrc+UdesL5/xJWv60q5z2UAk5+belyyrOn2Vl0ZZDOtlOY 66pQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=jlQH9ja3AEV3lasY1kCndebMW6lqw5qt1mFUHrGN+1Y=; fh=19Je2wg/uTT2A3FAWKIXtKSrLyDt9wzUngmn2f4aPvM=; b=U2ECsUoXSiqpDiRZowdcIk1ztF6CdQi3z08UjAuSw/+U3rICzBdRKDoVlYVBHd8qU2 m+sNpCR6hzp5f5aKkTxJc/ZIxrMWnwJsENHywKV2hLy1tgiDFB9T6z6vl61x+lUVIgrP wBy3Ue+ytw80fgmwPjaVqUjmCAMB58dX1B5fZturQftXK0o1Iq2rEHQ4qFCy75ZY+1MW khKIEARJ0SHG4v2XiIcf7bx/gXVqrPQNGuyH1HHmRAp1PZSwN/H7ecSJbqGpbYKtiHSr NBs946eGGxTAJDlG7z/lUXVQhkDxHeGVm6xEkMm+ZcN9nCK9FZspKfP8I+RRdxEaH0rV WgLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=li6L72f2; dkim=neutral (no key) header.i=@linutronix.de header.b="/rZYYYjI"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id t8-20020a17090aba8800b002746ab58dfcsi271420pjr.18.2023.09.19.16.42.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 16:42:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=li6L72f2; dkim=neutral (no key) header.i=@linutronix.de header.b="/rZYYYjI"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 7820F80BF1A9; Tue, 19 Sep 2023 13:17:19 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232805AbjISURA (ORCPT + 26 others); Tue, 19 Sep 2023 16:17:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229772AbjISUQ6 (ORCPT ); Tue, 19 Sep 2023 16:16:58 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC5F9BE; Tue, 19 Sep 2023 13:16:52 -0700 (PDT) Date: Tue, 19 Sep 2023 20:16:50 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1695154611; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jlQH9ja3AEV3lasY1kCndebMW6lqw5qt1mFUHrGN+1Y=; b=li6L72f2fQX26rC+LLqd3qQYmvaMQXquaR7HdSc6PSJ6SWvAt/Apk0u3Yq5boRwPxAQKoP Jb+y9ufjY4B1VJ7nGjYK3zVf3DFd0sanhaG6ldJWvu/uGMdNicV0EBs+Qv2OFVPkj+cwYM BZKtaUkkGrTszGUp9kLZN37IU1kn1EgmagwmxEoqGtvZhAC8T7HO+HlRlHFlSStJpmYGSL WK50s/uBXHcd8ExD4+TRM7Ir6nfK9ceUnwJ3AlDN3Ske7TxNsd04lkgMx0waMXU6gVjC2t EHCCm+yyjT1NvcDgMiUOnZ1h7WPa3tqCFEMfO1oH8VipPfe8nA1O1YlzBeayRQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1695154611; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jlQH9ja3AEV3lasY1kCndebMW6lqw5qt1mFUHrGN+1Y=; b=/rZYYYjIEjYrsntPkT9plYrK0FqUckWiiDUYYkfIywmbC49T3458I1aptGSIWxbGRREdQe /2AwnMpkSDlXREDw== From: "tip-bot2 for Sebastian Andrzej Siewior" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: core/core] signal: Don't disable preemption in ptrace_stop() on PREEMPT_RT Cc: Sebastian Andrzej Siewior , Thomas Gleixner , Oleg Nesterov , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230803100932.325870-3-bigeasy@linutronix.de> References: <20230803100932.325870-3-bigeasy@linutronix.de> MIME-Version: 1.0 Message-ID: <169515461053.27769.8949434164650886984.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Tue, 19 Sep 2023 13:17:19 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777511377001614223 X-GMAIL-MSGID: 1777511377001614223 The following commit has been merged into the core/core branch of tip: Commit-ID: 1aabbc532413ced293952f8e149ad0a607d6e470 Gitweb: https://git.kernel.org/tip/1aabbc532413ced293952f8e149ad0a607d6e470 Author: Sebastian Andrzej Siewior AuthorDate: Thu, 03 Aug 2023 12:09:32 +02:00 Committer: Thomas Gleixner CommitterDate: Tue, 19 Sep 2023 22:08:29 +02:00 signal: Don't disable preemption in ptrace_stop() on PREEMPT_RT On PREEMPT_RT keeping preemption disabled during the invocation of cgroup_enter_frozen() is a problem because the function acquires css_set_lock which is a sleeping lock on PREEMPT_RT and must not be acquired with disabled preemption. The preempt-disabled section is only for performance optimisation reasons and can be avoided. Extend the comment and don't disable preemption before scheduling on PREEMPT_RT. Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Thomas Gleixner Acked-by: Oleg Nesterov Link: https://lore.kernel.org/r/20230803100932.325870-3-bigeasy@linutronix.de --- kernel/signal.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/kernel/signal.c b/kernel/signal.c index 3035beb..f2a5578 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -2345,11 +2345,22 @@ static int ptrace_stop(int exit_code, int why, unsigned long message, * will be no preemption between unlock and schedule() and so * improving the performance since the ptracer will observe that * the tracee is scheduled out once it gets on the CPU. + * + * On PREEMPT_RT locking tasklist_lock does not disable preemption. + * Therefore the task can be preempted after do_notify_parent_cldstop() + * before unlocking tasklist_lock so there is no benefit in doing this. + * + * In fact disabling preemption is harmful on PREEMPT_RT because + * the spinlock_t in cgroup_enter_frozen() must not be acquired + * with preemption disabled due to the 'sleeping' spinlock + * substitution of RT. */ - preempt_disable(); + if (!IS_ENABLED(CONFIG_PREEMPT_RT)) + preempt_disable(); read_unlock(&tasklist_lock); cgroup_enter_frozen(); - preempt_enable_no_resched(); + if (!IS_ENABLED(CONFIG_PREEMPT_RT)) + preempt_enable_no_resched(); schedule(); cgroup_leave_frozen(true);