Re: svn commit: r233045 - in head/sys: conf kern

2012-03-20 Thread Gleb Smirnoff
On Mon, Mar 19, 2012 at 09:06:36PM +0100, Davide Italiano wrote:
D  These indented ifdefs look like a major violation of style used throughout
D  the FreeBSD kernel code. Can you please keep with common style?
D 
D 
D  Heh,
D  sorry, also Juli Mallet noticed this, I'm writing a fix for this and
D  after I'll have approval from my mentor I'll commit.

Looks okay, apart from additional empty line in NOTES. Isn't single
empty line enough?

-- 
Totus tuus, Glebius.
___
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: r233045 - in head/sys: conf kern

2012-03-20 Thread Davide Italiano
2012/3/20 Gleb Smirnoff gleb...@freebsd.org:
 On Mon, Mar 19, 2012 at 09:06:36PM +0100, Davide Italiano wrote:
 D  These indented ifdefs look like a major violation of style used 
 throughout
 D  the FreeBSD kernel code. Can you please keep with common style?
 D 
 D 
 D  Heh,
 D  sorry, also Juli Mallet noticed this, I'm writing a fix for this and
 D  after I'll have approval from my mentor I'll commit.

 Looks okay, apart from additional empty line in NOTES. Isn't single
 empty line enough?

 --
 Totus tuus, Glebius.

Well, I removed that in my previous commit.
It was a mistake.
But if you think it's ok to remove that line, I have no objections on this.

Davide
___
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: r233045 - in head/sys: conf kern

2012-03-20 Thread Gleb Smirnoff
On Tue, Mar 20, 2012 at 06:00:50PM +0100, Davide Italiano wrote:
D 2012/3/20 Gleb Smirnoff gleb...@freebsd.org:
D  On Mon, Mar 19, 2012 at 09:06:36PM +0100, Davide Italiano wrote:
D  D  These indented ifdefs look like a major violation of style used 
throughout
D  D  the FreeBSD kernel code. Can you please keep with common style?
D  D 
D  D 
D  D  Heh,
D  D  sorry, also Juli Mallet noticed this, I'm writing a fix for this and
D  D  after I'll have approval from my mentor I'll commit.
D 
D  Looks okay, apart from additional empty line in NOTES. Isn't single
D  empty line enough?
D 
D  --
D  Totus tuus, Glebius.
D 
D Well, I removed that in my previous commit.
D It was a mistake.
D But if you think it's ok to remove that line, I have no objections on this.

Well, I'm not that style(9)-evident person :) I just personally dislike
multiple empty lines, since less code fits on a terminal. So I won't insist
on any choice here.

I just noticed incorrect indentation of ifdefs, and that's all.

-- 
Totus tuus, Glebius.
___
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: r233045 - in head/sys: conf kern

2012-03-19 Thread Gleb Smirnoff
  Davide,

On Fri, Mar 16, 2012 at 08:32:11PM +, Davide Italiano wrote:
D Author: davide
D Date: Fri Mar 16 20:32:11 2012
D New Revision: 233045
D URL: http://svn.freebsd.org/changeset/base/233045
D 
D Log:
D   Add rudimentary profiling of the hash table used in the in the umtx code to
D   hold active lock queues.
D   
D   Reviewed by:   attilio
D   Approved by:   davidxu, gnn (mentor)
D   MFC after: 3 weeks
D 
D Modified:
D   head/sys/conf/NOTES
D   head/sys/conf/options
D   head/sys/kern/kern_umtx.c

...

