Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1969912imu; Fri, 23 Nov 2018 02:55:37 -0800 (PST) X-Google-Smtp-Source: AFSGD/VJTp+80PvrHlFakrXX6mO6XZ0aqIiNcjFaG8K/3QqNbPRBo8bKdiFKBDUvow1JVMn+pcCm X-Received: by 2002:a17:902:2c83:: with SMTP id n3mr15278739plb.104.1542970537080; Fri, 23 Nov 2018 02:55:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542970537; cv=none; d=google.com; s=arc-20160816; b=IYR/v+MREsycxoyRc2Q5k1BTxGq4GSwxMfcUE+cdL067d97ga4o0UdtavVdd9s7deJ HpVoIt9rUxoeGQHm4NFnDud7EAKVUNZr8k6zMnpLQ6kVSPf0EcyYfdQmW0sWOf6A+FQt u4bRi/FSd1Ijl5iZr5JaXIi5Vau9kFqka1JldNDrEFH5a+kh5g/OK28bgnwnAKBpTvLO 7yjxZVg/MwC637ifiAywMYlSD8P3zIrdhTbQGsm7AM46O6COopDb4jvPlGu/CwmINiem JyDeb70NafvFM7e3u6Bj8u66cEFAUW9LYxpAA39xaxMCgNH6IcyT/Cztvh2YTZZT9fnT ITiA== 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=zvOUiEdd++So3/bBk5kF86dGlc15yOK4LZVpEQJeCpo=; b=LDL3VFZgB8Tk51G/Ljvbznb0KpgI11bXIY1VasGWubzGE4+C50XNx7/J2cHrTu94f/ OSTV7DArVC1sMkmlHLVOnBtdA+C0Qp6BMzpeWhCysXI/Nj4cDJPbZuQI/rTU+yptPKub jL7kO9up4R8Pkma6m61soayVlDCydPGiNmrjeqLn3dqGgY89kAPSOhELvX7fZu7HEjgM VEXER4LL2vVKFvEy16JcLGTHFK/atDoagoqaKlNswIiEhMQMG0pXgbxJ4TGGSUo1kJiw 2bjaPdTfRQRLzy0xFXmLjhT8wxNl8KPZXKO01mUqcVZwQ88FKFRS3JIRexVrYemSf568 mzIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Y0rA0XS1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m3si20089031pld.331.2018.11.23.02.55.22; Fri, 23 Nov 2018 02:55:37 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=@kernel.org header.s=default header.b=Y0rA0XS1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394311AbeKVVD0 (ORCPT + 99 others); Thu, 22 Nov 2018 16:03:26 -0500 Received: from mail.kernel.org ([198.145.29.99]:57024 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387908AbeKVVDZ (ORCPT ); Thu, 22 Nov 2018 16:03:25 -0500 Received: from localhost (unknown [95.99.132.93]) (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 9C3B720684; Thu, 22 Nov 2018 10:24:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542882276; bh=wQ8QMnG0422IEoY3sw3jmvoOVmTswSFA5Z3QgydH0YE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Y0rA0XS1+OEnu901SR1hpgxygIudh6iSqOF0wpxdeS7+0IuE2QrT3G4Sthr6/vRNL ejXwmxaG8tbuScxvcCq2WBrWlbt8c2gGHE6FKjgmS066cDV3FKKvWTi9LLN/wLo6Mi XcQ/8gBRDV6hPIx1Ew/+CKM+QpRfZdVkCdbhMOP0= Date: Thu, 22 Nov 2018 11:24:31 +0100 From: Greg Kroah-Hartman To: Gao Xiang Cc: devel@driverdev.osuosl.org, linux-erofs@lists.ozlabs.org, Chao Yu , LKML , weidu.du@huawei.com, Miao Xie Subject: Re: [PATCH 08/10] staging: erofs: locked before registering for all new workgroups Message-ID: <20181122102431.GH3189@kroah.com> References: <20181120143425.43637-1-gaoxiang25@huawei.com> <20181120143425.43637-9-gaoxiang25@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181120143425.43637-9-gaoxiang25@huawei.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 20, 2018 at 10:34:23PM +0800, Gao Xiang wrote: > Let's make sure that the one registering a workgroup will also > take the primary work lock at first for two reasons: > 1) There's no need to introduce such a race window (and consequently > overhead) between registering and locking, other tasks could break > in by chance, and the race seems unnecessary (no benefit at all); > > 2) It's better to take the primary work when a workgroup > is registered to apply the cache managed policy, for example, > if some other tasks break in, it could turn into the in-place > decompression rather than use as the cached decompression. > > Reviewed-by: Chao Yu > Signed-off-by: Gao Xiang > --- > drivers/staging/erofs/unzip_vle.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/drivers/staging/erofs/unzip_vle.c b/drivers/staging/erofs/unzip_vle.c > index 4e5843e8ee35..a1376f3c6065 100644 > --- a/drivers/staging/erofs/unzip_vle.c > +++ b/drivers/staging/erofs/unzip_vle.c > @@ -420,18 +420,22 @@ z_erofs_vle_work_register(const struct z_erofs_vle_work_finder *f, > work = z_erofs_vle_grab_primary_work(grp); > work->pageofs = f->pageofs; > > + /* lock all primary followed works before visible to others */ > + if (unlikely(!mutex_trylock(&work->lock))) > + /* for a new workgroup, try_lock *never* fails */ > + DBG_BUGON(1); Again, drop this, if it never fails, then there's no need for this. If it can fail, then properly handle it. And trylock can fail, so this needs to be fixed. thanks, greg k-h