]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
Allow private implementations of osi_AllocSmall/LargeSpace
authorChas Williams (CONTRACTOR) <chas@cmf.nrl.navy.mil>
Mon, 4 Oct 2010 19:08:10 +0000 (15:08 -0400)
committerDerrick Brashear <shadow@dementia.org>
Tue, 19 Oct 2010 19:02:38 +0000 (12:02 -0700)
NBSD seemed to already do this at one point but was partly disabled.
This patches generalizes this feature by adding a define to disable the
standard pool macros.  Linux's slab based allocator should out perform
this single threaded allocator/pool.

Change-Id: Id8d498c11874b7d87736968b99f7ca023af4af36
Reviewed-on: http://gerrit.openafs.org/2998
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>
src/afs/LINUX/osi_alloc.c
src/afs/NBSD/osi_misc.c
src/afs/afs_init.c
src/afs/afs_osi_alloc.c
src/afs/afs_pag_call.c
src/config/param.linux26.h

index b10bbabf506b5e0d4127c3e04fa6b97eb552ca82..99256e44b154d11240d87e055489e81fed527c0b 100644 (file)
@@ -403,3 +403,34 @@ osi_linux_verify_alloced_memory()
     up(&afs_linux_alloc_sem);
     return;
 }
+
+#ifdef AFS_PRIVATE_OSI_ALLOCSPACES
+
+void
+osi_FreeLargeSpace(void *p)
+{
+    kfree(p);
+}
+
+void
+osi_FreeSmallSpace(void *p)
+{
+    kfree(p);
+}
+
+void *
+osi_AllocLargeSpace(size_t size)
+{
+    if (size > AFS_LRALLOCSIZ)
+       osi_Panic("osi_AllocLargeSpace: size=%d\n", (int) size);
+    return kmalloc(AFS_LRALLOCSIZ, GFP_NOFS);
+}
+
+void *
+osi_AllocSmallSpace(size_t size)
+{
+    if (size > AFS_SMALLOCSIZ)
+       osi_Panic("osi_AllocSmallS: size=%d\n", (int)size);
+    return kmalloc(AFS_SMALLOCSIZ, GFP_NOFS);
+}
+#endif /* AFS_PRIVATE_OSI_ALLOCSPACES */
index 845aa97dc24e84c65b37faef12eb84e50b9b174d..7c0b2bc5dafd3832789ab2f7a2e7dc7ce3c9b09e 100644 (file)
@@ -135,7 +135,7 @@ afs_osi_FreeStr(char *x)
 
 /* XXXX OpenBSD avoids space pool, presumably Rees believed the kernel
  * allocator did as well or better */
-#if 0
+#ifdef AFS_PRIVATE_OSI_ALLOCSPACES
 void
 osi_FreeLargeSpace(void *p)
 {
@@ -144,7 +144,6 @@ osi_FreeLargeSpace(void *p)
 
 /* XXXX OpenBSD avoids space pool, presumably Rees believed the kernel
  * allocator did as well or better */
-#if 0
 void
 osi_FreeSmallSpace(void *p)
 {
@@ -167,9 +166,7 @@ osi_AllocSmallSpace(size_t size)
     return (osi_nbsd_Alloc(size, 1));
 }
 
-#endif /* Space undef */
-
-#endif /* Space undef */
+#endif /* AFS_PRIVATE_OSI_ALLOCSPACES */
 
 int
 afs_syscall_icreate(dev, near_inode, param1, param2, param3, param4, retval)
index 7721a3facd25e9219fcfe160fe3fd6c1da670333..1ad7725e2776784d22ea30c209e977a4686cc082 100644 (file)
@@ -522,7 +522,7 @@ afs_ResourceInit(int preallocs)
     AFS_RWLOCK_INIT(&afs_icl_lock, "afs_icl_lock");
     AFS_RWLOCK_INIT(&afs_xinterface, "afs_xinterface");
     LOCK_INIT(&afs_puttofileLock, "afs_puttofileLock");
-#ifndef AFS_FBSD_ENV
+#ifndef AFS_PRIVATE_OSI_ALLOCSPACES
     LOCK_INIT(&osi_fsplock, "osi_fsplock");
     LOCK_INIT(&osi_flplock, "osi_flplock");
 #endif
index 6855afa626abc61fc4b987de68e18164f909a03e..fa750c4e5b807612384412fd954b0fc870e52072 100644 (file)
 #include "sys/sleep.h"
 #include "sys/syspest.h"
 #include "sys/lock_def.h"
-/*lock_t osi_fsplock = LOCK_AVAIL;*/
 #endif
 
+#ifndef AFS_PRIVATE_OSI_ALLOCSPACES
+
 afs_lock_t osi_fsplock;
+afs_lock_t osi_flplock;
 
 static struct osi_packet {
     struct osi_packet *next;
-} *freePacketList = NULL, *freeSmallList;
-afs_lock_t osi_flplock;
+} *freePacketList = NULL, *freeSmallList = NULL;
+
+#endif /* AFS_PRIVATE_OSI_ALLOCSPACES */
 
 static char memZero;           /* address of 0 bytes for kmem_alloc */
 
