Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp712134pxx; Thu, 29 Oct 2020 12:34:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwwFOavIAJrbTDAVyAEzurj/sGs+w4AKI/cHGQAYF2GpWqyL8pup0W2GxUebu9TcJueOatI X-Received: by 2002:aa7:d28a:: with SMTP id w10mr5757344edq.192.1604000054734; Thu, 29 Oct 2020 12:34:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1604000054; cv=none; d=google.com; s=arc-20160816; b=F8LDMYfAz1NsdKQ0QE7UkKbHFutwqqGm43AcRXUESEF+OM5CJu3OhKG91Xt121oNGR ynmOrQxtQ7dQFUm80AZr6P4YubycLMVANuSc75fgYIAFd39vNUJBF7LfSmY+j4cQApzR lLLD4VBgYH5yaKRsd5kr4RltpLXzAGL7V8Xnyh6XKQejPvwAm7xM6lmUHpqDZh166DkS 2bjYzMwCtbXRXu7ainIgFZwaNWGlPPNCHmGzZxt9WaVU8XwRUEQQniMyJmZAcGqrf/iJ mI8+LDd6AL1R8M0999z+Gmfog+jnH3GoYzBfPIqtolGGOmmYZllnTHQbHunZg7iXuUBb kVHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=3XcoWgPH0AN+Oywaa/F2vFOFsOZBS7dhM8HbJD9Kh4E=; b=QHWIShFHB+tThcGv5VV315ddgLsjFn4JAU/v6ys+KO6Wkgp2mZ52uvZwLnIKCYj9rH 0f4iGQw0FbwEFoPRQyzdwO85WofQ32aCkX3BIm+gbBekjEXKD5wPyZi09LKhSEuD52iJ NS6QFCUDulnmfeNcxOWuYdl7qrDS148GEUXYcbczlD5LBboRcDzkTB6CL0q6pt08mt10 wt3zOx6AMgOqiWsPGe4QA1/0l9oXUdwyTXO56r+GYTu8lQwehlZkIkiXEYIDkxvWmqI0 Uf9z2eqCAslaoUUoHJt71KqqqP1tw6qsjxaHzOWxczyo2KDsM0mAltcEuluGeR6G+Won GfRQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qx9si2394281ejb.327.2020.10.29.12.33.51; Thu, 29 Oct 2020 12:34:14 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726823AbgJ2T3l (ORCPT + 99 others); Thu, 29 Oct 2020 15:29:41 -0400 Received: from mx2.suse.de ([195.135.220.15]:51804 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726120AbgJ2T3d (ORCPT ); Thu, 29 Oct 2020 15:29:33 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 26D71AE72; Thu, 29 Oct 2020 19:28:42 +0000 (UTC) Date: Thu, 29 Oct 2020 12:07:48 -0700 From: Davidlohr Bueso To: Dave Chinner Cc: viro@zeniv.linux.org.uk, akpm@linux-foundation.org, peterz@infradead.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Davidlohr Bueso Subject: [PATCH v2] fs/dcache: optimize start_dir_add() Message-ID: <20201029190748.u5zrnk6rjtc4p43v@linux-p48b> References: <20201022211650.25045-1-dave@stgolabs.net> <20201026215923.GA306023@dread.disaster.area> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20201026215923.GA306023@dread.disaster.area> User-Agent: NeoMutt/20180716 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Considering both end_dir_add() and d_alloc_parallel(), the dir->i_dir_seq wants acquire/release semantics, therefore micro-optimize for ll/sc archs. Also add READ_ONCE around the variable mostly for documentation purposes - either the successful cmpxchg or the pause will avoid the tearing). Signed-off-by: Davidlohr Bueso --- fs/dcache.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/dcache.c b/fs/dcache.c index ea0485861d93..9177f0d08a5a 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -2504,8 +2504,8 @@ static inline unsigned start_dir_add(struct inode *dir) { for (;;) { - unsigned n = dir->i_dir_seq; - if (!(n & 1) && cmpxchg(&dir->i_dir_seq, n, n + 1) == n) + unsigned n = READ_ONCE(dir->i_dir_seq); + if (!(n & 1) && cmpxchg_acquire(&dir->i_dir_seq, n, n + 1) == n) return n; cpu_relax(); } -- 2.26.2