Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions include/linux/blkdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -1222,16 +1222,12 @@ static inline void blk_flush_plug(struct blk_plug *plug, bool async)
__blk_flush_plug(plug, async);
}

/*
* tsk == current here
*/
static inline void blk_plug_invalidate_ts(struct task_struct *tsk)
static __always_inline void blk_plug_invalidate_ts(void)
{
struct blk_plug *plug = tsk->plug;

if (plug)
plug->cur_ktime = 0;
current->flags &= ~PF_BLOCK_TS;
if (unlikely(current->flags & PF_BLOCK_TS)) {
current->plug->cur_ktime = 0;
current->flags &= ~PF_BLOCK_TS;
}
}

int blkdev_issue_flush(struct block_device *bdev);
Expand All @@ -1257,7 +1253,7 @@ static inline void blk_flush_plug(struct blk_plug *plug, bool async)
{
}

static inline void blk_plug_invalidate_ts(struct task_struct *tsk)
static inline void blk_plug_invalidate_ts(void)
{
}

Expand Down
1 change: 1 addition & 0 deletions kernel/fork.c
Original file line number Diff line number Diff line change
Expand Up @@ -2338,6 +2338,7 @@ __latent_entropy struct task_struct *copy_process(

#ifdef CONFIG_BLOCK
p->plug = NULL;
p->flags &= ~PF_BLOCK_TS;
#endif
futex_init_task(p);

Expand Down
12 changes: 8 additions & 4 deletions kernel/sched/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -5368,6 +5368,12 @@ static struct rq *finish_task_switch(struct task_struct *prev)
*/
kmap_local_sched_in();

/*
* Any cached block-layer timestamp (plug->cur_ktime) is stale now,
* invalidate it.
*/
blk_plug_invalidate_ts();

fire_sched_in_preempt_notifiers(current);
/*
* When switching through a kernel thread, the loop in
Expand Down Expand Up @@ -7290,12 +7296,10 @@ static inline void sched_submit_work(struct task_struct *tsk)

static void sched_update_worker(struct task_struct *tsk)
{
if (tsk->flags & (PF_WQ_WORKER | PF_IO_WORKER | PF_BLOCK_TS)) {
if (tsk->flags & PF_BLOCK_TS)
blk_plug_invalidate_ts(tsk);
if (tsk->flags & (PF_WQ_WORKER | PF_IO_WORKER)) {
if (tsk->flags & PF_WQ_WORKER)
wq_worker_running(tsk);
else if (tsk->flags & PF_IO_WORKER)
else
io_wq_worker_running(tsk);
}
}
Expand Down
Loading