]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
Linux CM: Use kernel allocator directly for events
authorSimon Wilkinson <sxw@your-file-system.com>
Sun, 17 Apr 2011 22:40:55 +0000 (23:40 +0100)
committerDerrick Brashear <shadow@dementia.org>
Sun, 5 Jun 2011 14:39:36 +0000 (07:39 -0700)
When allocating memory for our events system, use the kernel
allocator directly, rather than going via our shim. This is much
more efficient, but has the drawback that we are now responsible
for freeing our own memory, rather than it all being magically
given back upon shutdown.

Change-Id: I9cb31e4c6b5b4ff2497b627e7ab87716e6da6fa9
Reviewed-on: http://gerrit.openafs.org/4751
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
src/afs/LINUX/osi_module.c
src/afs/LINUX/osi_prototypes.h
src/afs/LINUX/osi_sleep.c

index a7b59d66eac71a3c30becd5116da2a83ce09a35a..f24dc6c330ca7e6264ee7a91af8007a8ded5986c 100644 (file)
@@ -103,6 +103,7 @@ afs_cleanup(void)
 #if !defined(AFS_NONFSTRANS)
     osi_linux_nfssrv_shutdown();
 #endif
+    osi_event_shutdown();
     osi_linux_free_afs_memory();
 
     osi_ioctl_clean();
index 3d576b4a8ea5f6acfddb596f47740a9970f3b0c3..755911de8c07459701957a8f49a6ef9463d3e247 100644 (file)
@@ -61,6 +61,9 @@ extern void *osi_find_syscall_table(int which);
 extern void osi_proc_init(void);
 extern void osi_proc_clean(void);
 
+/* osi_sleep.c */
+extern void osi_event_shutdown(void);
+
 /* osi_syscall.c */
 extern int osi_syscall_init(void);
 extern void osi_syscall_clean(void);
index b246f0a425d648808d656eb7de1417350aaad3dd..31b5149856e625e66df524c2825201a6078c888b 100644 (file)
@@ -85,6 +85,20 @@ afs_event_t *afs_evhasht[HASHSIZE];  /* Hash table for events */
 #define afs_evhash(event)      (afs_uint32) ((((long)event)>>2) & (HASHSIZE-1));
 int afs_evhashcnt = 0;
 
+void
+osi_event_shutdown(void)
+{
+   int i;
+
+   for (i=0;i<HASHSIZE;i++) {
+       while (afs_evhasht[i] != NULL) {
+           afs_event_t *tmp = afs_evhasht[i];
+           afs_evhasht[i] = tmp->next;
+           kfree(tmp);
+       }
+   }
+}
+
 /* Get and initialize event structure corresponding to lwp event (i.e. address)
  * */
 static afs_event_t *
@@ -119,10 +133,7 @@ afs_getevent(char *event)
  *     address.
  *
  * Locks:
- *     Called with GLOCK held. However the function might drop
- *     GLOCK when it calls osi_AllocSmallSpace for allocating
- *     a new event (In Linux, the allocator drops GLOCK to avoid
- *     a deadlock).
+ *     Called with GLOCK held.
  */
 
 static void
@@ -133,14 +144,12 @@ afs_addevent(char *event)
 
     AFS_ASSERT_GLOCK();
     hashcode = afs_evhash(event);
-    newp = osi_linux_alloc(sizeof(afs_event_t), 0);
+    newp = kzalloc(sizeof(afs_event_t), GFP_NOFS);
     afs_evhashcnt++;
     newp->next = afs_evhasht[hashcode];
     afs_evhasht[hashcode] = newp;
     init_waitqueue_head(&newp->cond);
-    newp->seq = 0;
     newp->event = &dummyV;     /* Dummy address for new events */
-    newp->refcount = 0;
 }
 
 #ifndef set_current_state