Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp4637687imm; Mon, 25 Jun 2018 20:48:03 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJPeFBRgKgHTVftCMmzWFc2E+evk2BRZvNVbQwp9MWNvxBEwTqyiOC4yf7+oq9ptSPNmC0b X-Received: by 2002:a62:3c15:: with SMTP id j21-v6mr15693330pfa.7.1529984883019; Mon, 25 Jun 2018 20:48:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529984882; cv=none; d=google.com; s=arc-20160816; b=f7LZOPrIdy8p0xun3s6ZrCeJj8D7H3t7EZoskLQT3RZ5M2PssNpiT1PhvmluD8JTyP nTWOJtwtEZiNTRE8lLk3EQU+fX5WN+GyeZS99jQsqwNHL1yHqVLuPArl496tYB/B0edX 7xr1OptcNPmrtgqoKjefhf7a29BRmAjbEP/Yr+pMYqGNI1y9xyRmiJ1Ct7/mOn9sDMGT 4Yu2cv38SXrWsa4AKDDdrb63qcJBQoSue1tpwEd/zDteWRge40a4OX8GGzqZqN1qFLX/ bWpDkqqJtt8DkldCsNSiSEr0zPGxSlyVjrKGqGpSCG6f5at7YOLsPKk+//zANkH8ij38 TF2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=ld/ghtcJfFDiS8mFcJfDLkjNV12ZeBssEVfk1PeHwtE=; b=pVaqV6Lfxbrt6nJlBY0tTQxXmhRcsjAfnd0B5BcBTW4WtXDuTGjW/ffq2DfUx2oGlQ JdxQiNMlUXinTxLxK4BHppPm3DenzlmXZsRwkuSLNMhl849IJllQMZ8NbFRtO0XEzPNx GK22F4sVbD59+5CkLPANiQ1Vyc9SogpjvQv+q4DBoWpJ+DJVT5ZgxwgqVz8r6WFPYdrw GPTgnlP75da9o4Jxorr5R5HYBDlie1JjY09OCrBAUD0JolcxepZpQKhpScogyJH+rua7 P5A2eM4axQPzKi3Ip46upC1MIFlXXKoV8F5CmGrfYFVnWFVcj1A32VDMMWeUsPc4GiPw NIDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=WO0I+Uth; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f28-v6si644677pfd.123.2018.06.25.20.47.48; Mon, 25 Jun 2018 20:48:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=WO0I+Uth; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965412AbeFZDrH (ORCPT + 99 others); Mon, 25 Jun 2018 23:47:07 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:58852 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965341AbeFZDrG (ORCPT ); Mon, 25 Jun 2018 23:47:06 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w5Q3hcke192731; Tue, 26 Jun 2018 03:47:04 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2017-10-26; bh=ld/ghtcJfFDiS8mFcJfDLkjNV12ZeBssEVfk1PeHwtE=; b=WO0I+UthdXzB/Ux8eQ18MFNRWpOphu2x4Q+H0hZqKiNkWNhttM5QHDtqVGV1GwI22gIZ ihlZUOzWqscPDOuT8EPPMbITsB3gqyZ4pmSzZ5eJVLeo4R5bK9EX/stJ88w57EcJYhtu 2hI260lxhlqULYRr9D4EHG3ZZOfR4w3yAlJST0oQlUupcMPIQYTJWgNrpi4YjXsGlanj D2FMjWx+tczYXWf1lcDElUrtgH0eMq/7hXudVKFH411L2Z7ovtYBdYNfS6FXkfDHo/vv R4ARxn7ePyjSViEUR6hZiIlvdJnd6d0TqEa0NQv0hfxyCiXThHcR5k5HfYq0XvAOID/2 dA== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2130.oracle.com with ESMTP id 2ju1wfj8ec-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 26 Jun 2018 03:47:04 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w5Q3l3D8019000 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 26 Jun 2018 03:47:03 GMT Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w5Q3l2gs030027; Tue, 26 Jun 2018 03:47:03 GMT Received: from [10.182.69.179] (/10.182.69.179) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 25 Jun 2018 20:47:02 -0700 Subject: Re: [PATCH] blk-mq: use mutex_trylock to avoid lock inversion To: Bart Van Assche , "axboe@kernel.dk" Cc: "linux-kernel@vger.kernel.org" , "linux-block@vger.kernel.org" References: <1529391637-1704-1-git-send-email-jianchao.w.wang@oracle.com> <2409013d789ca266879d24c815b76c2193e23fe3.camel@wdc.com> <2c2003ff1baac05688495677f67239d52f6d9527.camel@wdc.com> <2a1dda06-5c7c-b75b-c1ae-75d1a2a49694@oracle.com> From: "jianchao.wang" Message-ID: Date: Tue, 26 Jun 2018 11:46:59 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <2a1dda06-5c7c-b75b-c1ae-75d1a2a49694@oracle.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8935 signatures=668703 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=3 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=471 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1806260040 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Bart On 06/21/2018 04:23 PM, jianchao.wang wrote: > Hi Bart > > On 06/21/2018 12:18 AM, Bart Van Assche wrote: >> On Wed, 2018-06-20 at 10:09 +0800, jianchao.wang wrote: >>> It is very easy to reproduce with following scripts. >>> >>> script 0 >>> while true >>> do >>> modprobe null_blk queue_mode=2 shared_tags=1 >>> sleep 0.1 >>> rmmod null_blk >>> sleep 0.1 >>> done >>> >>> script 1 >>> file0="/sys/block/nullb0/mq/0/nr_tags" >>> file1="/sys/block/nullb0/mq/0/cpu0/rq_list" >>> while true; >>> do >>> if [ -e $file0 ];then >>> cat $file0 >>> fi >>> if [ -e $file1 ];then >>> cat $file1 >>> fi >>> done >> >> Hello Jianchao, >> >> Thanks for having shared a reproducer. However, the approach of the patch you >> posted doesn't seem like the right approach to me. I propose to proceed as >> follows: >> * Convert the reproducer into a blktests test and submit is as a patch to the >> blktests project (https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_osandov_blktests&d=DwIGaQ&c=RoP1YumCXCgaWHvlZYR8PZh8Bv7qIrMUB65eapI_JnE&r=7WdAxUBeiTUTCy8v-7zXyr4qk7sx26ATvfo6QSTvZyQ&m=_TjwODcX-0o-OZfrVTFMpvbS0QbYxoya17aHM9pZAXw&s=wdVpTkE6PJX3GXvjXNwEup3opdflyCGY324CAYXSixY&e=). >> * Remove the mutex_lock/unlock(&sysfs_lock) calls from blk_cleanup_queue(). >> These calls are useless. Block drivers are required to call del_gendisk() >> before calling blk_cleanup_queue(). That means that sysfs attributes are >> removed synchronously before blk_cleanup_queue() is called. The following >> statement in blk_cleanup_queue() verifies that: >> WARN_ON_ONCE(q->kobj.state_in_sysfs); >> BTW, this also means that the blk_queue_dying() checks in various show and >> store methods are superfluous. >> * Introduce a new mutex to serialize blk_mq_register_dev() and >> blk_mq_sysfs_register() and blk_mq_sysfs_unregister(). I think it is wrong >> that these functions use sysfs_mutex. >> * Document the purpose of sysfs_mutex in include/linux/blkdev.h, namely to >> serialize the sysfs .show() and .store() callback functions and also to >> serialize elevator changes. >> > > Really appreciate your kindly and detailed directive. > I will post the V2 version based on your suggestions later. > V2 patch has been posted, would you please take a look at on them ? https://marc.info/?l=linux-block&m=152965143412927&w=2 In addition, it is hard to add test case for this issue in blktests, because it is hard to decide how many times or how long time to run the test two scripts. If too long, it may delay the whole test, if too short, the issue may cannot be exposed. Thanks Jianchao