All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vivek Goyal <vgoyal@redhat.com>
To: Jeffle Xu <jefflexu@linux.alibaba.com>
Cc: virtio-fs@redhat.com, joseph.qi@linux.alibaba.com, miklos@szeredi.hu
Subject: Re: [Virtio-fs] [PATCH v7 6/6] virtiofsd: implement file size based dax policy
Date: Thu, 9 Dec 2021 16:59:14 -0500	[thread overview]
Message-ID: <YbJ8MjbX96EiwDxr@redhat.com> (raw)
In-Reply-To: <20211102055646.103337-7-jefflexu@linux.alibaba.com>

On Tue, Nov 02, 2021 at 01:56:46PM +0800, Jeffle Xu wrote:
> When DAX window is fully utilized and needs to be expanded to avoid the
> performance fluctuation triggered by DAX window recaliming, it may not
> be wise to allocate DAX window for files with size smaller than some
> specific point, considering from the perspective of reducing memory
> overhead.
> 
> To maintain one DAX window chunk (e.g., 2MB in size), 32KB
> (512 * 64 bytes) memory footprint will be consumed for page descriptors
> inside guest. Thus it'd better disable DAX for those files smaller than
> 32KB, to reduce the demand for DAX window and thus avoid the unworthy
> memory overhead.
> 
> Thus only flag the file with FUSE_ATTR_DAX when the file size is greater
> than 32 KB. The guest will enable DAX only for those files flagged with
> FUSE_ATTR_DAX, when virtiofs is mounted with '-o dax=inode'.
> 
> To be noted that both FUSE_LOOKUP and FUSE_READDIRPLUS are affected, and
> will convey FUSE_ATTR_DAX flag to the guest.
> 
> This policy will be used when '-o dax=filesize' option is specified for
> virtiofsd.
> 
> Signed-off-by: Jeffle Xu <jefflexu@linux.alibaba.com>
> ---
>  tools/virtiofsd/passthrough_ll.c | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
> index dac5063594..cbf81d1593 100644
> --- a/tools/virtiofsd/passthrough_ll.c
> +++ b/tools/virtiofsd/passthrough_ll.c
> @@ -54,6 +54,7 @@
>  #include <sys/syscall.h>
>  #include <sys/wait.h>
>  #include <sys/xattr.h>
> +#include <sys/user.h>
>  #include <syslog.h>
>  #include <linux/fs.h>
>  
> @@ -61,6 +62,20 @@
>  #include "passthrough_helpers.h"
>  #include "passthrough_seccomp.h"
>  
> +/*
> + * One page descriptor (64 bytes in size) needs to be maintained for every page
> + * in the DAX window chunk, i.e., there is certain guest memory overhead when
> + * DAX is enabled. Thus disable DAX for those with file size smaller than this
> + * certain memory overhead if virtiofs is mounted in per inode DAX mode. In
> + * this case, the guest page cache will consume less memory than that when DAX
> + * is enabled.
> + */
> +#define FUSE_DAX_SHIFT      21

Hmm.., this is hardcoded value. If we change chunk size down the
line then it will not be valid anymore.

I guess when we change chunk size, we can think of negotiating
this with server and that will help.

I guess for now it is ok.

Vivek

> +#define PAGE_DESC_SHIFT     6
> +#define FUSE_INODE_DAX_SHIFT \
> +    (FUSE_DAX_SHIFT - PAGE_SHIFT + PAGE_DESC_SHIFT)
> +#define FUSE_INODE_DAX_THRESH  (1 << FUSE_INODE_DAX_SHIFT)
> +
>  /* Keep track of inode posix locks for each owner. */
>  struct lo_inode_plock {
>      uint64_t lock_owner;
> @@ -1052,6 +1067,10 @@ static bool lo_should_enable_dax(struct lo_data *lo, struct lo_inode *inode,
>          return ret;
>      }
>  
> +    if (lo->dax == INODE_DAX_FILESIZE) {
> +        return e->attr.st_size > FUSE_INODE_DAX_THRESH;
> +    }
> +
>      return false;
>  }
>  
> -- 
> 2.27.0
> 


  reply	other threads:[~2021-12-09 21:59 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-02  5:56 [Virtio-fs] [PATCH v7 0/6] virtiofsd: support per inode DAX Jeffle Xu
2021-11-02  5:56 ` [Virtio-fs] [PATCH v7 1/6] virtiofsd: add .ioctl() support Jeffle Xu
2021-12-09 19:33   ` Vivek Goyal
2021-12-10  2:51     ` JeffleXu
2021-12-13 18:02       ` Vivek Goyal
2021-11-02  5:56 ` [Virtio-fs] [PATCH v7 2/6] virtiofsd: support per inode DAX in fuse protocol Jeffle Xu
2021-11-02  5:56 ` [Virtio-fs] [PATCH v7 3/6] virtiofsd: add 'dax=' option Jeffle Xu
2021-12-09 20:00   ` Vivek Goyal
2021-12-10  3:02     ` JeffleXu
2021-11-02  5:56 ` [Virtio-fs] [PATCH v7 4/6] virtiofsd: negotiate per inode DAX in FUSE_INIT Jeffle Xu
2021-11-02  5:56 ` [Virtio-fs] [PATCH v7 5/6] virtiofsd: implement xflag based dax policy Jeffle Xu
2021-12-09 20:16   ` Vivek Goyal
2021-12-10  3:13     ` JeffleXu
2021-12-09 22:02   ` Vivek Goyal
2021-12-10  3:16     ` JeffleXu
2021-11-02  5:56 ` [Virtio-fs] [PATCH v7 6/6] virtiofsd: implement file size " Jeffle Xu
2021-12-09 21:59   ` Vivek Goyal [this message]
2021-12-10  3:21     ` JeffleXu
2021-12-07 14:42 ` [Virtio-fs] [PATCH v7 0/6] virtiofsd: support per inode DAX Vivek Goyal
2021-12-08  1:38   ` JeffleXu
2021-12-08 20:05     ` Vivek Goyal
2021-12-09  1:41       ` JeffleXu
2021-12-10  2:54       ` JeffleXu
2021-12-13 18:03         ` Vivek Goyal
2021-12-14 10:17           ` Miklos Szeredi
2021-12-14 15:51             ` JeffleXu
2021-12-14 16:10               ` Miklos Szeredi
2021-12-15  1:08                 ` JeffleXu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YbJ8MjbX96EiwDxr@redhat.com \
    --to=vgoyal@redhat.com \
    --cc=jefflexu@linux.alibaba.com \
    --cc=joseph.qi@linux.alibaba.com \
    --cc=miklos@szeredi.hu \
    --cc=virtio-fs@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.