Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id ; Tue, 12 Feb 2002 15:01:24 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id ; Tue, 12 Feb 2002 15:01:15 -0500 Received: from air-2.osdl.org ([65.201.151.6]:2176 "EHLO doc.pdx.osdl.net") by vger.kernel.org with ESMTP id ; Tue, 12 Feb 2002 15:01:01 -0500 Date: Tue, 12 Feb 2002 12:01:00 -0800 From: Bob Miller To: linux-kernel@vger.kernel.org Subject: [PATCH] 2.5.4 Can't use spin_lock_* with wait_queue_head_t object. Message-ID: <20020212120100.A7619@doc.pdx.osdl.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.3.23i Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org There is code in sched.c that uses the spin_lock_* interfaces to acquire and release the lock in the wait_queue_head_t embedded in the struct completion. This is wrong and causes the system to OPPs on startup when compiled with wait.h:USE_RW_WAIT_QUEUE_SPINLOCK set to 1. The patch below changes the spin_lock_* calls to wq_write_lock_*. -- Bob Miller Email: rem@osdl.org Open Software Development Lab Phone: 503.626.2455 Ext. 17 diff -ru linux.2.5.4-orig/include/linux/wait.h linux.2.5.4/include/linux/wait.h --- linux.2.5.4-orig/include/linux/wait.h Sun Feb 10 17:50:07 2002 +++ linux.2.5.4/include/linux/wait.h Mon Feb 11 11:22:21 2002 @@ -45,6 +45,7 @@ # define wq_read_unlock read_unlock # define wq_write_lock_irq write_lock_irq # define wq_write_lock_irqsave write_lock_irqsave +# define wq_write_unlock_irq write_unlock_irq # define wq_write_unlock_irqrestore write_unlock_irqrestore # define wq_write_unlock write_unlock #else @@ -57,6 +58,7 @@ # define wq_read_unlock_irqrestore spin_unlock_irqrestore # define wq_write_lock_irq spin_lock_irq # define wq_write_lock_irqsave spin_lock_irqsave +# define wq_write_unlock_irq spin_unlock_irq # define wq_write_unlock_irqrestore spin_unlock_irqrestore # define wq_write_unlock spin_unlock #endif diff -ru linux.2.5.4-orig/kernel/sched.c linux.2.5.4/kernel/sched.c --- linux.2.5.4-orig/kernel/sched.c Sun Feb 10 17:50:12 2002 +++ linux.2.5.4/kernel/sched.c Mon Feb 11 11:22:21 2002 @@ -806,15 +806,15 @@ { unsigned long flags; - spin_lock_irqsave(&x->wait.lock, flags); + wq_write_lock_irqsave(&x->wait.lock, flags); x->done++; __wake_up_common(&x->wait, TASK_UNINTERRUPTIBLE | TASK_INTERRUPTIBLE, 1, 0); - spin_unlock_irqrestore(&x->wait.lock, flags); + wq_write_unlock_irqrestore(&x->wait.lock, flags); } void wait_for_completion(struct completion *x) { - spin_lock_irq(&x->wait.lock); + wq_write_lock_irq(&x->wait.lock); if (!x->done) { DECLARE_WAITQUEUE(wait, current); @@ -822,14 +822,14 @@ __add_wait_queue_tail(&x->wait, &wait); do { __set_current_state(TASK_UNINTERRUPTIBLE); - spin_unlock_irq(&x->wait.lock); + wq_write_unlock_irq(&x->wait.lock); schedule(); - spin_lock_irq(&x->wait.lock); + wq_write_lock_irq(&x->wait.lock); } while (!x->done); __remove_wait_queue(&x->wait, &wait); } x->done--; - spin_unlock_irq(&x->wait.lock); + wq_write_unlock_irq(&x->wait.lock); } #define SLEEP_ON_VAR \ - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/