linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: Dave Chinner <david@fromorbit.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 5/5] xfs: allocate xattr buffer on demand
Date: Thu, 29 Aug 2019 22:36:54 -0700	[thread overview]
Message-ID: <20190830053654.GH6077@infradead.org> (raw)
In-Reply-To: <20190829113505.27223-6-david@fromorbit.com>

On Thu, Aug 29, 2019 at 09:35:05PM +1000, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
> 
> When doing file lookups and checking for permissions, we end up in
> xfs_get_acl() to see if there are any ACLs on the inode. This
> requires and xattr lookup, and to do that we have to supply a buffer
> large enough to hold an maximum sized xattr.
> 
> On workloads were we are accessing a wide range of cache cold files
> under memory pressure (e.g. NFS fileservers) we end up spending a
> lot of time allocating the buffer. The buffer is 64k in length, so
> is a contiguous multi-page allocation, and if that then fails we
> fall back to vmalloc(). Hence the allocation here is /expensive/
> when we are looking up hundreds of thousands of files a second.
> 
> Initial numbers from a bpf trace show average time in xfs_get_acl()
> is ~32us, with ~19us of that in the memory allocation. Note these
> are average times, so there are going to be affected by the worst
> case allocations more than the common fast case...
> 
> To avoid this, we could just do a "null"  lookup to see if the ACL
> xattr exists and then only do the allocation if it exists. This,
> however, optimises the path for the "no ACL present" case at the
> expense of the "acl present" case. i.e. we can halve the time in
> xfs_get_acl() for the no acl case (i.e down to ~10-15us), but that
> then increases the ACL case by 30% (i.e. up to 40-45us).
> 
> To solve this and speed up both cases, drive the xattr buffer
> allocation into the attribute code once we know what the actual
> xattr length is. For the no-xattr case, we avoid the allocation
> completely, speeding up that case. For the common ACL case, we'll
> end up with a fast heap allocation (because it'll be smaller than a
> page), and only for the rarer "we have a remote xattr" will we have
> a multi-page allocation occur. Hence the common ACL case will be
> much faster, too.
> 
> Signed-off-by: Dave Chinner <dchinner@redhat.com>

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

      parent reply	other threads:[~2019-08-30  5:36 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-29 11:35 [PATCH 0/3 v3] xfs: allocate xattr buffer on demand Dave Chinner
2019-08-29 11:35 ` [PATCH 1/5] xfs: make attr lookup returns consistent Dave Chinner
2019-08-30  5:34   ` Christoph Hellwig
2019-08-29 11:35 ` [PATCH 2/5] xfs: remove unnecessary indenting from xfs_attr3_leaf_getvalue Dave Chinner
2019-08-29 21:23   ` Darrick J. Wong
2019-08-30  5:34   ` Christoph Hellwig
2019-08-29 11:35 ` [PATCH 3/5] xfs: move remote attr retrieval into xfs_attr3_leaf_getvalue Dave Chinner
2019-08-29 21:26   ` Darrick J. Wong
2019-08-30  5:35   ` Christoph Hellwig
2019-08-29 11:35 ` [PATCH 4/5] xfs: consolidate attribute value copying Dave Chinner
2019-08-29 21:26   ` Darrick J. Wong
2019-08-30  5:35   ` Christoph Hellwig
2019-08-29 11:35 ` [PATCH 5/5] xfs: allocate xattr buffer on demand Dave Chinner
2019-08-29 21:27   ` Darrick J. Wong
2019-08-30  5:36   ` Christoph Hellwig [this message]

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=20190830053654.GH6077@infradead.org \
    --to=hch@infradead.org \
    --cc=david@fromorbit.com \
    --cc=linux-xfs@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).