mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andreas Dilger <adilger@dilger.ca>
To: Daniel Xu <dxu@dxuuu.xyz>
Cc: cgroups@vger.kernel.org, tj@kernel.org, lizefan@huawei.com,
	hannes@cmpxchg.org, viro@zeniv.linux.org.uk, shakeelb@google.com,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	gregkh@linuxfoundation.org, kernel-team@fb.com
Subject: Re: [PATCH v3 1/4] kernfs: kvmalloc xattr value instead of kmalloc
Date: Thu, 12 Mar 2020 15:09:09 -0600	[thread overview]
Message-ID: <23C0E698-9507-40FE-9F37-9F1C4CD55192@dilger.ca> (raw)
In-Reply-To: <20200312200317.31736-2-dxu@dxuuu.xyz>

[-- Attachment #1: Type: text/plain, Size: 1477 bytes --]

On Mar 12, 2020, at 2:03 PM, Daniel Xu <dxu@dxuuu.xyz> wrote:
> 
> xattr values have a 64k maximum size. This can result in an order 4
> kmalloc request which can be difficult to fulfill. Since xattrs do not
> need physically contiguous memory, we can switch to kvmalloc and not
> have to worry about higher order allocations failing.
> 
> Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>

Reviewed-by: Andreas Dilger <adilger@dilger.ca>

> ---
> fs/xattr.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/xattr.c b/fs/xattr.c
> index 90dd78f0eb27..0d3c9b4d1914 100644
> --- a/fs/xattr.c
> +++ b/fs/xattr.c
> @@ -817,7 +817,7 @@ struct simple_xattr *simple_xattr_alloc(const void *value, size_t size)
> 	if (len < sizeof(*new_xattr))
> 		return NULL;
> 
> -	new_xattr = kmalloc(len, GFP_KERNEL);
> +	new_xattr = kvmalloc(len, GFP_KERNEL);
> 	if (!new_xattr)
> 		return NULL;
> 
> @@ -882,7 +882,7 @@ int simple_xattr_set(struct simple_xattrs *xattrs, const char *name,
> 
> 		new_xattr->name = kstrdup(name, GFP_KERNEL);
> 		if (!new_xattr->name) {
> -			kfree(new_xattr);
> +			kvfree(new_xattr);
> 			return -ENOMEM;
> 		}
> 	}
> @@ -912,7 +912,7 @@ int simple_xattr_set(struct simple_xattrs *xattrs, const char *name,
> 	spin_unlock(&xattrs->lock);
> 	if (xattr) {
> 		kfree(xattr->name);
> -		kfree(xattr);
> +		kvfree(xattr);
> 	}
> 	return err;
> 
> --
> 2.21.1
> 


Cheers, Andreas






[-- Attachment #2: Message signed with OpenPGP --]
[-- Type: application/pgp-signature, Size: 873 bytes --]

  parent reply	other threads:[~2020-03-12 21:09 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-12 20:03 [PATCH v3 0/4] Support user xattrs in cgroupfs Daniel Xu
2020-03-12 20:03 ` [PATCH v3 1/4] kernfs: kvmalloc xattr value instead of kmalloc Daniel Xu
2020-03-12 21:03   ` Shakeel Butt
2020-03-12 21:09   ` Andreas Dilger [this message]
2020-03-12 20:03 ` [PATCH v3 2/4] kernfs: Add removed_size out param for simple_xattr_set Daniel Xu
2020-03-12 20:03 ` [PATCH v3 3/4] kernfs: Add option to enable user xattrs Daniel Xu
2020-03-12 20:03 ` [PATCH v3 4/4] cgroupfs: Support " Daniel Xu
2020-03-12 20:09 ` [PATCH v3 0/4] Support user xattrs in cgroupfs Daniel Xu
2020-03-12 21:17 ` Tejun Heo
2020-03-12 21:19   ` Tejun Heo
2020-03-12 22:05   ` Greg KH
2020-03-13  1:00 ` Chris Down
2020-03-16 19:55 ` Tejun Heo

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=23C0E698-9507-40FE-9F37-9F1C4CD55192@dilger.ca \
    --to=adilger@dilger.ca \
    --cc=cgroups@vger.kernel.org \
    --cc=dxu@dxuuu.xyz \
    --cc=gregkh@linuxfoundation.org \
    --cc=hannes@cmpxchg.org \
    --cc=kernel-team@fb.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizefan@huawei.com \
    --cc=shakeelb@google.com \
    --cc=tj@kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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

all inboxes | Powered by JetHome®