Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp721726rdb; Tue, 19 Sep 2023 08:19:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHfqa9HuQiPs3wsEtLxPP+mjztSt4iL2+l851B4Ek9/9fddHVIsdii0l6dpRwPulPIMr44w X-Received: by 2002:a05:6358:430c:b0:139:d5b9:87d3 with SMTP id r12-20020a056358430c00b00139d5b987d3mr131889rwc.5.1695136749184; Tue, 19 Sep 2023 08:19:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695136749; cv=none; d=google.com; s=arc-20160816; b=JnvGqOWn/qkqmsfHcvE1UGo8UmUVpULkIy3ltOEYuoT/f3nHhIs0pX5Z584Q53+/G7 pTn/e1ijrx6JZPExNt5jPy+G1wJ9awjt6TVk8R+R7dsXuWMEt/RmxSlNdUPKZi8C6wl5 vNnyYvGJYWuZ9i0ylAMzYuzqlWl1EMFvSYn9LyuUAo73oWh0f6qgQElgxr0HX6Nhzl1G 9zvv+Io7HrWohd5iKBvdc+I9jNGi9tI3Y1XwPbDaXaocuVjbhi95Db4DBlceIECHKcUu lj/zZtAumSSnpP3bFs7SNgeJwd36HWJN7jP1MelKX0kjJSQ7JACyWdiouGWE+otIQYXK RNTA== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=7bkJNl6E96KYL5FArP+t0+UEGuqVqhn4DRsLminIM0I=; fh=f1fd7lOF2g8KGmh/dzqJThT6xtLurfb5p+A1a/zo9oM=; b=dr2dIReW8Wbx3mN3Lkqmr89djfzSLYL4YJ7cHLknrg4fLVfhNA12YpMd/S/aReBsK/ 3u/YPH1QMRqMdvREEABvbMy582hh7NI0XVEMIj0t7gM8B+gkg9hJ6BiIQxrWyKk7RNl+ swLE13COrSSffV3VZZhZfbg9hwkhJbT6vL0cM1z0oZRTiNz0gex4wH7AxLkKlrOVgyo5 Ulek2h/LBOUh+e35ievnczKpObCYZbb84MCcoRwrOKY5IePWQVA9fAHxfKHatM52oIDM 2P0n29DDx2tMaeijD6arCCryNCWX/OYIPlfHlTXq5DICFq6MNgtoRcnVYPxieBuU+2YW x6Sw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id e23-20020a63db17000000b005740286f2a8si1360502pgg.286.2023.09.19.08.18.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 08:19:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id E280D8209175; Tue, 19 Sep 2023 08:10:51 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233070AbjISPKd (ORCPT + 99 others); Tue, 19 Sep 2023 11:10:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233071AbjISPKb (ORCPT ); Tue, 19 Sep 2023 11:10:31 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D6227C6; Tue, 19 Sep 2023 08:10:24 -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 8AFF51FB; Tue, 19 Sep 2023 08:11:01 -0700 (PDT) Received: from FVFF77S0Q05N.cambridge.arm.com (FVFF77S0Q05N.cambridge.arm.com [10.1.31.185]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4CACC3F59C; Tue, 19 Sep 2023 08:10:22 -0700 (PDT) Date: Tue, 19 Sep 2023 16:10:14 +0100 From: Mark Rutland To: Baokun Li Cc: Yi Zhang , Ming Lei , Christian Brauner , linux-fsdevel@vger.kernel.org, Alexander Viro , linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org, Changhui Zhong , yangerkun , "zhangyi (F)" , peterz@infradead.org, Kees Cook , chengzhihao , Will Deacon Subject: Re: [czhong@redhat.com: [bug report] WARNING: CPU: 121 PID: 93233 at fs/dcache.c:365 __dentry_kill+0x214/0x278] Message-ID: References: <20230823-kuppe-lassen-bc81a20dd831@brauner> <89d049ed-6bbf-bba7-80d4-06c060e65e5b@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <89d049ed-6bbf-bba7-80d4-06c060e65e5b@huawei.com> X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 19 Sep 2023 08:10:52 -0700 (PDT) On Sat, Sep 16, 2023 at 02:55:47PM +0800, Baokun Li wrote: > On 2023/9/13 16:59, Yi Zhang wrote: > > The issue still can be reproduced on the latest linux tree[2]. > > To reproduce I need to run about 1000 times blktests block/001, and > > bisect shows it was introduced with commit[1], as it was not 100% > > reproduced, not sure if it's the culprit? > > > > > > [1] 9257959a6e5b locking/atomic: scripts: restructure fallback ifdeffery > Hello, everyone! > > We have confirmed that the merge-in of this patch caused hlist_bl_lock > (aka, bit_spin_lock) to fail, which in turn triggered the issue above. Thanks for this! I believe I know what the issue is. I took a look at the generated assembly for hlist_bl_lock() and hlist_bl_unlock(), and for the latter I see a plain store rather than a store-release as was intended. I believe that in 9257959a6e5b, I messed up the fallback logic for atomic*_set_release(): | static __always_inline void | raw_atomic64_set_release(atomic64_t *v, s64 i) | { | #if defined(arch_atomic64_set_release) | arch_atomic64_set_release(v, i); | #elif defined(arch_atomic64_set) | arch_atomic64_set(v, i); | #else | if (__native_word(atomic64_t)) { | smp_store_release(&(v)->counter, i); | } else { | __atomic_release_fence(); | raw_atomic64_set(v, i); | } | #endif | } On arm64 we want to use smp_store_release(), and don't provide arch_atomic64_set_release(). Unfortunately we *do* provide arch_atomic64_set(), and the ifdeffery above will choose that in preference. Prior to that commit, the ifdeffery would do what we want: | #ifndef arch_atomic64_set_release | static __always_inline void | arch_atomic64_set_release(atomic64_t *v, s64 i) | { | if (__native_word(atomic64_t)) { | smp_store_release(&(v)->counter, i); | } else { | __atomic_release_fence(); | arch_atomic64_set(v, i); | } | } | #define arch_atomic64_set_release arch_atomic64_set_release | #endif That explains the lock going wrong -- we lose the RELEASE semantic on hlist_bl_unlock(), and so loads and stores within the critical section aren't guaranteed to be visible to the next hlist_bl_lock(). On x86 this happens to work becauase of TSO. I'm working on fixing that now; I'll try to have a patch shortly. Thanks, Mark.