All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vivek Goyal <vgoyal@redhat.com>
To: Miklos Szeredi <mszeredi@redhat.com>
Cc: virtio-fs-list <virtio-fs@redhat.com>, Eric Ernst <eric_ernst@apple.com>
Subject: Re: [Virtio-fs] Large memory consumption by virtiofsd, suspecting fd's aren't being closed?
Date: Mon, 22 Mar 2021 12:47:04 -0400	[thread overview]
Message-ID: <20210322164704.GD446288@redhat.com> (raw)
In-Reply-To: <CAOssrKdGOL3Zqmhz4VGEccWw8N0tp1kP7qooB8gN7JOi5+5gew@mail.gmail.com>

On Mon, Mar 22, 2021 at 05:09:32PM +0100, Miklos Szeredi wrote:
> On Mon, Mar 22, 2021 at 6:52 AM Eric Ernst <eric_ernst@apple.com> wrote:
> >
> > Hey ya’ll,
> >
> > One challenge I’ve been looking at is how to setup an appropriate memory cgroup limit for workloads that are leveraging virtiofs (ie, running pods with Kata Containers). I noticed that memory usage of the daemon itself can grow considerably depending on the workload; though much more than I’d expect.
> >
> > I’m running workload that simply runs a build on kernel sources with -j3. In doing this, the source of the linux kernel are shared via virtiofs (no DAX), so as the build goes on, there are a lot of files opened, closed, as well as created. The rss memory of virtiofsd grows into several hundreds of MBs.
> >
> > When taking a look, I’m suspecting that virtiofsd is carrying out the opens, but never actually closing fds. In the guest, I’m seeing fd’s on the order of 10-40 for all the container processes as it runs, whereas I see the number of fds for virtiofsd continually increasing, reaching over 80,000 fds. I’m guessing this isn’t expected?
> 
> The reason could be that guest is keeping a ref on the inodes
> (dcache->dentry->inode) and current implementation of server keeps an
> O_PATH fd open for each inode referenced by the client.
> 
> One way to avoid this is to use the "cache=none" option, which forces
> the client to drop dentries immediately from the cache if not in use.
> This is not desirable if cache is actually in use.
> 
> The memory use of the server should still be limited by the memory use
> of the guest:  if there's memory pressure in the guest kernel, then it
> will clean out caches, which results in the memory use decreasing in
> the server as well.  If the server memory use looks unbounded, that
> might be indicative of too much memory used for dcache in the guest
> (cat /proc/slabinfo | grep ^dentry).     Can you verify?

Hi Miklos,

Apart from above, we identified one more issue on IRC. I asked Eric
to drop caches manually in guest. (echo 3 > /proc/sys/vm/drop_caches)
and while it reduced the fds open it did not seem to free up significant
amount of memory.

So question remains where is that memory. One possibility is that we
have memory allocated for mapping arrays (inode and fd). These arrays
only grow and never shrink. So they can lock down some memory.

But still, lot of lo_inode memory should have been freed when
echo 3 > /proc/sys/vm/drop_caches was done. Why all that did not
show up in virtiofsd RSS usage, that's kind of little confusing.

cache=none is an alternative only if application is not using mmap.
I think even kernel compilation now uses mmap towards the end and
fails with cache=none. 

Thanks
Vivek


  reply	other threads:[~2021-03-22 16:47 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-22  4:09 [Virtio-fs] Large memory consumption by virtiofsd, suspecting fd's aren't being closed? Eric Ernst
2021-03-22 16:09 ` Miklos Szeredi
2021-03-22 16:47   ` Vivek Goyal [this message]
2021-03-22 19:15     ` Miklos Szeredi
2021-03-23 11:55     ` Sergio Lopez
2021-03-23 13:47       ` Vivek Goyal
2021-03-23 14:52         ` Eric Ernst
2021-03-23 15:19           ` Sergio Lopez
2021-03-23 15:31           ` Vivek Goyal
  -- strict thread matches above, loose matches on Subject: below --
2021-03-22  4:14 Eric Ernst
2021-03-22 14:42 ` Vivek Goyal

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=20210322164704.GD446288@redhat.com \
    --to=vgoyal@redhat.com \
    --cc=eric_ernst@apple.com \
    --cc=mszeredi@redhat.com \
    --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.