svn commit: r232147 - head/sys/dev/wi

2012-02-25 Thread Adrian Chadd
Author: adrian
Date: Sat Feb 25 08:01:29 2012
New Revision: 232147
URL: http://svn.freebsd.org/changeset/base/232147

Log:
  If an interrupt is received with no vap attached, just fail LINK events.
  
  This fixes a NULL pointer dereference which occurs if the vap list is
  empty but someone brings up the wi0 interface.

Modified:
  head/sys/dev/wi/if_wi.c

Modified: head/sys/dev/wi/if_wi.c
==
--- head/sys/dev/wi/if_wi.c Sat Feb 25 07:58:59 2012(r232146)
+++ head/sys/dev/wi/if_wi.c Sat Feb 25 08:01:29 2012(r232147)
@@ -1511,6 +1511,10 @@ wi_info_intr(struct wi_softc *sc)
case WI_INFO_LINK_STAT:
wi_read_bap(sc, fid, sizeof(ltbuf), &stat, sizeof(stat));
DPRINTF(("wi_info_intr: LINK_STAT 0x%x\n", le16toh(stat)));
+
+   if (vap == NULL)
+   goto finish;
+
switch (le16toh(stat)) {
case WI_INFO_LINK_STAT_CONNECTED:
if (vap->iv_state == IEEE80211_S_RUN &&
@@ -1566,6 +1570,7 @@ wi_info_intr(struct wi_softc *sc)
le16toh(ltbuf[1]), le16toh(ltbuf[0])));
break;
}
+finish:
CSR_WRITE_2(sc, WI_EVENT_ACK, WI_EV_INFO);
 }
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r232152 - in head/sys: kern sys

2012-02-25 Thread Mikolaj Golub
Author: trociny
Date: Sat Feb 25 10:15:41 2012
New Revision: 232152
URL: http://svn.freebsd.org/changeset/base/232152

Log:
  When detaching an unix domain socket, uipc_detach() checks
  unp->unp_vnode pointer to detect if there is a vnode associated with
  (binded to) this socket and does necessary cleanup if there is.
  
  The issue is that after forced unmount this check may be too late as
  the unp_vnode is reclaimed and the reference is stale.
  
  To fix this provide a helper function that is called on a socket vnode
  reclamation to do necessary cleanup.
  
  Pointed by:   kib
  Reviewed by:  kib
  MFC after:2 weeks

Modified:
  head/sys/kern/uipc_usrreq.c
  head/sys/kern/vfs_subr.c
  head/sys/sys/vnode.h

Modified: head/sys/kern/uipc_usrreq.c
==
--- head/sys/kern/uipc_usrreq.c Sat Feb 25 10:10:43 2012(r232151)
+++ head/sys/kern/uipc_usrreq.c Sat Feb 25 10:15:41 2012(r232152)
@@ -2300,6 +2300,45 @@ unp_scan(struct mbuf *m0, void (*op)(str
}
 }
 
+/*
+ * A helper function called by VFS before socket-type vnode reclamation.
+ * For an active vnode it clears unp_vnode pointer and decrements unp_vnode
+ * use count.
+ */
+void
+vfs_unp_reclaim(struct vnode *vp)
+{
+   struct socket *so;
+   struct unpcb *unp;
+   int active;
+
+   ASSERT_VOP_ELOCKED(vp, "vfs_unp_reclaim");
+   KASSERT(vp->v_type == VSOCK,
+   ("vfs_unp_reclaim: vp->v_type != VSOCK"));
+
+   active = 0;
+   UNP_LINK_WLOCK();
+   so = vp->v_socket;
+   if (so == NULL)
+   goto done;
+   unp = sotounpcb(so);
+   if (unp == NULL)
+   goto done;
+   UNP_PCB_LOCK(unp);
+   if (unp->unp_vnode != NULL) {
+   KASSERT(unp->unp_vnode == vp,
+   ("vfs_unp_reclaim: vp != unp->unp_vnode"));
+   vp->v_socket = NULL;
+   unp->unp_vnode = NULL;
+   active = 1;
+   }
+   UNP_PCB_UNLOCK(unp);
+done:
+   UNP_LINK_WUNLOCK();
+   if (active)
+   vunref(vp);
+}
+
 #ifdef DDB
 static void
 db_print_indent(int indent)

Modified: head/sys/kern/vfs_subr.c
==
--- head/sys/kern/vfs_subr.cSat Feb 25 10:10:43 2012(r232151)
+++ head/sys/kern/vfs_subr.cSat Feb 25 10:15:41 2012(r232152)
@@ -2657,6 +2657,8 @@ vgonel(struct vnode *vp)
vinactive(vp, td);
VI_UNLOCK(vp);
}
+   if (vp->v_type == VSOCK)
+   vfs_unp_reclaim(vp);
/*
 * Reclaim the vnode.
 */

