Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 18 May 2010 10:24:23 +0000 (UTC)
From:      Attilio Rao <attilio@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r208261 - in stable/8/sys: arm/include ddb kern sys
Message-ID:  <201005181024.o4IAONxH018158@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: attilio
Date: Tue May 18 10:24:23 2010
New Revision: 208261
URL: http://svn.freebsd.org/changeset/base/208261

Log:
  MFC r207922, r207925, r207929, r208052:
  - Change the db_printf return value in order to catch up with printf
  - Make witness_list_locks() and witness_display_spinlock() accept
    callbacks for printf-like functions in order to queue the output on the
    correct channel.

Modified:
  stable/8/sys/arm/include/disassem.h
  stable/8/sys/ddb/db_output.c
  stable/8/sys/ddb/ddb.h
  stable/8/sys/kern/kern_mutex.c
  stable/8/sys/kern/subr_pcpu.c
  stable/8/sys/kern/subr_witness.c
  stable/8/sys/sys/lock.h
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)
  stable/8/sys/geom/sched/   (props changed)

Modified: stable/8/sys/arm/include/disassem.h
==============================================================================
--- stable/8/sys/arm/include/disassem.h	Tue May 18 10:21:49 2010	(r208260)
+++ stable/8/sys/arm/include/disassem.h	Tue May 18 10:24:23 2010	(r208261)
@@ -43,7 +43,7 @@
 typedef struct {
 	u_int	(*di_readword)(u_int);
 	void	(*di_printaddr)(u_int);	
-	void	(*di_printf)(const char *, ...) __printflike(1, 2);
+	int	(*di_printf)(const char *, ...) __printflike(1, 2);
 } disasm_interface_t;
 
 /* Prototypes for callable functions */

Modified: stable/8/sys/ddb/db_output.c
==============================================================================
--- stable/8/sys/ddb/db_output.c	Tue May 18 10:21:49 2010	(r208260)
+++ stable/8/sys/ddb/db_output.c	Tue May 18 10:24:23 2010	(r208261)
@@ -316,7 +316,7 @@ db_print_position()
 /*
  * Printing
  */
-void
+int
 db_printf(const char *fmt, ...)
 {
 #ifdef DDB_BUFR_SIZE
@@ -324,6 +324,7 @@ db_printf(const char *fmt, ...)
 #endif
 	struct dbputchar_arg dca;
 	va_list	listp;
+	int retval;
 
 #ifdef DDB_BUFR_SIZE
 	dca.da_pbufr = bufr;
@@ -336,13 +337,14 @@ db_printf(const char *fmt, ...)
 #endif
 
 	va_start(listp, fmt);
-	kvprintf (fmt, db_putchar, &dca, db_radix, listp);
+	retval = kvprintf (fmt, db_putchar, &dca, db_radix, listp);
 	va_end(listp);
 
 #ifdef DDB_BUFR_SIZE
 	if (*dca.da_pbufr != '\0')
 		db_puts(dca.da_pbufr);
 #endif
+	return (retval);
 }
 
 int db_indent;

Modified: stable/8/sys/ddb/ddb.h
==============================================================================
--- stable/8/sys/ddb/ddb.h	Tue May 18 10:21:49 2010	(r208260)
+++ stable/8/sys/ddb/ddb.h	Tue May 18 10:24:23 2010	(r208261)
@@ -200,7 +200,7 @@ int		db_md_clr_watchpoint(db_expr_t addr
 void		db_md_list_watchpoints(void);
 void		db_print_loc_and_inst(db_addr_t loc);
 void		db_print_thread(void);
-void		db_printf(const char *fmt, ...) __printflike(1, 2);
+int		db_printf(const char *fmt, ...) __printflike(1, 2);
 int		db_read_bytes(vm_offset_t addr, size_t size, char *data);
 				/* machine-dependent */
 int		db_readline(char *lstart, int lsize);

Modified: stable/8/sys/kern/kern_mutex.c
==============================================================================
--- stable/8/sys/kern/kern_mutex.c	Tue May 18 10:21:49 2010	(r208260)
+++ stable/8/sys/kern/kern_mutex.c	Tue May 18 10:24:23 2010	(r208261)
@@ -485,7 +485,7 @@ _mtx_lock_spin_failed(struct mtx *m)
 	printf( "spin lock %p (%s) held by %p (tid %d) too long\n",
 	    m, m->lock_object.lo_name, td, td->td_tid);
 #ifdef WITNESS
-	witness_display_spinlock(&m->lock_object, td);
+	witness_display_spinlock(&m->lock_object, td, printf);
 #endif
 	panic("spin lock held too long");
 }

