~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/Documentation/timers/timers-howto.rst

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /Documentation/timers/timers-howto.rst (Version linux-6.12-rc7) and /Documentation/timers/timers-howto.rst (Version linux-5.2.21)


  1 ==============================================    
  2 delays - Information on the various kernel del    
  3 ==============================================    
  4                                                   
  5 This document seeks to answer the common quest    
  6 RightWay (TM) to insert a delay?"                 
  7                                                   
  8 This question is most often faced by driver wr    
  9 deal with hardware delays and who may not be t    
 10 familiar with the inner workings of the Linux     
 11                                                   
 12                                                   
 13 Inserting Delays                                  
 14 ----------------                                  
 15                                                   
 16 The first, and most important, question you ne    
 17 code in an atomic context?"  This should be fo    
 18 it really need to delay in atomic context?" If    
 19                                                   
 20 ATOMIC CONTEXT:                                   
 21         You must use the `*delay` family of fu    
 22         functions use the jiffy estimation of     
 23         and will busy wait for enough loop cyc    
 24         the desired delay:                        
 25                                                   
 26         ndelay(unsigned long nsecs)               
 27         udelay(unsigned long usecs)               
 28         mdelay(unsigned long msecs)               
 29                                                   
 30         udelay is the generally preferred API;    
 31         precision may not actually exist on ma    
 32                                                   
 33         mdelay is macro wrapper around udelay,    
 34         possible overflow when passing large a    
 35         In general, use of mdelay is discourag    
 36         be refactored to allow for the use of     
 37                                                   
 38 NON-ATOMIC CONTEXT:                               
 39         You should use the `*sleep[_range]` fa    
 40         There are a few more options here, whi    
 41         work correctly, using the "right" slee    
 42         help the scheduler, power management,     
 43         driver better :)                          
 44                                                   
 45         -- Backed by busy-wait loop:              
 46                                                   
 47                 udelay(unsigned long usecs)       
 48                                                   
 49         -- Backed by hrtimers:                    
 50                                                   
 51                 usleep_range(unsigned long min    
 52                                                   
 53         -- Backed by jiffies / legacy_timers      
 54                                                   
 55                 msleep(unsigned long msecs)       
 56                 msleep_interruptible(unsigned     
 57                                                   
 58         Unlike the `*delay` family, the underl    
 59         driving each of these calls varies, th    
 60         quirks you should be aware of.            
 61                                                   
 62                                                   
 63         SLEEPING FOR "A FEW" USECS ( < ~10us?     
 64                 * Use udelay                      
 65                                                   
 66                 - Why not usleep?                 
 67                         On slower systems, (em    
 68                         stepped PC!) the overh    
 69                         for usleep *may* not b    
 70                         will obviously depend     
 71                         it is something to be     
 72                                                   
 73         SLEEPING FOR ~USECS OR SMALL MSECS ( 1    
 74                 * Use usleep_range                
 75                                                   
 76                 - Why not msleep for (1ms - 20    
 77                         Explained originally h    
 78                                 https://lore.k    
 79                                                   
 80                         msleep(1~20) may not d    
 81                         will often sleep longe    
 82                         value given in the 1~2    
 83                         is not the desired beh    
 84                                                   
 85                 - Why is there no "usleep" / W    
 86                         Since usleep_range is     
 87                         wakeup will be very pr    
 88                         usleep function would     
 89                         of undesired interrupt    
 90                                                   
 91                         With the introduction     
 92                         free to coalesce your     
 93                         that may have happened    
 94                         worst case, fire an in    
 95                                                   
 96                         The larger a range you    
 97                         that you will not trig    
 98                         be balanced with what     
 99                         delay / performance fo    
100                         tolerances here are ve    
101                         is left to the caller     
102                                                   
103         SLEEPING FOR LARGER MSECS ( 10ms+ )       
104                 * Use msleep or possibly mslee    
105                                                   
106                 - What's the difference?          
107                         msleep sets the curren    
108                         whereas msleep_interru    
109                         TASK_INTERRUPTIBLE bef    
110                         short, the difference     
111                         early by a signal. In     
112                         you know you have a ne    
113                                                   
114         FLEXIBLE SLEEPING (any delay, uninterr    
115                 * Use fsleep                      
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php