From 4d75219bedc12833c6265b6e018e6455aa88921c Mon Sep 17 00:00:00 2001 From: Chas Williams Date: Wed, 31 Jul 2002 23:29:38 +0000 Subject: [PATCH] linux-alloc-drop-glock-if-we-can-20020731 if we can drop the glock, do so. allocate up to PAGE_SIZE with kmalloc before switching to vmalloc --- src/afs/LINUX/osi_alloc.c | 10 ++++++---- src/afs/LINUX/osi_prototypes.h | 2 +- src/afs/LINUX/osi_sleep.c | 2 +- src/afs/afs_osi.c | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/afs/LINUX/osi_alloc.c b/src/afs/LINUX/osi_alloc.c index 20fc7b7026..9077db83ec 100644 --- a/src/afs/LINUX/osi_alloc.c +++ b/src/afs/LINUX/osi_alloc.c @@ -24,7 +24,7 @@ RCSID("$Header$"); #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 @@ static int hash_equal(const void *a, const void *b) * 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 @@ static void *linux_alloc(unsigned int asize) #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 @@ DECLARE_MUTEX(afs_linux_alloc_sem); 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); diff --git a/src/afs/LINUX/osi_prototypes.h b/src/afs/LINUX/osi_prototypes.h index 5bcbd305f2..1757f7cd91 100644 --- a/src/afs/LINUX/osi_prototypes.h +++ b/src/afs/LINUX/osi_prototypes.h @@ -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 */ diff --git a/src/afs/LINUX/osi_sleep.c b/src/afs/LINUX/osi_sleep.c index ceaf5699da..caf179914e 100644 --- a/src/afs/LINUX/osi_sleep.c +++ b/src/afs/LINUX/osi_sleep.c @@ -139,7 +139,7 @@ static void afs_addevent(char *event) 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; diff --git a/src/afs/afs_osi.c b/src/afs/afs_osi.c index 51f3659f09..a4c185a510 100644 --- a/src/afs/afs_osi.c +++ b/src/afs/afs_osi.c @@ -444,7 +444,7 @@ void *afs_osi_Alloc(size_t x) 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);