Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp457779ybm; Thu, 28 May 2020 07:11:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy7Jyn5L0GlDbHAN2X+D3E/LaXqXZZ/tguiUhA7l7ChOcQ3GfwZ0BXZJgTIKjHI6d/rGmvY X-Received: by 2002:a17:906:fac8:: with SMTP id lu8mr3084713ejb.432.1590675067092; Thu, 28 May 2020 07:11:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590675067; cv=none; d=google.com; s=arc-20160816; b=qqZ8WcCPBDNMKqU9PVN6LHqrxa1lzmZ0AwZczEdYjD2MbagSOHIv2ZLw4wVSsX4c2w YkgJq7WQeUcAc7G2dQdKZCNFMWJcDKX0W+AvlkZDuQoK1sFbzKYDw+CpapqXBW5qjo8T 6sN6sVItSZJgIDwSwAKgo6N9x1HDvztRp7uMrLRF2qHB57FG3D4GXFKqb0buE4bZHUbv 1s3yMMywsteS1os3Ia2/nK/IMPu62NCF/Cxwv12m1l7ujbf31wgFQUkhgOy3SyfeAnVH FGvD7bRMLK1kYJydP1oGFm5fn5K57FBJfjnPuZic++GJXmoE/pHRrGBLn1ZFcGe8ObdE zCKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=ZpO6geCXEfKtvVwoUpLjfojIWR34s984zqeSiyiYS48=; b=Wxi+w0xkUhDBIFZtxv6a+vRu2WWuEmMsds5XaFTz8cRIJW4xbIwWiWxeMlejuo+lVb 3FsN7XdsuHedlGlTvMViTVOhWd4xXW5TloNm1+EpGdpu9zYyqcTXyCdfnC/51OT17EE7 kVws8aYlK4usshrljPzhoP8rJmUsxQ/pQMnzQGn+tTr7t0UShMbnsp7tqwhk1u1U7ufl In0eVHixCnWlnmAcw0kZ2Q4cupR9P3iq6XPNGW3xixPzDkRkj1Ae5YI8qN2wPheOovtI ulJCGl7ZdZTKij0gN3bNXmA+rIZjbRvlmAG51P5WfnOYqid5dLtZFMwn3TjIObvYqT5U 7zbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=h5z6gv2K; 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=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b13si3347638eds.295.2020.05.28.07.10.44; Thu, 28 May 2020 07:11:07 -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=@oracle.com header.s=corp-2020-01-29 header.b=h5z6gv2K; 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=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390882AbgE1OIH (ORCPT + 99 others); Thu, 28 May 2020 10:08:07 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:35186 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390658AbgE1OIF (ORCPT ); Thu, 28 May 2020 10:08:05 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 04SE7nD5146260; Thu, 28 May 2020 14:08:00 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2020-01-29; bh=ZpO6geCXEfKtvVwoUpLjfojIWR34s984zqeSiyiYS48=; b=h5z6gv2KVvsDaOPttrHkFk2r058+LiTdnzBMPdpxqnfYVHG7q3T+S36fH0ORBUpqinHC T+tM5ZqpJqf+unhhEiboocr4GyB8RcfXQE97+85u8z1EuMk2LWyHIFrhVtg+gIe3hpQ7 QYFIfxiJJ9w37EHssl/vz0k85M/F2jAvZDRnSSi5u1007PoC9/PppOo8jYZ3K9bDFatW +UhXGDjaJUuX3bJScptDxT0+AG+yuK6XWk0wcrjETxBksdnDO+Uj1jldF4P+SjQk1Twa gkjvXe2Gbk1bXm1ybXip4fiRkgS3trZXs3aMpe07daXexjg+ZFEO8I3YgY2Ml1B0x+hp QA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 318xbk58ch-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 28 May 2020 14:08:00 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 04SE7d3c150848; Thu, 28 May 2020 14:07:59 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3020.oracle.com with ESMTP id 31a9ksjjga-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 May 2020 14:07:59 +0000 Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 04SE7w0i007174; Thu, 28 May 2020 14:07:58 GMT Received: from kadam (/41.57.98.10) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 28 May 2020 07:06:20 -0700 Date: Thu, 28 May 2020 17:06:13 +0300 From: Dan Carpenter To: Lai Jiangshan Cc: "Zhang, Qiang" , Markus Elfring , Tejun Heo , "linux-kernel@vger.kernel.org" , "kernel-janitors@vger.kernel.org" Subject: Re: =?utf-8?B?5Zue5aSNOiBbUEFUQ0ggdjU=?= =?utf-8?Q?=5D?= workqueue: Remove unnecessary kfree() call in rcu_free_wq() Message-ID: <20200528140613.GK30374@kadam> References: <20200527075715.36849-1-qiang.zhang@windriver.com> <284c7851-4e89-a00f-a2e6-aa8e2e1f3fce@web.de> <20200528095703.GH30374@kadam> <20200528122545.GP22511@kadam> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9634 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 mlxscore=0 adultscore=0 mlxlogscore=999 malwarescore=0 spamscore=0 bulkscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2005280097 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9634 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 spamscore=0 mlxscore=0 lowpriorityscore=0 priorityscore=1501 phishscore=0 cotscore=-2147483648 suspectscore=2 bulkscore=0 clxscore=1015 impostorscore=0 malwarescore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2005280097 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 09:27:03PM +0800, Lai Jiangshan wrote: > 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. > Ah... Thanks for the explanation! regards, dan carpenter