Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp11334106ybi; Thu, 25 Jul 2019 14:26:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqy4zpz98ZbgwlNauKXcc0QUq5epRe302zAJKbeUoNQRhYBO8d0MgbustHuJX4IMsRJSWaPq X-Received: by 2002:aa7:8481:: with SMTP id u1mr17828265pfn.243.1564089972196; Thu, 25 Jul 2019 14:26:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564089972; cv=none; d=google.com; s=arc-20160816; b=SEFdh4LWrUUFw6QyXLTJeDCZMZkHInjv+01LzubIvYux1A9Fuo1iX56HyLsR0pqKWh j6NaS7mixHWsjGNElTAzIOLFITu6QNmUER0YPE5Vq/ifNojyXvcSN1Mar3EMtMzJFmme V3oa+9sxzlkC//Eqj4zTGOWmsxQfqxGZoW7xtm5FaG2I8HOUbHSJQDFs1PYE726duv13 6LpmAurUL02DEjr9sTf94p592sXwNbV8Y0N7iW032B0IrDtzIJToC0pZ+YPY1Yu0K37E OJKaZtp6eX5RKgUZei1M9y1PkbkPGnbJbMJQ4XWcJruPd9ueJbGDzx6MdGl1ZOtWb9np UdzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=0FHLYwXChjiQiSvTSooHeQULBjqit8SM8K4FegGSKjQ=; b=wvakydOKkNkJWWP6MsrabExHiw5dGfksdxMrG+SdFdOglgALYBvckrfYKYtgr0fVAE HI8+XoAeVwypnyiBBZ3QtJh6i4Iu/HUqwh/QMi9GpRxn+/Exc9Wt0KApjds3pup4Xgqu taQrio7J7wQDJp/3EdQWwv3NwqwMufLgrxKcyKPojZjjqDp00UAlqrLx0Bz4sg5Xvslt VIKQhFZ6mnFAGUNIQgUvvZZF2ItaHzsyPf7+CIlKxmi5Y7RoXIt4QZ39dp/O9DoN7LUm 0EeGGrIYRk29RuMEveCwAQ7W9T2TRMlMqtNZvEQKsCRHnVTbGuONaLualN976rF7WuXI XHzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=VJDvALEb; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n6si17332253pgp.424.2019.07.25.14.25.53; Thu, 25 Jul 2019 14:26:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=VJDvALEb; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726803AbfGYVZq (ORCPT + 99 others); Thu, 25 Jul 2019 17:25:46 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:54622 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726674AbfGYVZq (ORCPT ); Thu, 25 Jul 2019 17:25:46 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x6PLNQux028419; Thu, 25 Jul 2019 21:25:24 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2018-07-02; bh=0FHLYwXChjiQiSvTSooHeQULBjqit8SM8K4FegGSKjQ=; b=VJDvALEbh2WRLgJ51/lOw+GuVaIChEtBFMVzz7/5m656+BbbSE1Pp93KOvuF/C9ekWGj dRTl9WLuZV5CDpXGZPAIvVQIanEfDbADCQtquO4r6a4kijH7FHN4mdsfHRNdAcmN/SyY iAUdHLkgTOLPp+dw7pcsoqLcqDtM8HW1m5AK0hPrktlIXx9cJb9gb+XHAvJ9XOnlNETz x98DDCPF+9KKnhwoM6sFxrZjjhTiQPMXXVexeW1kesJ3oiq3Y2mbg/791zkvye+8vGye JXMNb8mz+FngZZpNyO5x0kK4FUZuuSHC9HGxI6HJwXTpSFJ5jrj37e00K8NGyhu4T7bn dg== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 2tx61c6mev-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 25 Jul 2019 21:25:24 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x6PLNIT3066990; Thu, 25 Jul 2019 21:25:24 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 2tx60yj90c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 25 Jul 2019 21:25:24 +0000 Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x6PLPKx1030875; Thu, 25 Jul 2019 21:25:22 GMT Received: from localhost.localdomain (/73.60.114.248) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 25 Jul 2019 14:25:19 -0700 From: Daniel Jordan To: Steffen Klassert , Herbert Xu Cc: Tejun Heo , Lai Jiangshan , Peter Zijlstra , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, Daniel Jordan Subject: [RFC 3/9] workqueue: require CPU hotplug read exclusion for apply_workqueue_attrs Date: Thu, 25 Jul 2019 17:24:59 -0400 Message-Id: <20190725212505.15055-4-daniel.m.jordan@oracle.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190725212505.15055-1-daniel.m.jordan@oracle.com> References: <20190725212505.15055-1-daniel.m.jordan@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9329 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=914 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1907250257 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9329 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=956 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1907250257 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Change the calling convention for apply_workqueue_attrs to require CPU hotplug read exclusion. Avoids lockdep complaints about nested calls to get_online_cpus in a future patch where padata calls apply_workqueue_attrs when changing other CPU-hotplug-sensitive data structures with the CPU read lock already held. Signed-off-by: Daniel Jordan --- kernel/workqueue.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index f53705ff3ff1..bc2e09a8ea61 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -4030,6 +4030,8 @@ static int apply_workqueue_attrs_locked(struct workqueue_struct *wq, * * Performs GFP_KERNEL allocations. * + * Assumes caller has CPU hotplug read exclusion, i.e. get_online_cpus(). + * * Return: 0 on success and -errno on failure. */ int apply_workqueue_attrs(struct workqueue_struct *wq, @@ -4037,9 +4039,11 @@ int apply_workqueue_attrs(struct workqueue_struct *wq, { int ret; - apply_wqattrs_lock(); + lockdep_assert_cpus_held(); + + mutex_lock(&wq_pool_mutex); ret = apply_workqueue_attrs_locked(wq, attrs); - apply_wqattrs_unlock(); + mutex_unlock(&wq_pool_mutex); return ret; } @@ -4152,16 +4156,21 @@ static int alloc_and_link_pwqs(struct workqueue_struct *wq) mutex_unlock(&wq->mutex); } return 0; - } else if (wq->flags & __WQ_ORDERED) { + } + + get_online_cpus(); + if (wq->flags & __WQ_ORDERED) { ret = apply_workqueue_attrs(wq, ordered_wq_attrs[highpri]); /* there should only be single pwq for ordering guarantee */ WARN(!ret && (wq->pwqs.next != &wq->dfl_pwq->pwqs_node || wq->pwqs.prev != &wq->dfl_pwq->pwqs_node), "ordering guarantee broken for workqueue %s\n", wq->name); - return ret; } else { - return apply_workqueue_attrs(wq, unbound_std_wq_attrs[highpri]); + ret = apply_workqueue_attrs(wq, unbound_std_wq_attrs[highpri]); } + put_online_cpus(); + + return ret; } static int wq_clamp_max_active(int max_active, unsigned int flags, -- 2.22.0