Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp7811496ybl; Thu, 16 Jan 2020 06:04:42 -0800 (PST) X-Google-Smtp-Source: APXvYqxHN0rd/eHVIcmuoEWhEir4W+V+3W7EX1z2sfnXCnu3X+VNDb/1csmcNjkjizERL0D6VhkU X-Received: by 2002:a05:6830:1442:: with SMTP id w2mr2087928otp.143.1579183482702; Thu, 16 Jan 2020 06:04:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579183482; cv=none; d=google.com; s=arc-20160816; b=mPo8VHF6YAeBAuDbeFeokhsQsHTpX9h5P4063TAl0jcjxyt93Bmg05rLVIIRkrjjW4 FkjUPFNCqm7PLhff4T25U6nIfI1P8uZVymLZ72USgJ8k8OEP5YUMXErpI0tZIgYexgZ7 sP9svUbzRnAgSaXZvEQePUPB0Vw+6vFkVMdf6Y8RPESYpC2ANMCu+XQxTJVIDrjnmxYT 9Unr3YA3Irv0wriff64lyRJbfNkfLxY/BE2L9YSG24wP5KWlyENJxpBJ/GayXnmOi7H+ Ke/zNM64fgtbgQy5Hw9FZ8tcXDawffVhBNqxo+bkIlCY2EQFk6ycC+cUiQ1t3IMKOvcB Thdw== 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=xHcm9L3dRNb5ixg4Vx8DtSyRu6w9IGdCFJXH11ueGYU=; b=R+W2BNYUqqV7Ub7b9ZvjUu/7JC9oJYBV/MQx9swONvGmXY4Ae0KDh1zGi7wY6Telgq wu1hc/PMGdHnKYlKpGS3+ZrqwRX59r+I81Dsv9j7BaJZ1U+wa7cE1G1urKJSjSb+NqUU STLRZPwFIW3IZahRf2eMWcb2growy9swJnt7FCBBBo+u9LNG5Omr4qHMa93Q3Lzb5jb7 ISg/TtCQ8RvKFkL5l4WrB2awNXrXO7yTx9RehayqF0r/jklyxZyrTM9Vrl1Qlizz1mMV fcai5y8n5YEldAA5ppDiyMjP+2viw97Z59Jke3JQoww1sM71/tjUNB9EDJ0Ifis/8b6F TxSQ== 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 c21si13447550otr.223.2020.01.16.06.04.15; Thu, 16 Jan 2020 06:04:42 -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 S1726474AbgAPOCe (ORCPT + 99 others); Thu, 16 Jan 2020 09:02:34 -0500 Received: from mail-lj1-f196.google.com ([209.85.208.196]:43840 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726343AbgAPOCe (ORCPT ); Thu, 16 Jan 2020 09:02:34 -0500 Received: by mail-lj1-f196.google.com with SMTP id a13so22779377ljm.10 for ; Thu, 16 Jan 2020 06:02:33 -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=xHcm9L3dRNb5ixg4Vx8DtSyRu6w9IGdCFJXH11ueGYU=; b=SKq+cfrPkC8Ev/Dk9VchfmgKzCqUug+YRX76TxpG9tNlKIMNeYy9V8g+w8yEw8lS+z U8TD5vnfJ9GGVPE8QvWdA8Vw3BCoM5dupTJwWyl8r4jsdcNBBMsDSsK7e36OpmJa3lUJ 7281+1rQERy9Mv+TNwRYmlJng/3mqqdsV4mCl7WlsheSCOGvXu1o4r3eZzZxHoGx+ilP 1Ialio3rN9otCPqh59dc6MoRwv46lzjrFyJZEdCdrjaXAJiYnePUmJh+bA9xXrAWlw5j IeL8HkKwUhTBnU725rrRgW16Qq/dHDTrA8y4ezRF7tZkWvYQUOO38ZoK1StDSfbSH1t8 rBYQ== X-Gm-Message-State: APjAAAVi457pYsqegiYvcMD3pVvaZpv8LsdNr0uHmGz+1khIkISbUILM aG18Cj2ZhV8I0iu62i3+bwo= X-Received: by 2002:a2e:97d9:: with SMTP id m25mr2444728ljj.146.1579183352102; Thu, 16 Jan 2020 06:02:32 -0800 (PST) Received: from localhost.localdomain ([213.87.157.244]) by smtp.gmail.com with ESMTPSA id 204sm10682795lfj.47.2020.01.16.06.02.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jan 2020 06:02:30 -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 , linux-kernel@vger.kernel.org Cc: notify@kernel.org Subject: [PATCH 1/1] timer: Warn about schedule_timeout() called for tasks in TASK_RUNNING state Date: Thu, 16 Jan 2020 17:02:18 +0300 Message-Id: <20200116140218.1328022-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. Let's add a WARN_ONCE() under CONFIG_SCHED_DEBUG to detect such kernel API misuse. Signed-off-by: Alexander Popov --- kernel/time/timer.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kernel/time/timer.c b/kernel/time/timer.c index 4820823515e9..52ad2d6ce352 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -1887,6 +1887,11 @@ signed long __sched schedule_timeout(signed long timeout) } } +#ifdef CONFIG_SCHED_DEBUG + WARN_ONCE(current->state == TASK_RUNNING, + "schedule_timeout for TASK_RUNNING\n"); +#endif + expire = timeout + jiffies; timer.task = current; -- 2.24.1