Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp8959179ybi; Tue, 23 Jul 2019 18:55:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqyHV/x3S+94FCq/otHvXLTy1Ty1oG63lJTnxaRHyhOi6DQZMNI8x3qf98bU2XLYLJoERvr1 X-Received: by 2002:a62:1652:: with SMTP id 79mr8748634pfw.20.1563933359766; Tue, 23 Jul 2019 18:55:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563933359; cv=none; d=google.com; s=arc-20160816; b=P6DTxNlTNL1RsdYafvl0Vgz7VopuPRrwXwquKkeKQgIgGisGSDzOfNE2YCnuJWQoMT jgoiE+osBdv549J2/pcjAO4V2oxdH1viWTqoccdSyFmL8t8YUKrzNzh3ONpNQaYG7J81 J3zigtKBgaP/Hd9mEMMLRy9shzPJ3WvqqGLVx1zk9wQsBsxv889/sFhnoI+j1aNto06R ODgCGV4a2Zm+UVSeNd+zs8XWgCt4DH6hUt3O6VYDFcIGTTET97FUxmR/vut010wsjMl6 DfR9jwnA29p/skw6QG/ISBw+1JrEQRsmHdUBZxKjon0A8Q6ZVrXrptdN1mn2/VrdEoR5 DNZg== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=UcpYwgDngCnf4WL9gjTBN9UDviUZ6DZ0/PA93bwvVd0=; b=Uwljb3i3bYf8OR5bYjysdQAQ0g4XhRsuewf1Va6AaR/G4B/xRecXBaWFjMD/YOX7hQ LLuZmOs7PpeLd1kYZkHUbZJpKuRsLvmu7DiCCdYEta0u2N96FvWq6sPPRqNXXSz2Sp3/ jUep1YUCYzqsqv8KHNNGMnJNETDpNXNI1C1YjV37aCTpIAZ68shTq1Q2mnfayFqSVviG 24fEexQQCkSAMiJdrtmDU4JpNkabK72w2CSGdkvWrggUdKgsvM2/n2BDuzuonooF9/vm xzhTUEan2F5DBz5LFRzqpDH8DvZY4sO8vibnXfBWTcGcyqN9W9lZXBlb9qFFIaYsvyFv 84uw== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i97si18144526plb.50.2019.07.23.18.55.43; Tue, 23 Jul 2019 18:55:59 -0700 (PDT) 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387681AbfGWSGO (ORCPT + 99 others); Tue, 23 Jul 2019 14:06:14 -0400 Received: from mga12.intel.com ([192.55.52.136]:23143 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729734AbfGWSGO (ORCPT ); Tue, 23 Jul 2019 14:06:14 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Jul 2019 11:06:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,299,1559545200"; d="scan'208";a="177367161" Received: from iweiny-desk2.sc.intel.com ([10.3.52.157]) by FMSMGA003.fm.intel.com with ESMTP; 23 Jul 2019 11:06:13 -0700 Date: Tue, 23 Jul 2019 11:06:13 -0700 From: Ira Weiny To: John Hubbard Cc: john.hubbard@gmail.com, Andrew Morton , Alexander Viro , =?iso-8859-1?Q?Bj=F6rn_T=F6pel?= , Boaz Harrosh , Christoph Hellwig , Daniel Vetter , Dan Williams , Dave Chinner , David Airlie , "David S . Miller" , Ilya Dryomov , Jan Kara , Jason Gunthorpe , Jens Axboe , =?iso-8859-1?B?Suly9G1l?= Glisse , Johannes Thumshirn , Magnus Karlsson , Matthew Wilcox , Miklos Szeredi , Ming Lei , Sage Weil , Santosh Shilimkar , Yan Zheng , netdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-mm@kvack.org, linux-rdma@vger.kernel.org, bpf@vger.kernel.org, LKML Subject: Re: [PATCH 3/3] net/xdp: convert put_page() to put_user_page*() Message-ID: <20190723180612.GB29729@iweiny-DESK2.sc.intel.com> References: <20190722223415.13269-1-jhubbard@nvidia.com> <20190722223415.13269-4-jhubbard@nvidia.com> <20190723002534.GA10284@iweiny-DESK2.sc.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.11.1 (2018-12-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 22, 2019 at 09:41:34PM -0700, John Hubbard wrote: > On 7/22/19 5:25 PM, Ira Weiny wrote: > > On Mon, Jul 22, 2019 at 03:34:15PM -0700, john.hubbard@gmail.com wrote: > > > From: John Hubbard > > > > > > For pages that were retained via get_user_pages*(), release those pages > > > via the new put_user_page*() routines, instead of via put_page() or > > > release_pages(). > > > > > > This is part a tree-wide conversion, as described in commit fc1d8e7cca2d > > > ("mm: introduce put_user_page*(), placeholder versions"). > > > > > > Cc: Bj?rn T?pel > > > Cc: Magnus Karlsson > > > Cc: David S. Miller > > > Cc: netdev@vger.kernel.org > > > Signed-off-by: John Hubbard > > > --- > > > net/xdp/xdp_umem.c | 9 +-------- > > > 1 file changed, 1 insertion(+), 8 deletions(-) > > > > > > diff --git a/net/xdp/xdp_umem.c b/net/xdp/xdp_umem.c > > > index 83de74ca729a..0325a17915de 100644 > > > --- a/net/xdp/xdp_umem.c > > > +++ b/net/xdp/xdp_umem.c > > > @@ -166,14 +166,7 @@ void xdp_umem_clear_dev(struct xdp_umem *umem) > > > static void xdp_umem_unpin_pages(struct xdp_umem *umem) > > > { > > > - unsigned int i; > > > - > > > - for (i = 0; i < umem->npgs; i++) { > > > - struct page *page = umem->pgs[i]; > > > - > > > - set_page_dirty_lock(page); > > > - put_page(page); > > > - } > > > + put_user_pages_dirty_lock(umem->pgs, umem->npgs); > > > > What is the difference between this and > > > > __put_user_pages(umem->pgs, umem->npgs, PUP_FLAGS_DIRTY_LOCK); > > > > ? > > No difference. > > > > > I'm a bit concerned with adding another form of the same interface. We should > > either have 1 call with flags (enum in this case) or multiple calls. Given the > > previous discussion lets move in the direction of having the enum but don't > > introduce another caller of the "old" interface. > > I disagree that this is a "problem". There is no maintenance pitfall here; there > are merely two ways to call the put_user_page*() API. Both are correct, and > neither one will get you into trouble. > > Not only that, but there is ample precedent for this approach in other > kernel APIs. > > > > > So I think on this patch NAK from me. > > > > I also don't like having a __* call in the exported interface but there is a > > __get_user_pages_fast() call so I guess there is precedent. :-/ > > > > I thought about this carefully, and looked at other APIs. And I noticed that > things like __get_user_pages*() are how it's often done: > > * The leading underscores are often used for the more elaborate form of the > call (as oppposed to decorating the core function name with "_flags", for > example). > > * There are often calls in which you can either call the simpler form, or the > form with flags and additional options, and yes, you'll get the same result. > > Obviously, this stuff is all subject to a certain amount of opinion, but I > think I'm on really solid ground as far as precedent goes. So I'm pushing > back on the NAK... :) Fair enough... However, we have discussed in the past how GUP can be a confusing interface to use. So I'd like to see it be more directed. Only using the __put_user_pages() version allows us to ID callers easier through a grep of PUP_FLAGS_DIRTY_LOCK in addition to directing users to use that interface rather than having to read the GUP code to figure out that the 2 calls above are equal. It is not a huge deal but... Ira > > thanks, > -- > John Hubbard > NVIDIA >