svn commit: r364079 - head/sys/kern
Mateusz Guzik
mjg at FreeBSD.org
Mon Aug 10 12:05:55 UTC 2020
Author: mjg
Date: Mon Aug 10 12:05:55 2020
New Revision: 364079
URL: https://svnweb.freebsd.org/changeset/base/364079
Log:
cache: resize struct namecache to a multiply of alignment
For example struct namecache on amd64 is 100 bytes, but it has to occupies
104. Use the extra bytes to support longer names.
Modified:
head/sys/kern/vfs_cache.c
Modified: head/sys/kern/vfs_cache.c
==============================================================================
--- head/sys/kern/vfs_cache.c Mon Aug 10 11:51:56 2020 (r364078)
+++ head/sys/kern/vfs_cache.c Mon Aug 10 12:05:55 2020 (r364079)
@@ -159,7 +159,18 @@ struct namecache_ts {
* alignment for everyone. Note this is a nop for 64-bit platforms.
*/
#define CACHE_ZONE_ALIGNMENT UMA_ALIGNOF(time_t)
+#define CACHE_PATH_CUTOFF 39
+#define CACHE_ZONE_SMALL_SIZE (sizeof(struct namecache) + CACHE_PATH_CUTOFF + 1)
+#define CACHE_ZONE_SMALL_TS_SIZE (sizeof(struct namecache_ts) + CACHE_PATH_CUTOFF + 1)
+#define CACHE_ZONE_LARGE_SIZE (sizeof(struct namecache) + NAME_MAX + 1)
+#define CACHE_ZONE_LARGE_TS_SIZE (sizeof(struct namecache_ts) + NAME_MAX + 1)
+
+_Static_assert((CACHE_ZONE_SMALL_SIZE % (CACHE_ZONE_ALIGNMENT + 1)) == 0, "bad zone size");
+_Static_assert((CACHE_ZONE_SMALL_TS_SIZE % (CACHE_ZONE_ALIGNMENT + 1)) == 0, "bad zone size");
+_Static_assert((CACHE_ZONE_LARGE_SIZE % (CACHE_ZONE_ALIGNMENT + 1)) == 0, "bad zone size");
+_Static_assert((CACHE_ZONE_LARGE_TS_SIZE % (CACHE_ZONE_ALIGNMENT + 1)) == 0, "bad zone size");
+
#define nc_vp n_un.nu_vp
#define nc_neg n_un.nu_neg
@@ -339,8 +350,6 @@ static uma_zone_t __read_mostly cache_zone_small_ts;
static uma_zone_t __read_mostly cache_zone_large;
static uma_zone_t __read_mostly cache_zone_large_ts;
-#define CACHE_PATH_CUTOFF 35
-
static struct namecache *
cache_alloc(int len, int ts)
{
@@ -2095,22 +2104,14 @@ nchinit(void *dummy __unused)
{
u_int i;
- cache_zone_small = uma_zcreate("S VFS Cache",
- sizeof(struct namecache) + CACHE_PATH_CUTOFF + 1,
- NULL, NULL, NULL, NULL, CACHE_ZONE_ALIGNMENT,
- UMA_ZONE_ZINIT);
- cache_zone_small_ts = uma_zcreate("STS VFS Cache",
- sizeof(struct namecache_ts) + CACHE_PATH_CUTOFF + 1,
- NULL, NULL, NULL, NULL, CACHE_ZONE_ALIGNMENT,
- UMA_ZONE_ZINIT);
- cache_zone_large = uma_zcreate("L VFS Cache",
- sizeof(struct namecache) + NAME_MAX + 1,
- NULL, NULL, NULL, NULL, CACHE_ZONE_ALIGNMENT,
- UMA_ZONE_ZINIT);
- cache_zone_large_ts = uma_zcreate("LTS VFS Cache",
- sizeof(struct namecache_ts) + NAME_MAX + 1,
- NULL, NULL, NULL, NULL, CACHE_ZONE_ALIGNMENT,
- UMA_ZONE_ZINIT);
+ cache_zone_small = uma_zcreate("S VFS Cache", CACHE_ZONE_SMALL_SIZE,
+ NULL, NULL, NULL, NULL, CACHE_ZONE_ALIGNMENT, UMA_ZONE_ZINIT);
+ cache_zone_small_ts = uma_zcreate("STS VFS Cache", CACHE_ZONE_SMALL_TS_SIZE,
+ NULL, NULL, NULL, NULL, CACHE_ZONE_ALIGNMENT, UMA_ZONE_ZINIT);
+ cache_zone_large = uma_zcreate("L VFS Cache", CACHE_ZONE_LARGE_SIZE,
+ NULL, NULL, NULL, NULL, CACHE_ZONE_ALIGNMENT, UMA_ZONE_ZINIT);
+ cache_zone_large_ts = uma_zcreate("LTS VFS Cache", CACHE_ZONE_LARGE_TS_SIZE,
+ NULL, NULL, NULL, NULL, CACHE_ZONE_ALIGNMENT, UMA_ZONE_ZINIT);
VFS_SMR_ZONE_SET(cache_zone_small);
VFS_SMR_ZONE_SET(cache_zone_small_ts);
More information about the svn-src-all
mailing list