From patchwork Thu Feb 7 05:37:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Davidlohr Bueso X-Patchwork-Id: 10800375 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4424D13B4 for ; Thu, 7 Feb 2019 05:38:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 305002ABFC for ; Thu, 7 Feb 2019 05:38:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F0F42C557; Thu, 7 Feb 2019 05:38:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 928492ABFC for ; Thu, 7 Feb 2019 05:38:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BD2F48E001B; Thu, 7 Feb 2019 00:38:37 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B59728E0002; Thu, 7 Feb 2019 00:38:37 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A48998E001B; Thu, 7 Feb 2019 00:38:37 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by kanga.kvack.org (Postfix) with ESMTP id 5D7B38E0002 for ; Thu, 7 Feb 2019 00:38:37 -0500 (EST) Received: by mail-ed1-f69.google.com with SMTP id c34so3758571edb.8 for ; Wed, 06 Feb 2019 21:38:37 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=XTzdyLtai2BUGlbOWdmDrFpkGiuimymKU9xYTKalbrg=; b=QQpdQpgd8TN6MCL2yUTmE2ikX7Sn/YMf+/8zRt1AN0XFwkBnRNex2iPanm4mCsLbql NNKju0etBnadztfxB+KvVFJrHwcEERReeR7rG7qMqP9zciSx62h/P59YX57oRT7ycAtc M/162jdZ6CfU0Yv56flBxa/hiOqpJWRHAi1dfVekMCVQQo1UIjQImh/flcemibgR6R9Z WQTkukc+qsXMB55HUqc1+2ngwbhfjbzehwtRth49ORLs5Iij7OImgodPEdlPflgaApMs udzMjMWZ8t82h25M3YC6pCvc4lsrD1u4pMPrYgioM0Ge+AqIlyetWWUhD9k4il/CUeJi /XNQ== X-Original-Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning dave@stgolabs.net does not designate 195.135.221.5 as permitted sender) smtp.mailfrom=dave@stgolabs.net X-Gm-Message-State: AHQUAuYRc19KSTkwr3y+QF6amKRGsZL0R0VSHXRFoX2hgUZRZgvWsS2r Z2LdktvNhwELjI/MejyA3yUrLK0keIZuIntJZUxhFv8rezbxkfncXVy5ME0Z5y+WLULgjOLiK2I FGzcvB6fjNWRwJl/BFdnSh+VKYjoJX6l1GP/BmX5dkMwHDwdpS+vTxd19tziImT0= X-Received: by 2002:a17:906:28c9:: with SMTP id p9mr6411483ejd.77.1549517916884; Wed, 06 Feb 2019 21:38:36 -0800 (PST) X-Google-Smtp-Source: AHgI3IaJsuAkNTkt2L6wESQ0hJ32pVWwfoS1bzWGMcFSjaqKYjvlfB7u8yI2H05CqEBsVD/k4CMW X-Received: by 2002:a17:906:28c9:: with SMTP id p9mr6411434ejd.77.1549517915978; Wed, 06 Feb 2019 21:38:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549517915; cv=none; d=google.com; s=arc-20160816; b=o9/+r8/sh7FHIlgrdtzBcHjsIInD1vJUf5Ozorw9qP4B9cEpCxDVPhFEjyVqKKZAS3 870z8Y2BPynuS1iENFGsEnSV4Amj7MydbfhoZ2eGbov4NfephTs8a3iYqpgfD6Ufyj4v hPv2VJNa0tY1I01uUBGHhIvXrqdTRQ+WAaiO7gatuvbkWfC6IGg7v5sPNoefVPi61Hh3 Htg/xm/3+9krOO9LrF8TBCXFEUWTyI59VaoCnrpOhGk/YKo7ltp77N4WbpiFHUUAZJn1 QYxVjLAQzUw8wAvKSZd9yfuNBmhpdeX8GmD+NIi+41oie3FzziWhWnO9WwleInczTda3 XxNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=XTzdyLtai2BUGlbOWdmDrFpkGiuimymKU9xYTKalbrg=; b=gETUWbLd4MoQmcF8IW1FAJw+n7bwu94AfRHzXnFbsiXD5j2JiCmyswEdKxIZkX/h+d SJCkS02R86vB46tN6k02Ns2txa3+rC49kcABAvOvdEQFAHJzoppP7ECyQgoBqfBnhk0R HtviyS4wGJz5zcO2KebzYsBGTVfURfVfb0ogdM0V23kbCN10sF8LMeoiqhYhhB+iAQTN Rf3lcvfuSxDMJMC31LIZ+p/WdifgWwb6/xzlO6yfw5OdVpDRxlutUVL1T91+yGvF2uN4 YBneV9lCkM/FKM0mGc/gFNkkJa625HPUwa+cBO7iAq7Lqax+xWLAC43ZB1ynuMPuJMxQ XLow== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning dave@stgolabs.net does not designate 195.135.221.5 as permitted sender) smtp.mailfrom=dave@stgolabs.net Received: from smtp.nue.novell.com (smtp.nue.novell.com. [195.135.221.5]) by mx.google.com with ESMTPS id g13si6595976edk.370.2019.02.06.21.38.35 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Feb 2019 21:38:35 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning dave@stgolabs.net does not designate 195.135.221.5 as permitted sender) client-ip=195.135.221.5; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning dave@stgolabs.net does not designate 195.135.221.5 as permitted sender) smtp.mailfrom=dave@stgolabs.net Received: from emea4-mta.ukb.novell.com ([10.120.13.87]) by smtp.nue.novell.com with ESMTP (TLS encrypted); Thu, 07 Feb 2019 06:38:35 +0100 Received: from localhost.localdomain (nwb-a10-snat.microfocus.com [10.120.13.201]) by emea4-mta.ukb.novell.com with ESMTP (TLS encrypted); Thu, 07 Feb 2019 05:38:02 +0000 From: Davidlohr Bueso To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, dave@stgolabs.net, linux-kernel@vger.kernel.org, "David S . Miller" , Bjorn Topel , Magnus Karlsson , netdev@vger.kernel.org, Davidlohr Bueso Subject: [PATCH 1/2] xsk: do not use mmap_sem Date: Wed, 6 Feb 2019 21:37:39 -0800 Message-Id: <20190207053740.26915-2-dave@stgolabs.net> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190207053740.26915-1-dave@stgolabs.net> References: <20190207053740.26915-1-dave@stgolabs.net> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Holding mmap_sem exclusively for a gup() is an overkill. Lets replace the call for gup_fast() and let the mm take it if necessary. 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, 2 insertions(+), 4 deletions(-) diff --git a/net/xdp/xdp_umem.c b/net/xdp/xdp_umem.c index 5ab236c5c9a5..25e1e76654a8 100644 --- a/net/xdp/xdp_umem.c +++ b/net/xdp/xdp_umem.c @@ -265,10 +265,8 @@ 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, - gup_flags, &umem->pgs[0], NULL); - up_write(¤t->mm->mmap_sem); + npgs = get_user_pages_fast(umem->address, umem->npgs, + gup_flags, &umem->pgs[0]); if (npgs != umem->npgs) { if (npgs >= 0) { From patchwork Thu Feb 7 05:37:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Davidlohr Bueso X-Patchwork-Id: 10800377 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BE2A2922 for ; Thu, 7 Feb 2019 05:38:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AE8F52ABFC for ; Thu, 7 Feb 2019 05:38:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A297A2C557; Thu, 7 Feb 2019 05:38:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0D6372ABFC for ; Thu, 7 Feb 2019 05:38:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AED618E001C; Thu, 7 Feb 2019 00:38:39 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A97DF8E0002; Thu, 7 Feb 2019 00:38:39 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 912178E001C; Thu, 7 Feb 2019 00:38:39 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by kanga.kvack.org (Postfix) with ESMTP id 37A6C8E0002 for ; Thu, 7 Feb 2019 00:38:39 -0500 (EST) Received: by mail-ed1-f72.google.com with SMTP id m19so3850706edc.6 for ; Wed, 06 Feb 2019 21:38:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=XjTZPZGlz/MNyU6aOr7ZZyAeRmtbqpb7D/yFa34GyFM=; b=c/rH5aPmeNNOxD/hWafdxz0VIFueeZtlcBi/aaCnYzZ5QTuHOblvlCyJzV/QXFLowp R8mq1BkmH9IWoEOxq/KaLhjYGCOzseA5eHzkeHeVvW1l/pGTug8XsA3xieto3llRuuUu MLSWN7G5Psxh2yc2ZY1lHggXXjfAK21ctaW0ytfXoj/6dbaPr6QTAM5VSaI5WtAyKcf9 ws9sA4mKsYJRSzNs06bGkgiHlnLSN9Ms49OGGkCrK9h3P8aW4CpjoT+VS/VPJXq/ubII lcTolSYrYZKRlgHP3svugbMaGC7DhpU1JyinMxlDirXNw9XP8WYGyqMgwCyi47o25pXD CfNA== X-Original-Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning dave@stgolabs.net does not designate 195.135.221.5 as permitted sender) smtp.mailfrom=dave@stgolabs.net X-Gm-Message-State: AHQUAuYOcJVSWnd7XriN6L6CDWVEdtd3tvnK/CLc3MATAcfcls55ssKb ATNHjqGCerfK2jwMlpLFfg2DCbXu1LodGr4Qc1a3MQYpmFjwPlsZc15NiaMLJWSz9mWchhp0uhk sKo4Qy+Z9Nz30+YLradnOPFHWyGW+uAhWEHUem84tbkVXhFtN35xQGDEspMDbQpo= X-Received: by 2002:a05:6402:1347:: with SMTP id y7mr11043750edw.114.1549517918729; Wed, 06 Feb 2019 21:38:38 -0800 (PST) X-Google-Smtp-Source: AHgI3IYKqzn9IEpqAR0mtnlI+yD+9akH08xpX+yV1VfxpD++69kTjTULOPByjODy8fhwok0jXIbK X-Received: by 2002:a05:6402:1347:: with SMTP id y7mr11043707edw.114.1549517917858; Wed, 06 Feb 2019 21:38:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549517917; cv=none; d=google.com; s=arc-20160816; b=F+O0tRxRq7v4/108uPOJUfxDpCmcNNEV4cv5kBccOn94g8nI5eFyoIuRnWg9HfClNp mvrwIJ44D61Q4P8Ansf/N7pdUOCyZXb/AC76Nmeg7PMbw70vO2X92/Yg73juTrColJwG 85kbDKvXco5EBSajwdmuKu/4HsehmKO6sn0KqHQIRnDEOkuZoP3FPF7m27bc5QgEPxSJ IwQ3CV+xkUPjihAuINpGNU2b/jjMSjT5DS7qEcCCWky6aEIVKEJRP2AsFcXTxMLtgnQ5 6hUALeLLdwEwG0xd3rh6GcmHkhY5gnHpGRvGJkzGT9fzx+szc1zTaIjiyVT7qkPVD3I7 yzMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=XjTZPZGlz/MNyU6aOr7ZZyAeRmtbqpb7D/yFa34GyFM=; b=z2zH2QDv0Rd1tkEUXXo0ehjQo5RBq/DqSaiSXB8f+6gC3IC5gr1R4IIAFNJKoDjZqS /p/6wd7y+0i9UKsZaoCmigTKWsg0DywbjcjWJkI6ycRMMMMzjEf7WO3L8PXTA6DubKJa 3fmZh5NqJCo3JmxVOtqzMUZGYkECgqTTUpHBbEQ1UiTQZdX6SZSACLZdL++PDw+dhue6 +6dfr+lgkvZGDbJKPiWQTuBgar8MPus26fllCSFJ0u8y8K+H21mg1pqpkt7VUVl1tzE4 E7hLFytQ0CPVzwzGL/zIRSHs+2GhSK7pVH/lvDFvQ2/MkErb/OK4uL+d7p7cTWzeYdnv xuVg== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning dave@stgolabs.net does not designate 195.135.221.5 as permitted sender) smtp.mailfrom=dave@stgolabs.net Received: from smtp.nue.novell.com (smtp.nue.novell.com. [195.135.221.5]) by mx.google.com with ESMTPS id b17si1362602ejj.243.2019.02.06.21.38.37 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Feb 2019 21:38:37 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning dave@stgolabs.net does not designate 195.135.221.5 as permitted sender) client-ip=195.135.221.5; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning dave@stgolabs.net does not designate 195.135.221.5 as permitted sender) smtp.mailfrom=dave@stgolabs.net Received: from emea4-mta.ukb.novell.com ([10.120.13.87]) by smtp.nue.novell.com with ESMTP (TLS encrypted); Thu, 07 Feb 2019 06:38:36 +0100 Received: from localhost.localdomain (nwb-a10-snat.microfocus.com [10.120.13.201]) by emea4-mta.ukb.novell.com with ESMTP (TLS encrypted); Thu, 07 Feb 2019 05:38:05 +0000 From: Davidlohr Bueso To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, dave@stgolabs.net, linux-kernel@vger.kernel.org, Ralf Baechle , Paul Burton , James Hogan , linux-mips@vger.kernel.org, Davidlohr Bueso Subject: [PATCH 2/2] MIPS/c-r4k: do no use mmap_sem for gup_fast() Date: Wed, 6 Feb 2019 21:37:40 -0800 Message-Id: <20190207053740.26915-3-dave@stgolabs.net> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190207053740.26915-1-dave@stgolabs.net> References: <20190207053740.26915-1-dave@stgolabs.net> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP It is well known that because the mm can internally call the regular gup_unlocked if the lockless approach fails and take the sem there, the caller must not hold the mmap_sem already. Fixes: e523f289fe4d (MIPS: c-r4k: Fix sigtramp SMP call to use kmap) Cc: Ralf Baechle Cc: Paul Burton Cc: James Hogan Cc: linux-mips@vger.kernel.org Signed-off-by: Davidlohr Bueso --- arch/mips/mm/c-r4k.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/arch/mips/mm/c-r4k.c b/arch/mips/mm/c-r4k.c index cc4e17caeb26..38fe86928837 100644 --- a/arch/mips/mm/c-r4k.c +++ b/arch/mips/mm/c-r4k.c @@ -1034,11 +1034,9 @@ static void r4k_flush_cache_sigtramp(unsigned long addr) struct flush_cache_sigtramp_args args; int npages; - down_read(¤t->mm->mmap_sem); - npages = get_user_pages_fast(addr, 1, 0, &args.page); if (npages < 1) - goto out; + return; args.mm = current->mm; args.addr = addr; @@ -1046,8 +1044,6 @@ static void r4k_flush_cache_sigtramp(unsigned long addr) r4k_on_each_cpu(R4K_HIT, local_r4k_flush_cache_sigtramp, &args); put_page(args.page); -out: - up_read(¤t->mm->mmap_sem); } static void r4k_flush_icache_all(void)