Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1064442ybv; Fri, 7 Feb 2020 13:46:00 -0800 (PST) X-Google-Smtp-Source: APXvYqzshpXG/U/mH/d7c61vSu6vxxDY8mym9ALbK3MN/XYVt6HvZbHIRitB+SeJ94URWAyJYNid X-Received: by 2002:a05:6830:1bd5:: with SMTP id v21mr1216790ota.154.1581111960276; Fri, 07 Feb 2020 13:46:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581111960; cv=none; d=google.com; s=arc-20160816; b=SBwyM6CebyBmsH9MjVRLTZ4aefrDVMgyl4PTi6RI4pbgLBNk/TIQUJYbOXDum3fcgl wyuUWhVkdHP1rOanKHChxQI0li4GTB9x/45qK7k16MM+sQQNXcSNqFjNyaEm+0gCL3Iu bDuU9lK9+/95AiWudLYYBtq81NFnC9pVsiX+GXvm23B/Uk3150Id3bKHf+PqMpCroAd3 RGdZThlp8dOZRv/mFF4890Mkwi++57gtnN+KjAJROsG4aSe93gykFTt4WucRgFPHYeDK iJWBil2FRFoWhIEL/PdFkRO9dtnr1ULk0gvNApKhz1XqJIvv8CzAjr3MRBGMy7TGZtzB //2Q== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:from:references:cc:to:subject:reply-to; bh=EOAH8ECFFZIEB14xaWnDlsgAybajvshaGmxwPNViUdI=; b=JbdVivp8ejIGWORgR4pBtBMj4PbVWa7L8O8cqmneQfXjhocUx7HbQWeUwpf4BiOsaO H4L86+iLv+74QZXaCWFCydo+S3DUlX1dS0aWuPmQu211+27cWvle0aHC2gALweCG8bIP 7ElBDAiwtKwXW38k/3oHNLqliw/ybFdt8+pRUYnbZdVgOINEGaQuRPQTqDLm6v1HshCL SfTqcUB4rxYzCq3lChOcH5zqLUYPPy9dC2jaKK3+e2iDY7p0YS4YJ3eyTCLFIFABjqHS 93YXr4SBr16WeIKY4rGoJQqoy9zn3UMPluGunegpR3hClg3sYlpA71+BXeuuLK0M+1/i e4Sw== 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 u21si4474632oiv.267.2020.02.07.13.45.48; Fri, 07 Feb 2020 13:46:00 -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 S1727289AbgBGVoW (ORCPT + 99 others); Fri, 7 Feb 2020 16:44:22 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:36341 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726987AbgBGVoV (ORCPT ); Fri, 7 Feb 2020 16:44:21 -0500 Received: by mail-lj1-f193.google.com with SMTP id r19so878107ljg.3 for ; Fri, 07 Feb 2020 13:44:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:reply-to:subject:to:cc:references:from:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=EOAH8ECFFZIEB14xaWnDlsgAybajvshaGmxwPNViUdI=; b=gCZa6GL2weSliSIKnpmwXrvkAsPVTlPfU2+W5v0zl4ZfitoxP0ZpPQdfE3zJ3jGRKO zVWUSHrZXInBXuQD/s6FtV/dMN/yhWYouyJ7utzrBzawQm8idfnhpzt0bWbgrAsEsLmq 1Bh3kL4fX4aCdglyoqJuysfynAsZAw4MwWIHNGWV2gqbUW4QbdEoKrvVe48qVHG5ICFd GD3F6p7vgkyShD7utZ9fDbbrGdwuAK+2/gBmJuWM305ebRSTt3wYVcW+eLwKoiV2/rTv PclLSwW17hGItjZWkNL5NHn7VBMfB/uKhfERCFiIqv3ZkBbdvWdB/YYnZ86DTQYf0tzS XPPA== X-Gm-Message-State: APjAAAV46scMiNbMuuJmQShE01YaQolFhJO/5SB41NwEC4tVDYNxQUiE jVz3GNbNWRPjtG0Fp1haMy0= X-Received: by 2002:a2e:8651:: with SMTP id i17mr748079ljj.121.1581111859511; Fri, 07 Feb 2020 13:44:19 -0800 (PST) Received: from [192.168.1.184] (128-68-70-109.broadband.corbina.ru. [128.68.70.109]) by smtp.gmail.com with ESMTPSA id a28sm1606557lfg.86.2020.02.07.13.44.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 07 Feb 2020 13:44:18 -0800 (PST) Reply-To: alex.popov@linux.com Subject: Re: [PATCH 1/1] timer: Improve the comment describing schedule_timeout() 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 , linux-kernel@vger.kernel.org Cc: notify@kernel.org References: <20200117225900.16340-1-alex.popov@linux.com> From: Alexander Popov Autocrypt: addr=alex.popov@linux.com; prefer-encrypt=mutual; keydata= mQINBFX15q4BEADZartsIW3sQ9R+9TOuCFRIW+RDCoBWNHhqDLu+Tzf2mZevVSF0D5AMJW4f UB1QigxOuGIeSngfmgLspdYe2Kl8+P8qyfrnBcS4hLFyLGjaP7UVGtpUl7CUxz2Hct3yhsPz ID/rnCSd0Q+3thrJTq44b2kIKqM1swt/F2Er5Bl0B4o5WKx4J9k6Dz7bAMjKD8pHZJnScoP4 dzKPhrytN/iWM01eRZRc1TcIdVsRZC3hcVE6OtFoamaYmePDwWTRhmDt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S3j1vYC0wZJ99rrmQbcbYMh C2o0k4pSejaINmgyCajVOhUhln4IuwvZke1CLfXe1i3ZtlaIUrxfXqfYpeijfM/JSmliPxwW BRnQRcgS85xpC1pBUMrraxajaVPwu7hCTke03v6bu8zSZlgA1rd9E6KHu2VNS46VzUPjbR77 kO7u6H5PgQPKcuJwQQ+d3qa+5ZeKmoVkc2SuHVrCd1yKtAMmKBoJtSku1evXPwyBzqHFOInk mLMtrWuUhj+wtcnOWxaP+n4ODgUwc/uvyuamo0L2Gp3V5ItdIUDO/7ZpZ/3JxvERF3Yc1md8 5kfflpLzpxyl2fKaRdvxr48ZLv9XLUQ4qNuADDmJArq/+foORAX4BBFWvqZQKe8a9ZMAvGSh uoGUVg4Ks0uC4IeG7iNtd+csmBj5dNf91C7zV4bsKt0JjiJ9a4D85dtCOPmOeNuusK7xaDZc gzBW8J8RW+nUJcTpudX4TC2SGeAOyxnM5O4XJ8yZyDUY334seDRJWtS4wRHxpfYcHKTewR96 IsP1USE+9ndu6lrMXQ3aFsd1n1m1pfa/y8hiqsSYHy7JQ9Iuo9DxysOj22UNOmOE+OYPK48D j3lCqPk= Message-ID: <5754e3ba-bb3c-fcce-132b-3b080c4cdc28@linux.com> Date: Sat, 8 Feb 2020 00:44:17 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <20200117225900.16340-1-alex.popov@linux.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello everyone! Could I have any feedback for this patch? Thanks! On 18.01.2020 01:59, Alexander Popov wrote: > 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) >