PF has its own home-brewed solution for dealing with CPU hogging.  It
has been introduced in r1.88 of net/pf_table.c and I couldn't find any
explanation why it is different than the idiom we use in other places.

So let's use the same idiom, I promise to introduce a macro an unify all
of them once this is in.

ok?

Index: net/pf_table.c
===================================================================
RCS file: /cvs/src/sys/net/pf_table.c,v
retrieving revision 1.123
diff -u -p -r1.123 pf_table.c
--- net/pf_table.c      24 Jan 2017 10:08:30 -0000      1.123
+++ net/pf_table.c      6 Feb 2017 12:33:28 -0000
@@ -36,6 +36,7 @@
 #include <sys/mbuf.h>
 #include <sys/pool.h>
 #include <sys/syslog.h>
+#include <sys/proc.h>
 
 #include <net/if.h>
 
@@ -72,11 +73,8 @@
        (bcopy((from), (to), (size)), 0))
 
 #define YIELD(cnt, ok)                         \
-       do {                                    \
-               if ((cnt % 1024 == 1023) &&     \
-                   (ok))                       \
-                       yield();                \
-       } while (0)
+       if (curcpu()->ci_schedstate.spc_schedflags & SPCF_SHOULDYIELD) \
+               preempt(NULL)                   \
 
 #define        FILLIN_SIN(sin, addr)                   \
        do {                                    \

Reply via email to