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
This commit is contained in:
Chas Williams 2002-07-31 23:29:38 +00:00 committed by Derrick Brashear
parent f2ab9fd440
commit 4d75219bed
4 changed files with 9 additions and 7 deletions

View File

@ -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);

View File

@ -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 */

View File

@ -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;

View File

@ -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);