Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753504AbbLNTye (ORCPT ); Mon, 14 Dec 2015 14:54:34 -0500 Received: from www.linutronix.de ([62.245.132.108]:36545 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751317AbbLNTyd (ORCPT ); Mon, 14 Dec 2015 14:54:33 -0500 Date: Mon, 14 Dec 2015 20:53:40 +0100 (CET) From: Thomas Gleixner To: Aniroop Mathur cc: Clemens Ladisch , John Stultz , a.mathur@samsung.com, "linux-kernel@vger.kernel.org" Subject: Re: Ques: [kernel/time/*] Is there any disadvantage in using sleep_range for more than 20ms delay ? In-Reply-To: Message-ID: References: <566D3EC0.50408@ladisch.de> User-Agent: Alpine 2.11 (DEB 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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 List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2144 Lines: 57 On Tue, 15 Dec 2015, Aniroop Mathur wrote: > On Sun, Dec 13, 2015 at 3:17 PM, Clemens Ladisch wrote: > > Aniroop Mathur wrote: > >>> 2. If we use msleep(40), is it possible that process could wake up after > >>> 60 ms or 70 ms or 100 ms or more ? > > > > Yes, if lots of other processes compete for the CPU. > > You mean to say "yes" for process competing for changing state > from "waiting" to "ready" or "ready" to "running" ? There is no state ready. We change from [un]interruptible to running, but that's just the wakeup by the timer callback. When the task gets on the CPU is a different question. > Regarding above, could you please help to confirm below things? > 1. Using msleep(40) with HZ=1000 (1ms), process can still be in > "waiting" state and will not move to "ready" state even after 42,45 or 50 ms. > Right ? kernel/time/timer.c:apply_slack() > 2. Using usleep_range(40000, 41000), it is guaranteed that process will > change its state from waiting to ready state before or at 41 ms. > Right ? 1) It is supposed to be woken up by the timer in that range, but there is no guarantee. Depends also on your kernel configuration and hardware capabilities. 2) The state changes from [un]interruptible to running. And again that does not tell you when it gets on the CPU. > Regarding usleep_range disadvatage: > 1. Usleep_range has a disadvantage that it does not allow the system to > do optimal timer batching for power savings. Except that, Is there any > other disadvantage? Higher CPU usage. > 2. Is the impact of optimal timer batching in systems like android or ubuntu > with moderate cpu speed significant or it can be negligible also? > To understand the impact better, it would be really appreciating if you could > kindly explain in detail with some case and data input. http://bfy.tw/3HaV http://bfy.tw/3Han .... Thanks, tglx -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/