Modified: head/sys/sys/vnode.h
==
--- head/sys/sys/vnode.hSat Feb 25 10:10:43 2012(r232151)
+++ head/sys/sys/vnode.hSat Feb 25 10:15:41 2012(r232152)
@@ -793,6 +793,8 @@ int vfs_read_dirent(struct vop_readdir_a
 
 int vfs_unixify_accmode(accmode_t *accmode);
 
+void vfs_unp_reclaim(struct vnode *vp);
+
 int setfmode(struct thread *td, struct ucred *cred, struct vnode *vp, int 
mode);
 int setfown(struct thread *td, struct ucred *cred, struct vnode *vp, uid_t uid,
 gid_t gid);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r232154 - head/sys/sys

2012-02-25 Thread Martin Matuska
Author: mm
Date: Sat Feb 25 11:03:13 2012
New Revision: 232154
URL: http://svn.freebsd.org/changeset/base/232154

Log:
  Bump __FreeBSD_version due to libarchive update.

Modified:
  head/sys/sys/param.h

Modified: head/sys/sys/param.h
==
--- head/sys/sys/param.hSat Feb 25 10:58:02 2012(r232153)
+++ head/sys/sys/param.hSat Feb 25 11:03:13 2012(r232154)
@@ -58,7 +58,7 @@
  * in the range 5 to 9.
  */
 #undef __FreeBSD_version
-#define __FreeBSD_version 108  /* Master, propagated to newvers */
+#define __FreeBSD_version 109  /* Master, propagated to newvers */
 
 /*
  * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r232156 - head/sys/kern

2012-02-25 Thread Maxim Konovalov
Author: maxim
Date: Sat Feb 25 12:06:40 2012
New Revision: 232156
URL: http://svn.freebsd.org/changeset/base/232156

Log:
  o Reduce chances for integer overflow.
  o More verbose sysctl description added.
  
  MFC after:2 weeks
  Sponsored by: Nginx, Inc.

Modified:
  head/sys/kern/vfs_cache.c

Modified: head/sys/kern/vfs_cache.c
==
--- head/sys/kern/vfs_cache.c   Sat Feb 25 11:07:32 2012(r232155)
+++ head/sys/kern/vfs_cache.c   Sat Feb 25 12:06:40 2012(r232156)
@@ -369,7 +369,7 @@ sysctl_debug_hashstat_nchash(SYSCTL_HAND
maxlength = count;
}
n_nchash = nchash + 1;
-   pct = (used * 100 * 100) / n_nchash;
+   pct = (used * 100) / (n_nchash / 100);
error = SYSCTL_OUT(req, &n_nchash, sizeof(n_nchash));
if (error)
return (error);
@@ -386,7 +386,7 @@ sysctl_debug_hashstat_nchash(SYSCTL_HAND
 }
 SYSCTL_PROC(_debug_hashstat, OID_AUTO, nchash, CTLTYPE_INT|CTLFLAG_RD|
 CTLFLAG_MPSAFE, 0, 0, sysctl_debug_hashstat_nchash, "I",
-"nchash chain lengths");
+"nchash statistics (number of total/used buckets, maximum chain length, 
usage percentage)");
 #endif
 
 /*
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r232157 - in head: bin/expr lib/libc/sys lib/libmemstat lib/libpmc lib/libusb lib/libutil lib/libvgl sbin/iscontrol share/man/man3 share/man/man4 share/man/man5 share/man/man9 sys/boot/...

2012-02-25 Thread Glen Barber
Author: gjb (doc committer)
Date: Sat Feb 25 14:31:25 2012
New Revision: 232157
URL: http://svn.freebsd.org/changeset/base/232157

Log:
  Fix various typos in manual pages.
  
  Submitted by: amdmi3
  PR:   165431
  MFC after:1 week

Modified:
  head/bin/expr/expr.1
  head/lib/libc/sys/cap_enter.2
  head/lib/libc/sys/pdfork.2
  head/lib/libc/sys/posix_fadvise.2
  head/lib/libc/sys/posix_fallocate.2
  head/lib/libmemstat/libmemstat.3
  head/lib/libpmc/pmc.mips.3
  head/lib/libpmc/pmc.westmere.3
  head/lib/libusb/libusb.3
  head/lib/libutil/kinfo_getproc.3
  head/lib/libvgl/vgl.3
  head/sbin/iscontrol/iscsi.conf.5
  head/share/man/man3/pthread_getthreadid_np.3
  head/share/man/man4/acpi_panasonic.4
  head/share/man/man4/cxgbe.4
  head/share/man/man4/ed.4
  head/share/man/man4/mac_lomac.4
  head/share/man/man4/umcs.4
  head/share/man/man4/vr.4
  head/share/man/man5/rc.conf.5
  head/share/man/man9/kqueue.9
  head/share/man/man9/zone.9
  head/sys/boot/forth/menu.4th.8

Modified: head/bin/expr/expr.1
==
--- head/bin/expr/expr.1Sat Feb 25 12:06:40 2012(r232156)
+++ head/bin/expr/expr.1Sat Feb 25 14:31:25 2012(r232157)
@@ -30,7 +30,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd September 9, 2010
+.Dd February 25, 2012
 .Dt EXPR 1
 .Os
 .Sh NAME
@@ -52,7 +52,7 @@ Several of the operators have special me
 and must therefore be quoted appropriately.
 All integer operands are interpreted in base 10 and must consist of only
 an optional leading minus sign followed by one or more digits (unless
-less strict parsing has been enabled for backwards compatibilty with
+less strict parsing has been enabled for backwards compatibility with
 prior versions of
 .Nm
 in
@@ -284,7 +284,7 @@ An empty operand string is interpreted a
 .Bl -bullet
 .It
 Leading white space and/or a plus sign before an otherwise valid positive
-numberic operand are allowed and will be ignored.
+numeric operand are allowed and will be ignored.
 .El
 .Pp
 The extended arithmetic range and overflow checks do not conflict with

Modified: head/lib/libc/sys/cap_enter.2
==
--- head/lib/libc/sys/cap_enter.2   Sat Feb 25 12:06:40 2012
(r232156)
+++ head/lib/libc/sys/cap_enter.2   Sat Feb 25 14:31:25 2012
(r232157)
@@ -28,7 +28,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd June 11, 2009
+.Dd February 25, 2012
 .Dt CAP_ENTER 2
 .Os
 .Sh NAME
@@ -68,7 +68,7 @@ appropriately-crafted applications or ap
 returns a flag indicating whether or not the process is in a capability mode
 sandbox.
 .Sh CAVEAT
-Creating effecive process sandboxes is a tricky process that involves
+Creating effective process sandboxes is a tricky process that involves
 identifying the least possible rights required by the process and then
 passing those rights into the process in a safe manner.
 See the CAVEAT

Modified: head/lib/libc/sys/pdfork.2
==
--- head/lib/libc/sys/pdfork.2  Sat Feb 25 12:06:40 2012(r232156)
+++ head/lib/libc/sys/pdfork.2  Sat Feb 25 14:31:25 2012(r232157)
@@ -28,7 +28,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd August 16, 2011
+.Dd February 25, 2012
 .Dt PDFORK 2
 .Os
 .Sh NAME
@@ -87,7 +87,7 @@ except that it accepts a process descrip
 rather than a PID.
 .Pp
 .Fn pdwait4
-behaves identially to
+behaves identically to
 .Xr wait4 2 ,
 but operates with respect to a process descriptor argument rather than a PID.
 .Pp

Modified: head/lib/libc/sys/posix_fadvise.2
==
--- head/lib/libc/sys/posix_fadvise.2   Sat Feb 25 12:06:40 2012
(r232156)
+++ head/lib/libc/sys/posix_fadvise.2   Sat Feb 25 14:31:25 2012
(r232157)
@@ -28,7 +28,7 @@
 .\"@(#)madvise.2   8.1 (Berkeley) 6/9/93
 .\" $FreeBSD$
 .\"
-.Dd October 26, 2011
+.Dd February 25, 2012
 .Dt POSIX_FADVISE 2
 .Os
 .Sh NAME
@@ -74,7 +74,7 @@ This currently does nothing as the defau
 detect sequential behavior.
 .It Dv POSIX_FADV_WILLNEED
 Tells the system that the specified data will be accessed in the near future.
-The system may initiate an asychronous read of the data if it is not already
+The system may initiate an asynchronous read of the data if it is not already
 present in memory.
 .It Dv POSIX_FADV_DONTNEED
 Tells the system that the specified data will not be accessed in the near

Modified: head/lib/libc/sys/posix_fallocate.2
==
--- head/lib/libc/sys/posix_fallocate.2 Sat Feb 25 12:06:40 2012
(r232156)
+++ head/lib/libc/sys/posix_fallocate.2 Sat Feb 25 14:31:25 2012
(r232157)
@@ -28,7 +28,7 @@
 .\" @(#)open.2 8.2 (Berkeley) 11/16/93
 .\" $FreeBSD$
 .\"
-.Dd April 13, 2011
+.Dd February 25, 2012
 .Dt POSIX_FALLOCATE 2
 .Os
 .Sh NAME
@@ -48,7 +48,7 @

svn commit: r232158 - in head: bin/expr lib/libc/sys lib/libpmc sbin/iscontrol share/man/man4 share/man/man5 sys/boot/forth

2012-02-25 Thread Glen Barber
Author: gjb (doc committer)
Date: Sat Feb 25 15:21:43 2012
New Revision: 232158
URL: http://svn.freebsd.org/changeset/base/232158

Log:
  Whitespace cleanup:
   o Wrap sentences on to new lines
   o Cleanup trailing whitespace
  
  Found with:   textproc/igor
  MFC after:1 week
  X-MFC-With:   r232157

Modified:
  head/bin/expr/expr.1
  head/lib/libc/sys/pdfork.2
  head/lib/libpmc/pmc.mips.3
  head/sbin/iscontrol/iscsi.conf.5
  head/share/man/man4/cxgbe.4
  head/share/man/man4/ed.4
  head/share/man/man4/umcs.4
  head/share/man/man5/rc.conf.5
  head/sys/boot/forth/menu.4th.8

Modified: head/bin/expr/expr.1
==
--- head/bin/expr/expr.1Sat Feb 25 14:31:25 2012(r232157)
+++ head/bin/expr/expr.1Sat Feb 25 15:21:43 2012(r232158)
@@ -176,7 +176,8 @@ option, since this matches the historic 
 .Nm
 in
 .Fx . This option makes number parsing less strict and permits leading
-white space and an optional leading plus sign. In addition, empty operands
+white space and an optional leading plus sign.
+In addition, empty operands
 have an implied value of zero in numeric context.
 For historical reasons, defining the environment variable
 .Ev EXPR_COMPAT
@@ -300,7 +301,8 @@ standard, the use of string arguments
 .Va index ,
 or
 .Va match
-produces undefined results. In this version of
+produces undefined results.
+In this version of
 .Nm ,
 these arguments are treated just as their respective string values.
 .Pp

Modified: head/lib/libc/sys/pdfork.2
==
--- head/lib/libc/sys/pdfork.2  Sat Feb 25 14:31:25 2012(r232157)
+++ head/lib/libc/sys/pdfork.2  Sat Feb 25 15:21:43 2012(r232158)
@@ -101,7 +101,8 @@ queries status of a process descriptor; 
 .Fa st_ctime
 and
 .Fa st_mtime
-fields are defined. If the owner read, write, and execute bits are set then the
+fields are defined.
+If the owner read, write, and execute bits are set then the
 process represented by the process descriptor is still alive.
 .Pp
 .Xr poll 2

Modified: head/lib/libpmc/pmc.mips.3
==
--- head/lib/libpmc/pmc.mips.3  Sat Feb 25 14:31:25 2012(r232157)
+++ head/lib/libpmc/pmc.mips.3  Sat Feb 25 15:21:43 2012(r232158)
@@ -54,16 +54,16 @@ MIPS programmable PMCs support the follo
 .Bl -tag -width indent
 .It Li CYCLE
 .Pq Event 0, Counter 0/1
-Total number of cycles. 
+Total number of cycles.
 The performance counters are clocked by the
-top-level gated clock. 
+top-level gated clock.
 If the core is built with that clock gater
 present, none of the counters will increment while the clock is
 stopped - due to a WAIT instruction.
 .It Li INSTR_EXECUTED
 .Pq Event 1, Counter 0/1
 Total number of instructions completed.
-.It Li BRANCH_COMPLETED 
+.It Li BRANCH_COMPLETED
 .Pq Event 2, Counter 0
 Total number of branch instructions completed.
 .It Li BRANCH_MISPRED
@@ -85,9 +85,9 @@ If RPS use is disabled, JR $31 will not 
 .Pq Event 5, Counter 0
 Counts ITLB accesses that are due to fetches showing up in the
 instruction fetch stage of the pipeline and which do not use a fixed
-mapping or are not in unmapped space. 
+mapping or are not in unmapped space.
 If an address is fetched twice from the pipe (as in the case of a
-cache miss), that instruction willcount as 2 ITLB accesses. 
+cache miss), that instruction willcount as 2 ITLB accesses.
 Since each fetch gets us 2 instructions,there is one access marked per double
 word.
 .It Li ITLB_MISS
@@ -102,7 +102,8 @@ They are also ignored if there is some f
 Counts DTLB access including those in unmapped address spaces.
 .It Li DTLB_MISS
 .Pq Event 6, Counter 1
-Counts DTLB misses. Back to back misses that result in only one DTLB
+Counts DTLB misses.
+Back to back misses that result in only one DTLB
 entry getting refilled are counted as a single miss.
 .It Li JTLB_IACCESS
 .Pq Event 7, Counter 0
@@ -119,7 +120,8 @@ Data JTLB accesses.
 Counts data JTLB accesses that result in no match or a match on an invalid 
translation.
 .It Li IC_FETCH
 .Pq Event 9, Counter 0
-Counts every time the instruction cache is accessed. All replays,
+Counts every time the instruction cache is accessed.
+All replays,
 wasted fetches etc. are counted.
 For example, following a branch, even though the prediction is taken,
 the fall through access is counted.
@@ -179,7 +181,8 @@ when both stalls are active will only be
 replay traps (other than uTLB)
 .It Li STORE_COND_COMPLETED
 .Pq Event 19, Counter 0
-Conditional stores completed.  Counts all events, including failed stores.
+Conditional stores completed.
+Counts all events, including failed stores.
 .It Li STORE_COND_FAILED
 .Pq Event 19, Counter 1
 Conditional store instruction that did not update memory.
@@ -189,7 +192,7 @@ different and the observed operating mod
 causing some inaccuracy in the me

svn commit: r232159 - head/lib/libpmc

2012-02-25 Thread Glen Barber
Author: gjb (doc committer)
Date: Sat Feb 25 16:02:12 2012
New Revision: 232159
URL: http://svn.freebsd.org/changeset/base/232159

Log:
  Whitespace cleanup:
   o Wrap sentences on to new lines
   o Rewrap lines where possible while trying to keep the diff to a
 minimum
  
  Found with:   textproc/igor
  MFC after:1 week
  X-MFC-With:   r232157

Modified:
  head/lib/libpmc/pmc.westmere.3

Modified: head/lib/libpmc/pmc.westmere.3
==
--- head/lib/libpmc/pmc.westmere.3  Sat Feb 25 15:21:43 2012
(r232158)
+++ head/lib/libpmc/pmc.westmere.3  Sat Feb 25 16:02:12 2012
(r232159)
@@ -92,15 +92,17 @@ Configure the Off-core Response bits.
 .It Li DMND_DATA_RD
 Counts the number of demand and DCU prefetch data reads of full
 and partial cachelines as well as demand data page table entry
-cacheline reads. Does not count L2 data read prefetches or
+cacheline reads.
+Does not count L2 data read prefetches or
 instruction fetches.
 .It Li DMND_RFO
 Counts the number of demand and DCU prefetch reads for ownership
-(RFO) requests generated by a write to data cacheline. Does not
-count L2 RFO.
+(RFO) requests generated by a write to data cacheline.
+Does not count L2 RFO.
 .It Li DMND_IFETCH
 Counts the number of demand and DCU prefetch instruction cacheline
-reads. Does not count L2 code read prefetches.
+reads.
+Does not count L2 code read prefetches.
 WB
 Counts the number of writeback (modified to exclusive) transactions.
 .It Li PF_DATA_RD
@@ -181,7 +183,8 @@ All Store buffer stall cycles
 All store referenced with misaligned address
 .It Li STORE_BLOCKS.AT_RET
 .Pq Event 06H , Umask 04H
-Counts number of loads delayed with at-Retirement block code. The following
+Counts number of loads delayed with at-Retirement block code.
+The following
 loads need to be executed at retirement and wait for all senior stores on
 the same thread to be drained: load splitting across 4K boundary (page
 split), load accessing uncacheable (UC or USWC) memory, load lock, and load
@@ -225,9 +228,10 @@ ld_lat facility.
 In conjunction with ld_lat facility
 .It Li MEM_STORE_RETIRED.DTLB_MISS
 .Pq Event 0CH , Umask 01H
-The event counts the number of retired stores that missed the DTLB. The DTLB
-miss is not counted if the store operation causes a fault. Does not counter
-prefetches. Counts both primary and secondary misses to the TLB
+The event counts the number of retired stores that missed the DTLB.
+The DTLB miss is not counted if the store operation causes a fault.
+Does not counter prefetches.
+Counts both primary and secondary misses to the TLB
 .It Li UOPS_ISSUED.ANY
 .Pq Event 0EH , Umask 01H
 Counts the number of Uops issued by the Register Allocation Table to the
@@ -264,9 +268,11 @@ Load instructions retired remote DRAM an
 Load instructions retired I/O (Precise Event)
 .It Li FP_COMP_OPS_EXE.X87
 .Pq Event 10H , Umask 01H
-Counts the number of FP Computational Uops Executed. The number of FADD,
+Counts the number of FP Computational Uops Executed.
+The number of FADD,
 FSUB, FCOM, FMULs, integer MULsand IMULs, FDIVs, FPREMs, FSQRTS, integer
-DIVs, and IDIVs. This event does not distinguish an FADD used in the middle
+DIVs, and IDIVs.
+This event does not distinguish an FADD used in the middle
 of a transcendental flow from a separate FADD instruction.
 .It Li FP_COMP_OPS_EXE.MMX
 .Pq Event 10H , Umask 02H
@@ -316,9 +322,9 @@ Counts number of loads dispatched from t
 the Memory Order Buffer.
 .It Li LOAD_DISPATCH.RS_DELAYED
 .Pq Event 13H , Umask 02H
-Counts the number of delayed RS dispatches at the stage latch. If an RS
-dispatch can not bypass to LB, it has another chance to dispatch from the
-one-cycle delayed staging latch before it is written into the LB.
+Counts the number of delayed RS dispatches at the stage latch.
+If an RS dispatch can not bypass to LB, it has another chance to dispatch
+from the one-cycle delayed staging latch before it is written into the LB.
 .It Li LOAD_DISPATCH.MOB
 .Pq Event 13H , Umask 04H
 Counts the number of loads dispatched from the Reservation Station to the
@@ -329,13 +335,15 @@ Counts all loads dispatched from the Res
 .It Li ARITH.CYCLES_DIV_BUSY
 .Pq Event 14H , Umask 01H
 Counts the number of cycles the divider is busy executing divide or square
-root operations. The divide can be integer, X87 or Streaming SIMD Extensions
-(SSE). The square root operation can be either X87 or SSE.
+root operations.
+The divide can be integer, X87 or Streaming SIMD Extensions (SSE).
+The square root operation can be either X87 or SSE.
 Set 'edge =1, invert=1, cmask=1' to count the number of divides.
 Count may be incorrect When SMT is on
 .It Li ARITH.MUL
 .Pq Event 14H , Umask 02H
-Counts the number of multiply operations executed. This includes integer as
+Counts the number of multiply operations executed.
+This includes integer as
 well as floating point multiply operations but excludes DPPS mul a

svn commit: r232160 - head/sys/vm

2012-02-25 Thread Alan Cox
Author: alc
Date: Sat Feb 25 17:49:59 2012
New Revision: 232160
URL: http://svn.freebsd.org/changeset/base/232160

Log:
  Simplify vmspace_fork()'s control flow by copying immutable data before
  the vm map locks are acquired.  Also, eliminate redundant initialization
  of the new vm map's timestamp.
  
  Reviewed by:  kib
  MFC after:3 weeks

Modified:
  head/sys/vm/vm_map.c

Modified: head/sys/vm/vm_map.c
==
--- head/sys/vm/vm_map.cSat Feb 25 16:02:12 2012(r232159)
+++ head/sys/vm/vm_map.cSat Feb 25 17:49:59 2012(r232160)
@@ -3082,27 +3082,25 @@ struct vmspace *
 vmspace_fork(struct vmspace *vm1, vm_ooffset_t *fork_charge)
 {
struct vmspace *vm2;
-   vm_map_t old_map = &vm1->vm_map;
-   vm_map_t new_map;
-   vm_map_entry_t old_entry;
-   vm_map_entry_t new_entry;
+   vm_map_t new_map, old_map;
+   vm_map_entry_t new_entry, old_entry;
vm_object_t object;
int locked;
 
-   vm_map_lock(old_map);
-   if (old_map->busy)
-   vm_map_wait_busy(old_map);
-   new_map = NULL; /* silence gcc */
+   old_map = &vm1->vm_map;
+   /* Copy immutable fields of vm1 to vm2. */
vm2 = vmspace_alloc(old_map->min_offset, old_map->max_offset);
if (vm2 == NULL)
-   goto unlock_and_return;
+   return (NULL);
vm2->vm_taddr = vm1->vm_taddr;
vm2->vm_daddr = vm1->vm_daddr;
vm2->vm_maxsaddr = vm1->vm_maxsaddr;
-   new_map = &vm2->vm_map; /* XXX */
+   vm_map_lock(old_map);
+   if (old_map->busy)
+   vm_map_wait_busy(old_map);
+   new_map = &vm2->vm_map;
locked = vm_map_trylock(new_map); /* trylock to silence WITNESS */
KASSERT(locked, ("vmspace_fork: lock failed"));
-   new_map->timestamp = 1;
 
old_entry = old_map->header.next;
 
@@ -3223,15 +3221,13 @@ vmspace_fork(struct vmspace *vm1, vm_oof
}
old_entry = old_entry->next;
}
-unlock_and_return:
/*
 * Use inlined vm_map_unlock() to postpone handling the deferred
 * map entries, which cannot be done until both old_map and
 * new_map locks are released.
 */
