Received: by 10.223.176.46 with SMTP id f43csp2457301wra; Thu, 25 Jan 2018 10:07:08 -0800 (PST) X-Google-Smtp-Source: AH8x225Cvhx6yGoGvgiah89S4yI5vfXE8uu508mbmZ+Fp3no/kU5FiQk5wLReN14uUpDhZqSS/Yi X-Received: by 10.98.101.71 with SMTP id z68mr16791732pfb.181.1516903628178; Thu, 25 Jan 2018 10:07:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516903628; cv=none; d=google.com; s=arc-20160816; b=ebUSIoOJd+qxgs9sSaRP6Sr7rTF7QqIgRB94W/Oq78Inx/oc5wob9PIhGQa7czujls AiK6JXfnHUmmT8+gZTQPmR0E9VW8rPwNbD2nt5oMFVqGLbQv5hFqwwC6eydlmKcWEs2T yIgsp335wZ9PG7sWdtdc3OLZCUulm9S+mM9YvUX6sZJfuoAv5GyzOFLenBz9LFw+3gfA 1kk8LeOjQuO47x+LoW+LnbOj3z6rghzsjK4m47TL6GCoVIARNSO7ce5zMTBTwTtNwax1 HrLXAlhhDC70gIn8m1bboJ0nNkQMeDext72otB6BjJNQLTdYPGE8hxgB1VIFroYyXGVm dgtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:organization:references :in-reply-to:date:cc:to:from:subject:message-id :arc-authentication-results; bh=XXlAL0hmcRMgVOKGbbQGAnMQqzS/O9ST7DxOFeT7sH4=; b=WsrtadTyXOjCBSmBDHnl4x9JqEiVz5EQCVZIh4b0eGqbwIQ9qbexVV2Z0l8Fa3QyBz a88nHqHStpr1XF40HzjdIvvOFq10o1fJmnJV+RTDHK5iMjidmRKla4PA/7+LyteM+jsu vCMtYFJ2QiLkC+SbNZuXCCRmICu/hfM131Tcz8W3PLqWrDnsO23J9KK2GhtCAjUz+KdD a7EIX/OaBa0BK07evcYUKrjVyj9YUZzCT2y/qfEfRiCmuqgg2lGJWc7jw6TR2R9Dl5h1 PNAxIXghu6obVCUhijcHoV0ZZYP8E0uAcbd+1LPgNYgAHJHRvS7gG1Tz9y2gMEbH+tNM QC1w== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 77si4973863pfs.2.2018.01.25.10.06.53; Thu, 25 Jan 2018 10:07:08 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751457AbeAYSG2 (ORCPT + 99 others); Thu, 25 Jan 2018 13:06:28 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39690 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751174AbeAYSG0 (ORCPT ); Thu, 25 Jan 2018 13:06:26 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 344448FAC0; Thu, 25 Jan 2018 18:06:26 +0000 (UTC) Received: from haswell-e.nc.xsintricity.com (ovpn-120-73.rdu2.redhat.com [10.10.120.73]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5B5221711B; Thu, 25 Jan 2018 18:06:25 +0000 (UTC) Message-ID: <1516903584.27592.183.camel@redhat.com> Subject: Re: [PATCH] IB/mthca: Fix how mthca_map_user_db() calls gup From: Doug Ledford To: Jason Gunthorpe Cc: Davidlohr Bueso , roland@purestorage.com, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, Davidlohr Bueso Date: Thu, 25 Jan 2018 13:06:24 -0500 In-Reply-To: <20180125175048.GG10706@ziepe.ca> References: <20180123205459.432-1-dave@stgolabs.net> <1516898063.27592.136.camel@redhat.com> <20180125175048.GG10706@ziepe.ca> Organization: Red Hat, Inc. Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-MfhINExRB/p9KXW47Ibv" Mime-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 25 Jan 2018 18:06:26 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-MfhINExRB/p9KXW47Ibv Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, 2018-01-25 at 10:50 -0700, Jason Gunthorpe wrote: > On Thu, Jan 25, 2018 at 11:34:23AM -0500, Doug Ledford wrote: > > > - Should I be wrong about no callers already holding mmap_sem, > > > I still think calling gup without the mutex makes sense for > > > improved paralellism. Now, if callers can hold the mmap_sem, > > > it's wrong to do copy_from_user right before calling mthca_map_user= _db. > >=20 > > So, if I understand you correctly, we (well, you and Al would be more > > correct, we haven't looked into the situation yet, so Mellanox people > > that worked on this in the day might now, or someone taking the time to > > research it could find out) don't have a clear understanding of all the > > conditions this function is called under, and so we actually don't know > > what the best way forward is to fix it? >=20 > I looked at it enough to be confident that mthca_map_user_db is never > called with mmap_sem held. >=20 > Also pretty confident that mthca_unmap_user_db is never called with > mmap_sem. >=20 > So how about just grabbing mmap_sem around the call to get_user_pages > and no other changes? Since the original post was referred to an ABBA deadlock, wouldn't we have to drop db_tab->mutex, then grab both in the proper order? --=20 Doug Ledford GPG KeyID: B826A3330E572FDD Key fingerprint =3D AE6B 1BDA 122B 23B4 265B 1274 B826 A333 0E57 2FDD --=-MfhINExRB/p9KXW47Ibv Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEErmsb2hIrI7QmWxJ0uCajMw5XL90FAlpqHKAACgkQuCajMw5X L93PMxAAt1Z2i2YGiDziKaWivoDg3b7O5olASdhV6CbCYPBm2XrBWBCixJ95baBl ZSNVGGd+GGWFsoSPO6aKDWDwVoFl6zxIYI93C6YNQQIo2uoX+h8HzQSCb1UN2EPW a1G5oZ2ZwB4lc/wEs9fBCMxa7Tou8BWAOC47btI5KtdQvxkKGrPLYIhNyl02MNVc M/NU1vyNyKvuab6uPZDxZF6x8f2pJsQIenXZftpcAHfeuVxukmcyBC+fguGuOs2v OfLsDTisZl8n2wKEXXzRLmYjv+k5/FuFUpdgFPIh0t4XGNeu4wbYswMAnOuZTiQk zmqkYLXDk8y3PsDtzK2LVvqKrHQmCMmRevx1zB87JjndmcQ/RUmiYWrPrWjqKjSP POr+IZ4XxEDVq4vBAQtd/xwJuSsrB0/hVpbd10CzUgPBrQ/YBcxb8hs42H6N/R0x /YYiNaLnoGeu+H9Pun9nG3EYpdWZQKmAV/9j6ybTQAUaDyVIdRmFqxp7wSsK1Rng 2z7P/uYdIH5F8QpQgm8cycwMoPkZUUGUdLQk/G5GYjMtbelCiD/NhqeN4hK/yb3N XS2rxlhcXNd6FArOf5Pf8oGM+JOxIszVZPvOIwRzYwB1hJZOuHSQusNBqqoX+5sH H5fIJ6iB+whPjVhaZ8hK4pA9XIhTo2kMz6ILindS6oulrWAQwlI= =HSyc -----END PGP SIGNATURE----- --=-MfhINExRB/p9KXW47Ibv--