From patchwork Sun Jun 18 20:50:07 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: 109674 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2636534vqr; Sun, 18 Jun 2023 13:58:39 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7VVzpaamuyo2Kpw3LoeZFWrbgHBxpUf9JmgjIKg66euoekqCU7iLe1za2ApTY5gXe3kWdl X-Received: by 2002:a05:6a21:3a85:b0:11d:3c0c:e632 with SMTP id zv5-20020a056a213a8500b0011d3c0ce632mr7703553pzb.23.1687121919189; Sun, 18 Jun 2023 13:58:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687121919; cv=none; d=google.com; s=arc-20160816; b=b4lYQQFW5Q3UwIj+GJa0PghcB3Vv7sIhvSIoYhKMNaWnJVCsx+5aUgOiMhoGvAb1nB O4vbH2dGlA2GJ4IFAajSRm3fSxdU5TKY6NdrbiISRte5me1qvdDXIl883y3bk12QWGEA Z1o/ozzaZgthCRj55aw/XEwQ2yBY5v3lSide74W3gtF8r7GemEvaBKPLVLKDhuHnzHF1 cfk5hxJxTNgG22rqHu92tfApov5TvAqIczbEbfh96g6fi3npXKPv5y2WITCbp5+FDex8 xFw9M2UFt7ojAZejxtwxGGsluRr8j6tXSQ8XqJJfDgDglePr/njCGzcGXCMQmIRsHKyr 8uqg== 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=0rZmwii/QkARH24aAlxE20/L4+QJ9DGFPRuwo6gx48U=; b=B0rIWG/qOV0YI86qJ94g0t+1wmVRbRGJRBcAn5WaJw71eMPcXLho74h35dqu8UJOwl 0I6YDbBp5z+oc7nLepiJsn1fMKf5fiYXBWTWqfnhrPHI1eHlKwFErJ6xq+pvmQMcPmFQ ikbzJZs6tDNFRjVeVrY45cbXNBQJaxiVqaG5XKXeSoMm4wcQgXxJUWwLUG4XgPUfY+TA TmwAQr9OVj8L5/fcuQBFMFKRD2LwWHJByVXn/rM/8QXGdQuRX7Wr90HFDsXAU6SVNjUL aMFJmzAFri/ylDY1a1KHlSPKyVetG9aYGV/ileuRdcSsnUwt0BZl5FG46bvMOX4G3HpA kRNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=3GMDTePw; dkim=neutral (no key) header.i=@linutronix.de; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d18-20020a170902ced200b001b3d10e8b00si14425863plg.460.2023.06.18.13.58.26; Sun, 18 Jun 2023 13:58:39 -0700 (PDT) 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=@linutronix.de header.s=2020 header.b=3GMDTePw; dkim=neutral (no key) header.i=@linutronix.de; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229626AbjFRUvH (ORCPT + 99 others); Sun, 18 Jun 2023 16:51:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229628AbjFRUuL (ORCPT ); Sun, 18 Jun 2023 16:50:11 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E45DE5D; Sun, 18 Jun 2023 13:50:09 -0700 (PDT) Date: Sun, 18 Jun 2023 20:50:07 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1687121408; 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=0rZmwii/QkARH24aAlxE20/L4+QJ9DGFPRuwo6gx48U=; b=3GMDTePwyFmRAUOlTuiX/coZ1rY5XbdVyoFmMNFlHOlxTeXrih4QYUd5oUz+kTSx6vgmFJ VTt2gNZcLMT7mwnIknSZn2PUDF9vwb5ixO+ooL5Jo+ej9rVrGnSEsvPTt/sHgm6rvqLL+6 42h1AKg4BSV6g+lpa+P3HFTPrUxRObvFkiZuKU3rYnyU71P254IjArUFZwRsLXK6I0/sFj ghm7unyCrRNlpyT2Uppht1xXWrzyDb7S2wWphUnrjnihR0bk4v7+y61vBi+g4vO9n+/MkJ dGJfa31VOA27o9PUhWDcIzJsNQxyimo6Vhl/IXawsUKhS4DElH4YC/I/FDU3iw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1687121408; 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=0rZmwii/QkARH24aAlxE20/L4+QJ9DGFPRuwo6gx48U=; b=P9KTMmp5BsaP4TqEMxyCMq6Xy1d5hlP2Q0Nntg2wtq4WNVOSecnq4xswED73j/3g0+Aa2r U9Y8iJb5KtYUVaAQ== From: "tip-bot2 for Thomas Gleixner" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: timers/core] posix-timers: Clarify timer_wait_running() comment Cc: Thomas Gleixner , Frederic Weisbecker , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230425183312.985681995@linutronix.de> References: <20230425183312.985681995@linutronix.de> MIME-Version: 1.0 Message-ID: <168712140796.404.15897229283135813033.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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?1764175261657431559?= X-GMAIL-MSGID: =?utf-8?q?1769075553522331682?= The following commit has been merged into the timers/core branch of tip: Commit-ID: 7d9909026645064cd31b20cee5939a0f72282261 Gitweb: https://git.kernel.org/tip/7d9909026645064cd31b20cee5939a0f72282261 Author: Thomas Gleixner AuthorDate: Tue, 25 Apr 2023 20:49:00 +02:00 Committer: Thomas Gleixner CommitterDate: Sun, 18 Jun 2023 22:41:48 +02:00 posix-timers: Clarify timer_wait_running() comment Explain it better and add the CONFIG_POSIX_CPU_TIMERS_TASK_WORK=y aspect for completeness. Signed-off-by: Thomas Gleixner Reviewed-by: Frederic Weisbecker Link: https://lore.kernel.org/r/20230425183312.985681995@linutronix.de --- kernel/time/posix-timers.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c index 2d6cf93..0c61f29 100644 --- a/kernel/time/posix-timers.c +++ b/kernel/time/posix-timers.c @@ -836,10 +836,18 @@ static void common_timer_wait_running(struct k_itimer *timer) } /* - * On PREEMPT_RT this prevent priority inversion against softirq kthread in - * case it gets preempted while executing a timer callback. See comments in - * hrtimer_cancel_wait_running. For PREEMPT_RT=n this just results in a - * cpu_relax(). + * On PREEMPT_RT this prevents priority inversion and a potential livelock + * against the ksoftirqd thread in case that ksoftirqd gets preempted while + * executing a hrtimer callback. + * + * See the comments in hrtimer_cancel_wait_running(). For PREEMPT_RT=n this + * just results in a cpu_relax(). + * + * For POSIX CPU timers with CONFIG_POSIX_CPU_TIMERS_TASK_WORK=n this is + * just a cpu_relax(). With CONFIG_POSIX_CPU_TIMERS_TASK_WORK=y this + * prevents spinning on an eventually scheduled out task and a livelock + * when the task which tries to delete or disarm the timer has preempted + * the task which runs the expiry in task work context. */ static struct k_itimer *timer_wait_running(struct k_itimer *timer, unsigned long *flags)