Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp176794ybv; Wed, 5 Feb 2020 03:37:54 -0800 (PST) X-Google-Smtp-Source: APXvYqx03c5rcznaYaX6sOX12Sxb7Zv1TluQE32T/xCzNM/Fa0asYOanLlZ8ghC/JZQbt4bAiofe X-Received: by 2002:aca:fcd4:: with SMTP id a203mr2375978oii.167.1580902674446; Wed, 05 Feb 2020 03:37:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580902674; cv=none; d=google.com; s=arc-20160816; b=xn8U+5EG0idWSngwc16Jfnx13Uv5fl7RSF4nY4wFfPNeuD/1DyPh24XBlHOGZhVARf fivEQqk7AVP87y47O84925NDtOS8JkL2Ds5GTzbgWm1pD59mwy5loK044iW4JuXsbdm5 eeKOUMB1pzRut4r9RQwp5ZxDzthUWa1dE13+QFZJwuOiBwT3zbo0Osyftkt2luDv6w7u VxATUK3pL+YhQPUJORTU0awYWdNzvVjjakgTNO6+k4nWEFzL0MZT+8+yuCBIdmWNAB/7 BZ5R8ouIyozHIJBP47nmU18JDgJ/W3sJf/14sgt9iKON9FJCNT+AKanziSdJLWKLus/m UDcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=9dzJMqCXyJ0/sQ9WqS79itnSpMjlI4okwKhRKzVm4NM=; b=BlUvW/er0fntNojH2vH+og4+vB4SAwDRcqB3F3gaWQrbJIyu8F66Pttlx1gDLZ9BZl CKJLmmSiDjCQA44ZT6pzp/cs8HGPGbFHM/BUi349AL8ulHseUqXydzBxjTclN10vjRUJ FMry6YF/YkH4ct4Gdg1zYRdCb3PK99pkKWEsdqxJRjEzee1fPsev0wOFy70FL60cZjE0 5YLA3MEOQTeyD2dYALMrsc/4EJ7SNqNLns095Tq++C426GEnYSiXYu26Okxk4DyA0as+ Sq+T+uTP5hfA69ajj/BLaSb/ZTcq10q9Pfnd8DtVsiRinr8Gqwr0dJmERiwmMr3lRnSs J+pA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b="Cw/B6gNv"; 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 8si9647832oix.109.2020.02.05.03.37.41; Wed, 05 Feb 2020 03:37:54 -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=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b="Cw/B6gNv"; 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 S1728390AbgBELfb (ORCPT + 99 others); Wed, 5 Feb 2020 06:35:31 -0500 Received: from mail-lf1-f67.google.com ([209.85.167.67]:43053 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728258AbgBELfa (ORCPT ); Wed, 5 Feb 2020 06:35:30 -0500 Received: by mail-lf1-f67.google.com with SMTP id 9so1223814lfq.10 for ; Wed, 05 Feb 2020 03:35:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=9dzJMqCXyJ0/sQ9WqS79itnSpMjlI4okwKhRKzVm4NM=; b=Cw/B6gNv6WrKuynnb0hGrn8XHxmwFGHBK6Kx3ISr6g8541JII8R/dNAUM8FBm3EG/z 7mldHZr7bI2tp5pBfvfOfywWE8+h25kWovFkuNAA2Cj1Nuq4GHdG+S1n6nGJL+Qkvl7u DHVez+FLWMPQTo18ui7XxFbIAVT2/XZW7rBMXmKANw7Z3vjhI+/AgNja35tcKI2QrmWC iB0aW7cfR8lhqyI5gnu4EX1AdRGts8kF7neLmR0wRRiDXDyyZo4cXG1dDMjDe7evtrBV 2VevE1g/382CgqcWrvzbCGiEIdnuWbHFIW8EwV4GVppGEzPCncLDF7f4SZMsf2BMC46d Gxmg== 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:content-transfer-encoding :in-reply-to; bh=9dzJMqCXyJ0/sQ9WqS79itnSpMjlI4okwKhRKzVm4NM=; b=STb+mS7O4wZF+uVtT+cYy26MILluyJ7S3HXvAYrtVkp+WMjiJ93vwXpY3DSTpaRwSd AoNyIABhltQRplmW1ffMRkaISqnIRYnadNnEwY1JvGBFZ79bT7hU0uEYPbkG0qomj6cw lAO+WPFhVA7folussiL33SePRSU68xAAGKNfa1FcLokD8bUkhTXHAyK4eLGJ7yvYeAlD MPOvxgkUmFXPJ5NQ9EkIXeMmih1FVX1LhALgRE3114PjeBmWnW6aGWXGvG3IF4XmL86j OOX4hBH3g5hv64czOBkBoF15fjkwuLVM6VEm0NjS0f2AGfRsdpO871H2s5j1IpPf0G+Y qTCg== X-Gm-Message-State: APjAAAW2ch1aVWsst8gquBDYuiJ8CG4CyJ+zCzHxdktexvyirzz7vG/L 2F9TPVNdUhpxM94VmPdENzG4Vg== X-Received: by 2002:a19:6b11:: with SMTP id d17mr17471991lfa.168.1580902528148; Wed, 05 Feb 2020 03:35:28 -0800 (PST) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id f11sm14259401lfa.9.2020.02.05.03.35.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Feb 2020 03:35:27 -0800 (PST) Received: by box.localdomain (Postfix, from userid 1000) id 96D43100AF6; Wed, 5 Feb 2020 14:35:41 +0300 (+03) Date: Wed, 5 Feb 2020 14:35:41 +0300 From: "Kirill A. Shutemov" To: John Hubbard Cc: Andrew Morton , Al Viro , Christoph Hellwig , Dan Williams , Dave Chinner , Ira Weiny , Jan Kara , Jason Gunthorpe , Jonathan Corbet , =?utf-8?B?SsOpcsO0bWU=?= Glisse , Michal Hocko , Mike Kravetz , Shuah Khan , Vlastimil Babka , Matthew Wilcox , linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-rdma@vger.kernel.org, linux-mm@kvack.org, LKML , "Kirill A . Shutemov" Subject: Re: [PATCH v4 07/12] mm/gup: track FOLL_PIN pages Message-ID: <20200205113541.mi4kys5erldwxiog@box> References: <20200204234117.2974687-1-jhubbard@nvidia.com> <20200204234117.2974687-8-jhubbard@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200204234117.2974687-8-jhubbard@nvidia.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 04, 2020 at 03:41:12PM -0800, John Hubbard wrote: > Add tracking of pages that were pinned via FOLL_PIN. This tracking is > implemented via overloading of page->_refcount: pins are added by > adding GUP_PIN_COUNTING_BIAS (1024) to the refcount. This provides a > fuzzy indication of pinning, and it can have false positives (and that's > OK). Please see the pre-existing > Documentation/core-api/pin_user_pages.rst for details. > > As mentioned in pin_user_pages.rst, callers who effectively set FOLL_PIN > (typically via pin_user_pages*()) are required to ultimately free such > pages via unpin_user_page(). > > Please also note the limitation, discussed in pin_user_pages.rst under > the "TODO: for 1GB and larger huge pages" section. (That limitation will > be removed in a following patch.) > > The effect of a FOLL_PIN flag is similar to that of FOLL_GET, and may be > thought of as "FOLL_GET for DIO and/or RDMA use". > > Pages that have been pinned via FOLL_PIN are identifiable via a > new function call: > > bool page_maybe_dma_pinned(struct page *page); > > What to do in response to encountering such a page, is left to later > patchsets. There is discussion about this in [1], [2], [3], and [4]. > > This also changes a BUG_ON(), to a WARN_ON(), in follow_page_mask(). > > [1] Some slow progress on get_user_pages() (Apr 2, 2019): > https://lwn.net/Articles/784574/ > [2] DMA and get_user_pages() (LPC: Dec 12, 2018): > https://lwn.net/Articles/774411/ > [3] The trouble with get_user_pages() (Apr 30, 2018): > https://lwn.net/Articles/753027/ > [4] LWN kernel index: get_user_pages(): > https://lwn.net/Kernel/Index/#Memory_management-get_user_pages > > Reviewed-by: Jan Kara > Suggested-by: Jan Kara > Suggested-by: J?r?me Glisse > Cc: Kirill A. Shutemov > Signed-off-by: John Hubbard Acked-by: Kirill A. Shutemov -- Kirill A. Shutemov