From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (qmail 2820 invoked from network); 17 May 1999 18:40:31 -0000 Received: from mail.redhat.com (199.183.24.239) by lists.redhat.com with SMTP; 17 May 1999 18:40:31 -0000 Received: from jurassic.park.msu.ru (jurassic.park.msu.ru [195.208.223.243]) by mail.redhat.com (8.8.7/8.8.7) with ESMTP id OAA09550 for ; Mon, 17 May 1999 14:02:25 -0400 Received: (from ink@localhost) by jurassic.park.msu.ru (8.8.7/8.8.7) id WAA10763; Mon, 17 May 1999 22:01:21 +0400 Date: Mon, 17 May 1999 22:01:21 +0400 From: Ivan Kokshaysky To: Jean-Baptiste Vignaud , Richard Henderson Cc: axp-list Subject: Re: 2.3.x broken Message-ID: <19990517220121.A10751@jurassic.park.msu.ru> References: <000001bea046$0581cc60$cc000001@PC_VIGNAUD.xandmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.95.4i In-Reply-To: <000001bea046$0581cc60$cc000001@PC_VIGNAUD.xandmail.com>; from Jean-Baptiste Vignaud on Mon, May 17, 1999 at 11:17:01AM +0200 On Mon, May 17, 1999 at 11:17:01AM +0200, Jean-Baptiste Vignaud wrote: > > I'v downloaded the 2.2.8->2.3.0, 2.3.1 and 2.3.2 patches and the compilation > (redhat/sx164) fails for > 2.3.1 and 2.3.2 in semaphore.h. > Here is the patch against 2.3.3. It compiles, though I haven't boot it. Ivan diff -ur linux-2.3.3/arch/alpha/kernel/process.c linux/arch/alpha/kernel/process.c --- linux-2.3.3/arch/alpha/kernel/process.c Fri May 14 23:41:23 1999 +++ linux/arch/alpha/kernel/process.c Mon May 17 21:14:46 1999 @@ -58,10 +58,10 @@ static struct file * init_fd_array[NR_OPEN] = { NULL, }; static struct files_struct init_files = INIT_FILES; static struct signal_struct init_signals = INIT_SIGNALS; -struct mm_struct init_mm = INIT_MM; +struct mm_struct init_mm = INIT_MM(init_mm); union task_union init_task_union __attribute__((section("init_task"))) - = { task: INIT_TASK }; + = { task: INIT_TASK(init_task_union.task) }; /* * No need to acquire the kernel lock, we're entirely local.. diff -ur linux-2.3.3/include/asm-alpha/semaphore.h linux/include/asm-alpha/semaphore.h --- linux-2.3.3/include/asm-alpha/semaphore.h Sun May 16 02:05:37 1999 +++ linux/include/asm-alpha/semaphore.h Mon May 17 21:09:19 1999 @@ -11,20 +11,63 @@ #include #include #include +#include struct semaphore { /* Careful, inline assembly knows about the position of these two. */ atomic_t count; atomic_t waking; /* biased by -1 */ wait_queue_head_t wait; +#if WAITQUEUE_DEBUG + long __magic; +#endif }; -#define MUTEX ((struct semaphore) \ - { ATOMIC_INIT(1), ATOMIC_INIT(-1), NULL }) -#define MUTEX_LOCKED ((struct semaphore) \ - { ATOMIC_INIT(0), ATOMIC_INIT(-1), NULL }) +#if WAITQUEUE_DEBUG +# define __SEM_DEBUG_INIT(name) \ + , (long)&(name).__magic +#else +# define __SEM_DEBUG_INIT(name) +#endif + +#define __SEMAPHORE_INITIALIZER(name,count) \ +{ ATOMIC_INIT(count), ATOMIC_INIT(-1), __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \ + __SEM_DEBUG_INIT(name) } + +#define __MUTEX_INITIALIZER(name) \ + __SEMAPHORE_INITIALIZER(name,1) -#define sema_init(sem, val) atomic_set(&((sem)->count), val) +#define __DECLARE_SEMAPHORE_GENERIC(name,count) \ + struct semaphore name = __SEMAPHORE_INITIALIZER(name,count) + +#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1) +#define DECLARE_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,0) + +extern inline void sema_init (struct semaphore *sem, int val) +{ +/* + * *sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val); + * + * i'd rather use the more flexible initialization above, but sadly + * GCC 2.7.2.3 emits a bogus warning. EGCS doesnt. Oh well. + */ + atomic_set(&sem->count, val); + atomic_set(&sem->waking, -1); + init_waitqueue_head(&sem->wait); +#if WAITQUEUE_DEBUG + sem->__magic = (long)&sem->__magic; +#endif +} + +static inline void init_MUTEX (struct semaphore *sem) +{ + sema_init(sem, 1); +} + +static inline void init_MUTEX_LOCKED (struct semaphore *sem) +{ + sema_init(sem, 0); +} extern void __down(struct semaphore * sem); extern int __down_interruptible(struct semaphore * sem); @@ -59,6 +102,10 @@ the linker. */ register void *pv __asm__("$27") = __down_failed; +#if WAITQUEUE_DEBUG + CHECK_MAGIC(sem->__magic); +#endif + __asm__ __volatile__ ( "/* semaphore down operation */\n" "1: ldl_l $24,%1\n" @@ -90,6 +137,9 @@ register int ret __asm__("$24"); register void *pv __asm__("$27") = __down_failed_interruptible; +#if WAITQUEUE_DEBUG + CHECK_MAGIC(sem->__magic); +#endif __asm__ __volatile__ ( "/* semaphore down interruptible operation */\n" "1: ldl_l $24,%2\n" @@ -125,6 +175,9 @@ { long ret, tmp, tmp2, sub; +#if WAITQUEUE_DEBUG + CHECK_MAGIC(sem->__magic); +#endif /* "Equivalent" C. Note that we have to do this all without (taken) branches in order to be a valid ll/sc sequence. @@ -181,6 +234,9 @@ register void *pv __asm__("$27") = __up_wakeup; +#if WAITQUEUE_DEBUG + CHECK_MAGIC(sem->__magic); +#endif __asm__ __volatile__ ( "/* semaphore up operation */\n" " mb\n"