From patchwork Fri Mar 14 18:17:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hilman X-Patchwork-Id: 26278 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f70.google.com (mail-oa0-f70.google.com [209.85.219.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2114A202DD for ; Fri, 14 Mar 2014 18:17:49 +0000 (UTC) Received: by mail-oa0-f70.google.com with SMTP id n16sf11041142oag.1 for ; Fri, 14 Mar 2014 11:17:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version:sender:precedence :list-id:x-original-sender:x-original-authentication-results :mailing-list:list-post:list-help:list-archive:list-unsubscribe :content-type; bh=U+u19ZWdtuDy9zLApQugTQQuVtSd9kRdObXlaPqpZro=; b=a7m7UGEMmQfGDrceF0oahzYF5ZtTn8zebci0FK1eaHjXFztphpVd3MTNsmF8/LxRCY r62ZsjKcGsv9NRsAy62BFbKcsFJYJNvXReSKdzZAfKh07c1/Uwkfvznq7aoTRJ+5VEQO gr5L9KfdlYJxf74VsCfG4lubiahzuMrGnuqeJkfsITzeM6p5hPTxtHTAW9v9U/MJTVzG iMPZT7iUqEI8SqR4f0nV803/eOdmzZ9b9QXwDPcTvcKqoMSGSnW04qCk8GYN+2H6wIMn xPRAZz5ANzYuKKttfMMlJcB4oLTls/R3hqN6lGbrmgGT6tcsCR4QuqbacHoI1ZtLvBuJ 3ezA== X-Gm-Message-State: ALoCoQnxmwnFYcUTmyv+lnCVRr07m0DNpDBa/LqgznmxSf47tAVTJt/b2TyudVWiySM92uoBSWMH X-Received: by 10.182.34.169 with SMTP id a9mr3650370obj.49.1394821068642; Fri, 14 Mar 2014 11:17:48 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.83.85 with SMTP id i79ls821796qgd.21.gmail; Fri, 14 Mar 2014 11:17:48 -0700 (PDT) X-Received: by 10.52.15.132 with SMTP id x4mr1804413vdc.31.1394821068533; Fri, 14 Mar 2014 11:17:48 -0700 (PDT) Received: from mail-ve0-f178.google.com (mail-ve0-f178.google.com [209.85.128.178]) by mx.google.com with ESMTPS id x7si768534vel.162.2014.03.14.11.17.48 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 14 Mar 2014 11:17:48 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.178 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.178; Received: by mail-ve0-f178.google.com with SMTP id jw12so3210941veb.9 for ; Fri, 14 Mar 2014 11:17:48 -0700 (PDT) X-Received: by 10.52.37.161 with SMTP id z1mr1826515vdj.29.1394821068408; Fri, 14 Mar 2014 11:17:48 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.78.9 with SMTP id i9csp41778vck; Fri, 14 Mar 2014 11:17:47 -0700 (PDT) X-Received: by 10.66.231.104 with SMTP id tf8mr10689793pac.48.1394821067560; Fri, 14 Mar 2014 11:17:47 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id mt5si4945812pbb.126.2014.03.14.11.17.46; Fri, 14 Mar 2014 11:17:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755003AbaCNSRi (ORCPT + 26 others); Fri, 14 Mar 2014 14:17:38 -0400 Received: from mail-pb0-f44.google.com ([209.85.160.44]:55252 "EHLO mail-pb0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751946AbaCNSRh (ORCPT ); Fri, 14 Mar 2014 14:17:37 -0400 Received: by mail-pb0-f44.google.com with SMTP id rp16so2967967pbb.3 for ; Fri, 14 Mar 2014 11:17:37 -0700 (PDT) X-Received: by 10.68.249.100 with SMTP id yt4mr4712526pbc.165.1394821057201; Fri, 14 Mar 2014 11:17:37 -0700 (PDT) Received: from localhost (c-24-19-7-36.hsd1.wa.comcast.net. [24.19.7.36]) by mx.google.com with ESMTPSA id id10sm18757020pbc.35.2014.03.14.11.17.36 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 14 Mar 2014 11:17:36 -0700 (PDT) From: Kevin Hilman To: Frederic Weisbecker Cc: LKML , Christoph Lameter , Mike Galbraith , "Paul E. McKenney" , Tejun Heo , Viresh Kumar Subject: Re: [PATCH 2/3] workqueues: Account unbound workqueue in a seperate list References: <1394815131-17271-1-git-send-email-fweisbec@gmail.com> <1394815131-17271-3-git-send-email-fweisbec@gmail.com> Date: Fri, 14 Mar 2014 11:17:35 -0700 In-Reply-To: <1394815131-17271-3-git-send-email-fweisbec@gmail.com> (Frederic Weisbecker's message of "Fri, 14 Mar 2014 17:38:50 +0100") Message-ID: <7hob18ir0g.fsf@paris.lan> User-Agent: Gnus/5.130008 (Ma Gnus v0.8) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: khilman@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.178 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Frederic Weisbecker writes: > The workqueues are all listed in a global list protected by a big mutex. > And this big mutex is used in apply_workqueue_attrs() as well. > > Now as we plan to implement a directory to control the cpumask of > all non-ABI unbound workqueues, we want to be able to iterate over all > unbound workqueues and call apply_workqueue_attrs() for each of > them with the new cpumask. > > But the risk for a deadlock is on the way: we need to iterate the list > of workqueues under wq_pool_mutex. But then apply_workqueue_attrs() > itself calls wq_pool_mutex. > > The easiest solution to work around this is to keep track of unbound > workqueues in a separate list with a separate mutex. > > It's not very pretty unfortunately. > > Cc: Christoph Lameter > Cc: Kevin Hilman > Cc: Mike Galbraith > Cc: Paul E. McKenney > Cc: Tejun Heo > Cc: Viresh Kumar > Not-Signed-off-by: Frederic Weisbecker > --- > kernel/workqueue.c | 15 +++++++++++++++ > 1 file changed, 15 insertions(+) > > diff --git a/kernel/workqueue.c b/kernel/workqueue.c > index 4d230e3..ad8f727 100644 > --- a/kernel/workqueue.c > +++ b/kernel/workqueue.c > @@ -232,6 +232,7 @@ struct wq_device; > struct workqueue_struct { > struct list_head pwqs; /* WR: all pwqs of this wq */ > struct list_head list; /* PL: list of all workqueues */ > + struct list_head unbound_list; /* PL: list of unbound workqueues */ > > struct mutex mutex; /* protects this wq */ > int work_color; /* WQ: current work color */ > @@ -288,9 +289,11 @@ static bool wq_numa_enabled; /* unbound NUMA affinity enabled */ > static struct workqueue_attrs *wq_update_unbound_numa_attrs_buf; > > static DEFINE_MUTEX(wq_pool_mutex); /* protects pools and workqueues list */ > +static DEFINE_MUTEX(wq_unbound_mutex); /* protects list of unbound workqueues */ > static DEFINE_SPINLOCK(wq_mayday_lock); /* protects wq->maydays list */ > > static LIST_HEAD(workqueues); /* PL: list of all workqueues */ > +static LIST_HEAD(workqueues_unbound); /* PL: list of unbound workqueues */ > static bool workqueue_freezing; /* PL: have wqs started freezing? */ > > /* the per-cpu worker pools */ > @@ -4263,6 +4266,12 @@ struct workqueue_struct *__alloc_workqueue_key(const char *fmt, > > mutex_unlock(&wq_pool_mutex); > > + if (wq->flags & WQ_UNBOUND) { > + mutex_lock(&wq_unbound_mutex); > + list_add(&wq->unbound_list, &workqueues_unbound); > + mutex_unlock(&wq_unbound_mutex); > + } > + > return wq; > > err_free_wq: > @@ -4318,6 +4327,12 @@ void destroy_workqueue(struct workqueue_struct *wq) > list_del_init(&wq->list); > mutex_unlock(&wq_pool_mutex); > > + if (wq->flags & WQ_UNBOUND) { > + mutex_lock(&wq_unbound_mutex); > + list_del(&wq->unbound_list); > + mutex_unlock(&wq_unbound_mutex); > + } > + > workqueue_sysfs_unregister(wq); > > if (wq->rescuer) { Looks good, except for minor nit: I think you're missing an init of the new list: goto err_free_wq; Kevin --- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ diff --git a/kernel/workqueue.c b/kernel/workqueue.c index cc708f23d801..a01592f08321 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -4309,6 +4309,7 @@ struct workqueue_struct *__alloc_workqueue_key(const char *fmt, lockdep_init_map(&wq->lockdep_map, lock_name, key, 0); INIT_LIST_HEAD(&wq->list); + INIT_LIST_HEAD(&wq->unbound_list); if (alloc_and_link_pwqs(wq) < 0)