PR sparc64/71729

Pyun YongHyeon yongari at kt-is.co.kr
Mon Sep 20 03:40:13 PDT 2004


On Fri, Sep 17, 2004 at 09:29:41AM -0400, Doug Haigh wrote:
 > My emails & problem report follow-ups from my gatorzone.com domain seem to
 > be failing. Hopefully this will reach you...
 >  
 > Doug Haigh
 >  
 > -----Original Message-----
 > From: cd [mailto:cd_freebsd at gatorzone.com] 
 > Sent: Thursday, September 16, 2004 2:54 PM
 > To: 'freebsd-sparc64 at FreeBSD.org'
 > Subject: PR sparc64/71729
 > 
 > 
 > I am not sure if the PR got updated, but I wanted to let you know that the
 > printf in a kernel thread only fails if you are on a SMP machine. It appears
 > that if you printf on a CPU other than CPU #0, it will panic the kernel.
 >  

After reading your mail, I made a small test program which creates
a kernel thread and ran it on AXe(UP) and U2(SMP).
Under AXe it worked as expected but it paniced on U2.
So it seems that there is some issues in OF console.
Backtrace for the panic is somthing like:

openfirmware + 0x18
OF_write + 0x1c
ofw_cons_putc + 0x34
cnputc + 0x44
putchar + 0xbc
kvprintf + 0x4c
printf + 0x4c

I've attached simple test program used. I vaguely guess it may be
related with Kris' problem on his U30.

Regards,
Pyun YongHyeon
-- 
Pyun YongHyeon <http://www.kr.freebsd.org/~yongari>
-------------- next part --------------
#

.PATH:	${.CURDIR}

KMOD=	kthread
SRCS=	kthread.c

.include <bsd.kmod.mk>
-------------- next part --------------
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/kthread.h>
#include <sys/lock.h>
#include <sys/module.h>
#include <sys/mutex.h>
#include <sys/proc.h>
#include <sys/systm.h>

struct foo_struct {
	int term;
	struct mtx lock;
};
struct foo_struct foo_struct;

#define FOO_LOCK()	mtx_lock(&foo_struct.lock)
#define FOO_UNLOCK()	mtx_unlock(&foo_struct.lock)

static void
foo_thread(void *arg)
{
	int i = 0;

	FOO_LOCK();
	do {
		printf("foo_thread : %d\n", i++);
		msleep(&foo_struct, &foo_struct.lock, PWAIT, "twait1", 2*hz);
	} while(foo_struct.term == 0);

	printf("foo_thread termination request\n");
	foo_struct.term = 2;
	FOO_UNLOCK();
	kthread_exit(0);
}

static int
foo_alloc(void)
{
	int error;

	bzero(&foo_struct, sizeof(foo_struct));
	mtx_init(&foo_struct.lock, "foo mtx", NULL, MTX_DEF);
	error = kthread_create(foo_thread, NULL, NULL, 0, 0, "foo_thr");
	if (error != 0) {
		printf("kthread_create returned %d\n", error);
		return (1);
	}
	return (0);
}

static void
foo_free(void)
{
	FOO_LOCK();
	foo_struct.term = 1;
	wakeup(&foo_struct);
	printf("waiting for thread termination\n");
	msleep(&foo_struct, &foo_struct.lock, PWAIT, "twait2", 2*hz);
	FOO_UNLOCK();
	mtx_destroy(&foo_struct.lock);
}

static int
ktread_modevent(module_t mod, int type, void *data)
{
	int err = 0;

	switch(type) {
	case MOD_LOAD:
		foo_alloc();
		break;

	case MOD_UNLOAD:
		foo_free();
		break;
	default:
		err = EINVAL;
		break;
	}

	return (err);
}

static moduledata_t kthread_alloc = {
        "kthread",
        ktread_modevent,
        0
};

DECLARE_MODULE(kthread, kthread_alloc, SI_SUB_PSEUDO, SI_ORDER_FIRST);
MODULE_VERSION(kthread, 1);


More information about the freebsd-sparc64 mailing list