Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp430513ybm; Thu, 28 May 2020 06:32:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxZZOfp06n4/V/TPte75N9eqNnsiTR12PkOJuAWjoaXRu/FVlwpyejTG4qC09CYehLkmk3F X-Received: by 2002:a17:906:2f8d:: with SMTP id w13mr3201955eji.102.1590672736493; Thu, 28 May 2020 06:32:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590672736; cv=none; d=google.com; s=arc-20160816; b=Hc/CsixGfH8vPdmBiqzzAnoPCwdaqHab6BoPXMZMEiQrS0RLX0B7tOs8djeP1fSrl7 TWHsxsfZIenWn9shVdhjfoqqF4CAqkEJQu0Wo0aYXdm99Be/fjBpZjgG/jXcQf/Hi3mS ULZYWiMaY8kMpsPnYsiqy3CFXFTIdlglhCDxxYps3ZROrhJs4pO3shwJ4f2V835xSHK+ 5IdMfsPGtoDIPUjmhwG60hdakxLzLBy3A7wnOzmG7w2T3BmAVqYS3nrncyU4G0LeEoGG Kty05l3+97oYqSghTtHIB0lr95FiY+otVJaxhDcjffEdemAn8zqAvEM3OhBtIJEH10Lw Shtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=H100vx4HtZK6A8WC+MIYosS8a3IpEO7hNBhEASfUOGM=; b=UAN+sWdxb9/cTAFlgGnRBmFno923xyGLQOXo8xti3cHP6UYBIREcIaPnapVSYrR5Eb +yUtGt443d319G2uyyJZR69g4YpEP6cqwRo2ZuI0IjZSiZQywNgUu8/ELly0OGJNx5kB BzCPmXe/bocjIN3BvBRYAfNMK6O326J/qlQge+9mQNyvvjJdbbm8sQ23FIcSgGBrbctZ 072gAlPTuUwPYZYdtwt+1DZaUV++lhhCE0COFGmsxvC1CWnFB/U0C1HCNwELG4OHeDGP zrWSPm668neYEYiYqWQRzSeh1kWuxsXDmYD1t7N6ojexTzbwWfGaizY3a20AkbvCa4Tp NyFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Izd8YsFo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a26si3634614edr.356.2020.05.28.06.31.52; Thu, 28 May 2020 06:32:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Izd8YsFo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390355AbgE1N1u (ORCPT + 99 others); Thu, 28 May 2020 09:27:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390344AbgE1N1P (ORCPT ); Thu, 28 May 2020 09:27:15 -0400 Received: from mail-il1-x142.google.com (mail-il1-x142.google.com [IPv6:2607:f8b0:4864:20::142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF678C05BD1E; Thu, 28 May 2020 06:27:15 -0700 (PDT) Received: by mail-il1-x142.google.com with SMTP id a18so82202ilp.7; Thu, 28 May 2020 06:27:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=H100vx4HtZK6A8WC+MIYosS8a3IpEO7hNBhEASfUOGM=; b=Izd8YsFoxhrf/1rw5M5WLdUssMEblhPRFZbRnHk6wEbHvn9LJq/RfQAGTtUetmykel MOhYZKyvOVJSYLdlLFfShdGrq9SMN2sPFA+GAm1dsyKkYKv6EObC/H7VvAfhZY2PlAmf pgPMjrRV5WsPGMxOhLiHG/QWE7pQ/NZ+tXnPv4UZxUo1hVqaXdIw7hgDpagohmhVhCDt RtmCk06wnHq/Xvgi3eG+MNPH+e703foRfuxjTbyojVnN++2QrNr1VjuqTJzfjc2l1smX 90Gv6A2QngX8fqBmhrbZY5csJK5rPjYJ841MdL5opCQBrE3cVNN7oES+1ncGMfSaoPwH OAsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=H100vx4HtZK6A8WC+MIYosS8a3IpEO7hNBhEASfUOGM=; b=fMbtfgMkTcJ6KYcd8abR71L/vRuJgpdmPDPRtLx5J/YXX4iY7IkLQnUrDoxcQRM+0F cEYvsBrhc3JdtJ4cajddVDmMP4eQi7QjVoFE2oxFNPf0xdF7rH0hD+rqWUomgxB1vdkl 7NaRqroxxchldU3Z/RM6lh8w0fLXjKSvWAkkO9j1C7yr+EoLJIvJWhY7yDBDNPF1D5NF e21X8DPMPAgH94eFZDi39L1ikX7s6VYAssJdRhVz1y8zKLokEztHd/uhvd6m2gp1pLUi tkVQAETIKNIovOIbbZuqzMeZpImCaokPUcHmMiTEH03d38wy9cgYOwi2n4mvToCe6qgT kLfg== X-Gm-Message-State: AOAM531eyoAuAthUD5euMj4DylWTixeWLHYG39axqPIYcqyR/fjuIRh8 KnpVAh8vl7F0aMA1aSjtPgfyL0VN3Ct49q+P0Gk= X-Received: by 2002:a92:c8d1:: with SMTP id c17mr2695246ilq.308.1590672435135; Thu, 28 May 2020 06:27:15 -0700 (PDT) MIME-Version: 1.0 References: <20200527075715.36849-1-qiang.zhang@windriver.com> <284c7851-4e89-a00f-a2e6-aa8e2e1f3fce@web.de> <20200528095703.GH30374@kadam> <20200528122545.GP22511@kadam> In-Reply-To: <20200528122545.GP22511@kadam> From: Lai Jiangshan Date: Thu, 28 May 2020 21:27:03 +0800 Message-ID: Subject: =?UTF-8?B?UmU6IOWbnuWkjTogW1BBVENIIHY1XSB3b3JrcXVldWU6IFJlbW92ZSB1bm5lY2Vzc2FyeQ==?= =?UTF-8?B?IGtmcmVlKCkgY2FsbCBpbiByY3VfZnJlZV93cSgp?= To: Dan Carpenter Cc: "Zhang, Qiang" , Markus Elfring , Tejun Heo , "linux-kernel@vger.kernel.org" , "kernel-janitors@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 28, 2020 at 8:27 PM Dan Carpenter wrote: > > On Thu, May 28, 2020 at 08:08:06PM +0800, Lai Jiangshan wrote: > > On Thu, May 28, 2020 at 5:57 PM Dan Carpenter wrote: > > > > > > Guys, the patch is wrong. The kfree is harmless when this is called > > > from destroy_workqueue() and required when it's called from > > > pwq_unbound_release_workfn(). Lai Jiangshan already explained this > > > already. Why are we still discussing this? > > > > > > > I'm also confused why they have been debating about the changelog > > after the patch was queued. My statement was about "the patch is > > a correct cleanup, but the changelog is totally misleading". > > > > destroy_workqueue(percpu_wq) -> rcu_free_wq() > > or > > destroy_workqueue(unbound_wq) -> put_pwq() -> > > pwq_unbound_release_workfn() -> rcu_free_wq() > > > > So the patch is correct to me. Only can destroy_workqueue() > > lead to rcu_free_wq(). > > It looks like there are lots of paths which call put_pwq() and > put_pwq_unlocked(). > > 1168 static void pwq_dec_nr_in_flight(struct pool_workqueue *pwq, int color) > 1169 { > 1170 /* uncolored work items don't participate in flushing or nr_active */ > 1171 if (color == WORK_NO_COLOR) > 1172 goto out_put; > 1173 > > We don't take an extra reference in this function. > > 1200 out_put: > 1201 put_pwq(pwq); > 1202 } > > I don't know this code well, so I will defer to your expertise if you > say it is correct. wq owns the ultimate or permanent references to itself by owning references to wq->numa_pwq_tbl[node], wq->dfl_pwq. The pwq's references keep the pwq in wq->pwqs. Only destroy_workqueue() can release these ultimate references and then (after maybe a period of time) deplete the wq->pwqs finally and then free itself in rcu callback. Actually, in short, we don't need the care about the above detail. The responsibility to free rescuer is on destroy_workqueue(), and since it does the free early, it doesn't need to do it again later. e2dca7adff8f moved the free of rescuer into rcu callback, and I didn't check all the changes between then and now. But at least now, the rescuer is not accessed in rcu mananer, so we don't need to free it in rcu mananer. > > > > > Still, the kfree(NULL) is harmless. But it is cleaner > > to have the patch. But the changelog is wrong, even after > > the lengthened debating, and English is not my mother tongue, > > so I just looked on. > > We have tried to tell Markus not to advise people about commit messages > but he doesn't listen. He has discouraged some contributors. :/ > > regards, > dan carpenter