From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752640AbXJWTX4 (ORCPT ); Tue, 23 Oct 2007 15:23:56 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752497AbXJWTXr (ORCPT ); Tue, 23 Oct 2007 15:23:47 -0400 Received: from pentafluge.infradead.org ([213.146.154.40]:37718 "EHLO pentafluge.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752206AbXJWTXq (ORCPT ); Tue, 23 Oct 2007 15:23:46 -0400 Subject: [RFC/PATCH 7/5] rt: PI-workqueue: propagate prio for delayed work From: Peter Zijlstra To: linux-kernel@vger.kernel.org Cc: Daniel Walker , Steven Rostedt , Ingo Molnar , Thomas Gleixner , Gregory Haskins , Oleg Nesterov In-Reply-To: <20071023120357.782284000@chello.nl> References: <20071023120357.782284000@chello.nl> Content-Type: text/plain Date: Tue, 23 Oct 2007 21:22:26 +0200 Message-Id: <1193167347.5648.24.camel@lappy> Mime-Version: 1.0 X-Mailer: Evolution 2.12.0 Content-Transfer-Encoding: 7bit X-Bad-Reply: References and In-Reply-To but no 'Re:' in Subject. Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Subject: rt: PI-workqueue: propagate prio for delayed work Delayed work looses its enqueue priority, and will be enqueued on the prio of the softirq thread. Ammend this. Signed-off-by: Peter Zijlstra --- include/linux/workqueue.h | 1 + kernel/workqueue.c | 16 ++++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) Index: linux-2.6/include/linux/workqueue.h =================================================================== --- linux-2.6.orig/include/linux/workqueue.h +++ linux-2.6/include/linux/workqueue.h @@ -36,6 +36,7 @@ struct work_struct { struct delayed_work { struct work_struct work; struct timer_list timer; + int prio; }; struct execute_work { Index: linux-2.6/kernel/workqueue.c =================================================================== --- linux-2.6.orig/kernel/workqueue.c +++ linux-2.6/kernel/workqueue.c @@ -149,12 +149,12 @@ static void insert_work(struct cpu_workq /* Preempt must be disabled. */ static void __queue_work(struct cpu_workqueue_struct *cwq, - struct work_struct *work) + struct work_struct *work, int prio) { unsigned long flags; spin_lock_irqsave(&cwq->lock, flags); - insert_work(cwq, work, current->normal_prio, current->normal_prio); + insert_work(cwq, work, prio, prio); spin_unlock_irqrestore(&cwq->lock, flags); } @@ -176,7 +176,7 @@ int fastcall queue_work(struct workqueue if (!test_and_set_bit(WORK_STRUCT_PENDING, work_data_bits(work))) { BUG_ON(!plist_node_empty(&work->entry)); - __queue_work(wq_per_cpu(wq, cpu), work); + __queue_work(wq_per_cpu(wq, cpu), work, current->normal_prio); ret = 1; } return ret; @@ -189,7 +189,8 @@ void delayed_work_timer_fn(unsigned long struct cpu_workqueue_struct *cwq = get_wq_data(&dwork->work); struct workqueue_struct *wq = cwq->wq; - __queue_work(wq_per_cpu(wq, raw_smp_processor_id()), &dwork->work); + __queue_work(wq_per_cpu(wq, raw_smp_processor_id()), + &dwork->work, dwork->prio); } /** @@ -232,6 +233,7 @@ int queue_delayed_work_on(int cpu, struc BUG_ON(!plist_node_empty(&work->entry)); /* This stores cwq for the moment, for the timer_fn */ + dwork->prio = current->normal_prio; set_wq_data(work, wq_per_cpu(wq, raw_smp_processor_id())); timer->expires = jiffies + delay; timer->data = (unsigned long)dwork; @@ -702,7 +704,8 @@ int schedule_on_each_cpu(void (*func)(vo work->info = info; INIT_WORK(&work->work, schedule_on_each_cpu_func); set_bit(WORK_STRUCT_PENDING, work_data_bits(&work->work)); - __queue_work(per_cpu_ptr(keventd_wq->cpu_wq, cpu), &work->work); + __queue_work(per_cpu_ptr(keventd_wq->cpu_wq, cpu), + &work->work, current->normal_prio); } unlock_cpu_hotplug(); @@ -749,7 +752,8 @@ int schedule_on_each_cpu_wq(struct workq INIT_WORK(work, func); set_bit(WORK_STRUCT_PENDING, work_data_bits(work)); - __queue_work(per_cpu_ptr(wq->cpu_wq, cpu), work); + __queue_work(per_cpu_ptr(wq->cpu_wq, cpu), work, + current->normal_prio); } flush_workqueue(wq); free_percpu(works);