@@ -122,6 +125,10 @@ afs_osi_FreeStr(char *x)
     afs_osi_Free(x, strlen(x) + 1);
 }
 
+#endif /* !AFS_NBSD_ENV && !defined(AFS_NBSD50_ENV) */
+
+#ifndef AFS_PRIVATE_OSI_ALLOCSPACES
+
 /* free space allocated by AllocLargeSpace.  Also called by mclput when freeing
  * a packet allocated by osi_NetReceive. */
 
@@ -217,13 +224,13 @@ osi_AllocSmallSpace(size_t size)
     ReleaseWriteLock(&osi_fsplock);
     return (char *)tp;
 }
-
-#endif /* !AFS_NBSD_ENV && !defined(AFS_NBSD50_ENV) */
+#endif /* AFS_PRIVATE_OSI_ALLOCSPACES */
 
 void
 shutdown_osinet(void)
 {
     AFS_STATCNT(shutdown_osinet);
+#ifndef AFS_PRIVATE_OSI_ALLOCSPACES
     if (afs_cold_shutdown) {
        struct osi_packet *tp;
 
@@ -245,6 +252,7 @@ shutdown_osinet(void)
        LOCK_INIT(&osi_fsplock, "osi_fsplock");
        LOCK_INIT(&osi_flplock, "osi_flplock");
     }
+#endif /* AFS_PRIVATE_OSI_ALLOCSPACES */
     if (afs_stats_cmperf.LargeBlocksActive ||
        afs_stats_cmperf.SmallBlocksActive)
     {
@@ -253,3 +261,4 @@ shutdown_osinet(void)
                 afs_stats_cmperf.SmallBlocksActive);
     }
 }
+
index 2df8c02e4e64c8a99541cad5fdeac61ebfd0a042..7ca57dcbccd1fe0937aba8e51e66ed0eeccdaeae 100644 (file)
@@ -108,10 +108,6 @@ afspag_Init(afs_int32 nfs_server_addr)
     AFS_RWLOCK_INIT(&afs_xpagcell, "afs_xpagcell");
     AFS_RWLOCK_INIT(&afs_xpagsys, "afs_xpagsys");
     AFS_RWLOCK_INIT(&afs_icl_lock, "afs_icl_lock");
-#ifndef AFS_FBSD_ENV
-    LOCK_INIT(&osi_fsplock, "osi_fsplock");
-    LOCK_INIT(&osi_flplock, "osi_flplock");
-#endif
 
     afs_resourceinit_flag = 1;
     afs_nfs_server_addr = nfs_server_addr;
index 48e4b8734f67fd08d5b6cb0f3ba7c45e11df781a..73836ecdf9e2f515af9754e8c9606b47e66dcf59 100644 (file)
@@ -33,6 +33,8 @@
 #define AFS_USE_GETTIMEOFDAY   1       /* use gettimeofday to implement rx clock */
 #define AFS_MAXVCOUNT_ENV       1
 
+#define AFS_PRIVATE_OSI_ALLOCSPACES    1
+
 #if defined(__KERNEL__) && !defined(KDUMP_KERNEL)
 #define AFS_GLOBAL_SUNLOCK
 #endif /* __KERNEL__   && !DUMP_KERNEL */