From mboxrd@z Thu Jan 1 00:00:00 1970 From: gregkh@linuxfoundation.org (Greg Kroah-Hartman) Date: Mon, 25 Feb 2019 16:51:20 +0100 Subject: [PATCH for-4.19 06/12] staging: erofs: fix race when the managed cache is enabled In-Reply-To: <4efecbee-5e61-f8b4-a91a-3c14852bf574@huawei.com> References: <20190220091854.19242-1-gaoxiang25@huawei.com> <20190220091854.19242-7-gaoxiang25@huawei.com> <20190225150449.GD16015@kroah.com> <4efecbee-5e61-f8b4-a91a-3c14852bf574@huawei.com> Message-ID: <20190225155120.GA12525@kroah.com> On Mon, Feb 25, 2019@11:07:19PM +0800, Gao Xiang wrote: > > > On 2019/2/25 23:04, Greg Kroah-Hartman wrote: > > On Wed, Feb 20, 2019@05:18:48PM +0800, Gao Xiang wrote: > >> commit 51232df5e4b268936beccde5248f312a316800be upstream. > >> > >> When the managed cache is enabled, the last reference count > >> of a workgroup must be used for its workstation. > >> > >> Otherwise, it could lead to incorrect (un)freezes in > >> the reclaim path, and it would be harmful. > >> > >> A typical race as follows: > >> > >> Thread 1 (In the reclaim path) Thread 2 > >> workgroup_freeze(grp, 1) refcnt = 1 > >> ... > >> workgroup_unfreeze(grp, 1) refcnt = 1 > >> workgroup_get(grp) refcnt = 2 (x) > >> workgroup_put(grp) refcnt = 1 (x) > >> ...unexpected behaviors > >> > >> * grp is detached but still used, which violates cache-managed > >> freeze constraint. > >> > >> Reviewed-by: Chao Yu > >> Signed-off-by: Gao Xiang > >> Signed-off-by: Greg Kroah-Hartman > >> Signed-off-by: Gao Xiang > >> > >> Conflicts: > >> drivers/staging/erofs/utils.c > >> Updates: > >> include/linux/xarray.h: > >> add xa_untag_pointer,xa_tag_pointer,xa_pointer_tag > >> from upstream 3159f943aafd in order to reduce > >> conflicts. > > > > No, sorry, I don't want to add xarray.h to 4.19.y, that's crazy. > > Or can I define these xa_untag_pointer,xa_tag_pointer,xa_pointer_tag in > a erofs header internally? it is acceptable? No, that's not ok. If you want to backport a subset of the api, and Matthew agrees with it (I think he did), then let's backport a subset, as a single patch, that matches the original patch comments and git id. thanks, greg k-h From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.5 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8B8D6C43381 for ; Mon, 25 Feb 2019 15:51:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 581E320C01 for ; Mon, 25 Feb 2019 15:51:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1551109885; bh=Ht/WZY8Y1CUqdzHvHhn3PC5l6jmp2UBgqmW9nCQ0TEU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=jDHqVjw71hRPQ/n8t0Q2kdT9M5DOMazooss5b0LD1wnbloClicLbrgn27CDUmi5cU LaQFzO8TZkL+LGVC8xxYrfOr16amvxAd8Ld8keC7L2+ZLpK5gN3dv5QKWYRb2wXI86 tu6w/Bw13oWnX4JCu44c5rWOok0j44IRDA8YrfOo= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727660AbfBYPvY (ORCPT ); Mon, 25 Feb 2019 10:51:24 -0500 Received: from mail.kernel.org ([198.145.29.99]:55782 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727738AbfBYPvY (ORCPT ); Mon, 25 Feb 2019 10:51:24 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 03DBE20651; Mon, 25 Feb 2019 15:51:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1551109883; bh=Ht/WZY8Y1CUqdzHvHhn3PC5l6jmp2UBgqmW9nCQ0TEU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=V8X4+Bh0LylvrsFR7w8Dn8jqPfyip8a4br5MyfUrqtCtDl2hTjK7zlKHy9igNs5BB jt6+YjVFzOOU5iplyiw6/8UMS0C7m2WDcaLHNsK3ySEVz4RsthAB+SVuMfdxe4oMgj OwP1dn1OyJ01ZZi2XRasqFN+NGAum/fUUfIrJ9SY= Date: Mon, 25 Feb 2019 16:51:20 +0100 From: Greg Kroah-Hartman To: Gao Xiang Cc: stable@vger.kernel.org, Chao Yu , linux-erofs@lists.ozlabs.org, miaoxie@huawei.com, Matthew Wilcox Subject: Re: [PATCH for-4.19 06/12] staging: erofs: fix race when the managed cache is enabled Message-ID: <20190225155120.GA12525@kroah.com> References: <20190220091854.19242-1-gaoxiang25@huawei.com> <20190220091854.19242-7-gaoxiang25@huawei.com> <20190225150449.GD16015@kroah.com> <4efecbee-5e61-f8b4-a91a-3c14852bf574@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4efecbee-5e61-f8b4-a91a-3c14852bf574@huawei.com> User-Agent: Mutt/1.11.3 (2019-02-01) Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org On Mon, Feb 25, 2019 at 11:07:19PM +0800, Gao Xiang wrote: > > > On 2019/2/25 23:04, Greg Kroah-Hartman wrote: > > On Wed, Feb 20, 2019 at 05:18:48PM +0800, Gao Xiang wrote: > >> commit 51232df5e4b268936beccde5248f312a316800be upstream. > >> > >> When the managed cache is enabled, the last reference count > >> of a workgroup must be used for its workstation. > >> > >> Otherwise, it could lead to incorrect (un)freezes in > >> the reclaim path, and it would be harmful. > >> > >> A typical race as follows: > >> > >> Thread 1 (In the reclaim path) Thread 2 > >> workgroup_freeze(grp, 1) refcnt = 1 > >> ... > >> workgroup_unfreeze(grp, 1) refcnt = 1 > >> workgroup_get(grp) refcnt = 2 (x) > >> workgroup_put(grp) refcnt = 1 (x) > >> ...unexpected behaviors > >> > >> * grp is detached but still used, which violates cache-managed > >> freeze constraint. > >> > >> Reviewed-by: Chao Yu > >> Signed-off-by: Gao Xiang > >> Signed-off-by: Greg Kroah-Hartman > >> Signed-off-by: Gao Xiang > >> > >> Conflicts: > >> drivers/staging/erofs/utils.c > >> Updates: > >> include/linux/xarray.h: > >> add xa_untag_pointer,xa_tag_pointer,xa_pointer_tag > >> from upstream 3159f943aafd in order to reduce > >> conflicts. > > > > No, sorry, I don't want to add xarray.h to 4.19.y, that's crazy. > > Or can I define these xa_untag_pointer,xa_tag_pointer,xa_pointer_tag in > a erofs header internally? it is acceptable? No, that's not ok. If you want to backport a subset of the api, and Matthew agrees with it (I think he did), then let's backport a subset, as a single patch, that matches the original patch comments and git id. thanks, greg k-h