All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] null_blk: Fix: memory release when memory_backed=1
       [not found] <CGME20230605062713epcas5p15f43412fdef92c01567dd9c59a931d9b@epcas5p1.samsung.com>
@ 2023-06-05  6:23 ` Nitesh Shetty
  2023-06-05 22:15   ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Nitesh Shetty @ 2023-06-05  6:23 UTC (permalink / raw)
  To: Jens Axboe; +Cc: gost.dev, Nitesh Shetty, Anuj Gupta, linux-block, linux-kernel

Memory/pages are not freed, when unloading nullblk driver.

Steps to reproduce issue
  1.free -h
        total        used        free      shared  buff/cache   available
Mem:    7.8Gi       260Mi       7.1Gi       3.0Mi       395Mi       7.3Gi
Swap:      0B          0B          0B
  2.modprobe null_blk memory_backed=1
  3.dd if=/dev/urandom of=/dev/nullb0 oflag=direct bs=1M count=1000
  4.modprobe -r null_blk
  5.free -h
        total        used        free      shared  buff/cache   available
Mem:    7.8Gi       1.2Gi       6.1Gi       3.0Mi       398Mi       6.3Gi
Swap:      0B          0B          0B

Signed-off-by: Anuj Gupta <anuj20.g@samsung.com>
Signed-off-by: Nitesh Shetty <nj.shetty@samsung.com>
---

Added a blktest[1] block/034 to test the same issue.
We will raise a PR, if issue is acked and fix is pulled in kernel.

[1] https://github.com/nitesh-shetty/blktests/tree/fix/block/mem_leak
---
 drivers/block/null_blk/main.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/block/null_blk/main.c b/drivers/block/null_blk/main.c
index b3fedafe301e..864013019d6b 100644
--- a/drivers/block/null_blk/main.c
+++ b/drivers/block/null_blk/main.c
@@ -2244,6 +2244,7 @@ static void null_destroy_dev(struct nullb *nullb)
 	struct nullb_device *dev = nullb->dev;
 
 	null_del_dev(nullb);
+	null_free_device_storage(dev, false);
 	null_free_dev(dev);
 }
 

base-commit: bc708bbd8260ee4eb3428b0109f5f3be661fae46
-- 
2.35.1.500.gb896f729e2


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

* Re: [PATCH] null_blk: Fix: memory release when memory_backed=1
  2023-06-05  6:23 ` [PATCH] null_blk: Fix: memory release when memory_backed=1 Nitesh Shetty
@ 2023-06-05 22:15   ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2023-06-05 22:15 UTC (permalink / raw)
  To: Nitesh Shetty; +Cc: gost.dev, Anuj Gupta, linux-block, linux-kernel


On Mon, 05 Jun 2023 11:53:53 +0530, Nitesh Shetty wrote:
> Memory/pages are not freed, when unloading nullblk driver.
> 
> Steps to reproduce issue
>   1.free -h
>         total        used        free      shared  buff/cache   available
> Mem:    7.8Gi       260Mi       7.1Gi       3.0Mi       395Mi       7.3Gi
> Swap:      0B          0B          0B
>   2.modprobe null_blk memory_backed=1
>   3.dd if=/dev/urandom of=/dev/nullb0 oflag=direct bs=1M count=1000
>   4.modprobe -r null_blk
>   5.free -h
>         total        used        free      shared  buff/cache   available
> Mem:    7.8Gi       1.2Gi       6.1Gi       3.0Mi       398Mi       6.3Gi
> Swap:      0B          0B          0B
> 
> [...]

Applied, thanks!

[1/1] null_blk: Fix: memory release when memory_backed=1
      commit: 8cfb98196cceec35416041c6b91212d2b99392e4

Best regards,
-- 
Jens Axboe




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

end of thread, other threads:[~2023-06-05 22:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20230605062713epcas5p15f43412fdef92c01567dd9c59a931d9b@epcas5p1.samsung.com>
2023-06-05  6:23 ` [PATCH] null_blk: Fix: memory release when memory_backed=1 Nitesh Shetty
2023-06-05 22:15   ` Jens Axboe

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.