From 9fa043c8e1549a9b456ffedf7eadcea72e0dc4c5 Mon Sep 17 00:00:00 2001 From: Bret Lambert Date: Wed, 8 Oct 2014 15:28:40 +0000 Subject: make workq/taskq runner threads yield when they've hogged the cpu ok deraadt@ dlg@ phessler@ --- sys/kern/kern_task.c | 6 ++++-- sys/kern/kern_workq.c | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'sys/kern') diff --git a/sys/kern/kern_task.c b/sys/kern/kern_task.c index b685ce888e2..39f17370b32 100644 --- a/sys/kern/kern_task.c +++ b/sys/kern/kern_task.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_task.c,v 1.10 2014/07/12 18:43:32 tedu Exp $ */ +/* $OpenBSD: kern_task.c,v 1.11 2014/10/08 15:28:39 blambert Exp $ */ /* * Copyright (c) 2013 David Gwynne @@ -261,8 +261,10 @@ taskq_thread(void *xtq) if (tq->tq_unlocked) KERNEL_UNLOCK(); - while (taskq_next_work(tq, &work)) + while (taskq_next_work(tq, &work)) { (*work.t_func)(work.t_arg1, work.t_arg2); + sched_pause(); + } mtx_enter(&tq->tq_mtx); last = (--tq->tq_running == 0); diff --git a/sys/kern/kern_workq.c b/sys/kern/kern_workq.c index a019620ab1c..9aabaf7249e 100644 --- a/sys/kern/kern_workq.c +++ b/sys/kern/kern_workq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_workq.c,v 1.15 2014/07/12 18:43:32 tedu Exp $ */ +/* $OpenBSD: kern_workq.c,v 1.16 2014/10/08 15:28:39 blambert Exp $ */ /* * Copyright (c) 2007 David Gwynne @@ -236,6 +236,7 @@ workq_thread(void *arg) wqt->wqt_func(wqt->wqt_arg1, wqt->wqt_arg2); if (mypool) pool_put(&workq_task_pool, wqt); + sched_pause(); } kthread_exit(0); -- cgit v1.2.3