Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753574AbdHQUmD (ORCPT ); Thu, 17 Aug 2017 16:42:03 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:3725 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752632AbdHQUmA (ORCPT ); Thu, 17 Aug 2017 16:42:00 -0400 X-IronPort-AV: E=Sophos;i="5.41,389,1498492800"; d="scan'208";a="43192435" From: Bart Van Assche To: "longman@redhat.com" , "rostedt@goodmis.org" CC: "bfields@fieldses.org" , "mingo@kernel.org" , "jlayton@poochiereds.net" , "linux-block@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "axboe@kernel.dk" , "linux-fsdevel@vger.kernel.org" Subject: Re: [PATCH v2] blktrace: Fix potentail deadlock between delete & sysfs ops Thread-Topic: [PATCH v2] blktrace: Fix potentail deadlock between delete & sysfs ops Thread-Index: AQHTFtAejxW6mY/MvEitlZ7OnTs8A6KIjYsAgAAveoCAAETPAIAAAtuA Date: Thu, 17 Aug 2017 20:41:10 +0000 Message-ID: <1503002469.2615.13.camel@wdc.com> References: <1502916040-18067-1-git-send-email-longman@redhat.com> <20170817093444.3276f7ab@gandalf.local.home> <20170817163056.19ea42c8@gandalf.local.home> In-Reply-To: <20170817163056.19ea42c8@gandalf.local.home> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Bart.VanAssche@wdc.com; x-originating-ip: [63.163.107.100] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;BY1PR0401MB1529;20:GD4cndzykyUmYqYK8O97RxDOqwyepLq0C4VeVSg2gii8l6uCAtR/Sy8iiaAV4tEFqqbjvn2m+5iB2UIgUyOy9uPVUYasICQOoccxp7dNcFdwvWKubom8vcWBVjKzoMeZBbHjjJmPoCOZMPWL1brWpIODI4lkAfXT+/SBzz7D7b8= x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-correlation-id: eb1c5b16-6c1e-400c-ea9e-08d4e5b04b4e x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(2017052603031)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:BY1PR0401MB1529; x-ms-traffictypediagnostic: BY1PR0401MB1529: wdcipoutbound: EOP-TRUE x-exchange-antispam-report-test: UriScan:; x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(93006095)(93001095)(100000703101)(100105400095)(6055026)(6041248)(20161123555025)(201703131423075)(201703011903075)(201702281528075)(201703061421075)(20161123564025)(20161123562025)(20161123558100)(20161123560025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:BY1PR0401MB1529;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:BY1PR0401MB1529; x-forefront-prvs: 0402872DA1 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(39860400002)(199003)(189002)(377424004)(24454002)(377454003)(6506006)(6436002)(106356001)(2906002)(103116003)(2900100001)(105586002)(189998001)(86362001)(66066001)(3660700001)(229853002)(3846002)(6116002)(102836003)(97736004)(3280700002)(2950100002)(68736007)(6486002)(53936002)(508600001)(6246003)(53546010)(5660300001)(93886005)(7736002)(5250100002)(2501003)(4326008)(33646002)(50986999)(54356999)(76176999)(14454004)(101416001)(72206003)(81156014)(25786009)(54906002)(8676002)(81166006)(99286003)(305945005)(6512007)(36756003)(8936002);DIR:OUT;SFP:1102;SCL:1;SRVR:BY1PR0401MB1529;H:BY1PR0401MB1532.namprd04.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="utf-8" Content-ID: MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Aug 2017 20:41:10.4675 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0401MB1529 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by nfs id v7HKgHql002031 Content-Length: 1979 Lines: 42 On Thu, 2017-08-17 at 16:30 -0400, Steven Rostedt wrote: > On Thu, 17 Aug 2017 12:24:39 -0400 > Waiman Long wrote: > > > On 08/17/2017 09:34 AM, Steven Rostedt wrote: > > > On Wed, 16 Aug 2017 16:40:40 -0400 > > > Waiman Long wrote: > > > > > > > The lockdep code had reported the following unsafe locking scenario: > > > > > > > > CPU0 CPU1 > > > > ---- ---- > > > > lock(s_active#228); > > > > lock(&bdev->bd_mutex/1); > > > > lock(s_active#228); > > > > lock(&bdev->bd_mutex); > > > > > > Can you show the exact locations of these locks. I have no idea where > > > this "s_active" is. > > > > The s_active isn't an actual lock. It is a reference count (kn->count) > > on the sysfs (kernfs) file. Removal of a sysfs file, however, require > > a wait until all the references are gone. The reference count is > > treated like a rwsem using lockdep instrumentation code. > > Which kernel is this? I don't see any lockdep annotation around > kn->count (doing a git grep, I find it referenced in fs/kernfs/dir.c) As far as I know the s_active lockdep annotations were introduced in 2007 through commit 0ab66088c855 ("sysfs: implement sysfs_dirent active reference and immediate disconnect"). Today these annotations exist in kernfs: $ git grep -nHw dep_map fs/kernfs fs/kernfs/dir.c:421: rwsem_acquire_read(&kn->dep_map, 0, 1, _RET_IP_); fs/kernfs/dir.c:441: rwsem_release(&kn->dep_map, 1, _RET_IP_); fs/kernfs/dir.c:468: rwsem_acquire(&kn->dep_map, 0, 0, _RET_IP_); fs/kernfs/dir.c:470: lock_contended(&kn->dep_map, _RET_IP_); fs/kernfs/dir.c:478: lock_acquired(&kn->dep_map, _RET_IP_); fs/kernfs/dir.c:479: rwsem_release(&kn->dep_map, 1, _RET_IP_); fs/kernfs/dir.c:1385: rwsem_acquire(&kn->dep_map, 0, 1, _RET_IP_); fs/kernfs/file.c:1000: lockdep_init_map(&kn->dep_map, "s_active", key, 0); Bart.