linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/6] Fix potential kernel panic when increase hardware queue
@ 2020-04-28 13:25 Weiping Zhang
  2020-04-28 13:29 ` [RESEND PATCH " Weiping Zhang
  0 siblings, 1 reply; 2+ messages in thread
From: Weiping Zhang @ 2020-04-28 13:25 UTC (permalink / raw)
  To: axboe, tom.leiming, bvanassche; +Cc: linux-block

Hi,

This series do some improvement base on V2, and also fix two memleaks.
And V2 import a regression for blktest/block/test/029, this test case
will increase and decrease hardware queue count quickly.


Memleak 1:

__blk_mq_alloc_rq_maps
	__blk_mq_alloc_rq_map

if fail
	blk_mq_free_rq_map

Actually, __blk_mq_alloc_rq_map alloc both map and request, here
also need free request.

Memleak 2:
When driver decrease hardware queue, set->nr_hw_queues will be changed
firstly in blk_mq_realloc_tag_set_tags or __blk_mq_update_nr_hw_queues,
then blk_mq_realloc_hw_ctxs and blk_mq_map_swqueue, even
blk_mq_free_tag_set have no chance to free these hardware queue resource,
because they iterate hardware queue by
for (i = 0; i < set->nr_hw_queues; i++).

Patch1: fix Memleak 1.
Patch2: fix prev_nr_hw_queues issue, need be saved before change.
Patch3: refactor __blk_mq_alloc_rq_maps and fix Memleak 2.
Patch4: fix potential kernel panic when increase hardware queue.
Patch5~6: rename two function, because these two function alloc both
map and request, and keep in pair with blk_mq_free_map_and_request(s).

Changes since V3:
* record patchset, fix issue fistly then rename.
* rename function to blk_mq_alloc_map_and_request

Changes since V2:
 * rename some functions name and fix memleak when free map and requests
 * Not free new allocated map and request, they will be relased when tagset gone

Changes since V1:
 * Add fix for potential kernel panic when increase hardware queue

Weiping Zhang (6):
  block: free both rq_map and request
  block: save previous hardware queue count before udpate
  block: refactor __blk_mq_alloc_rq_maps
  block: alloc map and request for new hardware queue
  block: rename __blk_mq_alloc_rq_map
  block: rename blk_mq_alloc_rq_maps

 block/blk-mq.c         | 47 +++++++++++++++++++++++++++++-------------
 include/linux/blk-mq.h |  1 +
 2 files changed, 34 insertions(+), 14 deletions(-)

-- 
2.18.1


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

* [RESEND PATCH v4 0/6] Fix potential kernel panic when increase hardware queue
  2020-04-28 13:25 [PATCH v4 0/6] Fix potential kernel panic when increase hardware queue Weiping Zhang
@ 2020-04-28 13:29 ` Weiping Zhang
  0 siblings, 0 replies; 2+ messages in thread
From: Weiping Zhang @ 2020-04-28 13:29 UTC (permalink / raw)
  To: axboe, tom.leiming, bvanassche; +Cc: linux-block

Hi,

This series do some improvement base on V2, and also fix two memleaks.
And V2 import a regression for blktest/block/test/029, this test case
will increase and decrease hardware queue count quickly.


Memleak 1:

__blk_mq_alloc_rq_maps
	__blk_mq_alloc_rq_map

if fail
	blk_mq_free_rq_map

Actually, __blk_mq_alloc_rq_map alloc both map and request, here
also need free request.

Memleak 2:
When driver decrease hardware queue, set->nr_hw_queues will be changed
firstly in blk_mq_realloc_tag_set_tags or __blk_mq_update_nr_hw_queues,
then blk_mq_realloc_hw_ctxs and blk_mq_map_swqueue, even
blk_mq_free_tag_set have no chance to free these hardware queue resource,
because they iterate hardware queue by
for (i = 0; i < set->nr_hw_queues; i++).

Patch1: fix Memleak 1.
Patch2: fix prev_nr_hw_queues issue, need be saved before change.
Patch3: refactor __blk_mq_alloc_rq_maps and fix Memleak 2.
Patch4: fix potential kernel panic when increase hardware queue.
Patch5~6: rename two function, because these two function alloc both
map and request, and keep in pair with blk_mq_free_map_and_request(s).

Changes since V3:
* record patchset, fix issue fistly then rename.
* rename function to blk_mq_alloc_map_and_request

Changes since V2:
 * rename some functions name and fix memleak when free map and requests
 * Not free new allocated map and request, they will be relased when tagset gone

Changes since V1:
 * Add fix for potential kernel panic when increase hardware queue

Weiping Zhang (6):
  block: free both rq_map and request
  block: save previous hardware queue count before udpate
  block: refactor __blk_mq_alloc_rq_maps
  block: alloc map and request for new hardware queue
  block: rename __blk_mq_alloc_rq_map
  block: rename blk_mq_alloc_rq_maps

 block/blk-mq.c         | 47 +++++++++++++++++++++++++++++-------------
 include/linux/blk-mq.h |  1 +
 2 files changed, 34 insertions(+), 14 deletions(-)

-- 
2.18.1


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

end of thread, other threads:[~2020-04-28 13:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-28 13:25 [PATCH v4 0/6] Fix potential kernel panic when increase hardware queue Weiping Zhang
2020-04-28 13:29 ` [RESEND PATCH " Weiping Zhang

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