Re: NFS/VM panic in current with INVARIANTS

2000-12-27 Thread Mark Murray

It looks like you guys got it! What is currently checked in (by Assar)
is working fine! :-)

M

 :--=-=-=
 :
 :Matt Dillon [EMAIL PROTECTED] writes:
 : Well, yes... that's essentially what I suggested.  You didn't say
 : anything about removing the externalized inlines, which is what you
 : do in your patch.  Looks like a fine patch to me.
 :
 :Except it didn't work.  Now here's a patch that survived building a
 :kernel and modules.  ok?
 :
 :/assar

lets see.. ok, I'm going to read the patch carefully this time..
 
This isn't quite what I had in mind.  You are still making an API
change... you are now calling zalloci() from zalloc() for non-SMP boxes.
There is no need to do that.
 
Instead what I would recommend is making zalloc() and zfree() real
procedures, putting them in vm_zone.c, and removing their inlines from
vm_zone.h.  i.e. not have *ANY* inlines at all in vm_zone.h
 
Then as real procedures in vm_zone.c these functions can have the
#ifdef SMP / related code left intact.
 
   -Matt
 
 :
 :--=-=-=
 :Content-Disposition: attachment; filename=zalloc-diff
 :
 :Index: vm_zone.c
 :===
 :RCS file: /home/ncvs/src/sys/vm/vm_zone.c,v
 :retrieving revision 1.35
 :diff -u -w -r1.35 vm_zone.c
 :--- vm_zone.c2000/12/13 10:01:00 1.35
 :+++ vm_zone.c2000/12/27 00:59:14
 :@@ -32,6 +32,59 @@
 : 
 : static MALLOC_DEFINE(M_ZONE, "ZONE", "Zone header");
 : 
 :+#define ZONE_ERROR_INVALID 0
 :+#define ZONE_ERROR_NOTFREE 1
 :+#define ZONE_ERROR_ALREADYFREE 2
 :+
 :+#define ZONE_ROUNDING   32
 :+
 :+#define ZENTRY_FREE 0x12342378
 :+/*
 :+ * void *zalloc(vm_zone_t zone) --
 :+ *  Returns an item from a specified zone.
 :+ *
 :+ * void zfree(vm_zone_t zone, void *item) --
 :+ *  Frees an item back to a specified zone.
 :+ */
 :+static __inline__ void *
 :+_zalloc(vm_zone_t z)
 :+{
 :+void *item;
 :+
 :+#ifdef INVARIANTS
 :+if (z == 0)
 :+zerror(ZONE_ERROR_INVALID);
 :+#endif
 :+
 :+if (z-zfreecnt = z-zfreemin)
 :+return _zget(z);
 :+
 :+item = z-zitems;
 :+z-zitems = ((void **) item)[0];
 :+#ifdef INVARIANTS
 :+if (((void **) item)[1] != (void *) ZENTRY_FREE)
 :+zerror(ZONE_ERROR_NOTFREE);
 :+((void **) item)[1] = 0;
 :+#endif
 :+
 :+z-zfreecnt--;
 :+z-znalloc++;
 :+return item;
 :+}
 :+
 :+static __inline__ void
 :+_zfree(vm_zone_t z, void *item)
 :+{
 :+((void **) item)[0] = z-zitems;
 :+#ifdef INVARIANTS
 :+if (((void **) item)[1] == (void *) ZENTRY_FREE)
 :+zerror(ZONE_ERROR_ALREADYFREE);
 :+((void **) item)[1] = (void *) ZENTRY_FREE;
 :+#endif
 :+z-zitems = item;
 :+z-zfreecnt++;
 :+}
 :+
 : /*
 :  * This file comprises a very simple zone allocator.  This is used
 :  * in lieu of the malloc allocator, where needed or more optimal.
 :Index: vm_zone.h
 :===
 :RCS file: /home/ncvs/src/sys/vm/vm_zone.h,v
 :retrieving revision 1.13
 :diff -u -w -r1.13 vm_zone.h
 :--- vm_zone.h1999/08/28 00:52:44 1.13
 :+++ vm_zone.h2000/12/27 00:59:14
 :@@ -43,7 +43,6 @@
 : struct vm_zone  *znext; /* list of zones for sysctl */
 : } *vm_zone_t;
 : 
 :-
 : voidzerror __P((int)) __dead2;
 : vm_zone_t   zinit __P((char *name, int size, int nentries, int flags,
 :int zalloc));
 :@@ -57,77 +56,16 @@
 :int nitems));
 : void *  _zget __P((vm_zone_t z));
 : 
 :-#define ZONE_ERROR_INVALID 0
 :-#define ZONE_ERROR_NOTFREE 1
 :-#define ZONE_ERROR_ALREADYFREE 2
 :-
 :-#define ZONE_ROUNDING   32
 :-
 :-#define ZENTRY_FREE 0x12342378
 :-/*
 :- * void *zalloc(vm_zone_t zone) --
 :- *  Returns an item from a specified zone.
 :- *
 :- * void zfree(vm_zone_t zone, void *item) --
 :- *  Frees an item back to a specified zone.
 :- */
 :-static __inline__ void *
 :-_zalloc(vm_zone_t z)
 :-{
 :-void *item;
 :-
 :-#ifdef INVARIANTS
 :-if (z == 0)
 :-zerror(ZONE_ERROR_INVALID);
 :-#endif
 :-
 :-if (z-zfreecnt = z-zfreemin)
 :-return _zget(z);
 :-
 :-item = z-zitems;
 :-z-zitems = ((void **) item)[0];
 :-#ifdef INVARIANTS
 :-if (((void **) item)[1] != (void *) ZENTRY_FREE)
 :-zerror(ZONE_ERROR_NOTFREE);
 :-((void **) item)[1] = 0;
 :-#endif
 :-
 :-z-zfreecnt--;
 :-z-znalloc++;
 :-return item;
 :-}
 :-
 :-static __inline__ void
 :-_zfree(vm_zone_t z, void *item)
 :-{
 :-((void **) item)[0] = z-zitems;
 :-#ifdef INVARIANTS
 :-if (((void **) item)[1] == (void *) ZENTRY_FREE)
 :-zerror(ZONE_ERROR_ALREADYFREE);
 :-((void **) item)[1] = (void *) ZENTRY_FREE;
 :-#endif
 :-z-zitems = item;
 :-z-zfreecnt++;
 :-}
 :-
 : static __inline__ void *
 : zalloc(vm_zone_t z)
 : {
 :-#if defined(SMP)
 : 

Re: NFS/VM panic in current with INVARIANTS

2000-12-27 Thread Matt Dillon

:
:It looks like you guys got it! What is currently checked in (by Assar)
:is working fine! :-)
:
:M

