Skip to content

Commit af8ce93

Browse files
Cao GuanghuiMikulas Patocka
authored andcommitted
dm cache: make smq background work limit configurable
The maximum number of concurrent background work items (promotions, demotions, writebacks) in the SMQ policy was hardcoded to 4096, with a FIXME comment noting it should be made configurable. This value was originally tuned down from 10240 to balance memory overhead (~128 bytes per entry, ~512KB at 4096 entries) against I/O parallelism. However, different workloads and cache sizes may benefit from different limits: - Write-heavy workloads may need more writeback concurrency - Very large caches (10+ TB) may need more promotion slots - Memory-constrained systems may want a lower limit Make this configurable via the module parameter "smq_max_background_work" (defaulting to 4096 to preserve existing behaviour). Clamp the value to at least 1 to prevent setting 0, which would block all background work. The parameter only affects newly created cache devices; existing caches retain their value from creation time. Signed-off-by: Cao Guanghui <caoguanghui@kylinos.cn> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
1 parent f9f5797 commit af8ce93

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

drivers/md/dm-cache-policy-smq.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@
2121

2222
/*----------------------------------------------------------------*/
2323

24+
/*
25+
* Maximum number of concurrent background work items (promotions,
26+
* demotions, writebacks) that can be queued in the background tracker.
27+
* Tuneable via the module parameter smq_max_background_work.
28+
* Only affects newly created cache devices.
29+
*/
30+
static unsigned int smq_max_background_work = 4096;
31+
module_param(smq_max_background_work, uint, 0644);
32+
MODULE_PARM_DESC(smq_max_background_work, "Max concurrent background work items");
33+
2434
/*
2535
* Safe division functions that return zero on divide by zero.
2636
*/
@@ -1816,7 +1826,7 @@ __smq_create(dm_cblock_t cache_size, sector_t origin_size, sector_t cache_block_
18161826
mq->next_hotspot_period = jiffies;
18171827
mq->next_cache_period = jiffies;
18181828

1819-
mq->bg_work = btracker_create(4096); /* FIXME: hard coded value */
1829+
mq->bg_work = btracker_create(max(1u, smq_max_background_work));
18201830
if (!mq->bg_work)
18211831
goto bad_btracker;
18221832

0 commit comments

Comments
 (0)