All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dm persistent data: fix memory allocation failure
@ 2024-08-13 14:35 Mikulas Patocka
  2024-08-13 15:24 ` Mike Snitzer
  0 siblings, 1 reply; 2+ messages in thread
From: Mikulas Patocka @ 2024-08-13 14:35 UTC (permalink / raw)
  To: Joe Thornber, Zdenek Kabelac; +Cc: dm-devel, Mike Snitzer

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);
 


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: dm persistent data: fix memory allocation failure
  2024-08-13 14:35 [PATCH] dm persistent data: fix memory allocation failure Mikulas Patocka
@ 2024-08-13 15:24 ` Mike Snitzer
  0 siblings, 0 replies; 2+ messages in thread
From: Mike Snitzer @ 2024-08-13 15:24 UTC (permalink / raw)
  To: Mikulas Patocka; +Cc: Joe Thornber, Zdenek Kabelac, dm-devel

On Tue, Aug 13, 2024 at 04:35:14PM +0200, Mikulas Patocka wrote:
> 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.

Should add this tag here:
Reported-by: Zdenek Kabelac <zkabelac@redhat.com>
 
> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
> Cc: stable@vger.kernel.org

Reviewed-by: Mike Snitzer <snitzer@kernel.org>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-08-13 15:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-13 14:35 [PATCH] dm persistent data: fix memory allocation failure Mikulas Patocka
2024-08-13 15:24 ` Mike Snitzer

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.