Excellent news!

-Matt


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message



Re: NFS/VM panic in current with INVARIANTS

2000-12-26 Thread Matt Dillon

:Hi Matt
:
:I'm getting a reliable panic on CURRENT (2000/12/26) with INVARIANTS
:set. I suppose I could "fix" this by taking out INVARIANTS, but it
:seems to make more sense to try to get it fixed.
:
:The panic() is "freeing free entry", and the traceback (minus most
:of the numbers) is:
:
:panic
:zerror
:zfreei
:NDFREE
:nfsrv_lookup
:nfs_nfsd
:nfssvc
:syscall(2f, 2f, 2f, 1, 0)
:xint0x80
:
:NFS activity (not mounting) triggers it. The panic happens on the
:server box, which is a dual-cpu i386 class running an SMP kernel.
:
:What else do you need?
:
:M
:-- 
:Mark Murray
:Warning: this .sig is umop ap!sdn

It could be real, but it's impossible for me to tell because 
whoever wrote the INVARIANTS code for _zfree() wrote completely
and utterly illegal code.

static __inline__ void
_zfree(vm_zone_t z, void *item)
{ 
((void **) item)[0] = z-zitems;
#ifdef INVARIANTS
if (((void **) item)[1] == (void *) ZENTRY_FREE)
zerror(ZONE_ERROR_ALREADYFREE);
((void **) item)[1] = (void *) ZENTRY_FREE;
#endif
z-zitems = item;
z-zfreecnt++;
}

