CINXE.COM
LKML: Mark Rutland: Re: [PATCH 17/30] x86/thread_info: define TIF_NEED_RESCHED_LAZY
<?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: Mark Rutland: Re: [PATCH 17/30] x86/thread_info: define TIF_NEED_RESCHED_LAZY</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 Mark Rutland" href="/groupie.php?aid=" /><!--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/2024"> [2024]</a> 聽 <a class="nb" href="/lkml/2024/2"> [Feb]</a> 聽 <a class="nb" href="/lkml/2024/2/14"> [14]</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/2024/2/14/596" onclick="this.href='/lkml/headers'+'/2024/2/14/596';">[headers]</a>聽 <a href="/lkml/bounce/2024/2/14/596">[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/2024/2/12/1709">First message in thread</a></li><li><a href="/lkml/2024/2/12/1709">Ankur Arora</a><ul><li><a href="/lkml/2024/2/12/1710">Ankur Arora</a><ul><li><a href="/lkml/2024/2/19/914">Thomas Gleixner</a><ul><li><a href="/lkml/2024/2/20/1578">Ankur Arora</a></li></ul></li></ul></li><li><a href="/lkml/2024/2/12/1711">Ankur Arora</a><ul><li><a href="/lkml/2024/2/14/641">Mark Rutland</a><ul><li><a href="/lkml/2024/2/14/1466">Ankur Arora</a></li></ul></li></ul></li><li><a href="/lkml/2024/2/12/1712">Ankur Arora</a></li><li><a href="/lkml/2024/2/12/1713">Ankur Arora</a></li><li><a href="/lkml/2024/2/12/1714">Ankur Arora</a></li><li><a href="/lkml/2024/2/12/1715">Ankur Arora</a><ul><li><a href="/lkml/2024/2/19/912">Thomas Gleixner</a><ul><li><a href="/lkml/2024/2/20/1577">Ankur Arora</a><ul><li><a href="/lkml/2024/2/21/1158">Thomas Gleixner</a></li></ul></li></ul></li></ul></li><li><a href="/lkml/2024/2/12/1716">Ankur Arora</a><ul><li><a href="/lkml/2024/2/19/901">Thomas Gleixner</a><ul><li><a href="/lkml/2024/2/20/1584">Ankur Arora</a><ul><li><a href="/lkml/2024/2/21/1149">Thomas Gleixner</a></li></ul></li></ul></li><li><a href="/lkml/2024/2/21/1273">Steven Rostedt</a><ul><li><a href="/lkml/2024/2/21/1420">Thomas Gleixner</a></li></ul></li></ul></li><li><a href="/lkml/2024/2/12/1717">Ankur Arora</a></li><li><a href="/lkml/2024/2/12/1718">Ankur Arora</a></li><li><a href="/lkml/2024/2/12/1719">Ankur Arora</a></li><li><a href="/lkml/2024/2/12/1720">Ankur Arora</a></li><li><a href="/lkml/2024/2/12/1721">Ankur Arora</a><ul><li><a href="/lkml/2024/2/14/638">Mark Rutland</a><ul><li><a href="/lkml/2024/2/14/1479">Ankur Arora</a><ul><li><a href="/lkml/2024/2/19/640">Mark Rutland</a></li></ul></li><li><a href="/lkml/2024/2/19/906">Thomas Gleixner</a><ul><li><a href="/lkml/2024/2/20/1570">Ankur Arora</a></li></ul></li></ul></li></ul></li><li><a href="/lkml/2024/2/12/1722">Ankur Arora</a></li><li><a href="/lkml/2024/2/12/1723">Ankur Arora</a></li><li><a href="/lkml/2024/2/12/1724">Ankur Arora</a></li><li><a href="/lkml/2024/2/12/1725">Ankur Arora</a><ul><li><a href="/lkml/2024/3/10/209">"Paul E. McKenney"</a><ul><li><a href="/lkml/2024/3/10/282">Joel Fernandes</a><ul><li><a href="/lkml/2024/3/10/290">"Paul E. McKenney"</a></li><li><a href="/lkml/2024/3/10/296">Ankur Arora</a></li></ul></li></ul></li></ul></li><li><a href="/lkml/2024/2/12/1726">Ankur Arora</a><ul><li class="origin"><a href="/lkml/2024/2/14/1226">Mark Rutland</a><ul><li><a href="/lkml/2024/2/14/1226">Ankur Arora</a><ul><li><a href="/lkml/2024/2/19/651">Mark Rutland</a></li></ul></li></ul></li></ul></li><li><a href="/lkml/2024/2/12/1727">Ankur Arora</a></li><li><a href="/lkml/2024/2/12/1728">Ankur Arora</a></li><li><a href="/lkml/2024/2/12/1729">Ankur Arora</a></li><li><a href="/lkml/2024/2/12/1730">Ankur Arora</a></li><li><a href="/lkml/2024/2/12/1731">Ankur Arora</a></li><li><a href="/lkml/2024/2/12/1732">Ankur Arora</a><ul><li><a href="/lkml/2024/3/2/362">Joel Fernandes</a><ul><li><a href="/lkml/2024/3/5/390">Ankur Arora</a><ul><li><a href="/lkml/2024/3/6/1358">Joel Fernandes</a></li></ul></li></ul></li></ul></li><li><a href="/lkml/2024/2/12/1733">Ankur Arora</a></li><li><a href="/lkml/2024/2/12/1734">Ankur Arora</a></li><li><a href="/lkml/2024/2/12/1735">Ankur Arora</a></li><li><a href="/lkml/2024/2/12/1736">Ankur Arora</a></li><li><a href="/lkml/2024/2/12/1737">Ankur Arora</a><ul><li><a href="/lkml/2024/2/21/1538">Steven Rostedt</a><ul><li><a href="/lkml/2024/2/21/1618">Ankur Arora</a><ul><li><a href="/lkml/2024/2/21/1648">Steven Rostedt</a></li></ul></li><li><a href="/lkml/2024/3/1/1396">Ankur Arora</a><ul><li><a href="/lkml/2024/3/3/237">Joel Fernandes</a></li></ul></li></ul></li></ul></li><li><a href="/lkml/2024/2/13/336">Geert Uytterhoeven</a><ul><li><a href="/lkml/2024/2/13/1381">Ankur Arora</a></li></ul></li><li><a href="/lkml/2024/2/14/1423">"Paul E. McKenney"</a><ul><li><a href="/lkml/2024/2/14/1465">Ankur Arora</a><ul><li><a href="/lkml/2024/2/15/1266">"Paul E. McKenney"</a><ul><li><a href="/lkml/2024/2/15/1317">Thomas Gleixner</a></li><li><a href="/lkml/2024/2/15/1350">Ankur Arora</a></li><li><a href="/lkml/2024/2/15/1370">Ankur Arora</a></li></ul></li></ul></li></ul></li><li><a href="/lkml/2024/2/21/699">Raghavendra K T</a><ul><li><a href="/lkml/2024/2/21/1164">Thomas Gleixner</a><ul><li><a href="/lkml/2024/2/21/1183">Raghavendra K T</a><ul><li><a href="/lkml/2024/2/21/1489">Ankur Arora</a></li><li><a href="/lkml/2024/2/22/1477">Thomas Gleixner</a></li></ul></li><li><a href="/lkml/2024/2/22/724">Raghavendra K T</a></li></ul></li></ul></li><li><a href="/lkml/2024/2/21/1534">Steven Rostedt</a></li><li><a href="/lkml/2024/2/28/778">Juri Lelli</a><ul><li><a href="/lkml/2024/2/28/1640">Ankur Arora</a><ul><li><a href="/lkml/2024/2/29/403">Juri Lelli</a><ul><li><a href="/lkml/2024/2/29/1618">Ankur Arora</a></li></ul></li></ul></li></ul></li><li><a href="/lkml/2024/4/23/1061">Shrikanth Hegde</a><ul><li><a href="/lkml/2024/4/23/1123">Linus Torvalds</a><ul><li><a href="/lkml/2024/4/26/219">Shrikanth Hegde</a><ul><li><a href="/lkml/2024/4/26/934">Ankur Arora</a></li></ul></li></ul></li></ul></li></ul></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">Wed, 14 Feb 2024 13:25:32 +0000</td></tr><tr><td class="lp">From</td><td class="rp" itemprop="author">Mark Rutland <></td></tr><tr><td class="lp">Subject</td><td class="rp" itemprop="name">Re: [PATCH 17/30] x86/thread_info: define TIF_NEED_RESCHED_LAZY</td></tr></table></td><td></td></tr></table><pre itemprop="articleBody">Hi Ankur,<br /><br />On Mon, Feb 12, 2024 at 09:55:41PM -0800, Ankur Arora wrote:<br />> Define TIF_NEED_RESCHED_LAZY which, with TIF_NEED_RESCHED provides the<br />> scheduler with two kinds of rescheduling intent: TIF_NEED_RESCHED,<br />> for the usual rescheduling at the next safe preemption point;<br />> TIF_NEED_RESCHED_LAZY expressing an intent to reschedule at some<br />> time in the future while allowing the current task to run to<br />> completion.<br />> <br />> Cc: Ingo Molnar <mingo@redhat.com><br />> Cc: Borislav Petkov <bp@alien8.de><br />> Cc: Dave Hansen <dave.hansen@linux.intel.com><br />> Originally-by: Thomas Gleixner <tglx@linutronix.de><br />> Link: <a href="https://lore.kernel.org/lkml/87jzshhexi.ffs@tglx/">https://lore.kernel.org/lkml/87jzshhexi.ffs@tglx/</a><br />> Signed-off-by: Ankur Arora <ankur.a.arora@oracle.com><br />> ---<br />> arch/x86/Kconfig | 1 +<br />> arch/x86/include/asm/thread_info.h | 10 ++++++++--<br />> 2 files changed, 9 insertions(+), 2 deletions(-)<br />> <br />> diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig<br />> index 5edec175b9bf..ab58558068a4 100644<br />> --- a/arch/x86/Kconfig<br />> +++ b/arch/x86/Kconfig<br />> @@ -275,6 +275,7 @@ config X86<br />> select HAVE_STATIC_CALL<br />> select HAVE_STATIC_CALL_INLINE if HAVE_OBJTOOL<br />> select HAVE_PREEMPT_DYNAMIC_CALL<br />> + select HAVE_PREEMPT_AUTO<br />> select HAVE_RSEQ<br />> select HAVE_RUST if X86_64<br />> select HAVE_SYSCALL_TRACEPOINTS<br />> diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h<br />> index d63b02940747..88c1802185fc 100644<br />> --- a/arch/x86/include/asm/thread_info.h<br />> +++ b/arch/x86/include/asm/thread_info.h<br />> @@ -81,8 +81,11 @@ struct thread_info {<br />> #define TIF_NOTIFY_RESUME 1 /* callback before returning to user */<br />> #define TIF_SIGPENDING 2 /* signal pending */<br />> #define TIF_NEED_RESCHED 3 /* rescheduling necessary */<br />> -#define TIF_SINGLESTEP 4 /* reenable singlestep on user return*/<br />> -#define TIF_SSBD 5 /* Speculative store bypass disable */<br />> +#ifdef CONFIG_PREEMPT_AUTO<br />> +#define TIF_NEED_RESCHED_LAZY 4 /* Lazy rescheduling */<br />> +#endif<br />> +#define TIF_SINGLESTEP 5 /* reenable singlestep on user return*/<br />> +#define TIF_SSBD 6 /* Speculative store bypass disable */<br /><br />It's a bit awkward/ugly to conditionally define the TIF_* bits in arch code,<br />and we don't do that for other bits that are only used in some configurations<br />(e.g. TIF_UPROBE). That's not just for aesthetics -- for example, on arm64 we<br />try to keep the TIF_WORK_MASK bits contiguous, which is difficult if a bit in<br />the middle doesn't exist in some configurations.<br /><br />Is it painful to organise the common code so that arch code can define<br />TIF_NEED_RESCHED_LAZY regardless of whether CONFIG_PREEMPT_AUTO is selected?<br /><br />Mark.<br /><br />> #define TIF_SPEC_IB 9 /* Indirect branch speculation mitigation */<br />> #define TIF_SPEC_L1D_FLUSH 10 /* Flush L1D on mm switches (processes) */<br />> #define TIF_USER_RETURN_NOTIFY 11 /* notify kernel of userspace return */<br />> @@ -104,6 +107,9 @@ struct thread_info {<br />> #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)<br />> #define _TIF_SIGPENDING (1 << TIF_SIGPENDING)<br />> #define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)<br />> +#ifdef CONFIG_PREEMPT_AUTO<br />> +#define _TIF_NEED_RESCHED_LAZY (1 << TIF_NEED_RESCHED_LAZY)<br />> +#endif<br />> #define _TIF_SINGLESTEP (1 << TIF_SINGLESTEP)<br />> #define _TIF_SSBD (1 << TIF_SSBD)<br />> #define _TIF_SPEC_IB (1 << TIF_SPEC_IB)<br />> -- <br />> 2.31.1<br />> <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: 2024-05-27 15:02 聽聽 [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>