tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: tmpfs vs VV_LOCKSWORK
Now that I sent the e-mail I had a look at access().
The benchmark at hand is custom code added to will-it-scale, pasted at
the bottom.
On 8/20/20, Mateusz Guzik <mjguzik%gmail.com@localhost> wrote:
> tmpfs does *NOT* set the flag. While I can't be arsed to verify
> semantics, I suspect it is more than eligible.
>
> This came up as a slowdown in an "access" microbenchmark with target
> file on tmpfs, stemming from:
>
> commit 5645873e2da675f475c8b8d61260c8ffe9d411ab
> Author: riastradh <riastradh%NetBSD.org@localhost>
> Date: Tue Aug 4 03:00:10 2020 +0000
>
> Fix bogus fast path in vput.
>
> I wrote a trivial patch for it (see below).
> Results are (ops/s):
> stock: 1721941
> aug 4: 1592518
> patch: 1664363
>
> The difference stems from calling VOP_ISLOCKED.
>
I meant not all performance is recovered because of the newly added
VOP_ISLOCKED call.
However, looking closer, access() passes a share-locked vnode so the
Aug 4 change fixed a serious bug for tmpfs handling.
As for recovering perf, I once more suggest VOP_NEED_INACTIVE which is
the easiest way to avoid the read -> write transition in the common
case. Preferably the need to perform this processing would be
expressed with a bit in the usecount or similar, but that's rather
invasive.
> The patch is a PoC, I don't claim much correctness. Basically
> someone(tm) will have to take care of the problem.
> diff --git a/sys/fs/tmpfs/tmpfs_subr.c b/sys/fs/tmpfs/tmpfs_subr.c
> index 92a0eedf4443..394320fe71ce 100644
> --- a/sys/fs/tmpfs/tmpfs_subr.c
> +++ b/sys/fs/tmpfs/tmpfs_subr.c
> @@ -136,6 +136,8 @@ tmpfs_init_vnode(struct vnode *vp, tmpfs_node_t *node)
> /* FALLTHROUGH */
> case VLNK:
> case VREG:
> + vp->v_vflag |= VV_LOCKSWORK;
> + /* FALLTHROUGH */
> case VSOCK:
> vp->v_op = tmpfs_vnodeop_p;
> break;
>
> --
> Mateusz Guzik <mjguzik gmail.com>
>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <fcntl.h>
#include <assert.h>
char *testcase_description = "Separate file access(2)";
void testcase(unsigned long long *iterations, unsigned long nr)
{
char tmpfile[] = "/tmp/willitscale.XXXXXX";
int fd = mkstemp(tmpfile);
assert(fd >= 0);
close(fd);
while (1) {
int error = access(tmpfile, R_OK);
assert(error == 0);
(*iterations)++;
}
unlink(tmpfile);
}
--
Mateusz Guzik <mjguzik gmail.com>
Home |
Main Index |
Thread Index |
Old Index