[OpenAFS-devel] Re: Kernel oops, using openafs-1.2.6-rc1

chas williams chas@cmf.nrl.navy.mil
Mon, 29 Jul 2002 07:49:51 -0400


perhaps, i could be happy with the following.  i would prefer to
not drop glock during alloc (for reasons i have previously stated)
but the following will atleast not drop glock in osi_sleep which
is all i really need).  and PAGE_SIZE is probably the right
borderline between kmalloc/vmalloc.


? src/afs/LINUX/osi_vfs.h
Index: src/afs/afs_osi.c
===================================================================
RCS file: /cvs/openafs/src/afs/afs_osi.c,v
retrieving revision 1.8.2.7
diff -u -d -b -w -r1.8.2.7 afs_osi.c
--- src/afs/afs_osi.c	2002/07/10 20:42:29	1.8.2.7
+++ src/afs/afs_osi.c	2002/07/29 11:42:33
@@ -420,7 +420,7 @@
     AFS_STATS(afs_stats_cmperf.OutStandingAllocs++);
     AFS_STATS(afs_stats_cmperf.OutStandingMemUsage += x);
 #ifdef AFS_LINUX20_ENV
-    return osi_linux_alloc(x);
+    return osi_linux_alloc(x, 1);
 #else
     size = x;
     tm = (struct osimem *) AFS_KALLOC(size);
Index: src/afs/LINUX/osi_alloc.c
===================================================================
RCS file: /cvs/openafs/src/afs/LINUX/osi_alloc.c,v
retrieving revision 1.9.2.5
diff -u -d -b -w -r1.9.2.5 osi_alloc.c
--- src/afs/LINUX/osi_alloc.c	2002/07/10 20:05:03	1.9.2.5
+++ src/afs/LINUX/osi_alloc.c	2002/07/29 11:42:33
@@ -24,7 +24,7 @@
 #include "../afs/afs_atomlist.h"
 #include "../afs/afs_lhash.h"
 
-#define MAX_KMALLOC_SIZE AFS_SMALLOCSIZ /* Max we should alloc with kmalloc */
+#define MAX_KMALLOC_SIZE PAGE_SIZE /* Max we should alloc with kmalloc */
 #define MAX_BUCKET_LEN 30 /* max. no. of entries per buckets we expect to see */
 #define STAT_INTERVAL 8192 /* we collect stats once every STAT_INTERVAL allocs*/
 
@@ -76,7 +76,7 @@
  *  returns NULL if we failed to allocate memory.
  *  or pointer to memory if we succeeded.
  */
-static void *linux_alloc(unsigned int asize)
+static void *linux_alloc(unsigned int asize, int drop_glock)
 {
     void *new = NULL;
     int max_retry = 10;
@@ -106,7 +106,9 @@
 #else
 	    current->state = TASK_INTERRUPTIBLE;
 #endif
+	    if (drop_glock) AFS_GUNLOCK();
 	    schedule_timeout(HZ);
+	    if (drop_glock) AFS_GLOCK();
 #ifdef set_current_state
             set_current_state(TASK_RUNNING);
 #else
@@ -280,12 +282,12 @@
 struct semaphore afs_linux_alloc_sem = MUTEX;
 #endif
 
-void *osi_linux_alloc(unsigned int asize)
+void *osi_linux_alloc(unsigned int asize, int drop_glock)
 {
     void *new = NULL;
     struct osi_linux_mem *lmem;
 
-    new = linux_alloc(asize); /* get a chunk of memory of size asize */
+    new = linux_alloc(asize, drop_glock); /* get a chunk of memory of size asize */
 
     if (!new) {
 	printf("afs_osi_Alloc: Can't vmalloc %d bytes.\n", asize);
Index: src/afs/LINUX/osi_prototypes.h
===================================================================
RCS file: /cvs/openafs/src/afs/LINUX/osi_prototypes.h,v
retrieving revision 1.2
diff -u -d -b -w -r1.2 osi_prototypes.h
--- src/afs/LINUX/osi_prototypes.h	2000/11/04 10:03:25	1.2
+++ src/afs/LINUX/osi_prototypes.h	2002/07/29 11:42:33
@@ -14,7 +14,7 @@
 #define _OSI_PROTO_H_
 
 /* osi_alloc.c */
-extern void *osi_linux_alloc(unsigned int size);
+extern void *osi_linux_alloc(unsigned int size, int drop_glock);
 extern void osi_linux_free(void *addr);
 extern void osi_linux_free_afs_memory(void);
 /* Debugging aid */
Index: src/afs/LINUX/osi_sleep.c
===================================================================
RCS file: /cvs/openafs/src/afs/LINUX/osi_sleep.c,v
retrieving revision 1.6.4.5
diff -u -d -b -w -r1.6.4.5 osi_sleep.c
--- src/afs/LINUX/osi_sleep.c	2002/07/10 21:04:45	1.6.4.5
+++ src/afs/LINUX/osi_sleep.c	2002/07/29 11:42:33
@@ -139,7 +139,7 @@
     
     AFS_ASSERT_GLOCK();
     hashcode = afs_evhash(event);
-    newp = osi_AllocSmallSpace(sizeof(afs_event_t));
+    newp = osi_linux_alloc(sizeof(afs_event_t), 0);
     afs_evhashcnt++;
     newp->next = afs_evhasht[hashcode];
     afs_evhasht[hashcode] = newp;