pseudofs: Microoptimize struct pfs_node
Since 81167243b
the size of struct pfs_node is 280 bytes, so the kernel
memory allocator takes memory from 384 bytes sized bucket. However, the
length of the node name is mostly short, e.g., for Linux emulation layer
it is up to 16 bytes. The size of struct pfs_node w/o pfs_name is 152
bytes, i.e., we have 104 bytes left to fit the node name into the 256
bytes-sized bucket.
Reviewed by: des
Differential revision: https://reviews.freebsd.org/D39381
MFC after: 1 month
This commit is contained in:
parent
7ee18f5aad
commit
7f72324346
@ -72,18 +72,20 @@ pfs_alloc_node_flags(struct pfs_info *pi, const char *name, pfs_type_t type, int
|
|||||||
{
|
{
|
||||||
struct pfs_node *pn;
|
struct pfs_node *pn;
|
||||||
int malloc_flags;
|
int malloc_flags;
|
||||||
|
size_t len;
|
||||||
|
|
||||||
KASSERT(strlen(name) < PFS_NAMELEN,
|
len = strlen(name);
|
||||||
|
KASSERT(len < PFS_NAMELEN,
|
||||||
("%s(): node name is too long", __func__));
|
("%s(): node name is too long", __func__));
|
||||||
if (flags & PFS_NOWAIT)
|
if (flags & PFS_NOWAIT)
|
||||||
malloc_flags = M_NOWAIT | M_ZERO;
|
malloc_flags = M_NOWAIT | M_ZERO;
|
||||||
else
|
else
|
||||||
malloc_flags = M_WAITOK | M_ZERO;
|
malloc_flags = M_WAITOK | M_ZERO;
|
||||||
pn = malloc(sizeof *pn, M_PFSNODES, malloc_flags);
|
pn = malloc(sizeof(*pn) + len + 1, M_PFSNODES, malloc_flags);
|
||||||
if (pn == NULL)
|
if (pn == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
mtx_init(&pn->pn_mutex, "pfs_node", NULL, MTX_DEF | MTX_DUPOK);
|
mtx_init(&pn->pn_mutex, "pfs_node", NULL, MTX_DEF | MTX_DUPOK);
|
||||||
strlcpy(pn->pn_name, name, sizeof pn->pn_name);
|
memcpy(pn->pn_name, name, len);
|
||||||
pn->pn_type = type;
|
pn->pn_type = type;
|
||||||
pn->pn_info = pi;
|
pn->pn_info = pi;
|
||||||
return (pn);
|
return (pn);
|
||||||
|
@ -219,7 +219,6 @@ struct pfs_info {
|
|||||||
* is not enforcable by WITNESS.
|
* is not enforcable by WITNESS.
|
||||||
*/
|
*/
|
||||||
struct pfs_node {
|
struct pfs_node {
|
||||||
char pn_name[PFS_NAMELEN];
|
|
||||||
pfs_type_t pn_type;
|
pfs_type_t pn_type;
|
||||||
int pn_flags;
|
int pn_flags;
|
||||||
struct mtx pn_mutex;
|
struct mtx pn_mutex;
|
||||||
@ -240,6 +239,7 @@ struct pfs_node {
|
|||||||
struct pfs_node *pn_nodes; /* (o) */
|
struct pfs_node *pn_nodes; /* (o) */
|
||||||
struct pfs_node *pn_last_node; /* (o) */
|
struct pfs_node *pn_last_node; /* (o) */
|
||||||
struct pfs_node *pn_next; /* (p) */
|
struct pfs_node *pn_next; /* (p) */
|
||||||
|
char pn_name[]; /* Keep it last */
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user