Apply a similar patch as what was just applied to sk(4):

> Use a mutex instead of splvm() to protect the list of jubo-ready mbufs, as
> done with nfe(4) a while ago.
>
> Issue reported by Gary Duzan, who kindly fixed the patch I had sent him.

Lars Nordlund noted that such a change made things a lot better with his
msk(4).
This commit is contained in:
cube 2008-06-20 16:45:13 +00:00
parent 0ec953c973
commit aa5a552a2f
2 changed files with 15 additions and 8 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_msk.c,v 1.20 2008/05/28 16:20:17 joerg Exp $ */
/* $NetBSD: if_msk.c,v 1.21 2008/06/20 16:45:13 cube Exp $ */
/* $OpenBSD: if_msk.c,v 1.42 2007/01/17 02:43:02 krw Exp $ */
/*
@ -52,7 +52,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_msk.c,v 1.20 2008/05/28 16:20:17 joerg Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_msk.c,v 1.21 2008/06/20 16:45:13 cube Exp $");
#include "bpfilter.h"
#include "rnd.h"
@ -62,6 +62,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_msk.c,v 1.20 2008/05/28 16:20:17 joerg Exp $");
#include <sys/sockio.h>
#include <sys/mbuf.h>
#include <sys/malloc.h>
#include <sys/mutex.h>
#include <sys/kernel.h>
#include <sys/socket.h>
#include <sys/device.h>
@ -590,6 +591,7 @@ msk_alloc_jumbo_mem(struct sk_if_softc *sc_if)
LIST_INIT(&sc_if->sk_jfree_listhead);
LIST_INIT(&sc_if->sk_jinuse_listhead);
mutex_init(&sc_if->sk_jpool_mtx, MUTEX_DEFAULT, IPL_NET);
/*
* Now divide it up into 9K pieces and save the addresses
@ -641,13 +643,17 @@ msk_jalloc(struct sk_if_softc *sc_if)
{
struct sk_jpool_entry *entry;
mutex_enter(&sc_if->sk_jpool_mtx);
entry = LIST_FIRST(&sc_if->sk_jfree_listhead);
if (entry == NULL)
return (NULL);
if (entry == NULL) {
mutex_exit(&sc_if->sk_jpool_mtx);
return NULL;
}
LIST_REMOVE(entry, jpool_entries);
LIST_INSERT_HEAD(&sc_if->sk_jinuse_listhead, entry, jpool_entries);
mutex_exit(&sc_if->sk_jpool_mtx);
return (sc_if->sk_cdata.sk_jslots[entry->slot]);
}
@ -659,7 +665,7 @@ msk_jfree(struct mbuf *m, void *buf, size_t size, void *arg)
{
struct sk_jpool_entry *entry;
struct sk_if_softc *sc;
int i, s;
int i;
/* Extract the softc struct pointer. */
sc = (struct sk_if_softc *)arg;
@ -674,17 +680,17 @@ msk_jfree(struct mbuf *m, void *buf, size_t size, void *arg)
if ((i < 0) || (i >= MSK_JSLOTS))
panic("msk_jfree: asked to free buffer that we don't manage!");
s = splvm();
mutex_enter(&sc->sk_jpool_mtx);
entry = LIST_FIRST(&sc->sk_jinuse_listhead);
if (entry == NULL)
panic("msk_jfree: buffer not in use!");
entry->slot = i;
LIST_REMOVE(entry, jpool_entries);
LIST_INSERT_HEAD(&sc->sk_jfree_listhead, entry, jpool_entries);
mutex_exit(&sc->sk_jpool_mtx);
if (__predict_true(m != NULL))
pool_cache_put(mb_cache, m);
splx(s);
}
int

View File

@ -1,5 +1,5 @@
/* $OpenBSD: if_mskvar.h,v 1.3 2006/12/28 16:34:42 kettenis Exp $ */
/* $NetBSD: if_mskvar.h,v 1.6 2008/04/28 20:23:55 martin Exp $ */
/* $NetBSD: if_mskvar.h,v 1.7 2008/06/20 16:45:13 cube Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@ -234,6 +234,7 @@ struct sk_if_softc {
int sk_status_idx;
struct sk_softc *sk_softc; /* parent controller */
int sk_if_flags;
kmutex_t sk_jpool_mtx;
LIST_HEAD(__sk_jfreehead, sk_jpool_entry) sk_jfree_listhead;
LIST_HEAD(__sk_jinusehead, sk_jpool_entry) sk_jinuse_listhead;
SIMPLEQ_HEAD(__sk_txmaphead, sk_txmap_entry) sk_txmap_head;