Index: share/man/man9/Makefile =================================================================== RCS file: /cvs/src/share/man/man9/Makefile,v retrieving revision 1.237 diff -u -p -r1.237 Makefile --- share/man/man9/Makefile 8 Jul 2015 07:21:49 -0000 1.237 +++ share/man/man9/Makefile 23 Jul 2015 12:30:54 -0000 @@ -266,7 +266,8 @@ MLINKS+=microtime.9 getmicrotime.9 micro microtime.9 getnanotime.9 microtime.9 nanouptime.9 \ microtime.9 getnanouptime.9 microtime.9 bintime.9 \ microtime.9 binuptime.9 -MLINKS+=ml_init.9 ml_enqueue.9 ml_init.9 ml_dequeue.9 ml_init.9 ml_dechain.9 \ +MLINKS+=ml_init.9 ml_enqueue.9 ml_init.9 ml_dequeue.9 ml_init.9 ml_requeue.9 \ + ml_init.9 ml_dechain.9 \ ml_init.9 ml_filter.9 ml_init.9 ml_len.9 ml_init.9 ml_empty.9 \ ml_init.9 MBUF_LIST_INITIALIZER.9 ml_init.9 MBUF_LIST_FOREACH.9 MLINKS+=mountroothook_establish.9 mountroothook_disestablish.9 @@ -274,8 +275,9 @@ MLINKS+=mutex.9 mtx_init.9 mutex.9 mtx_e mutex.9 MUTEX_ASSERT_LOCKED.9 mutex.9 MUTEX_ASSERT_UNLOCKED.9 \ mutex.9 MUTEX_INITIALIZER.9 MLINKS+=mutex.9 mtx_enter_try.9 -MLINKS+=mq_init.9 mq_enqueue.9 mq_init.9 mq_dequeue.9 mq_init.9 mq_enlist.9 \ - mq_init.9 mq_delist.9 mq_init.9 mq_dechain.9 mq_init.9 mq_filter.9 \ +MLINKS+=mq_init.9 mq_enqueue.9 mq_init.9 mq_dequeue.9 mq_init.9 mq_requeue.9 \ + mq_init.9 mq_enlist.9 mq_init.9 mq_delist.9 \ + mq_init.9 mq_dechain.9 mq_init.9 mq_filter.9 \ mq_init.9 mq_len.9 mq_init.9 mq_empty.9 mq_init.9 mq_drops.9 \ mq_init.9 mq_set_maxlen.9 mq_init.9 MBUF_QUEUE_INITIALIZER.9 MLINKS+=namei.9 vfs_lookup.9 namei.9 vfs_relookup.9 namei.9 NDINIT.9 Index: share/man/man9/ml_init.9 =================================================================== RCS file: /cvs/src/share/man/man9/ml_init.9,v retrieving revision 1.1 diff -u -p -r1.1 ml_init.9 --- share/man/man9/ml_init.9 17 Jun 2015 06:24:46 -0000 1.1 +++ share/man/man9/ml_init.9 23 Jul 2015 12:30:54 -0000 @@ -21,6 +21,7 @@ .Nm ml_init , .Nm ml_enqueue , .Nm ml_dequeue , +.Nm ml_requeue , .Nm ml_dechain , .Nm ml_len , .Nm ml_empty , @@ -34,6 +35,8 @@ .Fn "ml_enqueue" "struct mbuf_list *ml" "struct mbuf *m" .Ft struct mbuf * .Fn "ml_dequeue" "struct mbuf_list *ml" +.Ft void +.Fn "ml_requeue" "struct mbuf_list *ml" "struct mbuf *m" .Ft struct mbuf * .Fn "ml_dechain" "struct mbuf_list *ml" .Ft struct mbuf * @@ -61,6 +64,8 @@ Insertion of a new mbuf at the end of th .It Removal of an mbuf from the head of the list. .It +Reinsertion of an mbuf at the head of the list. +.It Removal of the entire chain of mbufs on the list. .El .Bl -tag -width Ds @@ -80,6 +85,12 @@ mbuf list. Dequeue an mbuf from the front of the .Fa ml mbuf list. +.It Fn "ml_requeue" "struct mbuf_list *ml" "struct mbuf *m" +Enqueue mbuf +.Fa m +at the head of the +.Fa ml +mbuf list. .It Fn "ml_dechain" "struct mbuf_list *ml" Dequeues all mbufs from the .Fa ml @@ -124,6 +135,7 @@ Note that it is unsafe to modify the lis .Fn ml_init , .Fn ml_enqueue , .Fn ml_dequeue , +.Fn ml_requeue , .Fn ml_dechain , .Fn ml_len , .Fn ml_empty , Index: share/man/man9/mq_init.9 =================================================================== RCS file: /cvs/src/share/man/man9/mq_init.9,v retrieving revision 1.1 diff -u -p -r1.1 mq_init.9 --- share/man/man9/mq_init.9 17 Jun 2015 06:24:46 -0000 1.1 +++ share/man/man9/mq_init.9 23 Jul 2015 12:30:54 -0000 @@ -21,6 +21,7 @@ .Nm mq_init , .Nm mq_enqueue , .Nm mq_dequeue , +.Nm mq_requeue , .Nm mq_enlist , .Nm mq_delist , .Nm mq_dechain , @@ -38,6 +39,8 @@ .Ft struct mbuf * .Fn "mq_dequeue" "struct mbuf_queue *mq" .Ft int +.Fn "mq_requeue" "struct mbuf_queue *mq" "struct mbuf *m" +.Ft int .Fn "mq_enlist" "struct mbuf_queue *mq" "struct mbuf_list *ml" .Ft void .Fn "mq_delist" "struct mbuf_queue *mq" "struct mbuf_list *ml" @@ -78,24 +81,28 @@ Insertion of a new mbuf at the end of th .It Removal of an mbuf from the head of the queue. .It +Reinsertion of an mbuf at the head of the queue. +.It Removal of the entire chain of mbufs on the queue. .It Insertion of the mbufs in an mbuf_list at the end of the queue. .It Removal of all the mbufs on the queue as an mbuf_list. +.It +Reinsertion of the mbufs in an mbuf_list at the head of the queue. .El .Bl -tag -width Ds .It Fn "mq_init" "struct mbuf_queue *mq" "unsigned int maxlen" "int ipl" Initialises the mbuf queue structure .Fa mq . -The maximum number of mbufs that can be queued is specified with +The maximum number of mbufs that should be queued is specified with .Fa maxlen . The highest interrupt priority level the queue will be operated at is specified via .Fa ipl . .It Fn "MBUF_QUEUE_INITIALIZER" "unsigned int maxlen" "int ipl" Initialises an mbuf queue structure declaration. -The maximum number of mbufs that can be queued is specified with +The maximum number of mbufs that should be queued is specified with .Fa maxlen . The highest interrupt priority level the queue will be operated at is specified via @@ -110,6 +117,14 @@ mbuf queue. Dequeue an mbuf from the front of the .Fa mq mbuf queue. +.It Fn "mq_requeue" "struct mbuf_queue *mq" "struct mbuf *m" +Enqueue mbuf +.Fa m +at the head of the +.Fa mq +mbuf queue. +Note, this operation will succeed even if it will cause the queue to exceed its +maximum length. .It Fn "mq_enlist" "struct mbuf_queue *mq" "struct mbuf_list *ml" Enqueue all the mbufs on the .Fa ml @@ -161,7 +176,7 @@ if the .Fa mq mbuf queue was too full. .It Fn "mq_set_maxlen" "struct mbuf_queue *mq" "unsigned int" -Alter the maximum number of mbufs that can be queued on the +Alter the maximum number of mbufs that should be queued on the .Fa mq mbuf queue. Note, @@ -173,6 +188,7 @@ already exist on the queue. .Fn mq_init , .Fn mq_enqueue , .Fn mq_dequeue , +.Fn mq_requeue , .Fn mq_enlist , .Fn mq_delist , .Fn mq_dechain , @@ -213,6 +229,10 @@ returns a non-zero value if the queue is .Fn mq_enqueue returns 0 if the mbuf was successfully queued, or non-zero if the mbuf was freed because it would cause the queue to exceed its maximum +length. +.Pp +.Fn mq_requeue +returns non-zero if the mbuf queue is now full, otherwise 0. length. .Pp .Fn mq_enlist Index: share/man/man9/srp_enter.9 =================================================================== RCS file: /cvs/src/share/man/man9/srp_enter.9,v retrieving revision 1.2 diff -u -p -r1.2 srp_enter.9 --- share/man/man9/srp_enter.9 2 Jul 2015 01:38:35 -0000 1.2 +++ share/man/man9/srp_enter.9 23 Jul 2015 12:30:54 -0000 @@ -1,4 +1,4 @@ -.\" $OpenBSD: srp_enter.9,v 1.2 2015/07/02 01:38:35 dlg Exp $ +.\" $OpenBSD: srp_enter.9,v 1.1 2015/07/02 01:33:59 dlg Exp $ .\" .\" Copyright (c) 2015 David Gwynne .\" @@ -153,7 +153,7 @@ and can be called during autoconf, from process context, or from interrupt context. Calling .Fn srp_leave -from a different context to the preceding +from a different context or on a different CPU to the preceding .Fn srp_enter call will lead to undefined behaviour. .Sh RETURN VALUES Index: sys/kern/subr_pool.c =================================================================== RCS file: /cvs/src/sys/kern/subr_pool.c,v retrieving revision 1.186 diff -u -p -r1.186 subr_pool.c --- sys/kern/subr_pool.c 20 Jul 2015 23:47:20 -0000 1.186 +++ sys/kern/subr_pool.c 23 Jul 2015 12:30:55 -0000 @@ -102,9 +102,6 @@ int pool_debug = 1; int pool_debug = 0; #endif -#define POOL_NEEDS_CATCHUP(pp) \ - ((pp)->pr_nitems < (pp)->pr_minitems) - #define POOL_INPGHDR(pp) ((pp)->pr_phoffset != 0) struct pool_item_header * Index: sys/kern/uipc_mbuf.c =================================================================== RCS file: /cvs/src/sys/kern/uipc_mbuf.c,v retrieving revision 1.206 diff -u -p -r1.206 uipc_mbuf.c --- sys/kern/uipc_mbuf.c 15 Jul 2015 22:29:32 -0000 1.206 +++ sys/kern/uipc_mbuf.c 23 Jul 2015 12:30:55 -0000 @@ -1299,6 +1299,19 @@ ml_dequeue(struct mbuf_list *ml) return (m); } +void +ml_requeue(struct mbuf_list *ml, struct mbuf *m) +{ + if (ml->ml_tail == NULL) + ml->ml_head = ml->ml_tail = m; + else { + m->m_nextpkt = ml->ml_head; + ml->ml_head = m; + } + + ml->ml_len++; +} + struct mbuf * ml_dechain(struct mbuf_list *ml) { @@ -1382,6 +1395,19 @@ mq_dequeue(struct mbuf_queue *mq) mtx_leave(&mq->mq_mtx); return (m); +} + +int +mq_requeue(struct mbuf_queue *mq, struct mbuf *m) +{ + int full; + + mtx_enter(&mq->mq_mtx); + ml_requeue(&mq->mq_list, m); + full = mq_len(mq) > mq->mq_maxlen; + mtx_leave(&mq->mq_mtx); + + return (full); } int Index: sys/sys/mbuf.h =================================================================== RCS file: /cvs/src/sys/sys/mbuf.h,v retrieving revision 1.195 diff -u -p -r1.195 mbuf.h --- sys/sys/mbuf.h 8 Jul 2015 07:21:50 -0000 1.195 +++ sys/sys/mbuf.h 23 Jul 2015 12:30:55 -0000 @@ -482,6 +482,7 @@ struct mbuf_list { void ml_init(struct mbuf_list *); void ml_enqueue(struct mbuf_list *, struct mbuf *); struct mbuf * ml_dequeue(struct mbuf_list *); +void ml_requeue(struct mbuf_list *, struct mbuf *); struct mbuf * ml_dechain(struct mbuf_list *); struct mbuf * ml_filter(struct mbuf_list *, int (*)(void *, const struct mbuf *), void *); @@ -509,6 +510,7 @@ struct mbuf_queue { void mq_init(struct mbuf_queue *, u_int, int); int mq_enqueue(struct mbuf_queue *, struct mbuf *); struct mbuf * mq_dequeue(struct mbuf_queue *); +int mq_requeue(struct mbuf_queue *, struct mbuf *); int mq_enlist(struct mbuf_queue *, struct mbuf_list *); void mq_delist(struct mbuf_queue *, struct mbuf_list *); struct mbuf * mq_dechain(struct mbuf_queue *);