Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp586571imj; Thu, 7 Feb 2019 08:48:58 -0800 (PST) X-Google-Smtp-Source: AHgI3IYSW7xG6K1jXooGMthgkgN5itrbIFSGvmzcMSMVeSDHYPnnD/HvnPichw+T8DUjkBOzFEk1 X-Received: by 2002:a62:8d4f:: with SMTP id z76mr17492662pfd.2.1549558138867; Thu, 07 Feb 2019 08:48:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549558138; cv=none; d=google.com; s=arc-20160816; b=THKOfpMGzyD6lWNXiK0WLH49VkLOUZZAwsm1B/IQF8cJ43S40fzFbjt4rpsoja9ksp Q6ClyseflWEsis5PA8BtdTiAdgzKkJcm5RMPcWwhd+wCGvCDdAJQXCrzeBWmvnS575x8 1s6ZgHHUhiZyfasDqTfEBnDam0Q7d7Dihp/6nA6f9LQz1Mncj8IqouAGh4LsIvFZfA02 oElkZCF7rWBt88b+Ebo/T5pgeHSjBjf5A1LE3Y1Ezriz//UddkSiPR2Lh1c9h0awe9lO 8Ys5NByDT0obTXUsWMIfy/FdPAdVkjpVuqQpCxy3xyPa+/5N6oBjtGymTNNNRBCDKAGf zfQA== 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; bh=3Crx6L2SCrC/hAezTHTZyMkEY70y9OGZyoS8mOjuiIQ=; b=IBv8NbMASVYoyaJ4BUxdd4nPifIGEe8hRHgTN/ObgDN/10hgHyWqJvBGNpkLRkR3na IED87XKpJo5pObS0Irb7oRMrY6KW0fVZuNoaGfinFkjI6VNe/bpXElw5SAn4kUHsO4L4 5Djr5p2n32FhH+sWrSY0yhzukeV+6pbYCTay5XHvQ3XITYLnnw85ZNGHQbqgH5k+EUGO M6ly9F6iSnZtiubMOf7S/3kngsRGOv9zblz6yjDNLzMirYpNGUoHHfD8PJxoXNAPOZyG PuowFyvJj945m2a21gNHyBFwXaK5dIk5fKxChmGzE5TjoERQK4bvhsrARj+jZDbswejz 9Hag== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=MgrpJ4M1; 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 z14si8530024pgu.525.2019.02.07.08.48.42; Thu, 07 Feb 2019 08:48:58 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=MgrpJ4M1; 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 S1726860AbfBGQsS (ORCPT + 99 others); Thu, 7 Feb 2019 11:48:18 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:54386 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726196AbfBGQsS (ORCPT ); Thu, 7 Feb 2019 11:48:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=3Crx6L2SCrC/hAezTHTZyMkEY70y9OGZyoS8mOjuiIQ=; b=MgrpJ4M1SKwbB/Yo3N593SLwA QNDOZMk72sEtYMlIQ2rFvlvgbFIhWnRTu0thbBjirZlJknxymzD0HlsaEH8nReOJbVVxfO458DPHx 18yB2e7GdJ+zJKh8tL57dO6yUGJtkp6ZOctQW4gvRn8N7q103oDWHKd2S3aT32MGVDWPczZ0fLbKk 802j/CifGuu9dRvUnhxbfXQKEAmG4f1FQ+LjKl0KMb4UJPEZSsIyATZ9pCOxvhP9w6nv9+hI3EPu9 qv1xZyihrFaiRXH2Beb+ldPwNcCjSCXviraUqBQW8KnDrAxVFueDl/Uy9nOP9VkSNyTz0+UfhBWNV mRrXbihYg==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1grmpv-00037s-JZ; Thu, 07 Feb 2019 16:47:39 +0000 Date: Thu, 7 Feb 2019 08:47:39 -0800 From: Matthew Wilcox To: Souptick Joarder Cc: Mike Rapoport , Andrew Morton , Michal Hocko , "Kirill A. Shutemov" , vbabka@suse.cz, Rik van Riel , Stephen Rothwell , rppt@linux.vnet.ibm.com, Peter Zijlstra , Russell King - ARM Linux , robin.murphy@arm.com, iamjoonsoo.kim@lge.com, treding@nvidia.com, Kees Cook , Marek Szyprowski , stefanr@s5r6.in-berlin.de, hjc@rock-chips.com, Heiko Stuebner , airlied@linux.ie, oleksandr_andrushchenko@epam.com, joro@8bytes.org, pawel@osciak.com, Kyungmin Park , mchehab@kernel.org, Boris Ostrovsky , Juergen Gross , linux-kernel@vger.kernel.org, Linux-MM , linux-arm-kernel@lists.infradead.org, linux1394-devel@lists.sourceforge.net, dri-devel@lists.freedesktop.org, linux-rockchip@lists.infradead.org, xen-devel@lists.xen.org, iommu@lists.linux-foundation.org, linux-media@vger.kernel.org Subject: Re: [PATCHv2 1/9] mm: Introduce new vm_insert_range and vm_insert_range_buggy API Message-ID: <20190207164739.GX21860@bombadil.infradead.org> References: <20190131030812.GA2174@jordon-HP-15-Notebook-PC> <20190131083842.GE28876@rapoport-lnx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 07, 2019 at 09:19:47PM +0530, Souptick Joarder wrote: > Just thought to take opinion for documentation before placing it in v3. > Does it looks fine ? > > +/** > + * __vm_insert_range - insert range of kernel pages into user vma > + * @vma: user vma to map to > + * @pages: pointer to array of source kernel pages > + * @num: number of pages in page array > + * @offset: user's requested vm_pgoff > + * > + * This allow drivers to insert range of kernel pages into a user vma. > + * > + * Return: 0 on success and error code otherwise. > + */ > +static int __vm_insert_range(struct vm_area_struct *vma, struct page **pages, > + unsigned long num, unsigned long offset) For static functions, I prefer to leave off the second '*', ie make it formatted like a docbook comment, but not be processed like a docbook comment. That avoids cluttering the html with descriptions of internal functions that people can't actually call. > +/** > + * vm_insert_range - insert range of kernel pages starts with non zero offset > + * @vma: user vma to map to > + * @pages: pointer to array of source kernel pages > + * @num: number of pages in page array > + * > + * Maps an object consisting of `num' `pages', catering for the user's Rather than using `num', you should use @num. > + * requested vm_pgoff > + * > + * If we fail to insert any page into the vma, the function will return > + * immediately leaving any previously inserted pages present. Callers > + * from the mmap handler may immediately return the error as their caller > + * will destroy the vma, removing any successfully inserted pages. Other > + * callers should make their own arrangements for calling unmap_region(). > + * > + * Context: Process context. Called by mmap handlers. > + * Return: 0 on success and error code otherwise. > + */ > +int vm_insert_range(struct vm_area_struct *vma, struct page **pages, > + unsigned long num) > > > +/** > + * vm_insert_range_buggy - insert range of kernel pages starts with zero offset > + * @vma: user vma to map to > + * @pages: pointer to array of source kernel pages > + * @num: number of pages in page array > + * > + * Similar to vm_insert_range(), except that it explicitly sets @vm_pgoff to But vm_pgoff isn't a parameter, so it's misleading to format it as such. > + * 0. This function is intended for the drivers that did not consider > + * @vm_pgoff. > + * > + * Context: Process context. Called by mmap handlers. > + * Return: 0 on success and error code otherwise. > + */ > +int vm_insert_range_buggy(struct vm_area_struct *vma, struct page **pages, > + unsigned long num) I don't think we should call it 'buggy'. 'zero' would make more sense as a suffix. Given how this interface has evolved, I'm no longer sure than 'vm_insert_range' makes sense as the name for it. Is it perhaps 'vm_map_object' or 'vm_map_pages'?