sx_xunlock(&old_map->lock);
-   if (vm2 != NULL)
-   sx_xunlock(&new_map->lock);
+   sx_xunlock(&new_map->lock);
vm_map_process_deferred();
 
return (vm2);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r232163 - head/sys/dev/ath

2012-02-25 Thread Adrian Chadd
Author: adrian
Date: Sat Feb 25 19:12:54 2012
New Revision: 232163
URL: http://svn.freebsd.org/changeset/base/232163

Log:
  Attempt to further fix some of the concurrency/reset issues that occur.
  
  * ath_reset() is being called in softclock context, which may have the
thing sleep on a lock.  To avoid this, since we really _shouldn't_
be sleeping on any locks, break out the no-loss reset path into a tasklet
and call that from:
  
+ ath_calibrate()
+ ath_watchdog()
  
This has the added advantage that it'll end up also doing the frame
RX cleanup from within the taskqueue context, rather than the softclock
context.
  
  * Shuffle around the taskqueue_block() call to be before we grab the lock
and disable interrupts.
  
The trouble here is that taskqueue_block() doesn't block currently
queued (but not yet running) tasks so calling it doesn't guarantee
no further tasks (that weren't running on _A_ CPU at the time of this
call) will complete.  Calling taskqueue_drain() on these tasks won't
work because if any _other_ thread calls taskqueue_enqueue() for whatever
reason, everything gets very angry and stops working.
  
