From patchwork Tue Sep 19 20:16:51 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: 142097 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp3691955vqi; Tue, 19 Sep 2023 14:30:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHFoQ88vka1beDIH+7c570Huz2W5MeWscST/IuCRwfchQA5rPOAFftEpyKxOXtKBgDJUuoE X-Received: by 2002:a17:902:8217:b0:1c3:90c7:b99d with SMTP id x23-20020a170902821700b001c390c7b99dmr535073pln.41.1695159048773; Tue, 19 Sep 2023 14:30:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695159048; cv=none; d=google.com; s=arc-20160816; b=hQ3YrsclONLnofXbiHNI9Y5d5IqoRffxOp8wVPNgggqyPPnjbmsqZ1G+5gVyKsmG3p 7M7czD+R4Iumd0Ki1mYWrT0V3uWuKWY3EgFUqdytNQAeDKt9bdhkCCaazU5SoStv9tmG cbI5+IkqTAX0OB7qc6Ku+aNdTOB7Gx5qqRNa71evcBJ2vdcMBqHTqz+i6vwhEd801xFZ IHtDUaE7MMs9h02AviCzSvOaEhVY+oTLRX8P7eFqTwZ5YYDHMHaybLzu1DTStmtRk4oh 2IXA7kcpBeh+c+q54U0WhrfbLaL5U2uiPDe9D+RptUIaoqoVvx/HpsiDcG/YdsXvA6NR 92nQ== 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=vo0w5BZLCpHR/xC2Am5PL8qbWTO2IfzenEEO4d906mw=; fh=19Je2wg/uTT2A3FAWKIXtKSrLyDt9wzUngmn2f4aPvM=; b=xm1Soi/6d14zghaId5Eb/X4ua/OBtrJkIpkjULO7myNU+NV7DLnmLs9+4hx0pliq32 xONIKJm1C781lwmEPSH36JhsClNuUsV0mxiL8VeJ698E4/x6xsWpWnZI+DBgYm9tm/Y6 HmHw30mAGkku/RDjlrv8Al03tYudMcqRQ6+7wRUUGF9Et0xYaEiVKXXDBEzmozKdmiuQ +/yx+/FzMVa0k2y9Xnyv8WlvlSoYGMsfKwCo4/3kxpXcLD/IzbNTTv/0D7+21wD5jFsy QPGhNuAb7bAsOJS+y0+4xZHeNXRvVyZnQ2xIKIlNuJG1efkVa/0d6byltGCIFR2OmdDq ObYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=wIt1s6la; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id i1-20020a170902cf0100b001bba8a9e29dsi10502702plg.100.2023.09.19.14.30.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 14:30:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=wIt1s6la; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id D84F780BBE84; Tue, 19 Sep 2023 13:17:06 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233178AbjISURB (ORCPT + 26 others); Tue, 19 Sep 2023 16:17:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232649AbjISUQ7 (ORCPT ); Tue, 19 Sep 2023 16:16:59 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30B4CBA; Tue, 19 Sep 2023 13:16:53 -0700 (PDT) Date: Tue, 19 Sep 2023 20:16:51 -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=vo0w5BZLCpHR/xC2Am5PL8qbWTO2IfzenEEO4d906mw=; b=wIt1s6lab2692tECwEvCdTDKqaqNdAUzheElMYHkpiDByarVyjvWLMmv6N2FGvlQJ9IqpJ 5dXcTyA3iyoAhoqvb8ApTOTtLW6286PVL23M3CQ60NpSoXHBGQg8Wd+MOGuKHNLkvs6EVf NwbR18HhNwtB92jZrrZpqmVfj8M3RHPlO36HARcNUQyKAF649Q1yMcAH1ncUBcRHK7k7L0 9d2wTwZkq1qspxXEaU9Pp5bf9NVw45FtTx7ztrPqFwMWjt34yYup1P/+Ym91G5jHTzo9qh 0XX7lq4poXt7KTV+MLmrhBwG2c+Q9vpAwwJq5SE500X7tZJx3dp/S0oKftl/Gg== 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=vo0w5BZLCpHR/xC2Am5PL8qbWTO2IfzenEEO4d906mw=; b=74s1o/ZeyDjMMaVjV7BO/X9q0fFUHlA6Gxmdm1Os5bgbWU2dh0UTikCRhf/v/revjeElkX vj1z5SLmjWOf+DDA== 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: Add a proper comment about preempt_disable() in ptrace_stop() Cc: Sebastian Andrzej Siewior , Thomas Gleixner , Oleg Nesterov , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230803100932.325870-2-bigeasy@linutronix.de> References: <20230803100932.325870-2-bigeasy@linutronix.de> MIME-Version: 1.0 Message-ID: <169515461116.27769.12932058744920773528.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 19 Sep 2023 13:17:06 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777503095134430299 X-GMAIL-MSGID: 1777503095134430299 The following commit has been merged into the core/core branch of tip: Commit-ID: a20d6f63dbfc176697886d7709312ad0a795648e Gitweb: https://git.kernel.org/tip/a20d6f63dbfc176697886d7709312ad0a795648e Author: Sebastian Andrzej Siewior AuthorDate: Thu, 03 Aug 2023 12:09:31 +02:00 Committer: Thomas Gleixner CommitterDate: Tue, 19 Sep 2023 22:08:29 +02:00 signal: Add a proper comment about preempt_disable() in ptrace_stop() Commit 53da1d9456fe7 ("fix ptrace slowness") added a preempt-disable section between read_unlock() and the following schedule() invocation without explaining why it is needed. Replace the existing contentless comment with a proper explanation to clarify that it is not needed for correctness but for performance reasons. Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Thomas Gleixner Acked-by: Oleg Nesterov Link: https://lore.kernel.org/r/20230803100932.325870-2-bigeasy@linutronix.de --- kernel/signal.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/kernel/signal.c b/kernel/signal.c index 0901901..3035beb 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -2329,10 +2329,22 @@ static int ptrace_stop(int exit_code, int why, unsigned long message, do_notify_parent_cldstop(current, false, why); /* - * Don't want to allow preemption here, because - * sys_ptrace() needs this task to be inactive. + * The previous do_notify_parent_cldstop() invocation woke ptracer. + * One a PREEMPTION kernel this can result in preemption requirement + * which will be fulfilled after read_unlock() and the ptracer will be + * put on the CPU. + * The ptracer is in wait_task_inactive(, __TASK_TRACED) waiting for + * this task wait in schedule(). If this task gets preempted then it + * remains enqueued on the runqueue. The ptracer will observe this and + * then sleep for a delay of one HZ tick. In the meantime this task + * gets scheduled, enters schedule() and will wait for the ptracer. * - * XXX: implement read_unlock_no_resched(). + * This preemption point is not bad from a correctness point of + * view but extends the runtime by one HZ tick time due to the + * ptracer's sleep. The preempt-disable section ensures that there + * 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. */ preempt_disable(); read_unlock(&tasklist_lock);