Date: Fri, 28 Apr 2000 08:07:42 -0700 (PDT) From: Jake Burkholder <jake@io.yi.org> To: FreeBSD-gnats-submit@freebsd.org Subject: kern/18271: simplelock: klds not portable across UP and SMP Message-ID: <200004281507.IAA18339@io.yi.org>
next in thread | raw e-mail | index | archive | help
>Number: 18271
>Category: kern
>Synopsis: simplelock: klds not portable across UP and SMP
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Fri Apr 28 08:10:01 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator: Jake Burkholder
>Release: FreeBSD 5.0-CURRENT i386
>Organization:
none
>Environment:
5.0-current
>Description:
Due to the fact that the simplelock functions are #defined to nothing in
the UP kernel, klds compiled on a UP machine will have no simplelock calls
at all, and thus none of the necesary SMP locking if loaded on such a
machine. This patch makes simplelock a function call for klds, and adds
empty bodied functions to the UP kernel which are used in that case.
At least the following modules are affected:
ccd
cd9660
msdosfs
nfs
ntfs
nwfs
vinum
Which need to be recompiled.
>How-To-Repeat:
n/a
>Fix:
Index: alpha/include/lock.h
===================================================================
RCS file: /home/ncvs/src/sys/alpha/include/lock.h,v
retrieving revision 1.5
diff -u -r1.5 lock.h
--- alpha/include/lock.h 1999/08/28 00:38:47 1.5
+++ alpha/include/lock.h 2000/04/27 00:21:30
@@ -38,6 +38,17 @@
volatile int lock_data;
};
+void s_lock_init __P((struct simplelock *));
+void s_lock __P((struct simplelock *));
+int s_lock_try __P((struct simplelock *));
+
+/* inline simplelock functions */
+static __inline void
+s_unlock(struct simplelock *lkp)
+{
+ lkp->lock_data = 0;
+}
+
#define COM_LOCK()
#define COM_UNLOCK()
Index: i386/include/lock.h
===================================================================
RCS file: /home/ncvs/src/sys/i386/include/lock.h,v
retrieving revision 1.12
diff -u -r1.12 lock.h
--- i386/include/lock.h 2000/03/28 07:16:21 1.12
+++ i386/include/lock.h 2000/04/27 00:21:33
@@ -169,17 +169,6 @@
extern struct simplelock mpintr_lock;
extern struct simplelock mcount_lock;
-#if !defined(SIMPLELOCK_DEBUG) && NCPUS > 1
-/*
- * This set of defines turns on the real functions in i386/isa/apic_ipl.s.
- */
-#define simple_lock_init(alp) s_lock_init(alp)
-#define simple_lock(alp) s_lock(alp)
-#define simple_lock_try(alp) s_lock_try(alp)
-#define simple_unlock(alp) s_unlock(alp)
-
-#endif /* !SIMPLELOCK_DEBUG && NCPUS > 1 */
-
#endif /* LOCORE */
#endif /* !_MACHINE_LOCK_H_ */
Index: kern/kern_lock.c
===================================================================
RCS file: /home/ncvs/src/sys/kern/kern_lock.c,v
retrieving revision 1.32
diff -u -r1.32 kern_lock.c
--- kern/kern_lock.c 2000/03/16 08:51:50 1.32
+++ kern/kern_lock.c 2000/04/27 15:18:07
@@ -75,6 +75,27 @@
static int apause(struct lock *lkp, int flags);
static int acquiredrain(struct lock *lkp, int extflags) ;
+#ifndef SMP
+
+void
+s_lock_init(struct simplelock *lkp)
+{
+}
+
+void
+s_lock(struct simplelock *lkp)
+{
+}
+
+int
+s_lock_try(struct simplelock *lkp)
+{
+
+ return 1;
+}
+
+#endif
+
static LOCK_INLINE void
sharelock(struct lock *lkp, int incr) {
lkp->lk_flags |= LK_SHARE_NONZERO;
Index: sys/lock.h
===================================================================
RCS file: /home/ncvs/src/sys/sys/lock.h,v
retrieving revision 1.17
diff -u -r1.17 lock.h
--- sys/lock.h 1999/12/11 16:13:01 1.17
+++ sys/lock.h 2000/04/27 15:13:34
@@ -202,13 +202,18 @@
#define simple_lock(alp) _simple_lock(alp, __FILE__, __LINE__)
void simple_lock_init __P((struct simplelock *alp));
#else /* !SIMPLELOCK_DEBUG */
-#if NCPUS == 1 /* no multiprocessor locking is necessary */
+#if defined(SMP) || defined(KLD_MODULE)
+#define simple_lock_init(alp) s_lock_init(alp)
+#define simple_lock(alp) s_lock(alp)
+#define simple_lock_try(alp) s_lock_try(alp)
+#define simple_unlock(alp) s_unlock(alp)
+#else /* !SMP || !KLD_MODULE */
#define NULL_SIMPLELOCKS
#define simple_lock_init(alp)
#define simple_lock(alp)
#define simple_lock_try(alp) (1) /* always succeeds */
#define simple_unlock(alp)
-#endif /* NCPUS == 1 */
+#endif /* !SMP || !KLD_MODULE */
#endif /* !SIMPLELOCK_DEBUG */
#endif /* !_LOCK_H_ */
>Release-Note:
>Audit-Trail:
>Unformatted:
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200004281507.IAA18339>