This slightly changes the race condition enough to let ath_rx_tasklet()
run before we try disabling it, and thus quietens the warnings a bit.
  
The (more) true solution will be doing something like the following:
  
* having a taskqueue_blocked mask in ath_softc;
* having an interrupt_blocked mask in ath_softc;
* only calling taskqueue_drain() on each individual task _after_ the
  lock has been acquired - that way no further tasklet scheduling
  is going to occur.
* Then once the tasks have been blocked _and_ the interrupt has been
  disabled, call taskqueue_drain() on each, ensuring that anything
  that _was_ scheduled or running is removed.
  
The trouble is if something calls taskqueue_enqueue() on a task
after taskqueue_blocked() has been called but BEFORE taskqueue_drain()
has been called, ta_pending will be set to 1 and taskqueue_drain()
will sit there stuck in msleep() until you hard-kill the machine.
  
  PR: kern/165382
  PR: kern/165220

Modified:
  head/sys/dev/ath/if_ath.c
  head/sys/dev/ath/if_athvar.h

Modified: head/sys/dev/ath/if_ath.c
==
--- head/sys/dev/ath/if_ath.c   Sat Feb 25 18:48:06 2012(r232162)
+++ head/sys/dev/ath/if_ath.c   Sat Feb 25 19:12:54 2012(r232163)
@@ -159,6 +159,7 @@ static void ath_beacon_proc(void *, int)
 static struct ath_buf *ath_beacon_generate(struct ath_softc *,
struct ieee80211vap *);
 static voidath_bstuck_proc(void *, int);
