@@ -219,7 +219,7 @@ int wc_linuxkm_check_for_intr_signals(void) {
219219 if (sigismember (& current -> pending .signal , intr_signals [i ])) {
220220#ifdef WOLFSSL_LINUXKM_VERBOSE_DEBUG
221221 pr_err ("INFO: wc_linuxkm_check_for_intr_signals returning "
222- "-EINTR on signal %d\n" , intr_signals [i ]);
222+ "INTERRUPTED_E on signal %d\n" , intr_signals [i ]);
223223#endif
224224 return INTERRUPTED_E ;
225225 }
@@ -229,25 +229,33 @@ int wc_linuxkm_check_for_intr_signals(void) {
229229}
230230
231231void wc_linuxkm_relax_long_loop (void ) {
232- #if WC_LINUXKM_MAX_NS_WITHOUT_YIELD >= 0
232+ #if WC_LINUXKM_MAX_NS_WITHOUT_YIELD >= 0
233233 if (preempt_count () == 0 ) {
234- #if (WC_LINUXKM_MAX_NS_WITHOUT_YIELD == 0 ) || !defined(CONFIG_SCHED_INFO )
234+ #if (WC_LINUXKM_MAX_NS_WITHOUT_YIELD == 0 ) || !defined(CONFIG_SCHED_INFO )
235235 cond_resched ();
236- #else
236+ #else
237+ /* note that local_clock() wraps a local_clock_noinstr() in a
238+ * preempt_disable_notrace(), which sounds expensive but isn't --
239+ * preempt_disable_notrace() is actually just a nonlocking integer
240+ * increment of current_thread_info()->preempt.count, protected only by
241+ * various compiler optimizer barriers.
242+ */
237243 u64 now = local_clock ();
238244 u64 current_last_arrival = current -> sched_info .last_arrival ;
239245 s64 delta = (s64 )(now - current_last_arrival );
240246 if (delta > WC_LINUXKM_MAX_NS_WITHOUT_YIELD ) {
241247 cond_resched ();
242- /* note, if nothing else is runnable, cond_resched() is a no-op and
248+ /* if nothing else is runnable, cond_resched() is a no-op and
243249 * doesn't even update .last_arrival. we could force update by
244250 * sleeping, but there's no need. we've been nice enough by just
245- * cond_resched()ing.
251+ * cond_resched()ing, and it's actually preferable to call
252+ * cond_resched() frequently once computation has looped
253+ * continuously for longer than WC_LINUXKM_MAX_NS_WITHOUT_YIELD.
246254 */
247255 }
248- #endif
256+ #endif
249257 }
250- #endif
258+ #endif
251259}
252260
253261#if defined(WOLFSSL_LINUXKM_USE_SAVE_VECTOR_REGISTERS ) && defined(CONFIG_X86 )
0 commit comments