Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp3000022rdb; Tue, 26 Dec 2023 12:07:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IG68ib+UyP77ewHnEIEhOdIzqLZqvwk4930nmWAKZfVlEyAWaTdTBRahB+nF04emllH+FyR X-Received: by 2002:a05:6102:390d:b0:467:1794:6442 with SMTP id e13-20020a056102390d00b0046717946442mr814797vsu.33.1703621245274; Tue, 26 Dec 2023 12:07:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703621245; cv=none; d=google.com; s=arc-20160816; b=XJ3vdW1DMOYrnMrbuxcfDqSd02n/STcipTkFd8O22+RsfPIe8zCwZv4p8iYQLpLduj 46LnQwM3cyoytT4gtY+6Uyi0LpQ/Nuj1eZBiJyodEwcRfLlpFNYy1iGhdeNslgPSbjo6 OPpyuWPSQEZ9c3Dz3pUwzpMQZkRsiEPklVOfaHn3+VjWMMMbPxzSIgtctYlzhCHjFSv6 87W32QVCGhXy0e2aEmQ0PcCJCzT1Rx6LqBAcTzAxhC2m6B6ZIJvoVMA8ewhGCggLrdE3 oyZP5PVomHGd/XmbGaIeeOTA/VpXND4BjQXsdIqNAUpz+kmgY+nWeG8dxZ6uxC9iyRB+ EXAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:sender:dkim-signature; bh=GlJrDfGXlC8aDxhiickf9+UJIH5+CIJx7SEuHxHkX6Y=; fh=TXYzuIld3ZUQeXPpec9E/mX9DSWP5fA80EZAZ3xe2Wo=; b=G6RG4R6/j+tIJCSrH5P3lnddRFVMv6Uj5/onEKBjOa9suG2+n7K98+4Et3F3f6nHoD VDFsnn2Udercvb8OTFLswSpp5OoiawLLqis4sj19hMr9JH4SZHrGaolr2CwS0nBxHHNu mWp95nZ08ntldCtRNaQYUNAeRw9y7BtzL8D2yv2gQMAgly6+s/Ic+uB7NwKpwraqD26e m0jW9qR0Autd/YEBbh4jZAzYR/B5NuQN0RlU2XnFSfilbD1m9V4WKAV/go4pRcakj3Za EcCSbNhVZs26bRM8Eaj0OaODaBBhMSv3gbwnbhHuOdUZO2PlMntEcyj60hthnrgaE+NT 2V3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=MlIpRTM9; spf=pass (google.com: domain of linux-kernel+bounces-11677-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-11677-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id s11-20020a056102370b00b00466ff1c52e3si627458vst.554.2023.12.26.12.07.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Dec 2023 12:07:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-11677-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=MlIpRTM9; spf=pass (google.com: domain of linux-kernel+bounces-11677-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-11677-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 050111C2202C for ; Tue, 26 Dec 2023 20:07:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 79C28F4FA; Tue, 26 Dec 2023 20:06:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MlIpRTM9" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 72CDEF4E1 for ; Tue, 26 Dec 2023 20:06:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-1d3aa0321b5so38096965ad.2 for ; Tue, 26 Dec 2023 12:06:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703621213; x=1704226013; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:sender :from:to:cc:subject:date:message-id:reply-to; bh=GlJrDfGXlC8aDxhiickf9+UJIH5+CIJx7SEuHxHkX6Y=; b=MlIpRTM9jmZGMCyktyYxXkTBzXZokbgg6Ar6/o1ZwZ11a7/vK0Lp7tBDF3wEEASS+w DgwT4gDDlAPgnH5hdSVpaI7UZCZOG7I1F4QYFh448W6QmCdKHU/P5bQxfe+enRU8Vufj eQN4jXAUpak96Y1j+OUPqWjm8KiVC2cA2D1PxQBpcSnj/402D/0cYhBNJxuCxumV8kOL Db/lxwTcIcS+2ErD7MMwx+o3EOEiuYAICXn+XCgjUvudNptGca7KFq4HP40asaUU5w0S xjsEMnWVowKfShxpQiDCTxo52f58l1NUXmjnnhLgJ/u0ZoO5VqkpwWv1Upwc8EwpEcrE 8bCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703621213; x=1704226013; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:sender :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=GlJrDfGXlC8aDxhiickf9+UJIH5+CIJx7SEuHxHkX6Y=; b=QcO1uKQaQb1y3k7+r8onoaM/k0P9JmE2sDBL5HZPYLagdMb7W/jFqLNsxLZlZToFiW jbS0nRCVjodRtbgn9vIpSETJcgc7ciE5vTZnpMhPhwsjpgvhc/yQVITv0/W5Q0onwXKF 9Dd99Gzno6hP2YFtPl6nTMKlbVG9RDBWkBmAO0lrlYVNLkh2ucT6NEczhAgcWIdP5Xpk bnxOhd3blihT36rJ13xZyHJOjFfCB0sbkynxKpwq3yiXzMy2MIgAFOYY4gFzo7TpUw8g R9DwP66Lg2ZTuQb+gvePn7zMex+cZ9Mo6aig2WqOT3fgm1kbVEuhohuKMVfgx/eP9lFH 5dgg== X-Gm-Message-State: AOJu0YygknYIefaKo24HyaqZmEKFwJYEhbCOutEmUO9jpkAbyA5mJ4uX ywiYSbc8TMkDZ3Ok8b9DiBkU+p3Tsd8zFA== X-Received: by 2002:a17:902:b097:b0:1d3:fb6e:f392 with SMTP id p23-20020a170902b09700b001d3fb6ef392mr7711397plr.14.1703621212569; Tue, 26 Dec 2023 12:06:52 -0800 (PST) Received: from localhost ([121.174.67.130]) by smtp.gmail.com with ESMTPSA id o17-20020a170902779100b001d09c539c96sm10362790pll.229.2023.12.26.12.06.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Dec 2023 12:06:52 -0800 (PST) Sender: Tejun Heo Date: Wed, 27 Dec 2023 05:06:48 +0900 From: Tejun Heo To: Lai Jiangshan Cc: linux-kernel@vger.kernel.org, Naohiro.Aota@wdc.com, kernel-team@meta.com Subject: Re: [PATCH 04/10] workqueue: Move nr_active handling into helpers Message-ID: References: <20231220072529.1036099-1-tj@kernel.org> <20231220072529.1036099-5-tj@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Tue, Dec 26, 2023 at 05:12:55PM +0800, Lai Jiangshan wrote: > On Wed, Dec 20, 2023 at 3:25 PM Tejun Heo wrote: > > > +static bool pwq_tryinc_nr_active(struct pool_workqueue *pwq) > > { > > - struct work_struct *work = list_first_entry(&pwq->inactive_works, > > - struct work_struct, entry); > > + struct workqueue_struct *wq = pwq->wq; > > + struct worker_pool *pool = pwq->pool; > > + bool obtained; > > > > - pwq_activate_work(pwq, work); > > + lockdep_assert_held(&pool->lock); > > + > > + obtained = pwq->nr_active < wq->max_active; > > It is better to use READ_ONCE(wq->max_active) here in case > the compiler issues code to calculate "obtained" multi-time. > > Theoretically, READ_ONCE(wq->max_active) is recommended > from the patch1 in pwq_dec_nr_in_flight() and __queue_work() > since there is no wq->mutex for them. Yeah, good point. Lemme add WRITE/READ_ONCE() around max_active accesses. Thanks. -- tejun