From: Randolph Chung <randolph@tausq.org>
To: parisc-linux@lists.parisc-linux.org
Subject: [parisc-linux] [patch] pdc printing
Date: Fri, 30 Jul 2004 09:20:37 -0700 [thread overview]
Message-ID: <20040730162037.GG546@tausq.org> (raw)
Using debug spinlocks, sometimes we don't see any output, possibly
because of disabled interrupts or because of deadlocks in printk. This
patch makes the debug spinlock prints go through pdc console instead. It
works but i'm not completely happy with the fact that by replacing
printk() with pdc_printf() in debuglocks, the output only goes to
the pdc console and not "linux consoles" ... thoughts?
--- arch/parisc/kernel/pdc_cons.c 19 Jan 2004 05:15:47 -0000 1.6
+++ arch/parisc/kernel/pdc_cons.c 30 Jul 2004 00:47:55 -0000
@@ -71,6 +71,19 @@ void pdc_outc(unsigned char c)
pdc_iodc_outc(c);
}
+void pdc_printf(const char *fmt, ...)
+{
+ va_list args;
+ char buf[1024];
+ int i, len;
+
+ va_start(args, fmt);
+ len = vscnprintf(buf, sizeof(buf), fmt, args);
+ va_end(args);
+
+ for (i = 0; i < len; i++)
+ pdc_iodc_outc(buf[i]);
+}
int pdc_console_poll_key(struct console *co)
{
--- arch/parisc/lib/debuglocks.c 14 Jul 2004 18:20:34 -0000 1.7
+++ arch/parisc/lib/debuglocks.c 30 Jul 2004 00:47:55 -0000
@@ -27,12 +27,14 @@
#include <linux/spinlock.h>
#include <asm/system.h>
#include <asm/hardirq.h> /* in_interrupt() */
+#include <asm/pdc.h>
#undef INIT_STUCK
#define INIT_STUCK 1L << 30
#ifdef CONFIG_DEBUG_SPINLOCK
+
void _dbg_spin_lock(spinlock_t * lock, const char *base_file, int line_no)
{
volatile unsigned int *a;
@@ -64,7 +66,7 @@ try_again:
while ((*a == 0) && --stuck);
if (unlikely(stuck <= 0)) {
- printk(KERN_WARNING
+ pdc_printf(
"%s:%d: spin_lock(%s/%p) stuck in %s at %p(%d)"
" owned by %s:%d in %s at %p(%d)\n",
base_file, line_no, lock->module, lock,
@@ -84,7 +86,7 @@ try_again:
lock->bline = line_no;
if (unlikely(printed)) {
- printk(KERN_WARNING
+ pdc_printf(
"%s:%d: spin_lock grabbed in %s at %p(%d) %ld ticks\n",
base_file, line_no, current->comm, inline_pc,
cpu, jiffies - started);
@@ -97,7 +99,7 @@ void _dbg_spin_unlock(spinlock_t * lock,
volatile unsigned int *a = __ldcw_align(lock);
if (unlikely((*a != 0) && lock->babble)) {
lock->babble--;
- printk(KERN_WARNING
+ pdc_printf(
"%s:%d: spin_unlock(%s:%p) not locked\n",
base_file, line_no, lock->module, lock);
}
@@ -150,7 +152,7 @@ void _dbg_write_lock(rwlock_t *rw, const
int cpu = smp_processor_id();
if(unlikely(in_interrupt())) { /* acquiring write lock in interrupt context, bad idea */
- printk(KERN_WARNING "write_lock caller: %s:%d, IRQs enabled,\n", bfile, bline);
+ pdc_printf("write_lock caller: %s:%d, IRQs enabled,\n", bfile, bline);
BUG();
}
@@ -167,7 +169,7 @@ retry:
stuck--;
if ((unlikely(stuck <= 0)) && (rw->counter < 0)) {
- printk(KERN_WARNING
+ pdc_printf(
"%s:%d: write_lock stuck on writer"
" in %s at %p(%d) %ld ticks\n",
bfile, bline, current->comm, inline_pc,
@@ -176,7 +178,7 @@ retry:
printed = 1;
}
else if (unlikely(stuck <= 0)) {
- printk(KERN_WARNING
+ pdc_printf(
"%s:%d: write_lock stuck on reader"
" in %s at %p(%d) %ld ticks\n",
bfile, bline, current->comm, inline_pc,
@@ -194,7 +196,7 @@ retry:
rw->counter = -1; /* remember we are locked */
if (unlikely(printed)) {
- printk(KERN_WARNING
+ pdc_printf(
"%s:%d: write_lock grabbed in %s at %p(%d) %ld ticks\n",
bfile, bline, current->comm, inline_pc,
cpu, jiffies - started);
@@ -215,7 +217,7 @@ void _dbg_read_lock(rwlock_t * rw, const
rw->counter++;
#if 0
- printk(KERN_WARNING
+ pdc_printf(
"%s:%d: read_lock grabbed in %s at %p(%d) %ld ticks\n",
bfile, bline, current->comm, inline_pc,
cpu, jiffies - started);
--- include/asm-parisc/pdc.h 10 Jul 2004 07:51:15 -0000 1.8
+++ include/asm-parisc/pdc.h 30 Jul 2004 00:47:58 -0000
@@ -754,6 +754,7 @@ void pdc_io_reset_devices(void);
int pdc_iodc_getc(void);
void pdc_iodc_putc(unsigned char c);
void pdc_iodc_outc(unsigned char c);
+void pdc_printf(const char *fmt, ...);
void pdc_emergency_unlock(void);
int pdc_sti_call(unsigned long func, unsigned long flags,
--
Randolph Chung
Debian GNU/Linux Developer, hppa/ia64 ports
http://www.tausq.org/
_______________________________________________
parisc-linux mailing list
parisc-linux@lists.parisc-linux.org
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux
reply other threads:[~2004-07-30 16:20 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040730162037.GG546@tausq.org \
--to=randolph@tausq.org \
--cc=parisc-linux@lists.parisc-linux.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.