For all we know, item[1] might contain ZENTRY_FREE normally!  This
type of invariant code check is just asking for it.

I don't see anything specifically wrong with nfs's use of NDFREE.  It's
sophisticated enough that there certainly could be an issue there.

In order to tell for sure, the _zfree() code needs to have a little more
sophistication.  When it finds a ZENTRY_FREE, that's only a hint... it
really needs to also iterate through the items list to see if the
structure is in fact already on the freelist.  Please try the below
(completely untested!!) patch and see if you still get the panic.

-Matt

Index: vm_zone.h
===
RCS file: /home/ncvs/src/sys/vm/vm_zone.h,v
retrieving revision 1.13
diff -u -r1.13 vm_zone.h
--- vm_zone.h   1999/08/28 00:52:44 1.13
+++ vm_zone.h   2000/12/26 18:39:07
@@ -102,8 +102,14 @@
 {
((void **) item)[0] = z-zitems;
 #ifdef INVARIANTS
-   if (((void **) item)[1] == (void *) ZENTRY_FREE)
-   zerror(ZONE_ERROR_ALREADYFREE);
+   if (((void **) item)[1] == (void *) ZENTRY_FREE) {
+   void *scan;
+
+   for (scan = z-zitems; scan; scan = ((void **)scan)[0]) {
+   if (scan == item)
+   zerror(ZONE_ERROR_ALREADYFREE);
+   }
+   }
((void **) item)[1] = (void *) ZENTRY_FREE;
 #endif
z-zitems = item;


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message



Re: NFS/VM panic in current with INVARIANTS

2000-12-26 Thread David Malone

On Tue, Dec 26, 2000 at 02:00:54PM +0200, Mark Murray wrote:

 I'm getting a reliable panic on CURRENT (2000/12/26) with INVARIANTS
 set. I suppose I could "fix" this by taking out INVARIANTS, but it
 seems to make more sense to try to get it fixed.

Do you have NFS compiled in to the kernel? I've had trouble using
INVARIANTS in the kernel and NFS as a module many times - it always
panics in the zone allocation stuff.

(Either you always need to compile modules with the same INVARIENTS
options as the kernel, or we need to fix INVARIENTS so it doesn't
change the expected behaviour of anything in the kernel)

David.


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message



Re: NFS/VM panic in current with INVARIANTS

2000-12-26 Thread Matt Dillon

:Do you have NFS compiled in to the kernel? I've had trouble using
:INVARIANTS in the kernel and NFS as a module many times - it always
:panics in the zone allocation stuff.
:
:(Either you always need to compile modules with the same INVARIENTS
:options as the kernel, or we need to fix INVARIENTS so it doesn't
:change the expected behaviour of anything in the kernel)
:
:   David.

zalloc/zfree have inlined components.  Mixing INVARIENTS is virtually
guarenteed to crash the NDFREE code because the expected magic numbers
will not be there.  I sure hope this turns out to be Mark's problem. 

I have a feeling that the issue may go deeper.  There is conditional
code in the zalloc/zfree inlines for SMP vs non-SMP.  This will break
modules in an SMP system worse then the INVARIENTS will.  I mean
*seriously* break... massive corruption and the like can occur.

I think the only real solution is to rip out the externally visible
zalloc/zfree inlines and replace them with real routines.  I will happily
do this, those inlines have always been an eyesore to me and the
performance benefit is minimal at best.  That will solve the SMP and
INVARIENTS mixing problem (at least for zalloc/zfree).

-Matt



To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message



Re: NFS/VM panic in current with INVARIANTS

2000-12-26 Thread Assar Westerlund

Matt Dillon [EMAIL PROTECTED] writes:
 I think the only real solution is to rip out the externally visible
 zalloc/zfree inlines and replace them with real routines.  I will happily
 do this, those inlines have always been an eyesore to me and the
 performance benefit is minimal at best.  That will solve the SMP and
 INVARIENTS mixing problem (at least for zalloc/zfree).

Just make them always call zalloci() and zfreei().

/assar


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message



Re: NFS/VM panic in current with INVARIANTS

2000-12-26 Thread Matt Dillon


:
:Matt Dillon [EMAIL PROTECTED] writes:
: I think the only real solution is to rip out the externally visible
: zalloc/zfree inlines and replace them with real routines.  I will happily
: do this, those inlines have always been an eyesore to me and the
: performance benefit is minimal at best.  That will solve the SMP and
: INVARIENTS mixing problem (at least for zalloc/zfree).
:
:Just make them always call zalloci() and zfreei().
:
:/assar

I don't think that's good enough.  At the moment the API for non-interrupt
operation is zalloc() and zfree(), and zalloci() and zfreei() are
supposed to be called from interrupts.If we intend to keep both
families (zalloc() and zalloci()), then both families have to work
properly.  If we intend to remove one family (i.e. remove the zalloc()
family), then we have to physically remove the calls from the codebase
to prevent anyone from accidently calling them from an SMP build.

We can't just go do an end-run around the established API as a hack around
the problem.

-Matt



To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message



Re: NFS/VM panic in current with INVARIANTS

2000-12-26 Thread Assar Westerlund

Matt Dillon [EMAIL PROTECTED] writes:
 We can't just go do an end-run around the established API as a
 hack around the problem.

I fail too se how my suggestion would change the API at all, but in
case I was unclear, diffs are below.

/assar



Index: vm_zone.c
===
RCS file: /home/ncvs/src/sys/vm/vm_zone.c,v
retrieving revision 1.35
diff -u -w -r1.35 vm_zone.c
--- vm_zone.c   2000/12/13 10:01:00 1.35
+++ vm_zone.c   2000/12/27 00:13:44
@@ -32,6 +32,81 @@
 
 static MALLOC_DEFINE(M_ZONE, "ZONE", "Zone header");
 
+#include   machine/lock.h
+
+struct vm_zone {
+   struct simplelock zlock;/* lock for data structure */
+   void*zitems;/* linked list of items */
+   int zfreecnt;   /* free entries */
+   int zfreemin;   /* minimum number of free entries */
+   int znalloc;/* number of allocations */
+   vm_offset_t zkva;   /* Base kva of zone */
+   int zpagecount; /* Total # of allocated pages */
+   int zpagemax;   /* Max address space */
+   int zmax;   /* Max number of entries allocated */
+   int ztotal; /* Total entries allocated now */
+   int zsize;  /* size of each entry */
+   int zalloc; /* hint for # of pages to alloc */
+   int zflags; /* flags for zone */
+   int zallocflag; /* flag for allocation */
+   struct vm_object *zobj; /* object to hold zone */
+   char*zname; /* name for diags */
+   struct vm_zone  *znext; /* list of zones for sysctl */
+};
+
+#define ZONE_ERROR_INVALID 0
+#define ZONE_ERROR_NOTFREE 1
+#define ZONE_ERROR_ALREADYFREE 2
+
+#define ZONE_ROUNDING  32
+
+#define ZENTRY_FREE0x12342378
+/*
+ * void *zalloc(vm_zone_t zone) --
+ * Returns an item from a specified zone.
+ *
+ * void zfree(vm_zone_t zone, void *item) --
+ *  Frees an item back to a specified zone.
+ */
+static __inline__ void *
+_zalloc(vm_zone_t z)
+{
+   void *item;
+
+#ifdef INVARIANTS
+   if (z == 0)
+   zerror(ZONE_ERROR_INVALID);
+#endif
+
+   if (z-zfreecnt = z-zfreemin)
+   return _zget(z);
+
+   item = z-zitems;
+   z-zitems = ((void **) item)[0];
+#ifdef INVARIANTS
+   if (((void **) item)[1] != (void *) ZENTRY_FREE)
+   zerror(ZONE_ERROR_NOTFREE);
+   ((void **) item)[1] = 0;
+#endif
+
+   z-zfreecnt--;
+   z-znalloc++;
+   return item;
+}
+
+static __inline__ void
+_zfree(vm_zone_t z, void *item)
+{
+   ((void **) item)[0] = z-zitems;
+#ifdef INVARIANTS
+   if (((void **) item)[1] == (void *) ZENTRY_FREE)
+   zerror(ZONE_ERROR_ALREADYFREE);
+   ((void **) item)[1] = (void *) ZENTRY_FREE;
+#endif
+   z-zitems = item;
+   z-zfreecnt++;
+}
+
 /*
  * This file comprises a very simple zone allocator.  This is used
  * in lieu of the malloc allocator, where needed or more optimal.
Index: vm_zone.h
===
RCS file: /home/ncvs/src/sys/vm/vm_zone.h,v
retrieving revision 1.13
diff -u -w -r1.13 vm_zone.h
--- vm_zone.h   1999/08/28 00:52:44 1.13
+++ vm_zone.h   2000/12/27 00:13:44
@@ -21,29 +21,9 @@
 #define ZONE_INTERRUPT 1 /* Use this if you need to allocate at int time */
 #define ZONE_BOOT 16/* This is an internal flag used by zbootinit */
 
-#include   machine/lock.h
+struct vm_zone;
+typedef struct vm_zone *vm_zone_t;
 
-typedef struct vm_zone {
-   struct simplelock zlock;/* lock for data structure */
-   void*zitems;/* linked list of items */
-   int zfreecnt;   /* free entries */
-   int zfreemin;   /* minimum number of free entries */
-   int znalloc;/* number of allocations */
-   vm_offset_t zkva;   /* Base kva of zone */
-   int zpagecount; /* Total # of allocated pages */
-   int zpagemax;   /* Max address space */
-   int zmax;   /* Max number of entries allocated */
-   int ztotal; /* Total entries allocated now */
-   int zsize;  /* size of each entry */
-   int zalloc; /* hint for # of pages to alloc */
-   int zflags; /* flags for zone */
-   int zallocflag; /* flag for allocation */
-   struct vm_object *zobj; /* object to hold zone */
-   char*zname; /* name for diags */
-   struct vm_zone  *znext; /* list of zones for sysctl */
-} *vm_zone_t;
-
-
 void   zerror __P((int)) __dead2;
 vm_zone_t  zinit __P((char *name, int size, int nentries, 

Re: NFS/VM panic in current with INVARIANTS

2000-12-26 Thread Matt Dillon


:Matt Dillon [EMAIL PROTECTED] writes:
: We can't just go do an end-run around the established API as a
: hack around the problem.
:
:I fail too se how my suggestion would change the API at all, but in
:case I was unclear, diffs are below.
:
:/assar
:
Well, yes... that's essentially what I suggested.  You didn't say
anything about removing the externalized inlines, which is what you
do in your patch.  Looks like a fine patch to me.

-Matt



To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message



Re: NFS/VM panic in current with INVARIANTS

2000-12-26 Thread Assar Westerlund

Matt Dillon [EMAIL PROTECTED] writes:
 Well, yes... that's essentially what I suggested.  You didn't say
 anything about removing the externalized inlines, which is what you
 do in your patch.  Looks like a fine patch to me.

Except it didn't work.  Now here's a patch that survived building a
kernel and modules.  ok?

/assar


Index: vm_zone.c
===
RCS file: /home/ncvs/src/sys/vm/vm_zone.c,v
retrieving revision 1.35
diff -u -w -r1.35 vm_zone.c
--- vm_zone.c   2000/12/13 10:01:00 1.35
+++ vm_zone.c   2000/12/27 00:59:14
@@ -32,6 +32,59 @@
 
 static MALLOC_DEFINE(M_ZONE, "ZONE", "Zone header");
 
+#define ZONE_ERROR_INVALID 0
+#define ZONE_ERROR_NOTFREE 1
+#define ZONE_ERROR_ALREADYFREE 2
+
+#define ZONE_ROUNDING  32
+
+#define ZENTRY_FREE0x12342378
+/*
+ * void *zalloc(vm_zone_t zone) --
+ * Returns an item from a specified zone.
+ *
+ * void zfree(vm_zone_t zone, void *item) --
+ *  Frees an item back to a specified zone.
+ */
+static __inline__ void *
+_zalloc(vm_zone_t z)
+{
+   void *item;
+
+#ifdef INVARIANTS
+   if (z == 0)
+   zerror(ZONE_ERROR_INVALID);
+#endif
+
+   if (z-zfreecnt = z-zfreemin)
+   return _zget(z);
+
+   item = z-zitems;
+   z-zitems = ((void **) item)[0];
+#ifdef INVARIANTS
+   if (((void **) item)[1] != (void *) ZENTRY_FREE)
+   zerror(ZONE_ERROR_NOTFREE);
+   ((void **) item)[1] = 0;
+#endif
+
+   z-zfreecnt--;
+   z-znalloc++;
+   return item;
+}
+
+static __inline__ void
+_zfree(vm_zone_t z, void *item)
+{
+   ((void **) item)[0] = z-zitems;
+#ifdef INVARIANTS
+   if (((void **) item)[1] == (void *) ZENTRY_FREE)
+   zerror(ZONE_ERROR_ALREADYFREE);
+   ((void **) item)[1] = (void *) ZENTRY_FREE;
+#endif
+   z-zitems = item;
+   z-zfreecnt++;
+}
+
 /*
  * This file comprises a very simple zone allocator.  This is used
  * in lieu of the malloc allocator, where needed or more optimal.
Index: vm_zone.h
===
RCS file: /home/ncvs/src/sys/vm/vm_zone.h,v
retrieving revision 1.13
diff -u -w -r1.13 vm_zone.h
--- vm_zone.h   1999/08/28 00:52:44 1.13
+++ vm_zone.h   2000/12/27 00:59:14
@@ -43,7 +43,6 @@
struct vm_zone  *znext; /* list of zones for sysctl */
 } *vm_zone_t;
 
-
 void   zerror __P((int)) __dead2;
 vm_zone_t  zinit __P((char *name, int size, int nentries, int flags,
   int zalloc));
@@ -57,77 +56,16 @@
   int nitems));
 void * _zget __P((vm_zone_t z));
 
