From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1DB1AC433E0 for ; Fri, 19 Mar 2021 14:16:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E196564E5B for ; Fri, 19 Mar 2021 14:16:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229990AbhCSOQO (ORCPT ); Fri, 19 Mar 2021 10:16:14 -0400 Received: from www262.sakura.ne.jp ([202.181.97.72]:55378 "EHLO www262.sakura.ne.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230079AbhCSOPs (ORCPT ); Fri, 19 Mar 2021 10:15:48 -0400 Received: from fsav106.sakura.ne.jp (fsav106.sakura.ne.jp [27.133.134.233]) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTP id 12JEFlYg085436; Fri, 19 Mar 2021 23:15:47 +0900 (JST) (envelope-from penguin-kernel@i-love.sakura.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav106.sakura.ne.jp (F-Secure/fsigk_smtp/550/fsav106.sakura.ne.jp); Fri, 19 Mar 2021 23:15:47 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/550/fsav106.sakura.ne.jp) Received: from [192.168.1.9] (M106072142033.v4.enabler.ne.jp [106.72.142.33]) (authenticated bits=0) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTPSA id 12JEFkPv085433 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NO); Fri, 19 Mar 2021 23:15:47 +0900 (JST) (envelope-from penguin-kernel@i-love.sakura.ne.jp) Subject: Re: [syzbot] KCSAN: data-race in start_this_handle / start_this_handle To: Marco Elver , "Theodore Ts'o" Cc: Dmitry Vyukov , syzbot , Jan Kara , linux-ext4@vger.kernel.org, LKML , syzkaller-bugs , "Paul E. McKenney" , Jan Kara References: <0000000000008de88005bd40ac36@google.com> <20210311142503.GA31816@quack2.suse.cz> From: Tetsuo Handa Message-ID: <9dd08907-654c-bc38-fd9f-4324304152af@i-love.sakura.ne.jp> Date: Fri, 19 Mar 2021 23:15:42 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/03/12 0:54, Marco Elver wrote: >> But the more we could have the compiler automatically figure out >> things without needing an explicit tag, it would seem to me that this >> would be better, since manual tagging is going to be more error-prone. > > What you're alluding to here would go much further than a data race > detector ("data race" is still just defined by the memory model). The > wish that there was a static analysis tool that would automatically > understand the "concurrency semantics as intended by the developer" is > something that'd be nice to have, but just doesn't seem realistic. > Because how can a tool tell what the developer intended, without input > from that developer? Input from developers is very important for not only compilers and tools but also allowing bug-explorers to understand what is happening. ext4 currently has possible deadlock in start_this_handle (2) https://syzkaller.appspot.com/bug?id=38c060d5757cbc13fdffd46e80557c645fbe79ba which even maintainers cannot understand what is happening. How can bug-explorers know implicit logic which maintainers believe safe and correct? It is possible that some oversight in implicit logic is the cause of "possible deadlock in start_this_handle (2)". Making implicit assumptions clear helps understanding. Will "KCSAN: data-race in start_this_handle / start_this_handle" be addressed by marking? syzbot is already waiting for "KCSAN: data-race in jbd2_journal_dirty_metadata / jbd2_journal_dirty_metadata" at https://syzkaller.appspot.com/bug?id=5eb10023f53097f003e72c6a7c1a6f14b7c22929 . > > If there's worry marking accesses is error-prone, then that might be a > signal that the concurrency design is too complex (or the developer > hasn't considered all cases). > > For that reason, we need to mark accesses to tell the compiler and > tooling where to expect concurrency, so that 1) the compiler generates > correct code, and 2) tooling such as KCSAN can double-check what the > developer intended is actually what's happening. and 3) bug-explorers can understand what the developers are assuming/missing.