Modified: stable/8/sys/kern/subr_pcpu.c
==============================================================================
--- stable/8/sys/kern/subr_pcpu.c	Tue May 18 10:21:49 2010	(r208260)
+++ stable/8/sys/kern/subr_pcpu.c	Tue May 18 10:24:23 2010	(r208261)
@@ -363,7 +363,7 @@ show_pcpu(struct pcpu *pc)
 
 #ifdef WITNESS
 	db_printf("spin locks held:\n");
-	witness_list_locks(&pc->pc_spinlocks);
+	witness_list_locks(&pc->pc_spinlocks, db_printf);
 #endif
 }
 

Modified: stable/8/sys/kern/subr_witness.c
==============================================================================
--- stable/8/sys/kern/subr_witness.c	Tue May 18 10:21:49 2010	(r208260)
+++ stable/8/sys/kern/subr_witness.c	Tue May 18 10:24:23 2010	(r208261)
@@ -343,10 +343,10 @@ static int	sysctl_debug_witness_fullgrap
 static void	witness_add_fullgraph(struct sbuf *sb, struct witness *parent);
 #ifdef DDB
 static void	witness_ddb_compute_levels(void);
-static void	witness_ddb_display(void(*)(const char *fmt, ...));
-static void	witness_ddb_display_descendants(void(*)(const char *fmt, ...),
+static void	witness_ddb_display(int(*)(const char *fmt, ...));
+static void	witness_ddb_display_descendants(int(*)(const char *fmt, ...),
 		    struct witness *, int indent);
-static void	witness_ddb_display_list(void(*prnt)(const char *fmt, ...),
+static void	witness_ddb_display_list(int(*prnt)(const char *fmt, ...),
 		    struct witness_list *list);
 static void	witness_ddb_level_descendants(struct witness *parent, int l);
 static void	witness_ddb_list(struct thread *td);
@@ -367,7 +367,8 @@ static int	witness_lock_order_check(stru
 static struct witness_lock_order_data	*witness_lock_order_get(
 					    struct witness *parent,
 					    struct witness *child);
-static void	witness_list_lock(struct lock_instance *instance);
+static void	witness_list_lock(struct lock_instance *instance,
+		    int (*prnt)(const char *fmt, ...));
 static void	witness_setflag(struct lock_object *lock, int flag, int set);
 
 #ifdef KDB
@@ -905,7 +906,7 @@ witness_ddb_level_descendants(struct wit
 }
 
 static void
-witness_ddb_display_descendants(void(*prnt)(const char *fmt, ...),
+witness_ddb_display_descendants(int(*prnt)(const char *fmt, ...),
     struct witness *w, int indent)
 {
 	int i;
@@ -935,7 +936,7 @@ witness_ddb_display_descendants(void(*pr
 }
 
 static void
-witness_ddb_display_list(void(*prnt)(const char *fmt, ...),
+witness_ddb_display_list(int(*prnt)(const char *fmt, ...),
     struct witness_list *list)
 {
 	struct witness *w;
@@ -950,7 +951,7 @@ witness_ddb_display_list(void(*prnt)(con
 }
 	
 static void
-witness_ddb_display(void(*prnt)(const char *fmt, ...))
+witness_ddb_display(int(*prnt)(const char *fmt, ...))
 {
 	struct witness *w;
 
@@ -1594,7 +1595,7 @@ witness_thread_exit(struct thread *td)
 		printf("Thread %p exiting with the following locks held:\n",
 					    td);
 				n++;
-				witness_list_lock(&lle->ll_children[i]);
+				witness_list_lock(&lle->ll_children[i], printf);
 				
 			}
 		panic("Thread %p cannot exit while holding sleeplocks\n", td);
@@ -1643,7 +1644,7 @@ witness_warn(int flags, struct lock_obje
 				printf(" locks held:\n");
 			}
 			n++;
-			witness_list_lock(lock1);
+			witness_list_lock(lock1, printf);
 		}
 
 	/*
@@ -1674,7 +1675,7 @@ witness_warn(int flags, struct lock_obje
 		if (flags & WARN_SLEEPOK)
 			printf(" non-sleepable");
 		printf(" locks held:\n");
-		n += witness_list_locks(&lock_list);
+		n += witness_list_locks(&lock_list, printf);
 	} else
 		sched_unpin();
 	if (flags & WARN_PANIC && n)
@@ -2060,16 +2061,17 @@ find_instance(struct lock_list_entry *li
 }
 
 static void
-witness_list_lock(struct lock_instance *instance)
+witness_list_lock(struct lock_instance *instance,
+    int (*prnt)(const char *fmt, ...))
 {
 	struct lock_object *lock;
 
 	lock = instance->li_lock;
-	printf("%s %s %s", (instance->li_flags & LI_EXCLUSIVE) != 0 ?
+	prnt("%s %s %s", (instance->li_flags & LI_EXCLUSIVE) != 0 ?
 	    "exclusive" : "shared", LOCK_CLASS(lock)->lc_name, lock->lo_name);
 	if (lock->lo_witness->w_name != lock->lo_name)
-		printf(" (%s)", lock->lo_witness->w_name);
-	printf(" r = %d (%p) locked @ %s:%d\n",
+		prnt(" (%s)", lock->lo_witness->w_name);
+	prnt(" r = %d (%p) locked @ %s:%d\n",
 	    instance->li_flags & LI_RECURSEMASK, lock, instance->li_file,
 	    instance->li_line);
 }
@@ -2098,7 +2100,8 @@ witness_proc_has_locks(struct proc *p)
 #endif
 
 int
-witness_list_locks(struct lock_list_entry **lock_list)
+witness_list_locks(struct lock_list_entry **lock_list,
+    int (*prnt)(const char *fmt, ...))
 {
 	struct lock_list_entry *lle;
 	int i, nheld;
@@ -2106,7 +2109,7 @@ witness_list_locks(struct lock_list_entr
 	nheld = 0;
 	for (lle = *lock_list; lle != NULL; lle = lle->ll_next)
 		for (i = lle->ll_count - 1; i >= 0; i--) {
-			witness_list_lock(&lle->ll_children[i]);
+			witness_list_lock(&lle->ll_children[i], prnt);
 			nheld++;
 		}
 	return (nheld);
@@ -2120,7 +2123,8 @@ witness_list_locks(struct lock_list_entr
  * see when it was last acquired.
  */
 void
-witness_display_spinlock(struct lock_object *lock, struct thread *owner)
+witness_display_spinlock(struct lock_object *lock, struct thread *owner,
+    int (*prnt)(const char *fmt, ...))
 {
 	struct lock_instance *instance;
 	struct pcpu *pc;
@@ -2130,7 +2134,7 @@ witness_display_spinlock(struct lock_obj
 	pc = pcpu_find(owner->td_oncpu);
 	instance = find_instance(pc->pc_spinlocks, lock);
 	if (instance != NULL)
-		witness_list_lock(instance);
+		witness_list_lock(instance, prnt);
 }
 
 void
@@ -2303,7 +2307,7 @@ witness_ddb_list(struct thread *td)
 	if (witness_watch < 1)
 		return;
 
-	witness_list_locks(&td->td_sleeplocks);
+	witness_list_locks(&td->td_sleeplocks, db_printf);
 
 	/*
 	 * We only handle spinlocks if td == curthread.  This is somewhat broken
@@ -2319,7 +2323,7 @@ witness_ddb_list(struct thread *td)
 	 * handle threads on other CPU's for now.
 	 */
 	if (td == curthread && PCPU_GET(spinlocks) != NULL)
-		witness_list_locks(PCPU_PTR(spinlocks));
+		witness_list_locks(PCPU_PTR(spinlocks), db_printf);
 }
 
 DB_SHOW_COMMAND(locks, db_witness_list)

Modified: stable/8/sys/sys/lock.h
==============================================================================
--- stable/8/sys/sys/lock.h	Tue May 18 10:21:49 2010	(r208260)
+++ stable/8/sys/sys/lock.h	Tue May 18 10:24:23 2010	(r208261)
@@ -197,7 +197,7 @@ extern struct lock_class lock_class_lock
 extern struct lock_class *lock_classes[];
 
 void	lock_init(struct lock_object *, struct lock_class *,
-    const char *, const char *, int);
+	    const char *, const char *, int);
 void	lock_destroy(struct lock_object *);
 void	spinlock_enter(void);
 void	spinlock_exit(void);
@@ -205,17 +205,19 @@ void	witness_init(struct lock_object *, 
 void	witness_destroy(struct lock_object *);
 int	witness_defineorder(struct lock_object *, struct lock_object *);
 void	witness_checkorder(struct lock_object *, int, const char *, int,
-    struct lock_object *);
+	    struct lock_object *);
 void	witness_lock(struct lock_object *, int, const char *, int);
 void	witness_upgrade(struct lock_object *, int, const char *, int);
 void	witness_downgrade(struct lock_object *, int, const char *, int);
 void	witness_unlock(struct lock_object *, int, const char *, int);
 void	witness_save(struct lock_object *, const char **, int *);
 void	witness_restore(struct lock_object *, const char *, int);
-int	witness_list_locks(struct lock_list_entry **);
+int	witness_list_locks(struct lock_list_entry **,
+	    int (*)(const char *, ...));
 int	witness_warn(int, struct lock_object *, const char *, ...);
 void	witness_assert(struct lock_object *, int, const char *, int);
-void	witness_display_spinlock(struct lock_object *, struct thread *);
+void	witness_display_spinlock(struct lock_object *, struct thread *,
+	    int (*)(const char *, ...));
 int	witness_line(struct lock_object *);
 void	witness_norelease(struct lock_object *);
 void	witness_releaseok(struct lock_object *);



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