Skip to content

Commit 5ed964f

Browse files
Christoph Hellwigaxboe
authored andcommitted
mm: hide laptop_mode_wb_timer entirely behind the BDI API
Don't leak the detaіls of the timer into the block layer, instead initialize the timer in bdi_alloc and delete it in bdi_unregister. Note that this means the timer is initialized (but not armed) for non-block queues as well now. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Jan Kara <[email protected]> Reviewed-by: Johannes Thumshirn <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent d1254a8 commit 5ed964f

File tree

3 files changed

+3
-7
lines changed

3 files changed

+3
-7
lines changed

block/blk-core.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -394,10 +394,7 @@ void blk_cleanup_queue(struct request_queue *q)
394394
/* for synchronous bio-based driver finish in-flight integrity i/o */
395395
blk_flush_integrity();
396396

397-
/* @q won't process any more request, flush async actions */
398-
del_timer_sync(&q->backing_dev_info->laptop_mode_wb_timer);
399397
blk_sync_queue(q);
400-
401398
if (queue_is_mq(q))
402399
blk_mq_exit_queue(q);
403400

@@ -546,8 +543,6 @@ struct request_queue *blk_alloc_queue(int node_id)
546543

547544
atomic_set(&q->nr_active_requests_shared_sbitmap, 0);
548545

549-
timer_setup(&q->backing_dev_info->laptop_mode_wb_timer,
550-
laptop_mode_timer_fn, 0);
551546
timer_setup(&q->timeout, blk_rq_timed_out_timer, 0);
552547
INIT_WORK(&q->timeout_work, blk_timeout_work);
553548
INIT_LIST_HEAD(&q->icq_list);

mm/backing-dev.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,7 @@ struct backing_dev_info *bdi_alloc(int node_id)
807807
bdi->capabilities = BDI_CAP_WRITEBACK | BDI_CAP_WRITEBACK_ACCT;
808808
bdi->ra_pages = VM_READAHEAD_PAGES;
809809
bdi->io_pages = VM_READAHEAD_PAGES;
810+
timer_setup(&bdi->laptop_mode_wb_timer, laptop_mode_timer_fn, 0);
810811
return bdi;
811812
}
812813
EXPORT_SYMBOL(bdi_alloc);
@@ -928,6 +929,8 @@ static void bdi_remove_from_list(struct backing_dev_info *bdi)
928929

929930
void bdi_unregister(struct backing_dev_info *bdi)
930931
{
932+
del_timer_sync(&bdi->laptop_mode_wb_timer);
933+
931934
/* make sure nobody finds us on the bdi_list anymore */
932935
bdi_remove_from_list(bdi);
933936
wb_shutdown(&bdi->wb);

mm/page-writeback.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2010,7 +2010,6 @@ int dirty_writeback_centisecs_handler(struct ctl_table *table, int write,
20102010
return ret;
20112011
}
20122012

2013-
#ifdef CONFIG_BLOCK
20142013
void laptop_mode_timer_fn(struct timer_list *t)
20152014
{
20162015
struct backing_dev_info *backing_dev_info =
@@ -2045,7 +2044,6 @@ void laptop_sync_completion(void)
20452044

20462045
rcu_read_unlock();
20472046
}
2048-
#endif
20492047

20502048
/*
20512049
* If ratelimit_pages is too high then we can get into dirty-data overload

0 commit comments

Comments
 (0)