+static voidath_reset_proc(void *, int);
 static voidath_beacon_return(struct ath_softc *, struct ath_buf *);
 static voidath_beacon_free(struct ath_softc *);
 static voidath_beacon_config(struct ath_softc *, struct ieee80211vap *);
@@ -392,6 +393,7 @@ ath_attach(u_int16_t devid, struct ath_s
TASK_INIT(&sc->sc_rxtask, 0, ath_rx_tasklet, sc);
TASK_INIT(&sc->sc_bmisstask, 0, ath_bmiss_proc, sc);
TASK_INIT(&sc->sc_bstucktask,0, ath_bstuck_proc, sc);
+   TASK_INIT(&sc->sc_resettask,0, ath_reset_proc, sc);
 
/*
 * Allocate hardware transmit queues: one queue for
@@ -1910,9 +1912,6 @@ ath_txrx_stop_locked(struct ath_softc *s
ATH_UNLOCK_ASSERT(sc);
ATH_PCU_LOCK_ASSERT(sc);
 
-   /* Stop any new TX/RX from occuring */
-   taskqueue_block(sc->sc_tq);
-
/*
 * Sleep until all the pending operations have completed.
 *
@@ -2050,6 +2049,9 @@ ath_reset(struct ifnet *ifp, ATH_RESET_T
ATH_PCU_UNLOCK_ASSERT(sc);
ATH_UNLOCK_ASSERT(sc);
 
+   /* Try to (stop any further TX/RX from occuring */
+   taskqueue_block(sc->sc_tq);
+
ATH_PCU_LOCK(sc);
ath_hal_intrset(ah, 0); /* disable interrupts */
ath_txrx_stop_locked(sc);   /* Ensure TX/RX is stopped */
@@ -3163,6 +3165,23 @@ ath_beacon_start_adhoc(struct ath_softc 
 }
 
 /*
+ * Reset the hardware, with no loss.
+ *
+ * This can't be used for a general case reset.
+ */
+static void
+ath_reset_proc(void *arg, int pending)
+{
+   struct ath_softc *sc = arg;
+   struct ifnet *ifp = sc->sc_ifp;
+
+#if 0
+   if_printf(ifp, "%s: resetting\n", __func__);
+#endif
+   ath_reset(ifp, ATH_RESET_NOLOSS);
+}
+
+/*
  * Reset the hardware after detecting beacons have stopped.
  */
 static void
@@ -5387,6 +5406,12 @@ ath_chan_set(struct ath_softc *sc, struc
int ret = 0;
 
/* Treat this as an interface reset */
+   ATH_PCU_UNLOCK_ASSERT(sc);
+   ATH_UNLOCK_ASSERT(sc);
+
+   /* (Try to) stop TX/RX from occuring */
+   taskqueue_block(sc->sc_tq);
+
ATH_PCU_LOCK(sc);
ath_hal_intrset(ah, 0); /* Stop new RX/TX completion */
ath_txrx_stop_locked

svn commit: r232166 - head/sys/vm

2012-02-25 Thread Alan Cox
Author: alc
Date: Sat Feb 25 21:06:39 2012
New Revision: 232166
URL: http://svn.freebsd.org/changeset/base/232166

Log:
  Simplify vm_mmap()'s control flow.
  
  Add a comment describing what vm_mmap_to_errno() does.
  
  Reviewed by:  kib
  MFC after:3 weeks
  X-MFC after:  r232071

Modified:
  head/sys/vm/vm_mmap.c

Modified: head/sys/vm/vm_mmap.c
==
--- head/sys/vm/vm_mmap.c   Sat Feb 25 19:21:24 2012(r232165)
+++ head/sys/vm/vm_mmap.c   Sat Feb 25 21:06:39 2012(r232166)
@@ -1447,9 +1447,8 @@ vm_mmap(vm_map_t map, vm_offset_t *addr,
 {
boolean_t fitit;
vm_object_t object = NULL;
-   int rv = KERN_SUCCESS;
-   int docow, error;
struct thread *td = curthread;
+   int docow, error, rv;
boolean_t writecounted;
 
if (size == 0)
@@ -1555,31 +1554,35 @@ vm_mmap(vm_map_t map, vm_offset_t *addr,
rv = vm_map_fixed(map, object, foff, *addr, size,
 prot, maxprot, docow);
 
-   if (rv != KERN_SUCCESS) {
+   if (rv == KERN_SUCCESS) {
+   /*
+* If the process has requested that all future mappings
+* be wired, then heed this.
+*/
+   if (map->flags & MAP_WIREFUTURE)
+   vm_map_wire(map, *addr, *addr + size,
+   VM_MAP_WIRE_USER | VM_MAP_WIRE_NOHOLES);
+   } else {
/*
-* Lose the object reference. Will destroy the
-* object if it's an unnamed anonymous mapping
-* or named anonymous without other references.
-*
 * If this mapping was accounted for in the vnode's
 * writecount, then undo that now.
 */
if (writecounted)
vnode_pager_release_writecount(object, 0, size);
+   /*
+* Lose the object reference.  Will destroy the
+* object if it's an unnamed anonymous mapping
+* or named anonymous without other references.
+*/
vm_object_deallocate(object);
}
-
-   /*
-* If the process has requested that all future mappings
-* be wired, then heed this.
-*/
-   if ((rv == KERN_SUCCESS) && (map->flags & MAP_WIREFUTURE))
-   vm_map_wire(map, *addr, *addr + size,
-   VM_MAP_WIRE_USER|VM_MAP_WIRE_NOHOLES);
-
return (vm_mmap_to_errno(rv));
 }
 
+/*
+ * Translate a Mach VM return code to zero on success or the appropriate errno
+ * on failure.
+ */
 int
 vm_mmap_to_errno(int rv)
 {
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r232059 - in head: sys/fs/devfs sys/fs/nullfs sys/kern sys/sys usr.sbin/jail

2012-02-25 Thread Pawel Jakub Dawidek
On Thu, Feb 23, 2012 at 06:51:24PM +, Martin Matuska wrote:
> Author: mm
> Date: Thu Feb 23 18:51:24 2012
> New Revision: 232059
> URL: http://svn.freebsd.org/changeset/base/232059
> 
> Log:
>   To improve control over the use of mount(8) inside a jail(8), introduce
>   a new jail parameter node with the following parameters:
>   
>   allow.mount.devfs:
>   allow mounting the devfs filesystem inside a jail
>   
>   allow.mount.nullfs:
>   allow mounting the nullfs filesystem inside a jail
>   
>   Both parameters are disabled by default (equals the behavior before
>   devfs and nullfs in jails). Administrators have to explicitly allow
>   mounting devfs and nullfs for each jail. The value "-1" of the
>   devfs_ruleset parameter is removed in favor of the new allow setting.
>   
>   Reviewed by:jamie
>   Suggested by:   pjd
>   MFC after:  2 weeks

Thanks. Could you also add such an option for ZFS? It would also be nice
to document the fact that when file system is using VFCF_JAIL flag, it
should be added to allow.mount. Not sure where would be the best place
to document that, though. VFS_INIT(9) would be best, but eventhough it
is referenced by VFS(9), it doesn't exist...

-- 
Pawel Jakub Dawidek   http://www.wheelsystems.com
FreeBSD committer http://www.FreeBSD.org
Am I Evil? Yes, I Am! http://tupytaj.pl


pgpXl06vaJ0Vg.pgp
Description: PGP signature


Re: svn commit: r232156 - head/sys/kern

2012-02-25 Thread Bruce Evans

On Sat, 25 Feb 2012, Maxim Konovalov wrote:


Log:
 o Reduce chances for integer overflow.
 o More verbose sysctl description added.

 MFC after: 2 weeks
 Sponsored by:  Nginx, Inc.



Modified: head/sys/kern/vfs_cache.c
==
--- head/sys/kern/vfs_cache.c   Sat Feb 25 11:07:32 2012(r232155)
+++ head/sys/kern/vfs_cache.c   Sat Feb 25 12:06:40 2012(r232156)
...
@@ -386,7 +386,7 @@ sysctl_debug_hashstat_nchash(SYSCTL_HAND
}
SYSCTL_PROC(_debug_hashstat, OID_AUTO, nchash, CTLTYPE_INT|CTLFLAG_RD|
CTLFLAG_MPSAFE, 0, 0, sysctl_debug_hashstat_nchash, "I",
-"nchash chain lengths");
+"nchash statistics (number of total/used buckets, maximum chain length, usage 
percentage)");
#endif

/*


It is now excessively verbose, and misformats both the source code and the
output.

This is not the place to write missing man pages.

Just "nchash statistics" is almost enough.  "nchash chain lengths" was just
wrong, since this sysctl only returns a summary of the chain lengths.  Its
description seems to have been copied from the previous sysctl where the
description was correct.

This and the previous sysctl are now under DIAGNOSTIC, since they took
too long and spammed sysctl -a (although the spam is not usually
printed) and complicated the locking.  That might have been a mistake
for this sysctl, since it only returns 4 integers.  The previous sysctl
returns the length of each chain, 1 integer at a time.

1 at a time in this sysctl is a poor organization too.  Now it is very
easy to use an array containing everything to be returned, and return
everything using only 1 SYSCTL_OUT() with only 1 error check.

Other style bugs in this sysctl:

% static int
% sysctl_debug_hashstat_nchash(SYSCTL_HANDLER_ARGS)
% {
%   int error;
%   struct nchashhead *ncpp;
%   struct namecache *ncp;
%   int n_nchash;
%   int count, maxlength, used, pct;

These declarations are disordered, with 3 sets of int declarations
helping to give external disorder, and pct after `used' to give internal
disorder.

% 
% 	if (!req->oldptr)

%   return SYSCTL_OUT(req, 0, 4 * sizeof(int));

The magic is 4 better placed in an array with that many elements;
return this array.

% 
% 	n_nchash = nchash + 1;	/* nchash is max index, not count */

%   used = 0;
%   maxlength = 0;

Initializations are randomly sorted too.

% 
% 	/* Scan hash tables for applicable entries */

%   for (ncpp = nchashtbl; n_nchash > 0; n_nchash--, ncpp++) {
%   count = 0;
%   CACHE_RLOCK();

The order of the last 2 statements is gratuitously different than in the
previous sysctl.  This order is better.

%   LIST_FOREACH(ncp, ncpp, nc_hash) {
%   count++;
%   }
%   CACHE_RUNLOCK();

The previous sysctl has to unlock to avoid a LOR when it copies out the
data.  This fine-grained locking seems to just waste time here -- I
think all chains can be scanned fast enough.  If not, then unlocking
every 128'th or similar chain would reduce the lock flapping.

The previous sysctl could use an array with 128 elements or similar
to reduce the number of copyouts and/or the lock flapping.

Moving the locking outside of the loop also gives a non-gratuitously
different order for initializing `count'.

%   if (count)
%   used++;
%   if (maxlength < count)
%   maxlength = count;
%   }
%   n_nchash = nchash + 1;
%   pct = (used * 100 * 100) / n_nchash;

Putting these variables in the array takes also reduces style bugs
automatically.  It loses their descriptive names -- e.g., pct would
become array[3] (the 4th and last element copied out).

%   error = SYSCTL_OUT(req, &n_nchash, sizeof(n_nchash));
%   if (error)
%   return (error);
%   error = SYSCTL_OUT(req, &used, sizeof(used));
%   if (error)
%   return (error);
%   error = SYSCTL_OUT(req, &maxlength, sizeof(maxlength));
%   if (error)
%   return (error);
%   error = SYSCTL_OUT(req, &pct, sizeof(pct));
%   if (error)
%   return (error);

The last 9 lines go away using an array.

%   return (0);
% }

The comment on the NODE for these 2 sysctls says
"Grab an atomic snapshot...", but the unlocking makes both non-atomic.

Bruce
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r232147 - head/sys/dev/wi

2012-02-25 Thread Pawel Jakub Dawidek
On Sat, Feb 25, 2012 at 08:01:29AM +, Adrian Chadd wrote:
> Author: adrian
> Date: Sat Feb 25 08:01:29 2012
> New Revision: 232147
> URL: http://svn.freebsd.org/changeset/base/232147
> 
> Log:
>   If an interrupt is received with no vap attached, just fail LINK events.
>   
>   This fixes a NULL pointer dereference which occurs if the vap list is
>   empty but someone brings up the wi0 interface.
> 
> Modified:
>   head/sys/dev/wi/if_wi.c
> 
> Modified: head/sys/dev/wi/if_wi.c
> ==
> --- head/sys/dev/wi/if_wi.c   Sat Feb 25 07:58:59 2012(r232146)
> +++ head/sys/dev/wi/if_wi.c   Sat Feb 25 08:01:29 2012(r232147)
> @@ -1511,6 +1511,10 @@ wi_info_intr(struct wi_softc *sc)
>   case WI_INFO_LINK_STAT:
>   wi_read_bap(sc, fid, sizeof(ltbuf), &stat, sizeof(stat));
>   DPRINTF(("wi_info_intr: LINK_STAT 0x%x\n", le16toh(stat)));
> +
> + if (vap == NULL)
> + goto finish;
> +
>   switch (le16toh(stat)) {
>   case WI_INFO_LINK_STAT_CONNECTED:
>   if (vap->iv_state == IEEE80211_S_RUN &&
> @@ -1566,6 +1570,7 @@ wi_info_intr(struct wi_softc *sc)
>   le16toh(ltbuf[1]), le16toh(ltbuf[0])));
>   break;
>   }
> +finish:
>   CSR_WRITE_2(sc, WI_EVENT_ACK, WI_EV_INFO);
>  }

Can't you just 'break' instead of using goto?

-- 
Pawel Jakub Dawidek   http://www.wheelsystems.com
FreeBSD committer http://www.FreeBSD.org
Am I Evil? Yes, I Am! http://tupytaj.pl


pgpMeDP0m5wNj.pgp
Description: PGP signature


Re: svn commit: r232156 - head/sys/kern

2012-02-25 Thread Rick Macklem
Maxim Konovalov wrote:
> Author: maxim
> Date: Sat Feb 25 12:06:40 2012
> New Revision: 232156
> URL: http://svn.freebsd.org/changeset/base/232156
> 
> Log:
> o Reduce chances for integer overflow.
> o More verbose sysctl description added.
> 
> MFC after: 2 weeks
> Sponsored by: Nginx, Inc.
> 
> Modified:
> head/sys/kern/vfs_cache.c
> 
> Modified: head/sys/kern/vfs_cache.c
> ==
> --- head/sys/kern/vfs_cache.c Sat Feb 25 11:07:32 2012 (r232155)
> +++ head/sys/kern/vfs_cache.c Sat Feb 25 12:06:40 2012 (r232156)
> @@ -369,7 +369,7 @@ sysctl_debug_hashstat_nchash(SYSCTL_HAND
> maxlength = count;
> }
> n_nchash = nchash + 1;
> - pct = (used * 100 * 100) / n_nchash;
> + pct = (used * 100) / (n_nchash / 100);

You might want to consider a sanity check to make
sure n_nchash is >= 100, to avoid a "divide by zero".

There was an NFS PR# a while back, where "desiredvnodes" was
set very small and resulted in a "divide by zero" in the NFS code.

Just a suggestion, rick

> error = SYSCTL_OUT(req, &n_nchash, sizeof(n_nchash));
> if (error)
> return (error);
> @@ -386,7 +386,7 @@ sysctl_debug_hashstat_nchash(SYSCTL_HAND
> }
> SYSCTL_PROC(_debug_hashstat, OID_AUTO, nchash, CTLTYPE_INT|CTLFLAG_RD|
> CTLFLAG_MPSAFE, 0, 0, sysctl_debug_hashstat_nchash, "I",
> - "nchash chain lengths");
> + "nchash statistics (number of total/used buckets, maximum chain
> length, usage percentage)");
> #endif
> 
> /*
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r232156 - head/sys/kern

2012-02-25 Thread Bruce Evans

On Sat, 25 Feb 2012, Rick Macklem wrote:


Log:
o Reduce chances for integer overflow.
o More verbose sysctl description added.

MFC after: 2 weeks
Sponsored by: Nginx, Inc.

Modified:
head/sys/kern/vfs_cache.c

Modified: head/sys/kern/vfs_cache.c
==
--- head/sys/kern/vfs_cache.c Sat Feb 25 11:07:32 2012 (r232155)
+++ head/sys/kern/vfs_cache.c Sat Feb 25 12:06:40 2012 (r232156)
@@ -369,7 +369,7 @@ sysctl_debug_hashstat_nchash(SYSCTL_HAND
maxlength = count;
}
n_nchash = nchash + 1;
- pct = (used * 100 * 100) / n_nchash;
+ pct = (used * 100) / (n_nchash / 100);


You might want to consider a sanity check to make
sure n_nchash is >= 100, to avoid a "divide by zero".

There was an NFS PR# a while back, where "desiredvnodes" was
set very small and resulted in a "divide by zero" in the NFS code.


Interesting.  I considered mentioning this possibility in my reply,
but decided that desiredvnodes is always initially at least a few
hundred, since even an unbootable machine with 4MB memory has
1024 4K-pages.  You can tune desiredvnodes down to a bad value,
but another old bug is that tuning desiredvnodes doesn't affect
the namecache, so you can't make the above divide by provided
n_nchash was initially not bad.

In nfs, the problem is larger and still exists in oldnfs:

% nfsclient/nfs_vfsops.c-   nmp->nm_wsize = NFS_WSIZE;
% nfsclient/nfs_vfsops.c-   nmp->nm_rsize = NFS_RSIZE;
% nfsclient/nfs_vfsops.c-   }
% nfsclient/nfs_vfsops.c:   nmp->nm_wcommitsize = hibufspace / 
(desiredvnodes / 1000);

Now the divisor is 1000, so problems occur with the initial value occurs
on machines with 10 times as much memory as ones which have a problem in
the namecache code, and a good initial value can be tuned down to ensure
division by zero.

% nfsclient/nfs_vfsops.c-   nmp->nm_readdirsize = NFS_READDIRSIZE;
% nfsclient/nfs_vfsops.c-   nmp->nm_numgrps = NFS_MAXGRPS;
% nfsclient/nfs_vfsops.c-   nmp->nm_readahead = NFS_DEFRAHEAD;
% --
% fs/nfsclient/nfs_clvfsops.c-  nmp->nm_timeo = NFS_TIMEO;
% fs/nfsclient/nfs_clvfsops.c-  nmp->nm_retry = NFS_RETRANS;
% fs/nfsclient/nfs_clvfsops.c-  nmp->nm_readahead = NFS_DEFRAHEAD;
% fs/nfsclient/nfs_clvfsops.c:  if (desiredvnodes >= 11000)
% fs/nfsclient/nfs_clvfsops.c:  nmp->nm_wcommitsize = hibufspace / 
(desiredvnodes / 1000);
% fs/nfsclient/nfs_clvfsops.c-  else
% fs/nfsclient/nfs_clvfsops.c-  nmp->nm_wcommitsize = hibufspace / 10;
% fs/nfsclient/nfs_clvfsops.c-

Has been fixed, but if you only want to avoid division by 0, then a simpler
fix is to split up the powers of 10, e.g.:

nmp->nm_wcommitsize = hibufspace * 100 / (desiredvnodes / 10);

No one would set desiredvnodes to < 10, but now there is possible overflow
for the multiplication, and this is even easier to arrange then division
by zero since it is easy to set highbufspace to a non-physical value
(2**63-1 on 64-bit machines).  So this is too fragile.  Except the
sysctls are privileged and we should rely on their users to not misuse
them.

Bruce
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r232170 - head/sys/dev/ath/ath_rate/sample

2012-02-25 Thread Adrian Chadd
Author: adrian
Date: Sun Feb 26 06:04:44 2012
New Revision: 232170
URL: http://svn.freebsd.org/changeset/base/232170

Log:
  Add in some debugging code to check whether the current rate table has
  been bait-and-switched from the rate control code.
  
  This will avoid the panic that I saw and will avoid sending invalid rates
  (eg 11a/11g OFDM rates when in 11b, on 11b-only NICs (AR5211)) where the
  rate table is not "big".
  
  It also will point out situations where this occurs for the 11n NICs
  which will have sufficiently large rate tables that "invalid rix" doesn't
  occur.
  
  I'll try to follow this up with a commit that adds a current operating mode
  check. The "rix" is only relevant to the current operating mode and rate
  table.
  
  PR:   kern/165475

Modified:
  head/sys/dev/ath/ath_rate/sample/sample.c
  head/sys/dev/ath/ath_rate/sample/sample.h

Modified: head/sys/dev/ath/ath_rate/sample/sample.c
==
--- head/sys/dev/ath/ath_rate/sample/sample.c   Sun Feb 26 02:24:40 2012
(r232169)
+++ head/sys/dev/ath/ath_rate/sample/sample.c   Sun Feb 26 06:04:44 2012
(r232170)
@@ -495,6 +495,14 @@ ath_rate_findrate(struct ath_softc *sc, 
 
ath_rate_update_static_rix(sc, &an->an_node);
 
+   if (sn->currates != sc->sc_currates) {
+   device_printf(sc->sc_dev, "%s: currates != sc_currates!\n",
+   __func__);
+   rix = 0;
+   *try0 = ATH_TXMAXTRY;
+   goto done;
+   }
+
if (sn->static_rix != -1) {
rix = sn->static_rix;
*try0 = ATH_TXMAXTRY;
@@ -621,6 +629,20 @@ ath_rate_findrate(struct ath_softc *sc, 
}
*try0 = mrr ? sn->sched[rix].t0 : ATH_TXMAXTRY;
 done:
+
+   /*
+* This bug totally sucks and should be fixed.
+*
+* For now though, let's not panic, so we can start to figure
+* out how to better reproduce it.
+*/
+   if (rix < 0 || rix >= rt->rateCount) {
+   printf("%s: ERROR: rix %d out of bounds (rateCount=%d)\n",
+   __func__,
+   rix,
+   rt->rateCount);
+   rix = 0;/* XXX just default for now */
+   }
KASSERT(rix >= 0 && rix < rt->rateCount, ("rix is %d", rix));
 
*rix0 = rix;
@@ -1073,6 +1095,8 @@ ath_rate_ctl_reset(struct ath_softc *sc,
 sn->static_rix = -1;
ath_rate_update_static_rix(sc, ni);
 
+   sn->currates = sc->sc_currates;
+
/*
 * Construct a bitmask of usable rates.  This has all
 * negotiated rates minus those marked by the hal as

Modified: head/sys/dev/ath/ath_rate/sample/sample.h
==
--- head/sys/dev/ath/ath_rate/sample/sample.h   Sun Feb 26 02:24:40 2012
(r232169)
+++ head/sys/dev/ath/ath_rate/sample/sample.h   Sun Feb 26 06:04:44 2012
(r232170)
@@ -86,6 +86,8 @@ struct sample_node {
uint32_t ratemask;  /* bit mask of valid rate indices */
const struct txschedule *sched; /* tx schedule table */
 
+   const HAL_RATE_TABLE *currates;
+
struct rate_stats stats[NUM_PACKET_SIZE_BINS][SAMPLE_MAXRATES];
int last_sample_rix[NUM_PACKET_SIZE_BINS];
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r232147 - head/sys/dev/wi

2012-02-25 Thread Adrian Chadd
Good point..


Adiran


On 25 February 2012 00:01, Adrian Chadd  wrote:
> Author: adrian
> Date: Sat Feb 25 08:01:29 2012
> New Revision: 232147
> URL: http://svn.freebsd.org/changeset/base/232147
>
> Log:
>  If an interrupt is received with no vap attached, just fail LINK events.
>
>  This fixes a NULL pointer dereference which occurs if the vap list is
>  empty but someone brings up the wi0 interface.
>
> Modified:
>  head/sys/dev/wi/if_wi.c
>
> Modified: head/sys/dev/wi/if_wi.c
> ==
> --- head/sys/dev/wi/if_wi.c     Sat Feb 25 07:58:59 2012        (r232146)
> +++ head/sys/dev/wi/if_wi.c     Sat Feb 25 08:01:29 2012        (r232147)
> @@ -1511,6 +1511,10 @@ wi_info_intr(struct wi_softc *sc)
>        case WI_INFO_LINK_STAT:
>                wi_read_bap(sc, fid, sizeof(ltbuf), &stat, sizeof(stat));
>                DPRINTF(("wi_info_intr: LINK_STAT 0x%x\n", le16toh(stat)));
> +
> +               if (vap == NULL)
> +                       goto finish;
> +
>                switch (le16toh(stat)) {
>                case WI_INFO_LINK_STAT_CONNECTED:
>                        if (vap->iv_state == IEEE80211_S_RUN &&
> @@ -1566,6 +1570,7 @@ wi_info_intr(struct wi_softc *sc)
>                    le16toh(ltbuf[1]), le16toh(ltbuf[0])));
>                break;
>        }
> +finish:
>        CSR_WRITE_2(sc, WI_EVENT_ACK, WI_EV_INFO);
>  }
>
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"