Commit f7c9c6bb authored by Anton Blanchard's avatar Anton Blanchard Committed by James Bottomley

[SCSI] Fix block queue and elevator memory leak in scsi_alloc_sdev

When looking at memory consumption issues I noticed quite a
lot of memory in the kmalloc-2048 bucket:

  OBJS ACTIVE  USE OBJ SIZE  SLABS OBJ/SLAB CACHE SIZE NAME
  6561   6471  98%    2.30K    243       27     15552K kmalloc-2048

Over 15MB. slub debug shows that cfq is responsible for almost
all of it:

# sort -nr /sys/kernel/slab/kmalloc-2048/alloc_calls
6402 .cfq_init_queue+0xec/0x460 age=43423/43564/43655 pid=1 cpus=4,11,13

In scsi_alloc_sdev we do scsi_alloc_queue but if slave_alloc
fails we don't free it with scsi_free_queue.

The patch below fixes the issue:

  OBJS ACTIVE  USE OBJ SIZE  SLABS OBJ/SLAB CACHE SIZE NAME
   135     72  53%    2.30K      5       27       320K kmalloc-2048

# cat /sys/kernel/slab/kmalloc-2048/alloc_calls
3 .cfq_init_queue+0xec/0x460 age=3811/3876/3925 pid=1 cpus=4,11,13
Signed-off-by: default avatarAnton Blanchard <anton@samba.org>
Cc: <stable@kernel.org>		#2.6.38+
Signed-off-by: default avatarJames Bottomley <JBottomley@Parallels.com>
parent ab72002b
...@@ -322,6 +322,7 @@ static struct scsi_device *scsi_alloc_sdev(struct scsi_target *starget, ...@@ -322,6 +322,7 @@ static struct scsi_device *scsi_alloc_sdev(struct scsi_target *starget,
scsi_device_set_state(sdev, SDEV_DEL); scsi_device_set_state(sdev, SDEV_DEL);
transport_destroy_device(&sdev->sdev_gendev); transport_destroy_device(&sdev->sdev_gendev);
put_device(&sdev->sdev_dev); put_device(&sdev->sdev_dev);
scsi_free_queue(sdev->request_queue);
put_device(&sdev->sdev_gendev); put_device(&sdev->sdev_gendev);
out: out:
if (display_failure_msg) if (display_failure_msg)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment