Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp4487445ybx; Mon, 4 Nov 2019 14:14:38 -0800 (PST) X-Google-Smtp-Source: APXvYqyXS0DMKV/ePjVZk6UEM+hLfX99VZUiTmYEE39HG8+MSPVDjWzvGqf2817C2DfryCDTQDPE X-Received: by 2002:a17:906:1982:: with SMTP id g2mr26351183ejd.254.1572905678538; Mon, 04 Nov 2019 14:14:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572905678; cv=none; d=google.com; s=arc-20160816; b=0Pa2YK6DeOHjrdWEZcHnMj/PCGBqkIP8MewF/XebhbMswD3uTIy7OHwFkddOHC6hDN xfKSsHeKZjn4KF+BleSAuy29c2FJ6UD42J4QEmTPeFVcIbLraJpFzewLf96k4AZlIH63 l0thuM7B6RPDrOlZk3pDYGfKfd7jr7faesZ9oVSmvbYN4hhm/Lp8D/9bswdvb9FRC5gZ T8vSnCrJuXUT4gY7L2IYS5qjzhmd1N1tMEwgIZj92h9wUX05S96AakKw/MEroB8BSAuO E/Qg8mBiBjhlpJxpo7grcKrWwtZbq82CFbmJDuhSBuj8D6NKOYolhcmROUw22ixf7WSD qtqg== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=p+h/q0Xmc++LFMkreuJ4Ka+BgZN1X/CGpwzUodUf+vQ=; b=tq2mBltZgqwWa7dDua2qtzlZqXxHx+rk4jbI2GSBELaX/Momt/g6CCDlQTJTMXuQsO tOSz7sXsFfhoH+BhXNT3GvfFJcf1dxKoRrWH4BokdKKa8YgGx9M7PpgS0nv64/iGyoNA ZBNtv63raV+oAN17fQH2qD295xl+yrbb6MlpUldaFWvFpslqVqg6/SdnrXWs1yomIpFO NkDQdwhgGdd53TlqEQs6WNBFj6ipjH4UNaLAnSIvphemNOU7FVazODw3ZTJYaGOdNEBh gAWzsEK7ewWjXe5bq/zyXy0wH0+Nyk9LX/GZ7LFmHe+DnqKgXMgYtwkt7spT3rP25sl/ mNJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ClKwDdET; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b10si7493696eda.160.2019.11.04.14.14.14; Mon, 04 Nov 2019 14:14:38 -0800 (PST) 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=@kernel.org header.s=default header.b=ClKwDdET; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390372AbfKDWLb (ORCPT + 99 others); Mon, 4 Nov 2019 17:11:31 -0500 Received: from mail.kernel.org ([198.145.29.99]:44826 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390355AbfKDWL1 (ORCPT ); Mon, 4 Nov 2019 17:11:27 -0500 Received: from localhost (6.204-14-84.ripe.coltfrance.com [84.14.204.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5D6A320650; Mon, 4 Nov 2019 22:11:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572905485; bh=/fnF9QQKMvloVp+hOX+a33YssCR2+tqJVk7XpgMm03o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ClKwDdETHDdeTNiGpIv3v74HiMjbWVr73C5yrf+HfXNGZk0e++9HC5xkgam8QoZUg N7/DO7F3BQCe+csxm3gMTqinZCyFu1sY+PBlg3nAwStpivUUrTk6/YwyfEiy2+oZeB PfiBkbPQLjJMKxccltj6DCqxUUlnYi25lHOC8hQk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Leon Romanovsky , Jason Gunthorpe , Sasha Levin Subject: [PATCH 5.3 162/163] RDMA/mlx5: Use irq xarray locking for mkey_table Date: Mon, 4 Nov 2019 22:45:52 +0100 Message-Id: <20191104212152.049781479@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191104212140.046021995@linuxfoundation.org> References: <20191104212140.046021995@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jason Gunthorpe [ Upstream commit 1524b12a6e02a85264af4ed208b034a2239ef374 ] The mkey_table xarray is touched by the reg_mr_callback() function which is called from a hard irq. Thus all other uses of xa_lock must use the _irq variants. WARNING: inconsistent lock state 5.4.0-rc1 #12 Not tainted -------------------------------- inconsistent {IN-HARDIRQ-W} -> {HARDIRQ-ON-W} usage. python3/343 [HC0[0]:SC0[0]:HE1:SE1] takes: ffff888182be1d40 (&(&xa->xa_lock)->rlock#3){?.-.}, at: xa_erase+0x12/0x30 {IN-HARDIRQ-W} state was registered at: lock_acquire+0xe1/0x200 _raw_spin_lock_irqsave+0x35/0x50 reg_mr_callback+0x2dd/0x450 [mlx5_ib] mlx5_cmd_exec_cb_handler+0x2c/0x70 [mlx5_core] mlx5_cmd_comp_handler+0x355/0x840 [mlx5_core] [..] Possible unsafe locking scenario: CPU0 ---- lock(&(&xa->xa_lock)->rlock#3); lock(&(&xa->xa_lock)->rlock#3); *** DEADLOCK *** 2 locks held by python3/343: #0: ffff88818eb4bd38 (&uverbs_dev->disassociate_srcu){....}, at: ib_uverbs_ioctl+0xe5/0x1e0 [ib_uverbs] #1: ffff888176c76d38 (&file->hw_destroy_rwsem){++++}, at: uobj_destroy+0x2d/0x90 [ib_uverbs] stack backtrace: CPU: 3 PID: 343 Comm: python3 Not tainted 5.4.0-rc1 #12 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.12.1-0-ga5cab58e9a3f-prebuilt.qemu.org 04/01/2014 Call Trace: dump_stack+0x86/0xca print_usage_bug.cold.50+0x2e5/0x355 mark_lock+0x871/0xb50 ? match_held_lock+0x20/0x250 ? check_usage_forwards+0x240/0x240 __lock_acquire+0x7de/0x23a0 ? __kasan_check_read+0x11/0x20 ? mark_lock+0xae/0xb50 ? mark_held_locks+0xb0/0xb0 ? find_held_lock+0xca/0xf0 lock_acquire+0xe1/0x200 ? xa_erase+0x12/0x30 _raw_spin_lock+0x2a/0x40 ? xa_erase+0x12/0x30 xa_erase+0x12/0x30 mlx5_ib_dealloc_mw+0x55/0xa0 [mlx5_ib] uverbs_dealloc_mw+0x3c/0x70 [ib_uverbs] uverbs_free_mw+0x1a/0x20 [ib_uverbs] destroy_hw_idr_uobject+0x49/0xa0 [ib_uverbs] [..] Fixes: 0417791536ae ("RDMA/mlx5: Add missing synchronize_srcu() for MW cases") Link: https://lore.kernel.org/r/20191024234910.GA9038@ziepe.ca Acked-by: Leon Romanovsky Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin --- drivers/infiniband/hw/mlx5/mr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/mr.c index c15d05f61cc7b..a6198fe7f3768 100644 --- a/drivers/infiniband/hw/mlx5/mr.c +++ b/drivers/infiniband/hw/mlx5/mr.c @@ -1975,8 +1975,8 @@ int mlx5_ib_dealloc_mw(struct ib_mw *mw) int err; if (IS_ENABLED(CONFIG_INFINIBAND_ON_DEMAND_PAGING)) { - xa_erase(&dev->mdev->priv.mkey_table, - mlx5_base_mkey(mmw->mmkey.key)); + xa_erase_irq(&dev->mdev->priv.mkey_table, + mlx5_base_mkey(mmw->mmkey.key)); /* * pagefault_single_data_segment() may be accessing mmw under * SRCU if the user bound an ODP MR to this MW. -- 2.20.1