Re: Ques: [kernel/time/*] Is there any disadvantage in using usleep_range for more than 20ms delay ?
On Tue, Dec 8, 2015 at 2:33 PM, Clemens Ladisch wrote: > Aniroop Mathur wrote: >> As in the kernel documentation, it is mentioned to use msleep for >> 10ms+ delay, I am confused whether there would be any disadvantage in >> using usleep_range for higher delays values because normally drivers >> have variety of delays used (2, 10, 20, 40, 100, 500 ms). >> >> So, could you please help to confirm that if we use usleep_range for >> inserting delays greater than 20 ms, would it be harmful or beneficial >> or does not make any difference at all ? > > As the documentation told you, usleep_range() is likely to require > a separate interrupt, while msleep() is likely to round to some other, > already-scheduled interrupt. The former is possibly harmful regarding > CPU and power usage; you have to balance it against your need for > accuracy. > Thank you for the answer! usleep_range will generate an interrupt to achieve accuracy. However, would that be considered as harmful or a disadvantage ? Would the power usage and cpu really substantial ? PS: I have added my more concern and explanation in another email thread whose subject misses u in usleep_range, by mistake. Added you in it as well. > (And usleep_range() has a 32-bit nanosecond limit on 32-bit > architectures.) > > > Regards, > Clemens -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: Ques: [kernel/time/*] Is there any disadvantage in using usleep_range for more than 20ms delay ?
Aniroop Mathur wrote: > As in the kernel documentation, it is mentioned to use msleep for > 10ms+ delay, I am confused whether there would be any disadvantage in > using usleep_range for higher delays values because normally drivers > have variety of delays used (2, 10, 20, 40, 100, 500 ms). > > So, could you please help to confirm that if we use usleep_range for > inserting delays greater than 20 ms, would it be harmful or beneficial > or does not make any difference at all ? As the documentation told you, usleep_range() is likely to require a separate interrupt, while msleep() is likely to round to some other, already-scheduled interrupt. The former is possibly harmful regarding CPU and power usage; you have to balance it against your need for accuracy. (And usleep_range() has a 32-bit nanosecond limit on 32-bit architectures.) Regards, Clemens -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: Ques: [kernel/time/*] Is there any disadvantage in using usleep_range for more than 20ms delay ?
Aniroop Mathur wrote: > As in the kernel documentation, it is mentioned to use msleep for > 10ms+ delay, I am confused whether there would be any disadvantage in > using usleep_range for higher delays values because normally drivers > have variety of delays used (2, 10, 20, 40, 100, 500 ms). > > So, could you please help to confirm that if we use usleep_range for > inserting delays greater than 20 ms, would it be harmful or beneficial > or does not make any difference at all ? As the documentation told you, usleep_range() is likely to require a separate interrupt, while msleep() is likely to round to some other, already-scheduled interrupt. The former is possibly harmful regarding CPU and power usage; you have to balance it against your need for accuracy. (And usleep_range() has a 32-bit nanosecond limit on 32-bit architectures.) Regards, Clemens -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: Ques: [kernel/time/*] Is there any disadvantage in using usleep_range for more than 20ms delay ?
On Tue, Dec 8, 2015 at 2:33 PM, Clemens Ladischwrote: > Aniroop Mathur wrote: >> As in the kernel documentation, it is mentioned to use msleep for >> 10ms+ delay, I am confused whether there would be any disadvantage in >> using usleep_range for higher delays values because normally drivers >> have variety of delays used (2, 10, 20, 40, 100, 500 ms). >> >> So, could you please help to confirm that if we use usleep_range for >> inserting delays greater than 20 ms, would it be harmful or beneficial >> or does not make any difference at all ? > > As the documentation told you, usleep_range() is likely to require > a separate interrupt, while msleep() is likely to round to some other, > already-scheduled interrupt. The former is possibly harmful regarding > CPU and power usage; you have to balance it against your need for > accuracy. > Thank you for the answer! usleep_range will generate an interrupt to achieve accuracy. However, would that be considered as harmful or a disadvantage ? Would the power usage and cpu really substantial ? PS: I have added my more concern and explanation in another email thread whose subject misses u in usleep_range, by mistake. Added you in it as well. > (And usleep_range() has a 32-bit nanosecond limit on 32-bit > architectures.) > > > Regards, > Clemens -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Ques: [kernel/time/*] Is there any disadvantage in using usleep_range for more than 20ms delay ?
Dear Mr. John and Mr. Thomas, Greetings of the day !! This is Aniroop Mathur working on sensor kernel drivers for last 3 years. Recently, In my driver code, I have been changing msleep to usleep_range. But I got stuck at one point and could not find proper answer on internet. Could you please help to answer my query as mentioned below ? >From the kernel documentation, I understood that it is better to use usleep_range for 10 us - 20 ms delay. For delays 10ms+, it is mentioned to use msleep. If my understanding is right and considering HZ=100, Even for 33 ms delay, msleep would sleep for 40 ms, while usleep_range would sleep for 33 ms as desired. And for 40 ms delay, msleep and usleep_range both will wake up at desired time. Right ? As in the kernel documentation, it is mentioned to use msleep for 10ms+ delay, I am confused whether there would be any disadvantage in using usleep_range for higher delays values because normally drivers have variety of delays used (2, 10, 20, 40, 100, 500 ms). So, could you please help to confirm that if we use usleep_range for inserting delays greater than 20 ms, would it be harmful or beneficial or does not make any difference at all ? Thanks in advance ! Regards, Aniroop Mathur -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Ques: [kernel/time/*] Is there any disadvantage in using usleep_range for more than 20ms delay ?
Dear Mr. John and Mr. Thomas, Greetings of the day !! This is Aniroop Mathur working on sensor kernel drivers for last 3 years. Recently, In my driver code, I have been changing msleep to usleep_range. But I got stuck at one point and could not find proper answer on internet. Could you please help to answer my query as mentioned below ? >From the kernel documentation, I understood that it is better to use usleep_range for 10 us - 20 ms delay. For delays 10ms+, it is mentioned to use msleep. If my understanding is right and considering HZ=100, Even for 33 ms delay, msleep would sleep for 40 ms, while usleep_range would sleep for 33 ms as desired. And for 40 ms delay, msleep and usleep_range both will wake up at desired time. Right ? As in the kernel documentation, it is mentioned to use msleep for 10ms+ delay, I am confused whether there would be any disadvantage in using usleep_range for higher delays values because normally drivers have variety of delays used (2, 10, 20, 40, 100, 500 ms). So, could you please help to confirm that if we use usleep_range for inserting delays greater than 20 ms, would it be harmful or beneficial or does not make any difference at all ? Thanks in advance ! Regards, Aniroop Mathur -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/