D  static void
D  umtxq_sysinit(void *arg __unused)
D  {
D @@ -232,8 +265,15 @@ umtxq_sysinit(void *arg __unused)
D  TAILQ_INIT(umtxq_chains[i][j].uc_pi_list);
D  umtxq_chains[i][j].uc_busy = 0;
D  umtxq_chains[i][j].uc_waiters = 0;
D +#ifdef UMTX_PROFILING
D +umtxq_chains[i][j].length = 0;
D +umtxq_chains[i][j].max_length = 0;  
D +#endif
D  }
D  }
D +#ifdef UMTX_PROFILING
D +umtx_init_profiling();
D +#endif
D  mtx_init(umtx_lock, umtx lock, NULL, MTX_SPIN);
D  EVENTHANDLER_REGISTER(process_exec, umtx_exec_hook, NULL,
D  EVENTHANDLER_PRI_ANY);
D @@ -384,6 +424,14 @@ umtxq_insert_queue(struct umtx_q *uq, in
D  
D  TAILQ_INSERT_TAIL(uh-head, uq, uq_link);
D  uh-length++;
D +#ifdef UMTX_PROFILING
D +uc-length++;
D +if (uc-length  uc-max_length) {
D +uc-max_length = uc-length;
D +if (uc-max_length  max_length)
D +max_length = uc-max_length;
D +}
D +#endif
D  uq-uq_flags |= UQF_UMTXQ;
D  uq-uq_cur_queue = uh;
D  return;
D @@ -401,6 +449,9 @@ umtxq_remove_queue(struct umtx_q *uq, in
D  uh = uq-uq_cur_queue;
D  TAILQ_REMOVE(uh-head, uq, uq_link);
D  uh-length--;
D +#ifdef UMTX_PROFILING
D +uc-length--;
D +#endif
D  uq-uq_flags = ~UQF_UMTXQ;
D  if (TAILQ_EMPTY(uh-head)) {
D  KASSERT(uh-length == 0,

These indented ifdefs look like a major violation of style used throughout
the FreeBSD kernel code. Can you please keep with common style?

-- 
Totus tuus, Glebius.
___
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: r233045 - in head/sys: conf kern

2012-03-19 Thread Davide Italiano
2012/3/19 Gleb Smirnoff gleb...@freebsd.org:
  Davide,

 On Fri, Mar 16, 2012 at 08:32:11PM +, Davide Italiano wrote:
 D Author: davide
 D Date: Fri Mar 16 20:32:11 2012
 D New Revision: 233045
 D URL: http://svn.freebsd.org/changeset/base/233045
 D
 D Log:
 D   Add rudimentary profiling of the hash table used in the in the umtx code 
 to
 D   hold active lock queues.
 D
 D   Reviewed by:       attilio
 D   Approved by:       davidxu, gnn (mentor)
 D   MFC after: 3 weeks
 D
 D Modified:
 D   head/sys/conf/NOTES
 D   head/sys/conf/options
 D   head/sys/kern/kern_umtx.c

 ...

 D  static void
 D  umtxq_sysinit(void *arg __unused)
 D  {
 D @@ -232,8 +265,15 @@ umtxq_sysinit(void *arg __unused)
 D                      TAILQ_INIT(umtxq_chains[i][j].uc_pi_list);
 D                      umtxq_chains[i][j].uc_busy = 0;
 D                      umtxq_chains[i][j].uc_waiters = 0;
 D +                    #ifdef UMTX_PROFILING
 D +                    umtxq_chains[i][j].length = 0;
 D +                    umtxq_chains[i][j].max_length = 0;
 D +                    #endif
 D              }
 D      }
 D +    #ifdef UMTX_PROFILING
 D +    umtx_init_profiling();
 D +    #endif
 D      mtx_init(umtx_lock, umtx lock, NULL, MTX_SPIN);
 D      EVENTHANDLER_REGISTER(process_exec, umtx_exec_hook, NULL,
 D          EVENTHANDLER_PRI_ANY);
 D @@ -384,6 +424,14 @@ umtxq_insert_queue(struct umtx_q *uq, in
 D
 D      TAILQ_INSERT_TAIL(uh-head, uq, uq_link);
 D      uh-length++;
 D +    #ifdef UMTX_PROFILING
 D +    uc-length++;
 D +    if (uc-length  uc-max_length) {
 D +            uc-max_length = uc-length;
 D +            if (uc-max_length  max_length)
 D +                    max_length = uc-max_length;
 D +    }
 D +    #endif
 D      uq-uq_flags |= UQF_UMTXQ;
 D      uq-uq_cur_queue = uh;
 D      return;
 D @@ -401,6 +449,9 @@ umtxq_remove_queue(struct umtx_q *uq, in
 D              uh = uq-uq_cur_queue;
 D              TAILQ_REMOVE(uh-head, uq, uq_link);
 D              uh-length--;
 D +            #ifdef UMTX_PROFILING
 D +            uc-length--;
 D +            #endif
 D              uq-uq_flags = ~UQF_UMTXQ;
 D              if (TAILQ_EMPTY(uh-head)) {
 D                      KASSERT(uh-length == 0,

 These indented ifdefs look like a major violation of style used throughout
 the FreeBSD kernel code. Can you please keep with common style?

 --
 Totus tuus, Glebius.

Heh,
sorry, also Juli Mallet noticed this, I'm writing a fix for this and
after I'll have approval from my mentor I'll commit.

Davide
___
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: r233045 - in head/sys: conf kern

2012-03-19 Thread Davide Italiano
On Mon, Mar 19, 2012 at 8:54 PM, Davide Italiano
davide.itali...@gmail.com wrote:
 2012/3/19 Gleb Smirnoff gleb...@freebsd.org:
  Davide,

 On Fri, Mar 16, 2012 at 08:32:11PM +, Davide Italiano wrote:
 D Author: davide
 D Date: Fri Mar 16 20:32:11 2012
 D New Revision: 233045
 D URL: http://svn.freebsd.org/changeset/base/233045
 D
 D Log:
 D   Add rudimentary profiling of the hash table used in the in the umtx 
 code to
 D   hold active lock queues.
 D
 D   Reviewed by:       attilio
 D   Approved by:       davidxu, gnn (mentor)
 D   MFC after: 3 weeks
 D
 D Modified:
 D   head/sys/conf/NOTES
 D   head/sys/conf/options
 D   head/sys/kern/kern_umtx.c

 ...

 D  static void
 D  umtxq_sysinit(void *arg __unused)
 D  {
 D @@ -232,8 +265,15 @@ umtxq_sysinit(void *arg __unused)
 D                      TAILQ_INIT(umtxq_chains[i][j].uc_pi_list);
 D                      umtxq_chains[i][j].uc_busy = 0;
 D                      umtxq_chains[i][j].uc_waiters = 0;
 D +                    #ifdef UMTX_PROFILING
 D +                    umtxq_chains[i][j].length = 0;
 D +                    umtxq_chains[i][j].max_length = 0;
 D +                    #endif
 D              }
 D      }
 D +    #ifdef UMTX_PROFILING
 D +    umtx_init_profiling();
 D +    #endif
 D      mtx_init(umtx_lock, umtx lock, NULL, MTX_SPIN);
 D      EVENTHANDLER_REGISTER(process_exec, umtx_exec_hook, NULL,
 D          EVENTHANDLER_PRI_ANY);
 D @@ -384,6 +424,14 @@ umtxq_insert_queue(struct umtx_q *uq, in
 D
 D      TAILQ_INSERT_TAIL(uh-head, uq, uq_link);
 D      uh-length++;
 D +    #ifdef UMTX_PROFILING
 D +    uc-length++;
 D +    if (uc-length  uc-max_length) {
 D +            uc-max_length = uc-length;
 D +            if (uc-max_length  max_length)
 D +                    max_length = uc-max_length;
 D +    }
 D +    #endif
 D      uq-uq_flags |= UQF_UMTXQ;
 D      uq-uq_cur_queue = uh;
 D      return;
 D @@ -401,6 +449,9 @@ umtxq_remove_queue(struct umtx_q *uq, in
 D              uh = uq-uq_cur_queue;
 D              TAILQ_REMOVE(uh-head, uq, uq_link);
 D              uh-length--;
 D +            #ifdef UMTX_PROFILING
 D +            uc-length--;
 D +            #endif
 D              uq-uq_flags = ~UQF_UMTXQ;
 D              if (TAILQ_EMPTY(uh-head)) {
 D                      KASSERT(uh-length == 0,

 These indented ifdefs look like a major violation of style used throughout
 the FreeBSD kernel code. Can you please keep with common style?

 --
 Totus tuus, Glebius.

 Heh,
 sorry, also Juli Mallet noticed this, I'm writing a fix for this and
 after I'll have approval from my mentor I'll commit.

 Davide

This should fix:
http://people.freebsd.org/~davide/umtx_stylefix.diff
Can you plase give it a closer look?
George, if everythin' is ok, can I have also your approval?
___
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: r233045 - in head/sys: conf kern

2012-03-16 Thread Davide Italiano
Author: davide
Date: Fri Mar 16 20:32:11 2012
New Revision: 233045
URL: http://svn.freebsd.org/changeset/base/233045

Log:
  Add rudimentary profiling of the hash table used in the in the umtx code to
  hold active lock queues.
  
  Reviewed by:  attilio
  Approved by:  davidxu, gnn (mentor)
  MFC after:3 weeks

Modified:
  head/sys/conf/NOTES
  head/sys/conf/options
  head/sys/kern/kern_umtx.c

Modified: head/sys/conf/NOTES
==
--- head/sys/conf/NOTES Fri Mar 16 20:24:30 2012(r233044)
+++ head/sys/conf/NOTES Fri Mar 16 20:32:11 2012(r233045)
@@ -274,6 +274,8 @@ options SX_NOINLINE
 #frequency.
 # TURNSTILE_PROFILING enables rudimentary profiling of the hash table
 #used to hold active lock queues.
+# UMTX_PROFILING enables rudimentary profiling of the hash table used 
+ to hold active lock queues.
 # WITNESS enables the witness code which detects deadlocks and cycles
 # during locking operations.
 # WITNESS_KDB causes the witness code to drop into the kernel debugger if
@@ -297,8 +299,8 @@ options MPROF_HASH_SIZE=1543
 # Profiling for internal hash tables.
 optionsSLEEPQUEUE_PROFILING
 optionsTURNSTILE_PROFILING
+optionsUMTX_PROFILING
 
-
 #
 # COMPATIBILITY OPTIONS
 

Modified: head/sys/conf/options
==
--- head/sys/conf/options   Fri Mar 16 20:24:30 2012(r233044)
+++ head/sys/conf/options   Fri Mar 16 20:32:11 2012(r233045)
@@ -186,6 +186,7 @@ SYSVSEM opt_sysvipc.h
 SYSVSHMopt_sysvipc.h
 SW_WATCHDOGopt_watchdog.h
 TURNSTILE_PROFILING
+UMTX_PROFILING
 VFS_AIO
 VFS_ALLOW_NONMPSAFE
 VERBOSE_SYSINITopt_global.h

Modified: head/sys/kern/kern_umtx.c
==
--- head/sys/kern/kern_umtx.c   Fri Mar 16 20:24:30 2012(r233044)
+++ head/sys/kern/kern_umtx.c   Fri Mar 16 20:32:11 2012(r233045)
@@ -29,6 +29,8 @@
 __FBSDID($FreeBSD$);
 
 #include opt_compat.h
+#include opt_umtx_profiling.h
+
 #include sys/param.h
 #include sys/kernel.h
 #include sys/limits.h
@@ -154,6 +156,10 @@ struct umtxq_chain {
/* All PI in the list */
TAILQ_HEAD(,umtx_pi)uc_pi_list;
 
+#ifdef UMTX_PROFILING
+   int length;
+   int max_length;
+#endif
 };
 
 #defineUMTXQ_LOCKED_ASSERT(uc) mtx_assert((uc)-uc_lock, 
MA_OWNED)
@@ -190,6 +196,12 @@ static SYSCTL_NODE(_debug, OID_AUTO, umt
 SYSCTL_INT(_debug_umtx, OID_AUTO, umtx_pi_allocated, CTLFLAG_RD,
 umtx_pi_allocated, 0, Allocated umtx_pi);
 
+#ifdef UMTX_PROFILING
+static long max_length;
+SYSCTL_LONG(_debug_umtx, OID_AUTO, max_length, CTLFLAG_RD, max_length, 0, 
max_length);
+static SYSCTL_NODE(_debug_umtx, OID_AUTO, chains, CTLFLAG_RD, 0, umtx chain 
stats);
+#endif
+
 static void umtxq_sysinit(void *);
 static void umtxq_hash(struct umtx_key *key);
 static struct umtxq_chain *umtxq_getchain(struct umtx_key *key);
@@ -215,6 +227,27 @@ SYSINIT(umtx, SI_SUB_EVENTHANDLER+1, SI_
 
 static struct mtx umtx_lock;
 
+#ifdef UMTX_PROFILING
+static void
+umtx_init_profiling(void) 
+{
+   struct sysctl_oid *chain_oid;
+   char chain_name[10];
+   int i;
+
+   for (i = 0; i  UMTX_CHAINS; ++i) {
+   snprintf(chain_name, sizeof(chain_name), %d, i);
+   chain_oid = SYSCTL_ADD_NODE(NULL, 
+   SYSCTL_STATIC_CHILDREN(_debug_umtx_chains), OID_AUTO, 
+   chain_name, CTLFLAG_RD, NULL, umtx hash stats);
+   SYSCTL_ADD_INT(NULL, SYSCTL_CHILDREN(chain_oid), OID_AUTO,
+   max_length0, CTLFLAG_RD, umtxq_chains[0][i].max_length, 
0, NULL);
+   SYSCTL_ADD_INT(NULL, SYSCTL_CHILDREN(chain_oid), OID_AUTO,
+   max_length1, CTLFLAG_RD, umtxq_chains[1][i].max_length, 
0, NULL);
+   }
+}
+#endif
+
 static void
 umtxq_sysinit(void *arg __unused)
 {
@@ -232,8 +265,15 @@ umtxq_sysinit(void *arg __unused)
TAILQ_INIT(umtxq_chains[i][j].uc_pi_list);
umtxq_chains[i][j].uc_busy = 0;
umtxq_chains[i][j].uc_waiters = 0;
+   #ifdef UMTX_PROFILING
+   umtxq_chains[i][j].length = 0;
+   umtxq_chains[i][j].max_length = 0;  
+   #endif
}
}
+   #ifdef UMTX_PROFILING
+   umtx_init_profiling();
+   #endif
mtx_init(umtx_lock, umtx lock, NULL, MTX_SPIN);
EVENTHANDLER_REGISTER(process_exec, umtx_exec_hook, NULL,
EVENTHANDLER_PRI_ANY);
@@ -384,6 +424,14 @@ umtxq_insert_queue(struct umtx_q *uq, in
 
TAILQ_INSERT_TAIL(uh-head, uq, uq_link);