Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp639755pxb; Tue, 9 Feb 2021 08:53:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJytnADElgYzL//LRqwZ7xZEoz7Nm3rFfhTbcWi6QqY1v88SCK8nNLP4OmZHQQgTwFYO/L6l X-Received: by 2002:a05:6402:310a:: with SMTP id dc10mr24485249edb.258.1612889620514; Tue, 09 Feb 2021 08:53:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612889620; cv=none; d=google.com; s=arc-20160816; b=xIeUbFlnZWBKc6d+rA5n3FGxRkuSfHyvQdZ/Pm3kC+Lo3Sa0vKjPRoBk7MglaheHgH JQKRMcaVC6Oh9LxxZMhi31u01l9S19BHkQEea9bHE+QBH4fFTsqaX0GTvtT96RW+h17M CODM/yF02Bn0+FdBApdOdyRDUw1hmBhjFBrWVpk5tvOodYS3Km4xpEFH8Kk5gnJjZj80 JCxwL+8O96LHel5irlLdaq3DlXXgfEeeBWs1mLP80u+r2ebcQ89mnw3fdEW3n0lKhwp5 5qycjNSvY1ioDLPPlRwWL63iV4PrZdDwPEcLqVfk+xXe06MbEcjW+yfbCaHFAiLxYHUH O3BQ== 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=ill7G1j1buSwA6GppYeE7QFAR5rkX+OT+uJpcfpK4Ss=; b=TOYbJEahTBfaSkv0UZIW6iOqTW0AkP35UzvwDpFZVXvmeykLQJf6BGJ4MnUWe7omt5 +TuIM73inHEn5NA8nBCGu5L7kJks1UKj9+02tNBCBe8G31TT1D6lQX5vqLHhaoRdDHlA w24cxun1+I6dDMuGpCIklAe5sRLJuRcYlRVaDp84VtTt/EpBDeAEKY0ljnZ3xzRWhIV3 XNh2htrOX+e80yWlP0nNCDOnMw2VNXhQMRykE5ci7wRH7RFONtabbYnZZyuuCpOIy1XI IlF9a7CCtOYECevmf3cpSddpvs0Dx8tWxG2MmeZz85zi8eVwWCUeM6c6ihh1nGQ/XLzO cyyw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-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 rl24si12945447ejb.582.2021.02.09.08.53.04; Tue, 09 Feb 2021 08:53:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4-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-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233089AbhBIQvB (ORCPT + 99 others); Tue, 9 Feb 2021 11:51:01 -0500 Received: from mx2.suse.de ([195.135.220.15]:41286 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232686AbhBIQs7 (ORCPT ); Tue, 9 Feb 2021 11:48:59 -0500 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 DF038AC97; Tue, 9 Feb 2021 16:48:16 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id A4B2E1E13FD; Tue, 9 Feb 2021 17:48:16 +0100 (CET) Date: Tue, 9 Feb 2021 17:48:16 +0100 From: Jan Kara To: Alexander Lochmann Cc: Jan Kara , tytso@mit.edu, Jan Kara , Horst Schirmeier , linux-ext4@vger.kernel.org Subject: Re: [RFC] Fine-grained locking documentation for jbd2 data structures Message-ID: <20210209164816.GD19070@quack2.suse.cz> References: <20190408083500.66759-1-alexander.lochmann@tu-dortmund.de> <7827d153-f75c-89a2-1890-86e85f86c704@tu-dortmund.de> <14dbc946-b0c5-4165-3e6a-3cbe3c6a74b4@tu-dortmund.de> <20210208152750.GD30081@quack2.suse.cz> <02643d06-0066-a7c3-b6dd-2d190c8e0c41@tu-dortmund.de> <20210209120017.GB19070@quack2.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Tue 09-02-21 14:47:28, Alexander Lochmann wrote: > On 09.02.21 13:00, Jan Kara wrote: > > > > Yes, although in last year, people try to convert these unlocked reads to > > > > READ_ONCE() or similar as otherwise the compiler is apparently allowed to > > > > generate code which is not safe. But that's a different story. > > > Is this ongoing work? > > > > Yes, in a way. It's mostly prompted by KCSAN warnings generated by syzbot > > ;). > > > > > Using such a macro would a) make our work much easier as we can instrument > > > them, and b) would tell less experienced developers that no locking is > > > needed. > > > > Yes, I agree that it has some benefit for documentation and automatic > > checkers as well. OTOH code readability is sometimes hurt by this... > > > > > Does the usage of READ_ONCE() imply that no lock is needed? > > > > No, but it does indicate there's something unusual happening with the > > variable - usually that variable write can race with this read. > > > > > Otherwise, one could introduce another macro for jbd2, such as #define > > > READ_UNLOCKED() READ_ONCE(), which is more precise. > > > > Well, yes, but OTOH special macros for small subsystems like this are > > making more harm than good in terms of readability since people have to > > lookup what exactly they mean anyway. > > So the only option left would be a global macro such as READ_ONCE() I guess. > How hard would it be to establish such a global notation? > It would make things a lot easier for LockDoc, because we can instrument > such a macro, and therefore can annotate those accesses.> Well, READ_ONCE() macro already exists in the kernel and is used in quite some places. Generally, there's concensus that newly added unlocked accesses should use that macro. But the amount of already existing unlocked accesses in the kernel is large and the problem is mostly theoretical / for machine checkers so there's some resistance to the churn generated by global search-and-replace approach. But as I said we are moving in that direction and eventually get there. Honza -- Jan Kara SUSE Labs, CR