Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2775751imj; Mon, 11 Feb 2019 08:17:07 -0800 (PST) X-Google-Smtp-Source: AHgI3Ibd/jh8XufabcUcTyHZbmVRPEBWdzwpMjSlgPiGM1Rxd9l7OCp27v/PAwa5Mmw7BX+WVNgE X-Received: by 2002:a63:5518:: with SMTP id j24mr30521417pgb.208.1549901827759; Mon, 11 Feb 2019 08:17:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549901827; cv=none; d=google.com; s=arc-20160816; b=YAu3BpjUEEjJvczxY7QM/MsHerFQ+VDORG8UyFdTcAgDQVwt9JVNf9LVVtDHZ9d36B J0A0bdJW74qKmgceCV9/amJOOxZl+3PyE74TWuUWN5m/786Fq/NaKFtja+8Ejhb13Hz1 JhqUhe4PpoRuXqsnqpVD2ys9jG8hAi1Q6wyzdb0b672ADyJmsDl3+PXCPvjAPrIRc6zy g6UngYn7kwHXOGdO9qCjzeOvtYebhoVlbAn0265b3gg1hDzKJ1bEJhR8KLDM1MvkU1rw j0dSVB5g5HQ1yPNYyGLgEaoW2l4HnyMvmL3COs+EVlK7Bp3F9m1KYr7WAFq/lfSogbGB F1zQ== 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:mail-followup-to :message-id:subject:cc:to:from:date; bh=fC1fZt+IZT11l29dIaesmc+ItFE/dY5U8P2pwMDCNrs=; b=BvUKT9P8xbZfFl/76dtyk1jWUsdN2ZHBLf91YV1F4r2k0kTrlag0FkfB6SD6KGcG0K bi0zcr9xCn7jKiYo19ZubdYh2eEXtB3IvV6lpexx48J8XIfVXfo/LTxZ7O0eFVgamelF HD2wMZ5MSPBlnB9v4Ou/raK4JSNBDEagb5Y7roLeOkFigf0KpVBIcAQQa5mNspouCnq4 0fucol6qWpRpJ7zZ0yCOx/a3JzIDdyk2b2gdLqX1Vb1+/hc3LA70MUkZe9g7OyEBE++E ci6o1ebocs9VlRct7Zr0vOHcZlT/WK40/8WcL8R1KnHuCVevcxUU+D+tNMqc1yCF8d7d oziA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e4si9048186pgs.492.2019.02.11.08.16.47; Mon, 11 Feb 2019 08:17:07 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729303AbfBKQPm (ORCPT + 99 others); Mon, 11 Feb 2019 11:15:42 -0500 Received: from mx2.suse.de ([195.135.220.15]:55904 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727887AbfBKQPm (ORCPT ); Mon, 11 Feb 2019 11:15:42 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 6684CAC8D; Mon, 11 Feb 2019 16:15:40 +0000 (UTC) Date: Mon, 11 Feb 2019 08:15:29 -0800 From: Davidlohr Bueso To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, "David S . Miller" , Bjorn Topel , Magnus Karlsson , netdev@vger.kernel.org, Davidlohr Bueso Subject: [PATCH v2] xsk: share the mmap_sem for page pinning Message-ID: <20190211161529.uskq5ca7y3j5522i@linux-r8p5> Mail-Followup-To: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, "David S . Miller" , Bjorn Topel , Magnus Karlsson , netdev@vger.kernel.org, Davidlohr Bueso References: <20190207053740.26915-1-dave@stgolabs.net> <20190207053740.26915-2-dave@stgolabs.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20190207053740.26915-2-dave@stgolabs.net> User-Agent: NeoMutt/20180323 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Holding mmap_sem exclusively for a gup() is an overkill. Lets share the lock and replace the gup call for gup_longterm(), as it is better suited for the lifetime of the pinning. Cc: David S. Miller Cc: Bjorn Topel Cc: Magnus Karlsson CC: netdev@vger.kernel.org Signed-off-by: Davidlohr Bueso --- net/xdp/xdp_umem.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/xdp/xdp_umem.c b/net/xdp/xdp_umem.c index 5ab236c5c9a5..e7fa8d0d7090 100644 --- a/net/xdp/xdp_umem.c +++ b/net/xdp/xdp_umem.c @@ -265,10 +265,10 @@ static int xdp_umem_pin_pages(struct xdp_umem *umem) if (!umem->pgs) return -ENOMEM; - down_write(¤t->mm->mmap_sem); - npgs = get_user_pages(umem->address, umem->npgs, + down_read(¤t->mm->mmap_sem); + npgs = get_user_pages_longterm(umem->address, umem->npgs, gup_flags, &umem->pgs[0], NULL); - up_write(¤t->mm->mmap_sem); + up_read(¤t->mm->mmap_sem); if (npgs != umem->npgs) { if (npgs >= 0) { -- 2.16.4