From: Matthew Wilcox <willy@infradead.org>
To: Christopher Lameter <cl@linux.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Matthew Wilcox <mawilcox@microsoft.com>,
linux-mm@kvack.org, Kees Cook <keescook@chromium.org>,
linux-kernel@vger.kernel.org,
kernel-hardening@lists.openwall.com
Subject: Re: [PATCH 2/2] mm: Add kvmalloc_ab_c and kvzalloc_struct
Date: Wed, 14 Feb 2018 12:14:00 -0800 [thread overview]
Message-ID: <20180214201400.GD20627@bombadil.infradead.org> (raw)
In-Reply-To: <alpine.DEB.2.20.1802141354530.28235@nuc-kabylake>
On Wed, Feb 14, 2018 at 01:55:59PM -0600, Christopher Lameter wrote:
> On Wed, 14 Feb 2018, Matthew Wilcox wrote:
>
> > +#define kvzalloc_struct(p, member, n, gfp) \
> > + (typeof(p))kvzalloc_ab_c(n, \
> > + sizeof(*(p)->member) + __must_be_array((p)->member), \
> > + offsetof(typeof(*(p)), member), gfp)
> > +
>
> Uppercase like the similar KMEM_CACHE related macros in
> include/linux/slab.h?>
Do you think that would look better in the users? Compare:
@@ -1284,7 +1284,7 @@ static long vhost_set_memory(struct vhost_dev *d, struct vhost_memory __user *m)
return -EOPNOTSUPP;
if (mem.nregions > max_mem_regions)
return -E2BIG;
- newmem = kvzalloc(size + mem.nregions * sizeof(*m->regions), GFP_KERNEL);
+ newmem = kvzalloc_struct(newmem, regions, mem.nregions, GFP_KERNEL);
if (!newmem)
return -ENOMEM;
@@ -1284,7 +1284,7 @@ static long vhost_set_memory(struct vhost_dev *d, struct vhost_memory __user *m)
return -EOPNOTSUPP;
if (mem.nregions > max_mem_regions)
return -E2BIG;
- newmem = kvzalloc(size + mem.nregions * sizeof(*m->regions), GFP_KERNEL);
+ newmem = KVZALLOC_STRUCT(newmem, regions, mem.nregions, GFP_KERNEL);
if (!newmem)
return -ENOMEM;
Making it look like a function is more pleasing to my eye, but I'll
change it if that's the only thing keeping it from being merged.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2018-02-14 20:14 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-14 18:26 [PATCH 0/2] Add kvzalloc_struct to complement kvzalloc_array Matthew Wilcox
2018-02-14 18:26 ` [PATCH 1/2] mm: Add kernel-doc for kvfree Matthew Wilcox
2018-02-14 18:26 ` [PATCH 2/2] mm: Add kvmalloc_ab_c and kvzalloc_struct Matthew Wilcox
2018-02-14 19:22 ` Kees Cook
2018-02-14 19:27 ` Julia Lawall
2018-02-14 19:35 ` Matthew Wilcox
2018-03-07 21:18 ` Julia Lawall
2018-03-08 2:58 ` Matthew Wilcox
2018-03-08 6:24 ` Julia Lawall
2018-03-08 23:05 ` Matthew Wilcox
2018-03-09 5:59 ` Julia Lawall
2018-03-13 17:19 ` Julia Lawall
2018-03-13 18:32 ` Matthew Wilcox
2018-03-13 18:35 ` Julia Lawall
2018-04-29 16:59 ` Kees Cook
2018-04-29 20:30 ` Matthew Wilcox
2018-04-30 19:02 ` Kees Cook
2018-04-30 20:16 ` Matthew Wilcox
2018-04-30 21:29 ` Rasmus Villemoes
2018-04-30 22:41 ` Matthew Wilcox
2018-05-01 17:00 ` Kees Cook
2018-05-01 17:41 ` Julia Lawall
2018-05-03 23:00 ` Rasmus Villemoes
2018-05-04 0:36 ` Kees Cook
2018-05-04 0:40 ` Kees Cook
2018-04-30 22:29 ` Kees Cook
2018-02-14 19:55 ` Christopher Lameter
2018-02-14 20:14 ` Matthew Wilcox [this message]
2018-02-15 15:55 ` Christopher Lameter
2018-02-15 16:23 ` Matthew Wilcox
2018-02-15 17:06 ` Christopher Lameter
2018-02-22 1:28 ` Kees Cook
2018-05-04 7:42 ` Linus Torvalds
2018-05-04 13:14 ` Matthew Wilcox
2018-05-04 15:35 ` Linus Torvalds
2018-05-04 16:03 ` Kees Cook
2018-02-14 18:47 ` [PATCH 0/2] Add kvzalloc_struct to complement kvzalloc_array Joe Perches
2018-02-14 19:23 ` Kees Cook
2018-02-14 19:32 ` Joe Perches
2018-02-14 19:36 ` Matthew Wilcox
2018-02-14 19:43 ` Joe Perches
2018-02-14 19:56 ` Matthew Wilcox
2018-02-14 20:06 ` Joe Perches
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=20180214201400.GD20627@bombadil.infradead.org \
--to=willy@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=cl@linux.com \
--cc=keescook@chromium.org \
--cc=kernel-hardening@lists.openwall.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mawilcox@microsoft.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 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).