GFP_REPEAT usage in vhost_net_open resp. vhost_vsock_dev_open
Subsystems (2)
Hi Michael,
I am currently cleaning up opencoded kmalloc with vmalloc fallback users
[1] and my current kvmalloc_node helper doesn't support GFP_REPEAT because there are no users which would need it. At least that's what I thought until I've encountered vhost_vsock_dev_open resp. vhost_vsock_dev_open which are trying to use GFP_REPEAT for kmalloc. 23cc5a991c7a ("vhost-net: extend device allocation to vmalloc") explains the motivation as follows:
"
As vmalloc() adds overhead on a critical network path, add __GFP_REPEAT to kzalloc() flags to do this fallback only when really needed. "
I am wondering whether vmalloc adds more overhead than GFP_REPEAT which can get pretty costly for order-4 allocation which will be used here as struct vhost_net seems to be 36104 (at least in with my config). Have you ever measured the difference?
So I am just trying to understand whether we should teach kvmalloc_node to understand GFP_REPEAT or there is no strong reason to keep the repeat flag.
[1] http://lkml.kernel.org/r/[email protected]
Signature · 2 lines
Michal Hocko SUSE Labs
Michael S. Tsirkin
maintainerQuoted 13 lines · Michal Hocko
Hi Michael,
I am currently cleaning up opencoded kmalloc with vmalloc fallback users
[1] and my currentkvmalloc_nodehelper doesn't supportGFP_REPEATbecause there are no users which would need it. At least that's what I thought until I've encounteredvhost_vsock_dev_openresp.vhost_vsock_dev_openwhich are trying to useGFP_REPEATfor kmalloc.23cc5a991c7a("vhost-net: extend device allocation to vmalloc") explains the motivation as follows:
"
Asvmalloc()adds overhead on a critical network path, add__GFP_REPEATtokzalloc()flags to do this fallback only when really needed. "
Quoted 1 line
I am wondering whether vmalloc adds more overhead than
GFP_REPEAT
Yes but the GFP_REPEAT overhead is during allocation time. Using vmalloc means all accesses are slowed down. Allocation is not on data path, accesses are.
Quoted 4 lines
which
can get pretty costly for order-4 allocation which will be used here as structvhost_netseems to be 36104 (at least in with my config). Have you ever measured the difference?
I think it was measureable.
Quoted 8 lines
So I am just trying to understand whether we should teach
kvmalloc_nodeto understandGFP_REPEATor there is no strong reason to keep the repeat flag.[1] http://lkml.kernel.org/r/[email protected]
Signature · 2 lines
Michal Hocko SUSE Labs
Quoted 14 lines · Michael S. Tsirkin
Quoted 13 lines · Michal Hocko
Hi Michael,
I am currently cleaning up opencoded kmalloc with vmalloc fallback users
[1] and my currentkvmalloc_nodehelper doesn't supportGFP_REPEATbecause there are no users which would need it. At least that's what I thought until I've encounteredvhost_vsock_dev_openresp.vhost_vsock_dev_openwhich are trying to useGFP_REPEATfor kmalloc.23cc5a991c7a("vhost-net: extend device allocation to vmalloc") explains the motivation as follows:
"
Asvmalloc()adds overhead on a critical network path, add__GFP_REPEATtokzalloc()flags to do this fallback only when really needed. "
Quoted 5 lines
Quoted 1 line
I am wondering whether vmalloc adds more overhead than
GFP_REPEATYes but the
GFP_REPEAToverhead is during allocation time. Using vmalloc means all accesses are slowed down. Allocation is not on data path, accesses are.
OK, that wasn't clear to me. Thanks for the clarification. If the access path can compensate the allocation cost then I agree that GFP_REPEAT makes a lot of sense. I will cook up a patch to allow GFP_REPEAT in the current kvmalloc_node and convert vhost users to it.
Thanks!
Signature · 2 lines
Michal Hocko SUSE Labs
Quoted 14 lines · Michael S. Tsirkin
Quoted 13 lines · Michal Hocko
Hi Michael,
I am currently cleaning up opencoded kmalloc with vmalloc fallback users
[1] and my currentkvmalloc_nodehelper doesn't supportGFP_REPEATbecause there are no users which would need it. At least that's what I thought until I've encounteredvhost_vsock_dev_openresp.vhost_vsock_dev_openwhich are trying to useGFP_REPEATfor kmalloc.23cc5a991c7a("vhost-net: extend device allocation to vmalloc") explains the motivation as follows:
"
Asvmalloc()adds overhead on a critical network path, add__GFP_REPEATtokzalloc()flags to do this fallback only when really needed. "
Quoted 5 lines
Quoted 1 line
I am wondering whether vmalloc adds more overhead than
GFP_REPEATYes but the
GFP_REPEAToverhead is during allocation time. Using vmalloc means all accesses are slowed down. Allocation is not on data path, accesses are.
OK, that wasn't clear to me. Thanks for the clarification. If the access path can compensate the allocation cost then I agree that GFP_REPEAT makes a lot of sense. I will cook up a patch to allow GFP_REPEAT in the current kvmalloc_node and convert vhost users to it.
Thanks!
Signature · 8 lines
Michal Hocko SUSE Labs -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>