CINXE.COM
LKML: Nishanth Aravamudan: Re: [RFC][PATCH] new timeofday-based soft-timer subsystem
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>LKML: Nishanth Aravamudan: Re: [RFC][PATCH] new timeofday-based soft-timer subsystem</title><link href="/css/message.css" rel="stylesheet" type="text/css" /><link href="/css/wrap.css" rel="alternate stylesheet" type="text/css" title="wrap" /><link href="/css/nowrap.css" rel="stylesheet" type="text/css" title="nowrap" /><link href="/favicon.ico" rel="shortcut icon" /><script src="/js/simple-calendar.js" type="text/javascript"></script><script src="/js/styleswitcher.js" type="text/javascript"></script><link rel="alternate" type="application/rss+xml" title="lkml.org : last 100 messages" href="/rss.php" /><link rel="alternate" type="application/rss+xml" title="lkml.org : last messages by Nishanth Aravamudan" href="/groupie.php?aid=24053" /><!--Matomo--><script> var _paq = window._paq = window._paq || []; /* tracker methods like "setCustomDimension" should be called before "trackPageView" */ _paq.push(["setDoNotTrack", true]); _paq.push(["disableCookies"]); _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); (function() { var u="//m.lkml.org/"; _paq.push(['setTrackerUrl', u+'matomo.php']); _paq.push(['setSiteId', '1']); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s); })(); </script><!--End Matomo Code--></head><body onload="es.jasper.simpleCalendar.init();" itemscope="itemscope" itemtype="http://schema.org/BlogPosting"><table border="0" cellpadding="0" cellspacing="0"><tr><td width="180" align="center"><a href="/"><img style="border:0;width:135px;height:32px" src="/images/toprowlk.gif" alt="lkml.org" /></a></td><td width="32">聽</td><td class="nb"><div><a class="nb" href="/lkml"> [lkml]</a> 聽 <a class="nb" href="/lkml/2005"> [2005]</a> 聽 <a class="nb" href="/lkml/2005/5"> [May]</a> 聽 <a class="nb" href="/lkml/2005/5/3"> [3]</a> 聽 <a class="nb" href="/lkml/last100"> [last100]</a> 聽 <a href="/rss.php"><img src="/images/rss-or.gif" border="0" alt="RSS Feed" /></a></div><div>Views: <a href="#" class="nowrap" onclick="setActiveStyleSheet('wrap');return false;">[wrap]</a><a href="#" class="wrap" onclick="setActiveStyleSheet('nowrap');return false;">[no wrap]</a> 聽 <a class="nb" href="/lkml/mheaders/2005/5/3/156" onclick="this.href='/lkml/headers'+'/2005/5/3/156';">[headers]</a>聽 <a href="/lkml/bounce/2005/5/3/156">[forward]</a>聽 </div></td><td width="32">聽</td></tr><tr><td valign="top"><div class="es-jasper-simpleCalendar" baseurl="/lkml/"></div><div class="threadlist">Messages in this thread</div><ul class="threadlist"><li class="root"><a href="/lkml/2005/4/29/260">First message in thread</a></li><li><a href="/lkml/2005/4/29/268">Nishanth Aravamudan</a><ul><li><a href="/lkml/2005/5/2/108">Darren Hart</a></li><li><a href="/lkml/2005/5/3/106">Nishanth Aravamudan</a><ul><li><a href="/lkml/2005/5/3/109">Chris Friesen</a><ul><li><a href="/lkml/2005/5/3/116">Nish Aravamudan</a></li></ul></li><li class="origin"><a href="">Nishanth Aravamudan</a></li></ul></li></ul></li></ul><div class="threadlist">Patch in this message</div><ul class="threadlist"><li><a href="/lkml/diff/2005/5/3/156/1">Get diff 1</a></li></ul></td><td width="32" rowspan="2" class="c" valign="top"><img src="/images/icornerl.gif" width="32" height="32" alt="/" /></td><td class="c" rowspan="2" valign="top" style="padding-top: 1em"><table><tr><td><table><tr><td class="lp">Date</td><td class="rp" itemprop="datePublished">Tue, 3 May 2005 14:47:07 -0700</td></tr><tr><td class="lp">From</td><td class="rp" itemprop="author">Nishanth Aravamudan <></td></tr><tr><td class="lp">Subject</td><td class="rp" itemprop="name">Re: [RFC][PATCH] new timeofday-based soft-timer subsystem</td></tr></table></td><td></td></tr></table><pre itemprop="articleBody">On 03.05.2005 [10:02:24 -0700], Nishanth Aravamudan wrote:<br />> On 29.04.2005 [16:35:46 -0700], Nishanth Aravamudan wrote:<br />> > * john stultz <johnstul@us.ibm.com> [2005-0429 15:45:47 -0700]:<br />> > <br />> > > All,<br />> > > This patch implements the architecture independent portion of<br />> > > the time of day subsystem. For a brief description on the rework, see<br />> > > here: <a href="http://lwn.net/Articles/120850/">http://lwn.net/Articles/120850/</a> (Many thanks to the LWN team for<br />> > > that clear writeup!)<br />> > <br />> > I have been working closely with John to re-work the soft-timer subsytem<br />> > to use the new timeofday() subsystem. The following patch attempts to<br />> > being this process. I would greatly appreciate any comments.<br />> <br />> I am not sure if anyone has looked at this patch closely, but I have<br />> noticed one issue: My code assumes that all the rounding will be done<br />> internally (rounding up on addition to find to the nearest<br />> timerinterval); however, current interfaces do much of the rounding<br />> before passing on structures on to the soft-timer subsystem, because the<br />> jiffies-based one always rounds down.<br /><br />A for instance: sys_nanosleep() assumes (correctly) that the<br />jiffies-based soft-timer subsystem rounds down, so it rounds up (twice).<br />But since I now round-up internally, that is not necessary. Fix<br />sys_nanosleep() to do this right.<br /><br />Still todo: change restart->arg0 to be a pointer to an nsec_t.<br /><br />diff -urpN 2.6.12-rc2-tod/kernel/timer.c 2.6.12-rc2-tod-timer/kernel/timer.c<br />--- 2.6.12-rc2-tod/kernel/timer.c 2005-05-02 12:59:04.000000000 -0700<br />+++ 2.6.12-rc2-tod-timer/kernel/timer.c 2005-05-03 09:13:43.000000000 -0700<br />@@ -1141,21 +1311,21 @@ asmlinkage long sys_gettid(void)<br /> <br /> static long __sched nanosleep_restart(struct restart_block *restart)<br /> {<br />- unsigned long expire = restart->arg0, now = jiffies;<br />+ nsec_t expire = restart->arg0, now = do_monotonic_clock();<br /> struct timespec __user *rmtp = (struct timespec __user *) restart->arg1;<br /> long ret;<br /> <br /> /* Did it expire while we handled signals? */<br />- if (!time_after(expire, now))<br />+ if (now > expire)<br /> return 0;<br /> <br />- current->state = TASK_INTERRUPTIBLE;<br />- expire = schedule_timeout(expire - now);<br />+ set_current_state(TASK_INTERRUPTIBLE);<br />+ expire = schedule_timeout_nsecs(expire - now);<br /> <br /> ret = 0;<br /> if (expire) {<br /> struct timespec t;<br />- jiffies_to_timespec(expire, &t);<br />+ t = ns2timespec(expire);<br /> <br /> ret = -ERESTART_RESTARTBLOCK;<br /> if (rmtp && copy_to_user(rmtp, &t, sizeof(t)))<br />@@ -1168,7 +1338,7 @@ static long __sched nanosleep_restart(st<br /> asmlinkage long sys_nanosleep(struct timespec __user *rqtp, struct timespec __user *rmtp)<br /> {<br /> struct timespec t;<br />- unsigned long expire;<br />+ nsec_t expire;<br /> long ret;<br /> <br /> if (copy_from_user(&t, rqtp, sizeof(t)))<br />@@ -1177,20 +1347,20 @@ asmlinkage long sys_nanosleep(struct tim<br /> if ((t.tv_nsec >= 1000000000L) || (t.tv_nsec < 0) || (t.tv_sec < 0))<br /> return -EINVAL;<br /> <br />- expire = timespec_to_jiffies(&t) + (t.tv_sec || t.tv_nsec);<br />- current->state = TASK_INTERRUPTIBLE;<br />- expire = schedule_timeout(expire);<br />+ expire = timespec2ns(&t);<br />+ set_current_state(TASK_INTERRUPTIBLE);<br />+ expire = schedule_timeout_nsecs(expire);<br /> <br /> ret = 0;<br /> if (expire) {<br /> struct restart_block *restart;<br />- jiffies_to_timespec(expire, &t);<br />+ t = ns2timespec(expire);<br /> if (rmtp && copy_to_user(rmtp, &t, sizeof(t)))<br /> return -EFAULT;<br /> <br /> restart = &current_thread_info()->restart_block;<br /> restart->fn = nanosleep_restart;<br />- restart->arg0 = jiffies + expire;<br />+ restart->arg0 = do_monotonic_clock() + expire;<br /> restart->arg1 = (unsigned long) rmtp;<br /> ret = -ERESTART_RESTARTBLOCK;<br /> }<br /><br />-<br />To unsubscribe from this list: send the line "unsubscribe linux-kernel" in<br />the body of a message to majordomo@vger.kernel.org<br />More majordomo info at <a href="http://vger.kernel.org/majordomo-info.html">http://vger.kernel.org/majordomo-info.html</a><br />Please read the FAQ at <a href="http://www.tux.org/lkml/">http://www.tux.org/lkml/</a><br /><br /></pre></td><td width="32" rowspan="2" class="c" valign="top"><img src="/images/icornerr.gif" width="32" height="32" alt="\" /></td></tr><tr><td align="right" valign="bottom"> 聽 </td></tr><tr><td align="right" valign="bottom">聽</td><td class="c" valign="bottom" style="padding-bottom: 0px"><img src="/images/bcornerl.gif" width="32" height="32" alt="\" /></td><td class="c">聽</td><td class="c" valign="bottom" style="padding-bottom: 0px"><img src="/images/bcornerr.gif" width="32" height="32" alt="/" /></td></tr><tr><td align="right" valign="top" colspan="2"> 聽 </td><td class="lm">Last update: 2005-05-03 23:51 聽聽 [from the cache]<br />漏2003-2020 <a href="http://blog.jasper.es/"><span itemprop="editor">Jasper Spaans</span></a>|hosted at <a href="https://www.digitalocean.com/?refcode=9a8e99d24cf9">Digital Ocean</a> and my Meterkast|<a href="http://blog.jasper.es/categories.html#lkml-ref">Read the blog</a></td><td>聽</td></tr></table><script language="javascript" src="/js/styleswitcher.js" type="text/javascript"></script></body></html>