Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp810292ybb; Fri, 20 Mar 2020 08:26:19 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtVQNdiKp2El+APbqPqR1K4l/02zrUpPjahVCxTXX8d+MpuLYij0+9h6m0ce6CSAGqexwrx X-Received: by 2002:aca:bfc6:: with SMTP id p189mr6993466oif.21.1584717979407; Fri, 20 Mar 2020 08:26:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584717979; cv=none; d=google.com; s=arc-20160816; b=iABjEz1GLVccC06rfWReuBPAFVWKhw/nSchw9zcnzdR3HeIwzHv9AbbpXdIFyI7i5a GlB3t6pua5A/OdW0Gt8Z2piGYjxL/IFT7Vi5e2E3A03AA62pZXkz/0Dce63htqUBCB4W OzlUjAuDqEev5qByh63yyKGrldUzQv9HGYkXwmuZagb88r9lENAwz6CGebe//CtLhTJe sWg595r478GoX5+PUS8py7M+Tgv7xUOCNsFN4udLpdKSZViUhfGzxjunYFLX+JmxpRBd M42jRcSNV5XRcWF1YkrwwWm9Rar5uBW/IW6x59HC7LSwLoFWBY3e1OxjCY9E4uGTjL0G Fyag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject; bh=UA3eFysGVkRVfDKWqmZXy+2NPHE7UiW13T5Evicsj0A=; b=I97Mi17miJFdcGroSz6KtwqX9Va40Va97X7vEW6S5RwScg97EdTkScPiroG8PIvwOE ETEwbkFRsNO1zEWg1sHRfLyCZopeIImcR5J0CKZGuMbsOLnJaP5VD16MNk1XLXnsdcgA pVK6fKVRzVYJMzQWMsaJESEq87iO/WRBhB4bqpMSDdkm4YjRNaBdAnJ3EP366SfWe4jT j1PhfV65xwOISt+fLkmdd2sftV3Ox7JySiVFuaSxAz7qq6TGNe/hiMf2yxr8RfQP4owx g0A+dcDna4GAiPeGZKlDevC2PF+Mw6LCLnzQLdxNThHQILi/Ex40+PuD18f6SqHSOOMZ EkPw== ARC-Authentication-Results: i=1; mx.google.com; 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 m11si3328473otq.279.2020.03.20.08.25.59; Fri, 20 Mar 2020 08:26:19 -0700 (PDT) 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; 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 S1727572AbgCTPYx (ORCPT + 99 others); Fri, 20 Mar 2020 11:24:53 -0400 Received: from mx2.suse.de ([195.135.220.15]:56370 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726847AbgCTPYw (ORCPT ); Fri, 20 Mar 2020 11:24:52 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id AAFFAAD68; Fri, 20 Mar 2020 15:24:50 +0000 (UTC) Subject: Re: [PATCH] bcache: optimize barrier usage for Rmw atomic bitops To: Davidlohr Bueso , kent.overstreet@gmail.com Cc: linux-bcache@vger.kernel.org, linux-kernel@vger.kernel.org, Davidlohr Bueso References: <20200129180802.24626-1-dave@stgolabs.net> From: Coly Li Organization: SUSE Labs Message-ID: <877a5349-3133-404a-86ea-02309080a520@suse.de> Date: Fri, 20 Mar 2020 23:24:45 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <20200129180802.24626-1-dave@stgolabs.net> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020/1/30 2:08 上午, Davidlohr Bueso wrote: > We can avoid the unnecessary barrier on non LL/SC architectures, > such as x86. Instead, use the smp_mb__after_atomic(). > Hi Davidlohr, > Signed-off-by: Davidlohr Bueso Sorry for replying late. Indeed we don't need to worry about the extra smp_mb() because the code patch gets called every 5 seconds by default, which is very infrequent. But I like this more accurate patch, it is in my testing already. And by your inspiration, I also fix some other locations to use smp_mb__before/after_atomic(). Thank you. Coly Li > --- > drivers/md/bcache/writeback.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/md/bcache/writeback.c b/drivers/md/bcache/writeback.c > index 4a40f9eadeaf..284ff10f480f 100644 > --- a/drivers/md/bcache/writeback.c > +++ b/drivers/md/bcache/writeback.c > @@ -183,7 +183,7 @@ static void update_writeback_rate(struct work_struct *work) > */ > set_bit(BCACHE_DEV_RATE_DW_RUNNING, &dc->disk.flags); > /* paired with where BCACHE_DEV_RATE_DW_RUNNING is tested */ > - smp_mb(); > + smp_mb__after_atomic(); > > /* > * CACHE_SET_IO_DISABLE might be set via sysfs interface, > @@ -193,7 +193,7 @@ static void update_writeback_rate(struct work_struct *work) > test_bit(CACHE_SET_IO_DISABLE, &c->flags)) { > clear_bit(BCACHE_DEV_RATE_DW_RUNNING, &dc->disk.flags); > /* paired with where BCACHE_DEV_RATE_DW_RUNNING is tested */ > - smp_mb(); > + smp_mb__after_atomic(); > return; > } > > @@ -229,7 +229,7 @@ static void update_writeback_rate(struct work_struct *work) > */ > clear_bit(BCACHE_DEV_RATE_DW_RUNNING, &dc->disk.flags); > /* paired with where BCACHE_DEV_RATE_DW_RUNNING is tested */ > - smp_mb(); > + smp_mb__after_atomic(); > } > > static unsigned int writeback_delay(struct cached_dev *dc, > -- Coly Li