Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 20 Sep 2004 19:40:06 +0900
From:      Pyun YongHyeon <yongari@kt-is.co.kr>
To:        dhaigh@gatorzone.com
Cc:        sparc64@freebsd.org
Subject:   Re: PR sparc64/71729
Message-ID:  <20040920104006.GA1905@kt-is.co.kr>
In-Reply-To: <!~!UENERkVCMDkAAQACAAAAAAAAAAAAAAAAABgAAAAAAAAACQvSeqVn1BGUQgBglOsMr8KAAAAQAAAAcPmXkBll7EW4XKEqja5UUQEAAAAA@nc.rr.com>
References:  <!~!UENERkVCMDkAAQACAAAAAAAAAAAAAAAAABgAAAAAAAAACQvSeqVn1BGUQgBglOsMr8KAAAAQAAAAcPmXkBll7EW4XKEqja5UUQEAAAAA@nc.rr.com>

Next in thread | Previous in thread | Raw E-Mail | Index | Archive | Help

--a8Wt8u1KmwUX3Y2C
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

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@gatorzone.com] 
 > Sent: Thursday, September 16, 2004 2:54 PM
 > To: 'freebsd-sparc64@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>;

--a8Wt8u1KmwUX3Y2C
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=Makefile

#

.PATH:	${.CURDIR}

KMOD=	kthread
SRCS=	kthread.c

.include <bsd.kmod.mk>

--a8Wt8u1KmwUX3Y2C
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="kthread.c"

#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);

--a8Wt8u1KmwUX3Y2C--



Want to link to this message? Use this URL: <http://docs.FreeBSD.org/cgi/mid.cgi?20040920104006.GA1905>