linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vasily Averin <vvs@virtuozzo.com>
To: Michal Hocko <mhocko@suse.com>
Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org,
	Alexey Dobriyan <adobriyan@gmail.com>,
	Shakeel Butt <shakeelb@google.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Vladimir Davydov <vdavydov.dev@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Dmitry Safonov <0x7f454c46@gmail.com>
Subject: Re: [PATCH 2/2] ipc: use kmalloc for msg_queue and shmid_kernel
Date: Wed, 28 Apr 2021 08:15:10 +0300	[thread overview]
Message-ID: <70805e05-5e56-2ab9-2654-3d48e9fe5a0a@virtuozzo.com> (raw)
In-Reply-To: <YIaVKi+0VMrz5LGD@dhcp22.suse.cz>

On 4/26/21 1:25 PM, Michal Hocko wrote:
> Using kvmalloc for sub page size objects is suboptimal because kmalloc
> can easily fallback into vmalloc under memory pressure and smaller
> objects would fragment memory. Therefore replace kvmalloc by a simple
> kmalloc.

I think you're wrong here:
kvmalloc can failback to vmalloc for size > PAGE_SIZE only

Please take look at mm/util.c::kvmalloc_node()

        if (size > PAGE_SIZE) {
                kmalloc_flags |= __GFP_NOWARN;

                if (!(kmalloc_flags & __GFP_RETRY_MAYFAIL))
                        kmalloc_flags |= __GFP_NORETRY;
        }

        ret = kmalloc_node(size, kmalloc_flags, node);

        /*
         * It doesn't really make sense to fallback to vmalloc for sub page
         * requests
         */
        if (ret || size <= PAGE_SIZE)
                return ret;

        return __vmalloc_node(size, 1, flags, node,
                        __builtin_return_address(0));

For small objects kvmalloc is not much different just from kmalloc,
so the patch is mostly cosmetic.

  reply	other threads:[~2021-04-28  5:15 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <e67f2a95-4b01-9db2-fe47-0b2210f0b138@virtuozzo.com>
2021-04-26 10:18 ` [PATCH 0/2] ipc: allocations cleanup Vasily Averin
2021-04-28  7:35   ` [PATCH v2 " Vasily Averin
2021-04-28  7:35   ` [PATCH v2 1/2] ipc sem: use kvmalloc for sem_undo allocation Vasily Averin
2021-04-28  7:35   ` [PATCH v2 2/2] ipc: use kmalloc for msg_queue and shmid_kernel Vasily Averin
2021-04-26 10:18 ` [PATCH 1/2] ipc sem: use kvmalloc for sem_undo allocation Vasily Averin
2021-04-26 10:28   ` Michal Hocko
2021-04-26 16:22   ` Shakeel Butt
2021-04-26 20:29   ` Roman Gushchin
2021-04-26 10:18 ` [PATCH 2/2] ipc: use kmalloc for msg_queue and shmid_kernel Vasily Averin
2021-04-26 10:25   ` Michal Hocko
2021-04-28  5:15     ` Vasily Averin [this message]
2021-04-28  6:33       ` Michal Hocko
2021-04-26 16:23   ` Shakeel Butt
2021-04-26 20:29   ` Roman Gushchin

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=70805e05-5e56-2ab9-2654-3d48e9fe5a0a@virtuozzo.com \
    --to=vvs@virtuozzo.com \
    --cc=0x7f454c46@gmail.com \
    --cc=adobriyan@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=cgroups@vger.kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhocko@suse.com \
    --cc=shakeelb@google.com \
    --cc=vdavydov.dev@gmail.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).