Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp569365ybh; Wed, 18 Mar 2020 05:16:06 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsqbFNgogYuYKkjx+WPxOnzZcCpTpM45+1+sOlAOq/JOm4sRF4oZcRyPYyQ6fQrUicT0dGa X-Received: by 2002:aca:c4c5:: with SMTP id u188mr2756032oif.139.1584533766167; Wed, 18 Mar 2020 05:16:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584533766; cv=none; d=google.com; s=arc-20160816; b=lZGf/14wJ9AvytmjgVrfECghfG+GJ4FTJkhh3X1zS+s9Cq0Chlhx2N10TnCuud7I7u jG0WQDlDhpAtGQTeIJKDvmdVmePX6zH7OfGhj/5qktWV5aOcCzia6YMS8LsP8RO6e0rR WM+H6FjyuEvUam4fPzHq86vFmIC5ZAXUUOvWhsjLOuCBjIaz12/dsNZwJAmVIeovtbIA Z97XJNPT56qeNduEeoxjnjZil9cHm3n/2ZbQXoR01MogQ6t30Tw8LxL9TOeDLvVNUDZG KJlVgy7Xoileb254U5bKtPD+3xU2D/KPtR3Jd+OhxpTmp45S6oZbw1YjMEbr1+gLnQcL RcRA== 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=JtFXIfIE3pIhsgNz5a2Tc68ESm0JIZ+L7JiGzETmzNE=; b=y+GzzFi8nHVfWlM5G9N2+4gzfZhGYvxihsMXG1jFGevSEiD02cBVPYLk5NRrJHu3jP C3M8DRuz1SvfX8ywYw4ftPsdyQ5fGB10AibnszLe+mTIVpWFguxO2gpS7mi63VLptQkS P4GeJOTgv7TfkxOEvIFYZV7sYuKv8P1kknrc2lHF9t6KrONqOQcXQTqjZm0NHBDecdGZ mSz3loPQSI9qike8WfQQ0wfx+aTOS8qa/44ZQI8r9aFCAxhWfJrE/hGNnxPsDcKF8J70 2x3eB9XGD3ar2dF8j+kYtTs+m5zXI+gu1dhm4NuPJTgKCJxclv0/hB1L36DG66FeYcQM 7nqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=jvwZwXXB; 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 b6si3138990otj.275.2020.03.18.05.15.51; Wed, 18 Mar 2020 05:16:06 -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; dkim=pass header.i=@ziepe.ca header.s=google header.b=jvwZwXXB; 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 S1726869AbgCRMPG (ORCPT + 99 others); Wed, 18 Mar 2020 08:15:06 -0400 Received: from mail-qk1-f193.google.com ([209.85.222.193]:38099 "EHLO mail-qk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726616AbgCRMPG (ORCPT ); Wed, 18 Mar 2020 08:15:06 -0400 Received: by mail-qk1-f193.google.com with SMTP id h14so38225564qke.5 for ; Wed, 18 Mar 2020 05:15:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=JtFXIfIE3pIhsgNz5a2Tc68ESm0JIZ+L7JiGzETmzNE=; b=jvwZwXXB/uqCF8yPkz7NyKvPz4BuL1Iz9UcqkYw93vszZJnrvUaCGtoSlvnfEOOdPH XiQFYIOhsU8s+SjXT3HwWRpTtWkfSPAEHs3ObZkPlxCL7KN49qEovMOd5ZG7eGQMTx6U cMKXqkD3IcjO57ExTFkXbIiJRLSTFNnXkbmmJHVXM104i1SIrsWZQeMlWhNQIaOF67Dz QMF9gcnU0EwtBv3b5VvPJHAT4xzwCaV7404g6EtmsawjPtkJrmu1Me2L6vH7ahxK5+Gc MDhAPYcAWWCjgSYhIF4yynBwAv7U0OcGqbR7y2i0w5g6W3leSv9I4/Wj7ub2DiMAqd3B 1+NQ== 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:in-reply-to:user-agent; bh=JtFXIfIE3pIhsgNz5a2Tc68ESm0JIZ+L7JiGzETmzNE=; b=W5ke+wTkegEzDZS7VqyOzl3uaJ/UjI/muz8T9N7Ay/OND+5BBIWZIY9aBCxvPDqZyz xnv3caKbjZi1XN+H4MKNfq5puIrH+njAqFmK1Bxl1hv2OJCDGs9tXqtki5z7fu5L7zb8 uyhDj8fOlJFj+x+pJgLcmhHw2I8zGUQuRaGPefFUwTjfwm5wgdco9ySMeGzGxyE7u/gE oBulmrJRWOtlX5TJK6e2Caoa66M/946dm+ushJ/w7CU1nd7ruDWLPLpmFHG274pAeM2T xKXukZQZcd+HQ1VSFgRZWyPK/iLpxWaQWeV0UsBDnufXTVM/rWPzhZLhtoBgWysjzlIo m7ww== X-Gm-Message-State: ANhLgQ2/W+3vUW8OXnFf7p+wtesCzqMYD3289nfA7Vy/1P6HclZTMd0+ rqSmqG6sx9zsVIMxOm83KPlWTg== X-Received: by 2002:a05:620a:84d:: with SMTP id u13mr3705543qku.94.1584533705141; Wed, 18 Mar 2020 05:15:05 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-142-68-57-212.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.68.57.212]) by smtp.gmail.com with ESMTPSA id s49sm4525733qtc.29.2020.03.18.05.15.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 18 Mar 2020 05:15:04 -0700 (PDT) Received: from jgg by mlx.ziepe.ca with local (Exim 4.90_1) (envelope-from ) id 1jEXbC-0003dR-W7; Wed, 18 Mar 2020 09:15:03 -0300 Date: Wed, 18 Mar 2020 09:15:02 -0300 From: Jason Gunthorpe To: Pingfan Liu Cc: linux-mm@kvack.org, Ira Weiny , Andrew Morton , Mike Rapoport , Dan Williams , Matthew Wilcox , John Hubbard , "Aneesh Kumar K.V" , Christoph Hellwig , Shuah Khan , linux-kernel@vger.kernel.org Subject: Re: [PATCHv7 2/3] mm/gup: fix omission of check on FOLL_LONGTERM in gup fast path Message-ID: <20200318121502.GA13926@ziepe.ca> References: <1584333244-10480-3-git-send-email-kernelfans@gmail.com> <1584445652-30064-1-git-send-email-kernelfans@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1584445652-30064-1-git-send-email-kernelfans@gmail.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 17, 2020 at 07:47:32PM +0800, Pingfan Liu wrote: > FOLL_LONGTERM is a special case of FOLL_PIN. It suggests a pin which is > going to be given to hardware and can't move. It would truncate CMA > permanently and should be excluded. > > In gup slow path, slow path, where > __gup_longterm_locked->check_and_migrate_cma_pages() handles FOLL_LONGTERM, > but in fast path, there lacks such a check, which means a possible leak of > CMA page to longterm pinned. > > Place a check in try_grab_compound_head() in the fast path to fix the leak, > and if FOLL_LONGTERM happens on CMA, it will fall back to slow path to > migrate the page. > > Some note about the check: > Huge page's subpages have the same migrate type due to either > allocation from a free_list[] or alloc_contig_range() with param > MIGRATE_MOVABLE. So it is enough to check on a single subpage > by is_migrate_cma_page(subpage) > > Signed-off-by: Pingfan Liu > Cc: Ira Weiny > Cc: Andrew Morton > Cc: Mike Rapoport > Cc: Dan Williams > Cc: Matthew Wilcox > Cc: John Hubbard > Cc: "Aneesh Kumar K.V" > Cc: Christoph Hellwig > Cc: Shuah Khan > Cc: Jason Gunthorpe > To: linux-mm@kvack.org > Cc: linux-kernel@vger.kernel.org > --- > v6 -> v7: fix coding style issue > mm/gup.c | 9 +++++++++ > 1 file changed, 9 insertions(+) Much clearer, thank you Reviewed-by: Jason Gunthorpe Jason