Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp2104023rwi; Tue, 1 Nov 2022 04:02:34 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7uPqJxyfQFgM4RtNcL90d+tkpBwdJKGtxURafk7PPZK0HYfBbyDwJzFSEaRotABu8ZGZqW X-Received: by 2002:a17:907:2c78:b0:7ad:8a7a:3749 with SMTP id ib24-20020a1709072c7800b007ad8a7a3749mr17760057ejc.55.1667300554029; Tue, 01 Nov 2022 04:02:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667300554; cv=none; d=google.com; s=arc-20160816; b=Z9wAfH/8Ro2F9pBU2nfhB1MptxJuzsqnllQNiinmzdVo0uIFVLoeUUyC7r+XQF7U3S EHlyFzFXdAMCS61ZM+ZdKTDtiic+WeFYmqQzrHJPFG83n5OyV2nRwidG0umcooxJiCAX lEVyeGp5KVwQkwlTkVm/IjAvJKrcGXkV/7i8XX942Zz0QpIjQRi4ABg9nEQixtgmScUV ZS8RalR/kj+XupZ8LSSFQXqfeHGwKxwXwYUr2YVnVs17yhkBqc2nJVc+8J3MChteM7YU UaOs5dYLz3Uf6uh8YUoHllmnNC1lw4iblLt+StujIheiBe2ZJLgbuzev1Xuf6mdXJ66r W2hA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=g0TuX8J5Xj3oW4vwOymJYAUdxT9blEfiRF5KbgYnAZU=; b=HVP0rUcLieAB3mbA4PZnfiN6xkhWRX8t/6/NOOcwZx7P9ugkdOjXHZxoE6lrpUPRS0 M52Q+Hg6Ykj92IZRPFe9gUS8C+qoamDvVNb6FkU3c9VF/QvZtMy0jhSob+502txXLdB8 oRj/GXGUnUMzQDV5bUA/GeyzBjqf1KSyuMT/cgZSK8k/ZyNu77F1S2ECY1xcepCDG60r lSV1iF518RCJQJ21nR1b8oz6NCSjyZLo8DU6eVIU9qXLUahU4DzB/QHW+Gvs4W8bKvfY USQRX/zcxHvX/TxaPdt+uG8LgFzq1ewNmLxaA9c6drhrKG8CAgGlVhI8jCT2pKXNWGKV GzPA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hs37-20020a1709073ea500b00791a2a7e578si12094481ejc.641.2022.11.01.04.02.06; Tue, 01 Nov 2022 04:02:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230073AbiKAKxi (ORCPT + 98 others); Tue, 1 Nov 2022 06:53:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229770AbiKAKxd (ORCPT ); Tue, 1 Nov 2022 06:53:33 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6762C18E27; Tue, 1 Nov 2022 03:53:31 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3FB1D1FB; Tue, 1 Nov 2022 03:53:37 -0700 (PDT) Received: from FVFF77S0Q05N (unknown [10.57.3.81]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B2E223F5A1; Tue, 1 Nov 2022 03:53:29 -0700 (PDT) Date: Tue, 1 Nov 2022 10:53:20 +0000 From: Mark Rutland To: Linus Torvalds Cc: Jann Horn , Al Viro , Miklos Szeredi , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Will Deacon Subject: Re: [PATCH] fs: add memory barrier in __fget_light() Message-ID: References: <20221031171307.2784981-1-jannh@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 31, 2022 at 10:37:01AM -0700, Linus Torvalds wrote: > On Mon, Oct 31, 2022 at 10:13 AM Jann Horn wrote: > > > > If this is too expensive on platforms like arm64, I guess the more > > performant alternative would be to add another flags field that tracks > > whether the fs_struct was ever shared and check that instead of the > > reference count in __fget_light(). > > No, the problem is that you should never use the "smp_*mb()" horrors > for any new code. > > All the "smp_*mb()" things really are broken. Please consider them > legacy garbage. It was how people though about SMP memory ordering in > the bad old days. > > So get with the 21st century, and instead replace the "atomic_read()" > with a "smp_load_acquire()". Minor nit: atomic{,64,_long}_{read_acquire,set_release}() exist to be used directly on atomics and should d.t.r.t. on all architectures (e.g. where 64-bit atomics on 32-bit platforms have extra requirements). So this instance can be: ... if (atomic_read_acquire(&files->count) == 1) { ... Mark.