Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 11 Oct 2014 16:34:02 +0000 (UTC)
From:      Marcel Moolenaar <marcel@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r272944 - head/sys/kern
Message-ID:  <201410111634.s9BGY2jN057945@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: marcel
Date: Sat Oct 11 16:34:01 2014
New Revision: 272944
URL: https://svnweb.freebsd.org/changeset/base/272944

Log:
  Fix nits in previous commit:
  1.  Remove initializer for badstack_sbuf_size; it gets set unconditionally.
  2.  Remove meaningless comment.
  3.  Group witness_count and its sysctl together.
  4.  Fix spacing in for statements (space after for and within condition).
  5.  Change *all* M_NOWAIT usages in witness_initialize() to M_WAITOK; not
      just those that were newly introduced -- the allocation is assumed to
      succeed for all allocations.
  6.  Avoid using uint8_t as the base type in sizeof() expressions; Use the
      variable name (w_rmatrix) as much as possible.
  
  Pointed out by: jhb@ (thanks!)

Modified:
  head/sys/kern/subr_witness.c

Modified: head/sys/kern/subr_witness.c
==============================================================================
--- head/sys/kern/subr_witness.c	Sat Oct 11 16:17:49 2014	(r272943)
+++ head/sys/kern/subr_witness.c	Sat Oct 11 16:34:01 2014	(r272944)
@@ -414,10 +414,9 @@ int	witness_skipspin = 0;
 #endif
 SYSCTL_INT(_debug_witness, OID_AUTO, skipspin, CTLFLAG_RDTUN, &witness_skipspin, 0, "");
 
-/* tunable for Witness count */
-int witness_count = WITNESS_COUNT;
-int badstack_sbuf_size = WITNESS_COUNT * 256;
+int badstack_sbuf_size;
 
+int witness_count = WITNESS_COUNT;
 SYSCTL_INT(_debug_witness, OID_AUTO, witness_count, CTLFLAG_RDTUN, 
     &witness_count, 0, "");
 
@@ -732,17 +731,17 @@ witness_initialize(void *dummy __unused)
 	int i;
 
 	w_data = malloc(sizeof (struct witness) * witness_count, M_WITNESS,
-	    M_NOWAIT | M_ZERO);
+	    M_WAITOK | M_ZERO);
 
-	w_rmatrix = malloc(sizeof(uint8_t *) * (witness_count+1),
-	    M_WITNESS, M_NOWAIT | M_ZERO);
+	w_rmatrix = malloc(sizeof(*w_rmatrix) * (witness_count + 1),
+	    M_WITNESS, M_WAITOK | M_ZERO);
 
-	for(i = 0; i < witness_count+1; i++) {
-		w_rmatrix[i] = malloc(sizeof(uint8_t) * (witness_count + 1), 
-		    M_WITNESS, M_NOWAIT | M_ZERO);
+	for (i = 0; i < witness_count + 1; i++) {
+		w_rmatrix[i] = malloc(sizeof(*w_rmatrix[i]) *
+		    (witness_count + 1), M_WITNESS, M_WAITOK | M_ZERO);
 	}
 	badstack_sbuf_size = witness_count * 256;
-	
+
 	/*
 	 * We have to release Giant before initializing its witness
 	 * structure so that WITNESS doesn't get confused.
@@ -766,8 +765,8 @@ witness_initialize(void *dummy __unused)
 	STAILQ_REMOVE_HEAD(&w_free, w_list);
 	w_free_cnt--;
 
-	for(i = 0; i < witness_count; i++) {
-		memset(w_rmatrix[i], 0, sizeof(uint8_t) * 
+	for (i = 0; i < witness_count; i++) {
+		memset(w_rmatrix[i], 0, sizeof(*w_rmatrix[i]) * 
 		    (witness_count + 1));
 	}
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201410111634.s9BGY2jN057945>