From: Matthew Wilcox <willy@infradead.org>
To: Marc Orr <marcorr@google.com>
Cc: kvm@vger.kernel.org, Jim Mattson <jmattson@google.com>,
David Rientjes <rientjes@google.com>,
Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
linux-mm@kvack.org, akpm@linux-foundation.org
Subject: Re: [kvm PATCH 2/2] kvm: vmx: use vmalloc() to allocate vcpus
Date: Wed, 24 Oct 2018 04:41:42 -0700 [thread overview]
Message-ID: <20181024114142.GD25444@bombadil.infradead.org> (raw)
In-Reply-To: <CAA03e5HWA4Vca=_J=VuQ__bLAdO8ohUU4r-hmxY1EbnVzsQHww@mail.gmail.com>
On Tue, Oct 23, 2018 at 05:13:40PM -0400, Marc Orr wrote:
> > + struct vcpu_vmx *vmx = __vmalloc_node_range(
> > + sizeof(struct vcpu_vmx),
> > + __alignof__(struct vcpu_vmx),
> > + VMALLOC_START,
> > + VMALLOC_END,
> > + GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO | __GFP_ACCOUNT,
> > + PAGE_KERNEL,
> > + 0,
> > + NUMA_NO_NODE,
> > + __builtin_return_address(0));
I don't understand why you need to expose the lowest-level
__vmalloc_node_range to do what you need to do.
For example, __vmalloc_node would be easier for you to use while giving you
all the flexibility you think you want.
In fact, I don't think you need all the flexibility you're using.
vmalloc is always going to give you a page-aligned address, so
__alignof__(struct foo) isn't going to do anything worthwhile.
VMALLOC_START, VMALLOC_END, PAGE_KERNEL, 0, NUMA_NO_NODE, and
__builtin_return_address(0) are all the defaults. So all you actually
need are these GFP flags. __GFP_HIGHMEM isn't needed; vmalloc can
always allocate from highmem unless you're doing a DMA alloc. So
it's just __GFP_ACCOUNT that's not supported by regular vzalloc().
I see __vmalloc_node_flags_caller is already non-static, so that would
be where I went and your call becomes simply:
vmx = __vmalloc_node_flags_caller(sizeof(struct vcpu_vmx),
NUMA_NO_NODE,
GFP_KERNEL | __GFP_ZERO | __GFP_ACCOUNT,
__builtin_return_address(0));
I suspect a better option might be to add a vzalloc_account() call
and then your code becomes:
vmx = vzalloc_account(sizeof(struct vcpu_vmx));
while vmalloc gains:
void *vmalloc_account(unsigned long size)
{
return __vmalloc_node_flags(size, NUMA_NO_NODE,
GFP_KERNEL | __GFP_ZERO | __GFP_ACCOUNT);
}
EXPORT_SYMBOL(vmalloc_account);
next prev parent reply other threads:[~2018-10-24 11:41 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20181020211200.255171-1-marcorr@google.com>
[not found] ` <20181020211200.255171-2-marcorr@google.com>
2018-10-22 20:06 ` [kvm PATCH 1/2] mm: export __vmalloc_node_range() Konrad Rzeszutek Wilk
2018-10-23 12:33 ` Michal Hocko
2018-10-23 21:10 ` Marc Orr
2018-10-24 6:16 ` Michal Hocko
2018-10-24 8:12 ` Marc Orr
2018-10-24 8:22 ` Michal Hocko
2018-10-23 21:13 ` [kvm PATCH 0/2] kvm: vmalloc vmx vcpus Marc Orr
[not found] ` <20181020211200.255171-3-marcorr@google.com>
2018-10-23 21:13 ` [kvm PATCH 2/2] kvm: vmx: use vmalloc() to allocate vcpus Marc Orr
2018-10-24 11:41 ` Matthew Wilcox [this message]
2018-10-24 18:05 ` Marc Orr
2018-10-25 12:58 ` Michal Hocko
2018-10-24 22:31 ` Sean Christopherson
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=20181024114142.GD25444@bombadil.infradead.org \
--to=willy@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=jmattson@google.com \
--cc=konrad.wilk@oracle.com \
--cc=kvm@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=marcorr@google.com \
--cc=rientjes@google.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).