From: Mikulas Patocka <mpatocka@redhat.com>
To: Joe Thornber <thornber@redhat.com>, Zdenek Kabelac <zkabelac@redhat.com>
Cc: dm-devel@lists.linux.dev, Mike Snitzer <snitzer@kernel.org>
Subject: [PATCH] dm persistent data: fix memory allocation failure
Date: Tue, 13 Aug 2024 16:35:14 +0200 (CEST) [thread overview]
Message-ID: <12f6fc8a-a0cb-48c-e792-57f09b62cd@redhat.com> (raw)
kmalloc is unreliable when allocating more than 8 pages of memory. It may
fail when there is plenty of free memory but the memory is fragmented.
Zdenek Kabelac observed such failure in his tests.
This commit changes kmalloc to kvmalloc - kvmalloc will fall back to
vmalloc if the large allocation fails.
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Cc: stable@vger.kernel.org
---
drivers/md/persistent-data/dm-space-map-metadata.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Index: linux-2.6/drivers/md/persistent-data/dm-space-map-metadata.c
===================================================================
--- linux-2.6.orig/drivers/md/persistent-data/dm-space-map-metadata.c 2024-08-13 13:25:04.000000000 +0200
+++ linux-2.6/drivers/md/persistent-data/dm-space-map-metadata.c 2024-08-13 14:39:08.000000000 +0200
@@ -277,7 +277,7 @@ static void sm_metadata_destroy(struct d
{
struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm);
- kfree(smm);
+ kvfree(smm);
}
static int sm_metadata_get_nr_blocks(struct dm_space_map *sm, dm_block_t *count)
@@ -772,7 +772,7 @@ struct dm_space_map *dm_sm_metadata_init
{
struct sm_metadata *smm;
- smm = kmalloc(sizeof(*smm), GFP_KERNEL);
+ smm = kvmalloc(sizeof(*smm), GFP_KERNEL);
if (!smm)
return ERR_PTR(-ENOMEM);
next reply other threads:[~2024-08-13 14:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-13 14:35 Mikulas Patocka [this message]
2024-08-13 15:24 ` dm persistent data: fix memory allocation failure Mike Snitzer
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=12f6fc8a-a0cb-48c-e792-57f09b62cd@redhat.com \
--to=mpatocka@redhat.com \
--cc=dm-devel@lists.linux.dev \
--cc=snitzer@kernel.org \
--cc=thornber@redhat.com \
--cc=zkabelac@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.