Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp9591319ybl; Fri, 17 Jan 2020 15:00:25 -0800 (PST) X-Google-Smtp-Source: APXvYqznf1sESlAN/Zd8ua6hpPq0ytIfY9U3QxmB2QjbkH9cQ8HVS8yjSubwkkGvAMlKYZqjaES/ X-Received: by 2002:aca:530e:: with SMTP id h14mr5137927oib.105.1579302025327; Fri, 17 Jan 2020 15:00:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579302025; cv=none; d=google.com; s=arc-20160816; b=AEMawDdBz5+PXA455EtkAEQGhUMHzzwlu6QjXvTEfVIISgg6Vy/vp5EGxZmJXkq0F5 jlf2u3VG4lsbGLevt1qqZWD1NxR7mncRutlZHVpkcnenZ59c/mklnQImf4Zh1A90SKsL lGyeaRpjo+LcMrryPOWVnzipAQrG2EPiM7U6lS41dJVGQ7NVtpB2CU+X0L5QSiDWtuTy Wl+00Sq66vPb6fbi0XmA2NZb2qpujCpXkH17nXd0xDLEiswy9+OJwkaossTNqsiFYKBa VuDykq7M3M/3JkUdScpajSYue6Jpcw4Pmim9xaXTmVoh+RCO+k18x7NNCmXfZ8TMEgox OBlg== 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:mime-version :message-id:date:subject:cc:to:from; bh=n8t5sesjNU4GLzY8Ju+3vDc9euUX5JJDxPn6PxTGKqI=; b=dBsl/2LEl18lhf4UWl2+PLnySG9kjJThuhtpd1q7nYVlcWiwK94ymrYvjGI219ImVy g++n38QZZqpjl2hsGivdw/7XpV9aQ+Ba9zFpsI9haGu/71oM+/EyztpNJL9liWrqPRo4 MoloN0I4NGJsqv2/CGmf5DT/8X7k9kVLrIYK3WaWrIA+5fWHzcGqvZRQhvUgedoxg0/s Q2rcUn8DXe0mizdI+Ip/Dxj1GSOLzf+3YMgURKezp+9cZAP85Ty5IHEQR9nOk8iKMTDK TjwqOYy51vSZJMuAjaAOBtMVCrRRGGzdD9qzwABhnpVDHipkFT+2/zQk9D6GYfu0tsu3 XZsw== 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 i11si15627028otc.105.2020.01.17.15.00.12; Fri, 17 Jan 2020 15:00:25 -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 S1730119AbgAQW7P (ORCPT + 99 others); Fri, 17 Jan 2020 17:59:15 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:43924 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730075AbgAQW7O (ORCPT ); Fri, 17 Jan 2020 17:59:14 -0500 Received: by mail-lf1-f65.google.com with SMTP id 9so19577754lfq.10 for ; Fri, 17 Jan 2020 14:59:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=n8t5sesjNU4GLzY8Ju+3vDc9euUX5JJDxPn6PxTGKqI=; b=LrX0GVfvApBDiFPAKXsTC6ZXEq3wFPVScIxV2pKP4/NrhX2lMLybDqv3vuTYX+t0pI Lhktehq0OHOl73zq5jUdqinKKO4kz3KQ3CZCVTDb5mkGD2BZorxLp3pRvlovZcT5kPao hXv9mgqLNSerZ6Yy8bvmwbYF2gUbPNEQYF2FwEDhqYIc+bbrC3ayEtaHsX6RWNyZrSlO xot1UbPgeRa8MwLKAruM4tLOK8pUOO9DYba0U/D6wbiB2vLDcZz2Z+ZznciDT0mlYZl5 BAVa0Srgj4Ez+qLuGb+ADsgQZuG0NS1Hb6Ux5YuLQ03U3MMNFp4DgrQDe0WAbTwN5rc0 bOgw== X-Gm-Message-State: APjAAAWSTvB4hX85Ujt/MfzFAN2G095qbo1zgctpaGVjbOAU/HM1ugiz K64MjEr7Nzc6wV6i1IvCUO4= X-Received: by 2002:ac2:43af:: with SMTP id t15mr6790438lfl.154.1579301953025; Fri, 17 Jan 2020 14:59:13 -0800 (PST) Received: from hackbase.lan (128-68-70-109.broadband.corbina.ru. [128.68.70.109]) by smtp.gmail.com with ESMTPSA id n3sm12769556lfk.61.2020.01.17.14.59.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jan 2020 14:59:12 -0800 (PST) From: Alexander Popov To: Linus Torvalds , John Stultz , Thomas Gleixner , Stephen Boyd , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Alexander Popov , linux-kernel@vger.kernel.org Cc: notify@kernel.org Subject: [PATCH 1/1] timer: Improve the comment describing schedule_timeout() Date: Sat, 18 Jan 2020 01:59:00 +0300 Message-Id: <20200117225900.16340-1-alex.popov@linux.com> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When we were preparing the patch 6dcd5d7a7a29c1e, we made a mistake 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. Let's improve the comment about schedule_timeout() and describe that more explicitly. Signed-off-by: Alexander Popov --- 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 4820823515e9..cb34fac9d9f7 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) -- 2.24.1