Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp5058930ybv; Mon, 17 Feb 2020 11:21:24 -0800 (PST) X-Google-Smtp-Source: APXvYqz7sy17ZAaHNJEC+KSO2xMAEaclxuHv2nskumgO9EAt+sphXDPvec5CpZU4mNG+OZbYrvS+ X-Received: by 2002:a05:6808:9a4:: with SMTP id e4mr318081oig.127.1581967284464; Mon, 17 Feb 2020 11:21:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581967284; cv=none; d=google.com; s=arc-20160816; b=ScB/kqdTMNkQa7ZMkzZPl41Rxwco/nt9F+jHDVIuxFUxeozftvbeZ7C1mssWS0MO7v CHj1uu8hwJNE6YnTHNJBr6RKwvDNNcZ+GKXT7B/a2QZsl7tOfZfzFNZhcUmvN15DWR0s rK2mpy70F5ldFCVGOZK4g/X19jE0mJfp9StZvY5gNlKZTM+11V06cKXkE5+m7Kays1ky k+YhyJwbfEmq/08MgTMBf4tWnKlMyJXM+haEtQHMz9u/naOaMjilCA9+NiLu3/1cF0CF B09jCbIZ8FirfBrhGlinilYOv4fmhyGVxfOp8UBTFCe9aVUmM69YlRGkdpMReiiHOtKt UxMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=GPOqhPqfUZe4u2vkMAu0MK7sBH2YsuSUuIOZbcQbStM=; b=hqcvZeNvQkJUTTIIHVaGtw2eqZoDR86QnOOQe2fhOPNYlmCcLJafIcOL45Vh1RJnFl i/S/c2Hn3hpKW8brkwRC6eXJB0fXS1E8vkKxYrsF+UG1uKHpEnUgDbIGe2Ex/xMKToUu ePMtDs5iDzGd49C+yH3H0zkye7prnuT3iUgLoMy7I0VqZfGuLPD+1bOIcsH04XxG0Kqh 7gHvjKpR41xG52Mun/WJ+3IhLzcK00XoC2/TO+AklNTvfOPxSD4EIcLZyjUezxVNGgu1 zbTGZBpYnOGYc2iBEM28iNAkza7U2x4ftaqUgXr3GJcyzKwz3/iW0peWjwx/9GewLQca sMeA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g2si663977otn.117.2020.02.17.11.21.12; Mon, 17 Feb 2020 11:21:24 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729950AbgBQTTU (ORCPT + 99 others); Mon, 17 Feb 2020 14:19:20 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:34631 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729716AbgBQTSv (ORCPT ); Mon, 17 Feb 2020 14:18:51 -0500 Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1j3luo-0006BS-De; Mon, 17 Feb 2020 20:18:46 +0100 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id 02DA91C20B9; Mon, 17 Feb 2020 20:18:46 +0100 (CET) Date: Mon, 17 Feb 2020 19:18:45 -0000 From: "tip-bot2 for Alexander Popov" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: timers/core] timer: Improve the comment describing schedule_timeout() Cc: Alexander Popov , Thomas Gleixner , x86 , LKML In-Reply-To: <20200117225900.16340-1-alex.popov@linux.com> References: <20200117225900.16340-1-alex.popov@linux.com> MIME-Version: 1.0 Message-ID: <158196712575.13786.9130197359091225757.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the timers/core branch of tip: Commit-ID: 6e317c32fd39a13e4854a27958d5e35d15d196be Gitweb: https://git.kernel.org/tip/6e317c32fd39a13e4854a27958d5e35d15d196be Author: Alexander Popov AuthorDate: Sat, 18 Jan 2020 01:59:00 +03:00 Committer: Thomas Gleixner CommitterDate: Mon, 17 Feb 2020 20:12:19 +01:00 timer: Improve the comment describing schedule_timeout() When working commit 6dcd5d7a7a29c1e, a mistake was noticed by Linus: schedule_timeout() was called without setting the task state to anything particular. It calls the scheduler, but doesn't delay anything, because the task stays runnable. That happens because sched_submit_work() does nothing for tasks in TASK_RUNNING state. That turned out to be the intended behavior. Adding a WARN() is not useful as the task could be woken up right after setting the state and before reaching schedule_timeout(). Improve the comment about schedule_timeout() and describe that more explicitly. Signed-off-by: Alexander Popov Signed-off-by: Thomas Gleixner Link: https://lkml.kernel.org/r/20200117225900.16340-1-alex.popov@linux.com --- kernel/time/timer.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/kernel/time/timer.c b/kernel/time/timer.c index 4820823..cb34fac 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -1828,21 +1828,23 @@ static void process_timeout(struct timer_list *t) * schedule_timeout - sleep until timeout * @timeout: timeout value in jiffies * - * Make the current task sleep until @timeout jiffies have - * elapsed. The routine will return immediately unless - * the current task state has been set (see set_current_state()). + * Make the current task sleep until @timeout jiffies have elapsed. + * The function behavior depends on the current task state + * (see also set_current_state() description): * - * You can set the task state as follows - + * %TASK_RUNNING - the scheduler is called, but the task does not sleep + * at all. That happens because sched_submit_work() does nothing for + * tasks in %TASK_RUNNING state. * * %TASK_UNINTERRUPTIBLE - at least @timeout jiffies are guaranteed to * pass before the routine returns unless the current task is explicitly - * woken up, (e.g. by wake_up_process())". + * woken up, (e.g. by wake_up_process()). * * %TASK_INTERRUPTIBLE - the routine may return early if a signal is * delivered to the current task or the current task is explicitly woken * up. * - * The current task state is guaranteed to be TASK_RUNNING when this + * The current task state is guaranteed to be %TASK_RUNNING when this * routine returns. * * Specifying a @timeout value of %MAX_SCHEDULE_TIMEOUT will schedule @@ -1850,7 +1852,7 @@ static void process_timeout(struct timer_list *t) * value will be %MAX_SCHEDULE_TIMEOUT. * * Returns 0 when the timer has expired otherwise the remaining time in - * jiffies will be returned. In all cases the return value is guaranteed + * jiffies will be returned. In all cases the return value is guaranteed * to be non-negative. */ signed long __sched schedule_timeout(signed long timeout)