Received: by 10.223.176.46 with SMTP id f43csp2507110wra; Thu, 25 Jan 2018 10:54:43 -0800 (PST) X-Google-Smtp-Source: AH8x225LDC6AgH7PhHo11wUlyYgoz8ga5WfB2Us771NhK8XhlPUgkLG+nTiNUKJQNEShL3gP1R/x X-Received: by 10.99.65.134 with SMTP id o128mr5168087pga.323.1516906483728; Thu, 25 Jan 2018 10:54:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516906483; cv=none; d=google.com; s=arc-20160816; b=NFtLBKqeCUVwWnGXwQK8DZ32KCyoyyt2gCXIVqjV608FsTZ6zEAMV1wUX22hmqJrk5 55D9bjjthYFHFGR6vet9rV9pNkzO34hGsLOcFtAqoqffTWLi7y4oa3hLhdWZJ0IUw72S j/M3jNn8z9Oz2n3GP72uAq3NZNQ998ki2XR6+UynZipslUhMWlwFId2OSaklZRVUdFVN 23ftt21+tpW7ojdaZWdb/vump2MpHi4o2CgAe7u5Udq8b1Zpyh0bzbdtb2yiDAPQTpia Lyh7mNFq/OjNhf/rAR4qLZvW2OoShXs9ndR4TiiNUtpA+ktAfWcv5wvJvO/JwZ4EvUZQ 3X6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=zPPZTOv8bw+hReaLSuDLMnLVBcapl5phubBUHRtS1xY=; b=cAuMa3hl9fAiGblQoULntvOpfaXQBtWn/oShWCus4I1e+DoSgvK7lX/VIp6mOHIE8P 6LmA6FXK4TG1Nisi6Qez25jFO7eLxKnzIT/2hIkd8oN55u6Q+AEkExL4TRfmGUrQfcEg LxUU3bs+n6919k+cR4zvfbMC/34836lYQ9220y/khhwyidlG7KdCofXusP5KdMH9uax8 ydAyCeRPCLkWHLX1zU902aB8+GvixvhGy1rRwUDWGRFUniRlEm+B3maknbZ1mIVOg/2w FZK3EHpfAkVirEZXHgSWbTxNJRRabXlPak5FYQcVikVzyLX4NE3xjBW9OTTzEuJbv2Kb BZOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=nh5ZKqt/; 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 x75si5016315pfa.144.2018.01.25.10.54.30; Thu, 25 Jan 2018 10:54:43 -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=@ziepe.ca header.s=google header.b=nh5ZKqt/; 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 S1751267AbeAYSxk (ORCPT + 99 others); Thu, 25 Jan 2018 13:53:40 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:40332 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751011AbeAYSxi (ORCPT ); Thu, 25 Jan 2018 13:53:38 -0500 Received: by mail-wm0-f67.google.com with SMTP id v123so16775807wmd.5 for ; Thu, 25 Jan 2018 10:53:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=zPPZTOv8bw+hReaLSuDLMnLVBcapl5phubBUHRtS1xY=; b=nh5ZKqt/jjslVF9Cy0sKI42zgpd8DQmRA1/a4WOzui+gIIUR5xI3vEdESqcugc44EG qGf+YnDN4VBDWnPcOS3alb7Hm1oXF04z+HP/5EYHraZiLpRNVknAP6xE58OsMLc4o2mC hzZxmWswF9e5XkH1MaqgNaoWT1jFGBlKd/mxIbm8MAFCOZL0me1Mggo+e5R+IjLpDAPh dYA+M3HmIrSHcAGw7/HjA0GN95TRNY5S5QylH7lC296+gQX3XI/R/W9nHQk8tE4drlWQ xZbQ0Qm4DrVXsZON1ckt1Y3RNqAu6NqOiV9oAFcy8qwKdFrkGm6H2detp/4pQza7yKp5 PjEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=zPPZTOv8bw+hReaLSuDLMnLVBcapl5phubBUHRtS1xY=; b=Pc5D/Vg5z+wIbuJK4eCulAOlx/edE+CcLM1xXktANmCn3EBMtwrsSa710xhw8JzXUq OWL9pw4GbW47tsj1joQI1+5KJ0QpieoUiLM4Kq9Ky0cYfFYweFgeg2VK98RfsVH5LUmj i0JswX/6ldnx5KvzSEg/cE+J4NZVBFldN6aydUb11KlWDUDldhe2Yg5CdxxHkPEppzqN 9/UyVQyPlrH+Q1cJj1fWL3jQZWk51l0t8Pa0lWLHn+ZuYM3VM1MGq0pyTKFDzlX3IFAr 19EeFOf5M29GoSK8ly8JojszmOKOIFIMoquNZPc9on88x/SB59fkXUvV5orRU3fne6db R5SA== X-Gm-Message-State: AKwxytdxnsJ6oP92AgpFbyw/6zz1iZs2PO48UTH7lhVKSs+J92bAoMei XpP615cnNCeOEJrYHywY4tZi8w== X-Received: by 10.28.111.219 with SMTP id c88mr9351070wmi.41.1516906416399; Thu, 25 Jan 2018 10:53:36 -0800 (PST) Received: from ziepe.ca (S010614cc2056d97f.ed.shawcable.net. [70.74.179.152]) by smtp.gmail.com with ESMTPSA id d8sm7713897wra.22.2018.01.25.10.53.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Jan 2018 10:53:35 -0800 (PST) Received: from jgg by mlx.ziepe.ca with local (Exim 4.86_2) (envelope-from ) id 1eemeQ-0001vq-2K; Thu, 25 Jan 2018 11:53:30 -0700 Date: Thu, 25 Jan 2018 11:53:30 -0700 From: Jason Gunthorpe To: Doug Ledford Cc: Davidlohr Bueso , roland@purestorage.com, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, Davidlohr Bueso Subject: Re: [PATCH] IB/mthca: Fix how mthca_map_user_db() calls gup Message-ID: <20180125185330.GH10706@ziepe.ca> References: <20180123205459.432-1-dave@stgolabs.net> <1516898063.27592.136.camel@redhat.com> <20180125175048.GG10706@ziepe.ca> <1516903584.27592.183.camel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1516903584.27592.183.camel@redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 25, 2018 at 01:06:24PM -0500, Doug Ledford wrote: > 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. > > > > > > 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? > > > > I looked at it enough to be confident that mthca_map_user_db is never > > called with mmap_sem held. > > > > Also pretty confident that mthca_unmap_user_db is never called with > > mmap_sem. > > > > 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? I had understood that was only a concern because Davidlohr was having trouble proving the callchain didn't include mmap_sem already.. I can see the call chain all ends on verbs ops, and I know verbs ops with ucontext's are never called under mmap_sem by the core code.. Jason