PERFORCE change 55858 for review
Robert Watson
rwatson at FreeBSD.org
Sat Jun 26 20:35:39 GMT 2004
http://perforce.freebsd.org/chv.cgi?CH=55858
Change 55858 by rwatson at rwatson_tislabs on 2004/06/26 20:35:25
Integrate netperf_socket:
- Loop back soabort() comment from rwatson_netperf following CVS
merge.
- Loop back lock coallescing between sbappend/sowakeup and in
related situations.
- Loop back spl removal from tcp usrreq.
Affected files ...
.. //depot/projects/netperf_socket/sys/conf/NOTES#23 integrate
.. //depot/projects/netperf_socket/sys/i386/i386/pmap.c#14 integrate
.. //depot/projects/netperf_socket/sys/kern/imgact_elf.c#8 integrate
.. //depot/projects/netperf_socket/sys/kern/kern_fork.c#11 integrate
.. //depot/projects/netperf_socket/sys/kern/kern_kse.c#3 integrate
.. //depot/projects/netperf_socket/sys/kern/kern_thr.c#7 integrate
.. //depot/projects/netperf_socket/sys/kern/kern_thread.c#16 integrate
.. //depot/projects/netperf_socket/sys/kern/uipc_socket.c#25 integrate
.. //depot/projects/netperf_socket/sys/kern/uipc_socket2.c#21 integrate
.. //depot/projects/netperf_socket/sys/kern/uipc_usrreq.c#17 integrate
.. //depot/projects/netperf_socket/sys/netinet/ip_divert.c#9 integrate
.. //depot/projects/netperf_socket/sys/netinet/ip_mroute.c#8 integrate
.. //depot/projects/netperf_socket/sys/netinet/raw_ip.c#8 integrate
.. //depot/projects/netperf_socket/sys/netinet/tcp_input.c#15 integrate
.. //depot/projects/netperf_socket/sys/netinet/tcp_usrreq.c#10 integrate
.. //depot/projects/netperf_socket/sys/netinet/udp_usrreq.c#8 integrate
.. //depot/projects/netperf_socket/sys/sys/proc.h#14 integrate
.. //depot/projects/netperf_socket/sys/vm/vm_map.h#5 integrate
Differences ...
==== //depot/projects/netperf_socket/sys/conf/NOTES#23 (text+ko) ====
@@ -1,4 +1,4 @@
-# $FreeBSD: src/sys/conf/NOTES,v 1.1233 2004/06/22 22:02:57 bms Exp $
+# $FreeBSD: src/sys/conf/NOTES,v 1.1234 2004/06/26 17:19:44 mpp Exp $
#
# NOTES -- Lines that can be cut/pasted into kernel and hints configs.
#
@@ -95,7 +95,7 @@
#
# BLKDEV_IOSIZE sets the default block size used in user block
-# device I/O. Note that this value will be overriden by the label
+# device I/O. Note that this value will be overridden by the label
# when specifying a block device from a label with a non-0
# partition blocksize. The default is PAGE_SIZE.
#
@@ -184,7 +184,7 @@
# WITNESS enables the witness code which detects deadlocks and cycles
# during locking operations.
# WITNESS_DDB causes the witness code to drop into the kernel debugger if
-# a lock heirarchy violation occurs or if locks are held when going to
+# a lock hierarchy violation occurs or if locks are held when going to
# sleep.
# WITNESS_SKIPSPIN disables the witness checks on spin mutexes.
options MUTEX_DEBUG
@@ -328,7 +328,7 @@
#
# REGRESSION causes optional kernel interfaces necessary only for regression
-# testing to be enabled. These interfaces may consitute security risks
+# testing to be enabled. These interfaces may constitute security risks
# when enabled, as they permit processes to easily modify aspects of the
# run-time environment to reproduce unlikely or unusual (possibly normally
# impossible) scenarios.
@@ -408,7 +408,7 @@
options ALTQ_RIO # RED In/Out
options ALTQ_HFSC # Hierarchical Packet Scheduler
options ALTQ_CDNR # Traffic conditioner
-options ALTQ_PRIQ # Prioirity Queueing
+options ALTQ_PRIQ # Priority Queueing
options ALTQ_NOPCC # Required for SMP build
options ALTQ_DEBUG
@@ -589,7 +589,7 @@
# packets without touching the ttl). This can be useful to hide firewalls
# from traceroute and similar tools.
#
-# PFIL_HOOKS enables an abtraction layer which is meant to be used in
+# PFIL_HOOKS enables an abstraction layer which is meant to be used in
# network code where filtering is required. See pfil(9). This option is
# required by the IPFILTER option and the PF device.
#
@@ -657,7 +657,7 @@
options BRIDGE
# Zero copy sockets support. This enables "zero copy" for sending and
-# receving data via a socket. The send side works for any type of NIC,
+# receiving data via a socket. The send side works for any type of NIC,
# the receive side only works for NICs that support MTUs greater than the
# page size of your architecture and that support header splitting. See
# zero_copy(9) for more details.
@@ -932,8 +932,8 @@
#
# The cd driver drives SCSI Read Only Direct Access ("cd") devices.
#
-# The ses driver drives SCSI Envinronment Services ("ses") and
-# SAF-TE ("SCSI Accessable Fault-Tolerant Enclosure") devices.
+# The ses driver drives SCSI Environment Services ("ses") and
+# SAF-TE ("SCSI Accessible Fault-Tolerant Enclosure") devices.
#
# The pt driver drives SCSI Processor devices.
#
@@ -1554,7 +1554,7 @@
#
# MII bus support is required for some PCI 10/100 ethernet NICs,
# namely those which use MII-compliant transceivers or implement
-# tranceiver control interfaces that operate like an MII. Adding
+# transceiver control interfaces that operate like an MII. Adding
# "device miibus0" to the kernel config pulls in support for
# the generic miibus API and all of the PHY drivers, including a
# generic one for PHYs that aren't specifically handled by an
@@ -1644,7 +1644,7 @@
# Compaq Netelligent 10/100 cards and the built-in ethernet controllers
# in several Compaq Prosignia, Proliant and Deskpro systems. It also
# supports several Olicom 10Mbps and 10/100 boards.
-# tx: SMC 9432 TX, BTX and FTX cards. (SMC EtherPower II serie)
+# tx: SMC 9432 TX, BTX and FTX cards. (SMC EtherPower II series)
# txp: Support for 3Com 3cR990 cards with the "Typhoon" chipset
# vr: Support for various fast ethernet adapters based on the VIA
# Technologies VT3043 `Rhine I' and VT86C100A `Rhine II' chips,
@@ -1800,7 +1800,7 @@
# Gravis UltraSound ISA PnP/non-PnP
# Crystal Semiconductor CS461x/428x PCI
# Neomagic 256AV (ac97)
-# Most of the more common ISA/PnP sb/mss/ess compatable cards.
+# Most of the more common ISA/PnP sb/mss/ess compatible cards.
device pcm
@@ -1919,7 +1919,7 @@
# options BROOKTREE_SYSTEM_DEFAULT=BROOKTREE_PAL
# or
# options BROOKTREE_SYSTEM_DEFAULT=BROOKTREE_NTSC
-# Specifes the default video capture mode.
+# Specifies the default video capture mode.
# This is required for Dual Crystal (28&35Mhz) boards where PAL is used
# to prevent hangs during initialisation. eg VideoLogic Captivator PCI.
#
@@ -2224,12 +2224,12 @@
makeoptions UKBD_DFLT_KEYMAP=it.iso
# options for uplcom:
-options UPLCOM_INTR_INTERVAL=100 # interrpt pipe interval
+options UPLCOM_INTR_INTERVAL=100 # interrupt pipe interval
# in milliseconds
# options for uvscom:
options UVSCOM_DEFAULT_OPKTSIZE=8 # default output packet size
-options UVSCOM_INTR_INTERVAL=100 # interrpt pipe interval
+options UVSCOM_INTR_INTERVAL=100 # interrupt pipe interval
# in milliseconds
#####################################################################
==== //depot/projects/netperf_socket/sys/i386/i386/pmap.c#14 (text+ko) ====
@@ -73,7 +73,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i386/i386/pmap.c,v 1.477 2004/06/22 19:35:43 alc Exp $");
+__FBSDID("$FreeBSD: src/sys/i386/i386/pmap.c,v 1.478 2004/06/26 19:10:12 alc Exp $");
/*
* Manages physical address maps.
@@ -878,12 +878,14 @@
vm_page_hold(m);
}
} else {
+ sched_pin();
pte = *pmap_pte_quick(pmap, va);
if (pte != 0 &&
((pte & PG_RW) || (prot & VM_PROT_WRITE) == 0)) {
m = PHYS_TO_VM_PAGE(pte & PG_FRAME);
vm_page_hold(m);
}
+ sched_unpin();
}
}
vm_page_unlock_queues();
==== //depot/projects/netperf_socket/sys/kern/imgact_elf.c#8 (text+ko) ====
@@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/imgact_elf.c,v 1.151 2004/06/05 02:18:28 tjr Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/imgact_elf.c,v 1.152 2004/06/26 18:58:22 marcel Exp $");
#include <sys/param.h>
#include <sys/exec.h>
@@ -910,10 +910,10 @@
static void cb_put_phdr(vm_map_entry_t, void *);
static void cb_size_segment(vm_map_entry_t, void *);
-static void each_writable_segment(struct proc *, segment_callback, void *);
+static void each_writable_segment(struct thread *, segment_callback, void *);
static int __elfN(corehdr)(struct thread *, struct vnode *, struct ucred *,
int, void *, size_t);
-static void __elfN(puthdr)(struct proc *, void *, size_t *, int);
+static void __elfN(puthdr)(struct thread *, void *, size_t *, int);
static void __elfN(putnote)(void *, size_t *, const char *, int,
const void *, size_t);
@@ -922,11 +922,10 @@
int
__elfN(coredump)(td, vp, limit)
struct thread *td;
- register struct vnode *vp;
+ struct vnode *vp;
off_t limit;
{
- register struct proc *p = td->td_proc;
- register struct ucred *cred = td->td_ucred;
+ struct ucred *cred = td->td_ucred;
int error = 0;
struct sseg_closure seginfo;
void *hdr;
@@ -935,7 +934,7 @@
/* Size the program segments. */
seginfo.count = 0;
seginfo.size = 0;
- each_writable_segment(p, cb_size_segment, &seginfo);
+ each_writable_segment(td, cb_size_segment, &seginfo);
/*
* Calculate the size of the core file header area by making
@@ -943,7 +942,7 @@
* size is calculated.
*/
hdrsize = 0;
- __elfN(puthdr)(p, (void *)NULL, &hdrsize, seginfo.count);
+ __elfN(puthdr)(td, (void *)NULL, &hdrsize, seginfo.count);
if (hdrsize + seginfo.size >= limit)
return (EFAULT);
@@ -1036,11 +1035,12 @@
* caller-supplied data.
*/
static void
-each_writable_segment(p, func, closure)
- struct proc *p;
+each_writable_segment(td, func, closure)
+ struct thread *td;
segment_callback func;
void *closure;
{
+ struct proc *p = td->td_proc;
vm_map_t map = &p->p_vmspace->vm_map;
vm_map_entry_t entry;
@@ -1103,13 +1103,12 @@
size_t hdrsize;
void *hdr;
{
- struct proc *p = td->td_proc;
size_t off;
/* Fill in the header. */
bzero(hdr, hdrsize);
off = 0;
- __elfN(puthdr)(p, hdr, &off, numsegs);
+ __elfN(puthdr)(td, hdr, &off, numsegs);
/* Write it to the core file. */
return (vn_rdwr_inchunks(UIO_WRITE, vp, hdr, hdrsize, (off_t)0,
@@ -1118,7 +1117,7 @@
}
static void
-__elfN(puthdr)(struct proc *p, void *dst, size_t *off, int numsegs)
+__elfN(puthdr)(struct thread *td, void *dst, size_t *off, int numsegs)
{
struct {
prstatus_t status;
@@ -1128,9 +1127,12 @@
prstatus_t *status;
prfpregset_t *fpregset;
prpsinfo_t *psinfo;
- struct thread *first, *thr;
+ struct proc *p;
+ struct thread *thr;
size_t ehoff, noteoff, notesz, phoff;
+ p = td->td_proc;
+
ehoff = *off;
*off += sizeof(Elf_Ehdr);
@@ -1169,22 +1171,16 @@
sizeof *psinfo);
/*
- * We want to start with the registers of the initial thread in the
- * process so that the .reg and .reg2 pseudo-sections created by bfd
- * will be identical to the .reg/$PID and .reg2/$PID pseudo-sections.
- * This makes sure that any tool that only looks for .reg and .reg2
- * and not for .reg/$PID and .reg2/$PID will behave the same as
- * before. The first thread is the thread with an ID equal to the
- * process' ID.
- * Note that the initial thread may already be gone. In that case
- * 'first' is NULL.
+ * For backward compatibility, we dump the registers of the current
+ * thread (as passed to us in td) first and set pr_pid to the PID of
+ * the process. We then dump the other threads, but with pr_pid set
+ * to the TID of the thread itself. This has two advantages:
+ * 1) We preserve the meaning of pr_pid for as much as is possible.
+ * 2) The debugger will select the current thread as its initial
+ * "thread", which is likely what we want.
*/
- thr = first = TAILQ_FIRST(&p->p_threads);
- while (first != NULL && first->td_tid > PID_MAX)
- first = TAILQ_NEXT(first, td_plist);
- if (first != NULL)
- thr = first;
- do {
+ thr = td;
+ while (thr != NULL) {
if (dst != NULL) {
status->pr_version = PRSTATUS_VERSION;
status->pr_statussz = sizeof(prstatus_t);
@@ -1192,7 +1188,7 @@
status->pr_fpregsetsz = sizeof(fpregset_t);
status->pr_osreldate = osreldate;
status->pr_cursig = p->p_sig;
- status->pr_pid = thr->td_tid;
+ status->pr_pid = (thr == td) ? p->p_pid : thr->td_tid;
fill_regs(thr, &status->pr_reg);
fill_fpregs(thr, fpregset);
}
@@ -1200,12 +1196,14 @@
sizeof *status);
__elfN(putnote)(dst, off, "FreeBSD", NT_FPREGSET, fpregset,
sizeof *fpregset);
+
/* XXX allow for MD specific notes. */
- thr = (thr == first) ? TAILQ_FIRST(&p->p_threads) :
+
+ thr = (thr == td) ? TAILQ_FIRST(&p->p_threads) :
TAILQ_NEXT(thr, td_plist);
- if (thr == first && thr != NULL)
+ if (thr == td)
thr = TAILQ_NEXT(thr, td_plist);
- } while (thr != NULL);
+ }
notesz = *off - noteoff;
@@ -1266,7 +1264,7 @@
/* All the writable segments from the program. */
phc.phdr = phdr;
phc.offset = *off;
- each_writable_segment(p, cb_put_phdr, &phc);
+ each_writable_segment(td, cb_put_phdr, &phc);
}
}
==== //depot/projects/netperf_socket/sys/kern/kern_fork.c#11 (text+ko) ====
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/kern_fork.c,v 1.226 2004/04/05 21:03:34 imp Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/kern_fork.c,v 1.227 2004/06/26 18:58:22 marcel Exp $");
#include "opt_ktrace.h"
#include "opt_mac.h"
@@ -493,7 +493,6 @@
(unsigned) RANGEOF(struct ksegrp, kg_startcopy, kg_endcopy));
#undef RANGEOF
- td2->td_tid = p2->p_pid;
td2->td_sigstk = td->td_sigstk;
/* Set up the thread as an active thread (as if runnable). */
==== //depot/projects/netperf_socket/sys/kern/kern_kse.c#3 (text+ko) ====
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/kern_kse.c,v 1.181 2004/06/11 17:48:20 julian Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/kern_kse.c,v 1.182 2004/06/26 18:58:22 marcel Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -872,10 +872,8 @@
if (td->td_standin)
return;
- if (spare == NULL) {
+ if (spare == NULL)
spare = thread_alloc();
- spare->td_tid = thread_new_tid();
- }
td->td_standin = spare;
bzero(&spare->td_startzero,
(unsigned)RANGEOF(struct thread, td_startzero, td_endzero));
==== //depot/projects/netperf_socket/sys/kern/kern_thr.c#7 (text+ko) ====
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/kern_thr.c,v 1.19 2004/04/19 14:20:01 mtm Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/kern_thr.c,v 1.20 2004/06/26 18:58:22 marcel Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -130,7 +130,6 @@
/* Initialize our td. */
td0 = thread_alloc();
- td0->td_tid = thread_new_tid();
/*
* Try the copyout as soon as we allocate the td so we don't have to
==== //depot/projects/netperf_socket/sys/kern/kern_thread.c#16 (text+ko) ====
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/kern_thread.c,v 1.184 2004/06/21 20:44:02 julian Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/kern_thread.c,v 1.185 2004/06/26 18:58:22 marcel Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -149,7 +149,6 @@
struct thread *td;
td = (struct thread *)mem;
- td->td_tid = 0;
td->td_state = TDS_INACTIVE;
td->td_oncpu = NOCPU;
@@ -175,28 +174,9 @@
thread_dtor(void *mem, int size, void *arg)
{
struct thread *td;
- struct tid_bitmap_part *bmp;
- lwpid_t tid;
- int bit, idx;
td = (struct thread *)mem;
- if (td->td_tid > PID_MAX) {
- STAILQ_FOREACH(bmp, &tid_bitmap, bmp_next) {
- if (td->td_tid >= bmp->bmp_base &&
- td->td_tid < bmp->bmp_base + TID_IDS_PER_PART)
- break;
- }
- KASSERT(bmp != NULL, ("No TID bitmap?"));
- mtx_lock(&tid_lock);
- tid = td->td_tid - bmp->bmp_base;
- idx = tid / TID_IDS_PER_IDX;
- bit = 1UL << (tid % TID_IDS_PER_IDX);
- bmp->bmp_bitmap[idx] |= bit;
- bmp->bmp_free++;
- mtx_unlock(&tid_lock);
- }
-
#ifdef INVARIANTS
/* Verify that this thread is in a safe state to free. */
switch (td->td_state) {
@@ -225,9 +205,47 @@
static void
thread_init(void *mem, int size)
{
- struct thread *td;
+ struct thread *td;
+ struct tid_bitmap_part *bmp, *new;
+ int bit, idx;
td = (struct thread *)mem;
+
+ mtx_lock(&tid_lock);
+ STAILQ_FOREACH(bmp, &tid_bitmap, bmp_next) {
+ if (bmp->bmp_free)
+ break;
+ }
+ /* Create a new bitmap if we run out of free bits. */
+ if (bmp == NULL) {
+ mtx_unlock(&tid_lock);
+ new = uma_zalloc(tid_zone, M_WAITOK);
+ mtx_lock(&tid_lock);
+ bmp = STAILQ_LAST(&tid_bitmap, tid_bitmap_part, bmp_next);
+ if (bmp == NULL || bmp->bmp_free < TID_IDS_PER_PART/2) {
+ /* 1=free, 0=assigned. This way we can use ffsl(). */
+ memset(new->bmp_bitmap, ~0U, sizeof(new->bmp_bitmap));
+ new->bmp_base = (bmp == NULL) ? TID_MIN :
+ bmp->bmp_base + TID_IDS_PER_PART;
+ new->bmp_free = TID_IDS_PER_PART;
+ STAILQ_INSERT_TAIL(&tid_bitmap, new, bmp_next);
+ bmp = new;
+ new = NULL;
+ }
+ } else
+ new = NULL;
+ /* We have a bitmap with available IDs. */
+ idx = 0;
+ while (idx < TID_BITMAP_SIZE && bmp->bmp_bitmap[idx] == 0UL)
+ idx++;
+ bit = ffsl(bmp->bmp_bitmap[idx]) - 1;
+ td->td_tid = bmp->bmp_base + idx * TID_IDS_PER_IDX + bit;
+ bmp->bmp_bitmap[idx] &= ~(1UL << bit);
+ bmp->bmp_free--;
+ mtx_unlock(&tid_lock);
+ if (new != NULL)
+ uma_zfree(tid_zone, new);
+
vm_thread_new(td, 0);
cpu_thread_setup(td);
td->td_sleepqueue = sleepq_alloc();
@@ -241,12 +259,29 @@
static void
thread_fini(void *mem, int size)
{
- struct thread *td;
+ struct thread *td;
+ struct tid_bitmap_part *bmp;
+ lwpid_t tid;
+ int bit, idx;
td = (struct thread *)mem;
turnstile_free(td->td_turnstile);
sleepq_free(td->td_sleepqueue);
vm_thread_dispose(td);
+
+ STAILQ_FOREACH(bmp, &tid_bitmap, bmp_next) {
+ if (td->td_tid >= bmp->bmp_base &&
+ td->td_tid < bmp->bmp_base + TID_IDS_PER_PART)
+ break;
+ }
+ KASSERT(bmp != NULL, ("No TID bitmap?"));
+ mtx_lock(&tid_lock);
+ tid = td->td_tid - bmp->bmp_base;
+ idx = tid / TID_IDS_PER_IDX;
+ bit = 1UL << (tid % TID_IDS_PER_IDX);
+ bmp->bmp_bitmap[idx] |= bit;
+ bmp->bmp_free++;
+ mtx_unlock(&tid_lock);
}
/*
@@ -536,55 +571,6 @@
}
/*
- * Assign a thread ID.
- */
-lwpid_t
-thread_new_tid(void)
-{
- struct tid_bitmap_part *bmp, *new;
- lwpid_t tid;
- int bit, idx;
-
- mtx_lock(&tid_lock);
- STAILQ_FOREACH(bmp, &tid_bitmap, bmp_next) {
- if (bmp->bmp_free)
- break;
- }
- /* Create a new bitmap if we run out of free bits. */
- if (bmp == NULL) {
- mtx_unlock(&tid_lock);
- new = uma_zalloc(tid_zone, M_WAITOK);
- mtx_lock(&tid_lock);
- bmp = STAILQ_LAST(&tid_bitmap, tid_bitmap_part, bmp_next);
- if (bmp == NULL || bmp->bmp_free < TID_IDS_PER_PART/2) {
- /* 1=free, 0=assigned. This way we can use ffsl(). */
- memset(new->bmp_bitmap, ~0U, sizeof(new->bmp_bitmap));
- new->bmp_base = (bmp == NULL) ? TID_MIN :
- bmp->bmp_base + TID_IDS_PER_PART;
- new->bmp_free = TID_IDS_PER_PART;
- STAILQ_INSERT_TAIL(&tid_bitmap, new, bmp_next);
- bmp = new;
- new = NULL;
- }
- } else
- new = NULL;
- /* We have a bitmap with available IDs. */
- idx = 0;
- while (idx < TID_BITMAP_SIZE && bmp->bmp_bitmap[idx] == 0UL)
- idx++;
- bit = ffsl(bmp->bmp_bitmap[idx]) - 1;
- tid = bmp->bmp_base + idx * TID_IDS_PER_IDX + bit;
- bmp->bmp_bitmap[idx] &= ~(1UL << bit);
- bmp->bmp_free--;
- mtx_unlock(&tid_lock);
-
- if (new != NULL)
- uma_zfree(tid_zone, new);
- return (tid);
-}
-
-
-/*
* Discard the current thread and exit from its context.
* Always called with scheduler locked.
*
==== //depot/projects/netperf_socket/sys/kern/uipc_socket.c#25 (text+ko) ====
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/uipc_socket.c,v 1.189 2004/06/24 04:28:30 rwatson Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/uipc_socket.c,v 1.190 2004/06/26 17:12:29 rwatson Exp $");
#include "opt_inet.h"
#include "opt_mac.h"
@@ -432,7 +432,10 @@
}
/*
- * Must be called at splnet...
+ * soabort() must not be called with any socket locks held, as it calls
+ * into the protocol, which will call back into the socket code causing
+ * it to acquire additional socket locks that may cause recursion or lock
+ * order reversals.
*/
int
soabort(so)
==== //depot/projects/netperf_socket/sys/kern/uipc_socket2.c#21 (text+ko) ====
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/uipc_socket2.c,v 1.135 2004/06/24 01:37:03 rwatson Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/uipc_socket2.c,v 1.136 2004/06/26 19:10:38 rwatson Exp $");
#include "opt_mac.h"
#include "opt_param.h"
@@ -171,13 +171,11 @@
SOCK_UNLOCK(so);
SOCKBUF_LOCK(&so->so_rcv);
so->so_rcv.sb_state |= SBS_CANTRCVMORE;
- SOCKBUF_UNLOCK(&so->so_rcv);
+ sorwakeup_locked(so);
SOCKBUF_LOCK(&so->so_snd);
so->so_snd.sb_state |= SBS_CANTSENDMORE;
- SOCKBUF_UNLOCK(&so->so_snd);
+ sowwakeup_locked(so);
wakeup(&so->so_timeo);
- sowwakeup(so);
- sorwakeup(so);
}
void
@@ -190,20 +188,19 @@
* SOCKBUF_LOCK(&so->so_rcv) even though they are the same mutex to
* avoid introducing the assumption that they are the same.
*/
+ /* XXXRW: so_state locking? */
SOCK_LOCK(so);
so->so_state &= ~(SS_ISCONNECTING|SS_ISCONNECTED|SS_ISDISCONNECTING);
so->so_state |= SS_ISDISCONNECTED;
SOCK_UNLOCK(so);
SOCKBUF_LOCK(&so->so_rcv);
so->so_rcv.sb_state |= SBS_CANTRCVMORE;
- SOCKBUF_UNLOCK(&so->so_rcv);
+ sorwakeup_locked(so);
SOCKBUF_LOCK(&so->so_snd);
so->so_snd.sb_state |= SBS_CANTSENDMORE;
sbdrop_locked(&so->so_snd, so->so_snd.sb_cc);
- SOCKBUF_UNLOCK(&so->so_snd);
+ sowwakeup_locked(so);
wakeup(&so->so_timeo);
- sowwakeup(so);
- sorwakeup(so);
}
/*
==== //depot/projects/netperf_socket/sys/kern/uipc_usrreq.c#17 (text+ko) ====
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/uipc_usrreq.c,v 1.130 2004/06/25 20:12:06 rwatson Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/uipc_usrreq.c,v 1.131 2004/06/26 19:10:38 rwatson Exp $");
#include "opt_mac.h"
@@ -302,8 +302,7 @@
newhiwat, RLIM_INFINITY);
unp->unp_cc = so->so_rcv.sb_cc;
SOCKBUF_UNLOCK(&so->so_rcv);
- SOCKBUF_UNLOCK(&so2->so_snd);
- sowwakeup(so2);
+ sowwakeup_locked(so2);
break;
default:
@@ -371,8 +370,7 @@
from = &sun_noname;
SOCKBUF_LOCK(&so2->so_rcv);
if (sbappendaddr_locked(&so2->so_rcv, from, m, control)) {
- SOCKBUF_UNLOCK(&so2->so_rcv);
- sorwakeup(so2);
+ sorwakeup_locked(so2);
m = NULL;
control = NULL;
} else {
@@ -431,8 +429,7 @@
(void)chgsbsize(so->so_cred->cr_uidinfo, &so->so_snd.sb_hiwat,
newhiwat, RLIM_INFINITY);
unp->unp_conn->unp_cc = so2->so_rcv.sb_cc;
- SOCKBUF_UNLOCK(&so2->so_rcv);
- sorwakeup(so2);
+ sorwakeup_locked(so2);
m = NULL;
break;
==== //depot/projects/netperf_socket/sys/netinet/ip_divert.c#9 (text+ko) ====
@@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: src/sys/netinet/ip_divert.c,v 1.92 2004/06/22 04:00:51 rwatson Exp $
+ * $FreeBSD: src/sys/netinet/ip_divert.c,v 1.93 2004/06/26 19:10:38 rwatson Exp $
*/
#include "opt_inet.h"
@@ -228,12 +228,14 @@
/* XXX why does only one socket match? */
if (inp->inp_lport == nport) {
sa = inp->inp_socket;
- if (sbappendaddr(&sa->so_rcv,
+ SOCKBUF_LOCK(&sa->so_rcv);
+ if (sbappendaddr_locked(&sa->so_rcv,
(struct sockaddr *)&divsrc, m,
- (struct mbuf *)0) == 0)
+ (struct mbuf *)0) == 0) {
sa = NULL; /* force mbuf reclaim below */
- else
- sorwakeup(sa);
+ SOCKBUF_UNLOCK(&sa->so_rcv);
+ } else
+ sorwakeup_locked(sa);
INP_UNLOCK(inp);
break;
}
==== //depot/projects/netperf_socket/sys/netinet/ip_mroute.c#8 (text+ko) ====
@@ -17,7 +17,7 @@
* and PIM-SMv2 and PIM-DM support, advanced API support,
* bandwidth metering and signaling
*
- * $FreeBSD: src/sys/netinet/ip_mroute.c,v 1.101 2004/06/24 02:01:48 rwatson Exp $
+ * $FreeBSD: src/sys/netinet/ip_mroute.c,v 1.102 2004/06/26 19:10:38 rwatson Exp $
*/
#include "opt_mac.h"
@@ -1307,10 +1307,13 @@
socket_send(struct socket *s, struct mbuf *mm, struct sockaddr_in *src)
{
if (s) {
- if (sbappendaddr(&s->so_rcv, (struct sockaddr *)src, mm, NULL) != 0) {
- sorwakeup(s);
+ SOCKBUF_LOCK(&s->so_rcv);
+ if (sbappendaddr_locked(&s->so_rcv, (struct sockaddr *)src, mm,
+ NULL) != 0) {
+ sorwakeup_locked(s);
return 0;
}
+ SOCKBUF_UNLOCK(&s->so_rcv);
}
m_freem(mm);
return -1;
==== //depot/projects/netperf_socket/sys/netinet/raw_ip.c#8 (text+ko) ====
@@ -27,7 +27,7 @@
* SUCH DAMAGE.
*
* @(#)raw_ip.c 8.7 (Berkeley) 5/15/95
- * $FreeBSD: src/sys/netinet/raw_ip.c,v 1.134 2004/06/09 20:10:38 ru Exp $
+ * $FreeBSD: src/sys/netinet/raw_ip.c,v 1.135 2004/06/26 19:10:39 rwatson Exp $
*/
#include "opt_inet6.h"
@@ -160,18 +160,22 @@
#endif
if (!policyfail) {
struct mbuf *opts = NULL;
+ struct socket *so;
+ so = last->inp_socket;
if ((last->inp_flags & INP_CONTROLOPTS) ||
- (last->inp_socket->so_options & SO_TIMESTAMP))
+ (so->so_options & SO_TIMESTAMP))
ip_savecontrol(last, &opts, ip, n);
- if (sbappendaddr(&last->inp_socket->so_rcv,
+ SOCKBUF_LOCK(&so->so_rcv);
+ if (sbappendaddr_locked(&so->so_rcv,
(struct sockaddr *)&ripsrc, n, opts) == 0) {
/* should notify about lost packet */
m_freem(n);
if (opts)
m_freem(opts);
+ SOCKBUF_UNLOCK(&so->so_rcv);
} else
- sorwakeup(last->inp_socket);
+ sorwakeup_locked(so);
} else
m_freem(n);
return policyfail;
==== //depot/projects/netperf_socket/sys/netinet/tcp_input.c#15 (text+ko) ====
@@ -27,7 +27,7 @@
* SUCH DAMAGE.
*
* @(#)tcp_input.c 8.12 (Berkeley) 5/24/95
- * $FreeBSD: src/sys/netinet/tcp_input.c,v 1.247 2004/06/25 04:11:26 ps Exp $
+ * $FreeBSD: src/sys/netinet/tcp_input.c,v 1.248 2004/06/26 19:10:39 rwatson Exp $
*/
#include "opt_ipfw.h" /* for ipfw_fwd */
@@ -353,22 +353,24 @@
q = LIST_FIRST(&tp->t_segq);
if (!q || q->tqe_th->th_seq != tp->rcv_nxt)
return (0);
+ SOCKBUF_LOCK(&so->so_rcv);
do {
tp->rcv_nxt += q->tqe_len;
flags = q->tqe_th->th_flags & TH_FIN;
nq = LIST_NEXT(q, tqe_q);
LIST_REMOVE(q, tqe_q);
+ /* Unlocked read. */
if (so->so_rcv.sb_state & SBS_CANTRCVMORE)
m_freem(q->tqe_m);
else
- sbappendstream(&so->so_rcv, q->tqe_m);
+ sbappendstream_locked(&so->so_rcv, q->tqe_m);
uma_zfree(tcp_reass_zone, q);
tp->t_segqlen--;
tcp_reass_qsize--;
q = nq;
} while (q && q->tqe_th->th_seq == tp->rcv_nxt);
ND6_HINT(tp);
- sorwakeup(so);
+ sorwakeup_locked(so);
return (flags);
}
@@ -1264,13 +1266,15 @@
#endif
* Add data to socket buffer.
*/
+ /* Unlocked read. */
+ SOCKBUF_LOCK(&so->so_rcv);
if (so->so_rcv.sb_state & SBS_CANTRCVMORE) {
m_freem(m);
} else {
m_adj(m, drop_hdrlen); /* delayed header drop */
- sbappendstream(&so->so_rcv, m);
+ sbappendstream_locked(&so->so_rcv, m);
}
- sorwakeup(so);
+ sorwakeup_locked(so);
if (DELAY_ACK(tp)) {
tp->t_flags |= TF_DELACK;
} else {
@@ -2155,8 +2159,7 @@
tp->snd_wnd -= acked;
ourfinisacked = 0;
}
- SOCKBUF_UNLOCK(&so->so_snd);
- sowwakeup(so);
+ sowwakeup_locked(so);
/* detect una wraparound */
if ((tcp_do_newreno || tp->sack_enable) &&
!IN_FASTRECOVERY(tp) &&
@@ -2365,11 +2368,13 @@
tcpstat.tcps_rcvpack++;
tcpstat.tcps_rcvbyte += tlen;
ND6_HINT(tp);
+ /* Unlocked read. */
+ SOCKBUF_LOCK(&so->so_rcv);
if (so->so_rcv.sb_state & SBS_CANTRCVMORE)
m_freem(m);
else
- sbappendstream(&so->so_rcv, m);
- sorwakeup(so);
+ sbappendstream_locked(&so->so_rcv, m);
+ sorwakeup_locked(so);
} else {
thflags = tcp_reass(tp, th, &tlen, m);
tp->t_flags |= TF_ACKNOW;
==== //depot/projects/netperf_socket/sys/netinet/tcp_usrreq.c#10 (text+ko) ====
@@ -27,7 +27,7 @@
* SUCH DAMAGE.
*
* From: @(#)tcp_usrreq.c 8.2 (Berkeley) 1/3/94
- * $FreeBSD: src/sys/netinet/tcp_usrreq.c,v 1.102 2004/06/18 20:22:21 rwatson Exp $
+ * $FreeBSD: src/sys/netinet/tcp_usrreq.c,v 1.103 2004/06/26 17:50:50 rwatson Exp $
*/
#include "opt_ipsec.h"
==== //depot/projects/netperf_socket/sys/netinet/udp_usrreq.c#8 (text+ko) ====
@@ -27,7 +27,7 @@
* SUCH DAMAGE.
*
* @(#)udp_usrreq.c 8.6 (Berkeley) 5/23/95
- * $FreeBSD: src/sys/netinet/udp_usrreq.c,v 1.155 2004/06/16 08:50:14 bms Exp $
+ * $FreeBSD: src/sys/netinet/udp_usrreq.c,v 1.156 2004/06/26 19:10:39 rwatson Exp $
*/
#include "opt_ipsec.h"
@@ -447,6 +447,7 @@
int off;
{
struct sockaddr *append_sa;
+ struct socket *so;
struct mbuf *opts = 0;
INP_LOCK_ASSERT(last);
@@ -496,13 +497,17 @@
#endif
append_sa = (struct sockaddr *)&udp_in;
m_adj(n, off);
- if (sbappendaddr(&last->inp_socket->so_rcv, append_sa, n, opts) == 0) {
+
+ so = last->inp_socket;
+ SOCKBUF_LOCK(&so->so_rcv);
+ if (sbappendaddr_locked(&so->so_rcv, append_sa, n, opts) == 0) {
m_freem(n);
if (opts)
m_freem(opts);
udpstat.udps_fullsock++;
+ SOCKBUF_UNLOCK(&so->so_rcv);
} else
- sorwakeup(last->inp_socket);
+ sorwakeup_locked(so);
}
/*
==== //depot/projects/netperf_socket/sys/sys/proc.h#14 (text+ko) ====
@@ -32,7 +32,7 @@
* SUCH DAMAGE.
*
* @(#)proc.h 8.15 (Berkeley) 5/19/95
- * $FreeBSD: src/sys/sys/proc.h,v 1.381 2004/06/19 17:58:32 marcel Exp $
+ * $FreeBSD: src/sys/sys/proc.h,v 1.382 2004/06/26 18:58:22 marcel Exp $
*/
#ifndef _SYS_PROC_H_
@@ -903,7 +903,6 @@
int thread_export_context(struct thread *td, int willexit);
void thread_free(struct thread *td);
void thread_link(struct thread *td, struct ksegrp *kg);
-lwpid_t thread_new_tid(void);
void thread_reap(void);
struct thread *thread_schedule_upcall(struct thread *td, struct kse_upcall *ku);
int thread_single(int how);
==== //depot/projects/netperf_socket/sys/vm/vm_map.h#5 (text+ko) ====
@@ -57,7 +57,7 @@
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*
- * $FreeBSD: src/sys/vm/vm_map.h,v 1.109 2004/04/24 03:46:44 alc Exp $
+ * $FreeBSD: src/sys/vm/vm_map.h,v 1.110 2004/06/26 19:16:35 alc Exp $
*/
/*
@@ -223,8 +223,7 @@
int vm_refcnt; /* number of references */
struct shmmap_state *vm_shm; /* SYS5 shared memory private data XXX */
/* we copy between vm_startcopy and vm_endcopy on fork */
-#define vm_startcopy vm_rssize
- segsz_t vm_rssize; /* current resident set size in pages */
+#define vm_startcopy vm_swrss
>>> TRUNCATED FOR MAIL (1000 lines) <<<
More information about the p4-projects
mailing list