-#define ZONE_ERROR_INVALID 0
-#define ZONE_ERROR_NOTFREE 1
-#define ZONE_ERROR_ALREADYFREE 2
-
-#define ZONE_ROUNDING  32
-
-#define ZENTRY_FREE0x12342378
-/*
- * void *zalloc(vm_zone_t zone) --
- * Returns an item from a specified zone.
- *
- * void zfree(vm_zone_t zone, void *item) --
- *  Frees an item back to a specified zone.
- */
-static __inline__ void *
-_zalloc(vm_zone_t z)
-{
-   void *item;
-
-#ifdef INVARIANTS
-   if (z == 0)
-   zerror(ZONE_ERROR_INVALID);
-#endif
-
-   if (z-zfreecnt = z-zfreemin)
-   return _zget(z);
-
-   item = z-zitems;
-   z-zitems = ((void **) item)[0];
-#ifdef INVARIANTS
-   if (((void **) item)[1] != (void *) ZENTRY_FREE)
-   zerror(ZONE_ERROR_NOTFREE);
-   ((void **) item)[1] = 0;
-#endif
-
-   z-zfreecnt--;
-   z-znalloc++;
-   return item;
-}
-
-static __inline__ void
-_zfree(vm_zone_t z, void *item)
-{
-   ((void **) item)[0] = z-zitems;
-#ifdef INVARIANTS
-   if (((void **) item)[1] == (void *) ZENTRY_FREE)
-   zerror(ZONE_ERROR_ALREADYFREE);
-   ((void **) item)[1] = (void *) ZENTRY_FREE;
-#endif
-   z-zitems = item;
-   z-zfreecnt++;
-}
-
 static __inline__ void *
 zalloc(vm_zone_t z)
 {
-#if defined(SMP)
return zalloci(z);
-#else
-   return _zalloc(z);
-#endif
 }
 
 static __inline__ void
 zfree(vm_zone_t z, void *item)
 {
-#ifdef SMP
zfreei(z, item);
-#else
-   _zfree(z, item);
-#endif
 }
 
