Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1885989imu; Fri, 23 Nov 2018 01:28:53 -0800 (PST) X-Google-Smtp-Source: AFSGD/VVWYSS1OJZ7g1bP/28yi2+4uZ7AhR8dZOwDXa/YqAtq0HLrr2B410LJyHy5j6unnOMKZ6a X-Received: by 2002:a17:902:7443:: with SMTP id e3mr11925370plt.304.1542965333728; Fri, 23 Nov 2018 01:28:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542965333; cv=none; d=google.com; s=arc-20160816; b=DrJWfZCMXi6cAq57GTWQOcofHxXwn6qulnA97Qx0HN5zSRQYOoQy6SrADxWWKYVkzl uTM0/nK1D2hZ+w/NeSJsg0se3eOe52rJ0HOzTydepIsZcJ+kN2ORJawcOG/0XOuZTpVO 3jacL/42hodVfVQuorpkG35xzMI47xtQN/fs1WLfJ6zZ278EeSyCdFiG6XuUUyuvJiUz X6Df5i0j+J6rFrEAP5uThhEO9jDbXWULv0aXsUB+JEYo7M2w63Tb0GfCvH2wiTeofLb7 Bt4maMmZmnAgis9fM+CiE7PCYFkKRhmRipGJx9W+r9bNytdWAuf+ZmbzFab03eWPE3Fh Apjg== 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=h22mgMX+YSZpxZa7730QuAY/7+Pw3etr9AoSm2FCRX4=; b=pzHolO/jw5LDIylLNyPl2OKB/6quA+1kcpiEaK8S7WWqTYYwae/4hCMYsqmjNoYzmN wKKMrxtQDD/OS6VxwxRO/pZ/FxPk6Yx8j0LseKPB6PEptr/lqCVpjENhdyFQLK0EeqV4 xxAZmft5AawDCXAYAwX/MTOyZ5ldAiZiXPWQVzBEuJJl8wnN6hdTKsUDGfRhSw2dIwNn 4RytMAEs8z0YRVqeEuHNmD/HBpSXM3KymzqyV5no8ccxGDMnDnkTZlYChLLvCz1ZPYXM OQqPRbPKCWKPiR+++3yGyRLQPG/t9NZ/gzzRbiT/0cvgATUhMJB7b7/peW7vWuCiJnPw 5VJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ZyoA9j9b; 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 l85-v6si54805117pfb.31.2018.11.23.01.28.39; Fri, 23 Nov 2018 01:28:53 -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=ZyoA9j9b; 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 S2394167AbeKVU7h (ORCPT + 99 others); Thu, 22 Nov 2018 15:59:37 -0500 Received: from mail.kernel.org ([198.145.29.99]:54254 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731554AbeKVU7h (ORCPT ); Thu, 22 Nov 2018 15:59:37 -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 DEBE920684; Thu, 22 Nov 2018 10:20:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542882050; bh=KCUkvC/hppxT223CzA2yW6igTjdLakLXjGFU3qkoUcE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ZyoA9j9bnlLIZuZV/UX9dmx7zWJZXbgOjYKS+XkNmeYXAtjvg+yb2bbmuvSpWutb4 pMg5An7QIvvFi60nP8O1HmcieSMCRYMrAaTp1iaoEdaUmVOUj2clBNnZSLM+4zEwA3 Tu4zIzhWUD/hhAKQZ+5NWVS0podbkz/2yCPV9Pss= Date: Thu, 22 Nov 2018 11:20:46 +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 03/10] staging: erofs: atomic_cond_read_relaxed on ref-locked workgroup Message-ID: <20181122102046.GD3189@kroah.com> References: <20181120143425.43637-1-gaoxiang25@huawei.com> <20181120143425.43637-4-gaoxiang25@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181120143425.43637-4-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:18PM +0800, Gao Xiang wrote: > It's better to use atomic_cond_read_relaxed, which is implemented > in hardware instructions to monitor a variable changes currently > for ARM64, instead of open-coded busy waiting. > > Reviewed-by: Chao Yu > Signed-off-by: Gao Xiang > --- > drivers/staging/erofs/internal.h | 30 ++++++++++++++++++------------ > 1 file changed, 18 insertions(+), 12 deletions(-) > > diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h > index 89dbd0888e53..eb80ba44d072 100644 > --- a/drivers/staging/erofs/internal.h > +++ b/drivers/staging/erofs/internal.h > @@ -221,23 +221,29 @@ static inline void erofs_workgroup_unfreeze( > preempt_enable(); > } > > +#if defined(CONFIG_SMP) > +static inline int erofs_wait_on_workgroup_freezed(struct erofs_workgroup *grp) > +{ > + return atomic_cond_read_relaxed(&grp->refcount, > + VAL != EROFS_LOCKED_MAGIC); > +} > +#else > +static inline int erofs_wait_on_workgroup_freezed(struct erofs_workgroup *grp) > +{ > + int v = atomic_read(&grp->refcount); Again, why not use the refcount api instead of doing this yourself? thanks, greg k-h