From 45071f4bc0a8631eb6bd09c73a24de33714fa151 Mon Sep 17 00:00:00 2001 From: Simon Wilkinson Date: Sun, 17 Apr 2011 23:40:55 +0100 Subject: [PATCH] Linux CM: Use kernel allocator directly for events 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 Reviewed-by: Derrick Brashear --- src/afs/LINUX/osi_module.c | 1 + src/afs/LINUX/osi_prototypes.h | 3 +++ src/afs/LINUX/osi_sleep.c | 23 ++++++++++++++++------- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/afs/LINUX/osi_module.c b/src/afs/LINUX/osi_module.c index a7b59d6..f24dc6c 100644 --- a/src/afs/LINUX/osi_module.c +++ b/src/afs/LINUX/osi_module.c @@ -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(); diff --git a/src/afs/LINUX/osi_prototypes.h b/src/afs/LINUX/osi_prototypes.h index 3d576b4..755911d 100644 --- a/src/afs/LINUX/osi_prototypes.h +++ b/src/afs/LINUX/osi_prototypes.h @@ -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); diff --git a/src/afs/LINUX/osi_sleep.c b/src/afs/LINUX/osi_sleep.c index b246f0a..31b5149 100644 --- a/src/afs/LINUX/osi_sleep.c +++ b/src/afs/LINUX/osi_sleep.c @@ -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;inext; + 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 -- 1.9.4