-#endif
+#endif /* _SYS_ZONE_H */



Re: NFS/VM panic in current with INVARIANTS

2000-12-26 Thread Matt Dillon


:--=-=-=
:
:Matt Dillon [EMAIL PROTECTED] writes:
: Well, yes... that's essentially what I suggested.  You didn't say
: anything about removing the externalized inlines, which is what you
: do in your patch.  Looks like a fine patch to me.
:
:Except it didn't work.  Now here's a patch that survived building a
:kernel and modules.  ok?
:
:/assar
   
   lets see.. ok, I'm going to read the patch carefully this time..

   This isn't quite what I had in mind.  You are still making an API
   change... you are now calling zalloci() from zalloc() for non-SMP boxes.
   There is no need to do that.

   Instead what I would recommend is making zalloc() and zfree() real
   procedures, putting them in vm_zone.c, and removing their inlines from
   vm_zone.h.  i.e. not have *ANY* inlines at all in vm_zone.h

   Then as real procedures in vm_zone.c these functions can have the
   #ifdef SMP / related code left intact.

-Matt

:
:--=-=-=
:Content-Disposition: attachment; filename=zalloc-diff
:
:Index: vm_zone.c
:===
:RCS file: /home/ncvs/src/sys/vm/vm_zone.c,v
:retrieving revision 1.35
:diff -u -w -r1.35 vm_zone.c
:--- vm_zone.c  2000/12/13 10:01:00 1.35
:+++ vm_zone.c  2000/12/27 00:59:14
:@@ -32,6 +32,59 @@
: 
: static MALLOC_DEFINE(M_ZONE, "ZONE", "Zone header");
: 
:+#define ZONE_ERROR_INVALID 0
:+#define ZONE_ERROR_NOTFREE 1
:+#define ZONE_ERROR_ALREADYFREE 2
:+
:+#define ZONE_ROUNDING 32
:+
:+#define ZENTRY_FREE   0x12342378
:+/*
:+ * void *zalloc(vm_zone_t zone) --
:+ *Returns an item from a specified zone.
:+ *
:+ * void zfree(vm_zone_t zone, void *item) --
:+ *  Frees an item back to a specified zone.
:+ */
:+static __inline__ void *
:+_zalloc(vm_zone_t z)
:+{
:+  void *item;
:+
:+#ifdef INVARIANTS
:+  if (z == 0)
:+  zerror(ZONE_ERROR_INVALID);
:+#endif
:+
:+  if (z-zfreecnt = z-zfreemin)
:+  return _zget(z);
:+
:+  item = z-zitems;
:+  z-zitems = ((void **) item)[0];
:+#ifdef INVARIANTS
:+  if (((void **) item)[1] != (void *) ZENTRY_FREE)
:+  zerror(ZONE_ERROR_NOTFREE);
:+  ((void **) item)[1] = 0;
:+#endif
:+
:+  z-zfreecnt--;
:+  z-znalloc++;
:+  return item;
:+}
:+
:+static __inline__ void
:+_zfree(vm_zone_t z, void *item)
:+{
:+  ((void **) item)[0] = z-zitems;
:+#ifdef INVARIANTS
:+  if (((void **) item)[1] == (void *) ZENTRY_FREE)
:+  zerror(ZONE_ERROR_ALREADYFREE);
:+  ((void **) item)[1] = (void *) ZENTRY_FREE;
:+#endif
:+  z-zitems = item;
:+  z-zfreecnt++;
:+}
:+
: /*
:  * This file comprises a very simple zone allocator.  This is used
:  * in lieu of the malloc allocator, where needed or more optimal.
:Index: vm_zone.h
:===
:RCS file: /home/ncvs/src/sys/vm/vm_zone.h,v
:retrieving revision 1.13
:diff -u -w -r1.13 vm_zone.h
:--- vm_zone.h  1999/08/28 00:52:44 1.13
:+++ vm_zone.h  2000/12/27 00:59:14
:@@ -43,7 +43,6 @@
:   struct vm_zone  *znext; /* list of zones for sysctl */
: } *vm_zone_t;
: 
:-
: void  zerror __P((int)) __dead2;
: vm_zone_t zinit __P((char *name, int size, int nentries, int flags,
:  int zalloc));
:@@ -57,77 +56,16 @@
:  int nitems));
: void *_zget __P((vm_zone_t z));
: 
:-#define ZONE_ERROR_INVALID 0
:-#define ZONE_ERROR_NOTFREE 1
:-#define ZONE_ERROR_ALREADYFREE 2
:-
:-#define ZONE_ROUNDING 32
:-
:-#define ZENTRY_FREE   0x12342378
:-/*
:- * void *zalloc(vm_zone_t zone) --
:- *Returns an item from a specified zone.
:- *
:- * void zfree(vm_zone_t zone, void *item) --
:- *  Frees an item back to a specified zone.
:- */
:-static __inline__ void *
:-_zalloc(vm_zone_t z)
:-{
:-  void *item;
:-
:-#ifdef INVARIANTS
:-  if (z == 0)
:-  zerror(ZONE_ERROR_INVALID);
:-#endif
:-
:-  if (z-zfreecnt = z-zfreemin)
:-  return _zget(z);
:-
:-  item = z-zitems;
:-  z-zitems = ((void **) item)[0];
:-#ifdef INVARIANTS
:-  if (((void **) item)[1] != (void *) ZENTRY_FREE)
:-  zerror(ZONE_ERROR_NOTFREE);
:-  ((void **) item)[1] = 0;
:-#endif
:-
:-  z-zfreecnt--;
:-  z-znalloc++;
:-  return item;
:-}
:-
:-static __inline__ void
:-_zfree(vm_zone_t z, void *item)
:-{
:-  ((void **) item)[0] = z-zitems;
:-#ifdef INVARIANTS
:-  if (((void **) item)[1] == (void *) ZENTRY_FREE)
:-  zerror(ZONE_ERROR_ALREADYFREE);
:-  ((void **) item)[1] = (void *) ZENTRY_FREE;
:-#endif
:-  z-zitems = item;
:-  z-zfreecnt++;
:-}
:-
: static __inline__ void *
: zalloc(vm_zone_t z)
: {
:-#if defined(SMP)
:   return zalloci(z);
:-#else
:-  return _zalloc(z);
:-#endif
: }
: 
: static __inline__ void
: zfree(vm_zone_t z, void *item)
: {
:-#ifdef SMP
:   zfreei(z, item);
:-#else
:-  _zfree(z, item);
:-#endif
: 

Re: NFS/VM panic in current with INVARIANTS

2000-12-26 Thread Mark Murray

 On Tue, Dec 26, 2000 at 02:00:54PM +0200, Mark Murray wrote:
 
  I'm getting a reliable panic on CURRENT (2000/12/26) with INVARIANTS
  set. I suppose I could "fix" this by taking out INVARIANTS, but it
  seems to make more sense to try to get it fixed.
 
 Do you have NFS compiled in to the kernel? I've had trouble using
 INVARIANTS in the kernel and NFS as a module many times - it always
 panics in the zone allocation stuff.

No I don't. Hmmm...

 (Either you always need to compile modules with the same INVARIENTS
 options as the kernel, or we need to fix INVARIENTS so it doesn't
 change the expected behaviour of anything in the kernel)

OK.

M
--
Mark Murray
Warning: this .sig is umop ap!sdn


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message