Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp3706872ybh; Tue, 17 Mar 2020 05:11:49 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtMCmC3X4PNKgRQQy1oMCEawK5WSOWU62Be3HSKarqBcNWYE50AVXje2FdUyEInnt74Mxyw X-Received: by 2002:a9d:23a1:: with SMTP id t30mr3307938otb.253.1584447109115; Tue, 17 Mar 2020 05:11:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584447109; cv=none; d=google.com; s=arc-20160816; b=sRcNRKWEIdmp0Ba8Y++lpWFnK/2nLjxz/WP4PKm3ULm5vl6SyjWAIuR64tpkq9tWjl I4nSKuWWPMjBc/1aJR8hZ/qCXgthHmu0tufMFuBpuXBeh3IpRs+wwDOeXN70cFGGQ6La v3rocvX+obBqUHxKHwBiFRlzpUW5QVSPR8tDk7TrtUIznw+RIOvrPzH5cjgRoSCStGkm 5QRixjEnNiRc+GyzRU2guMKT9A6dPMTLgKV4Iuco7U0AfSZbWNs2ClSmj5lXV6mlumXX ppE5HVeUgcecUnIAMbsjv0eXYwZhfKw3fJWF86LUSu+4W+eDksb7yqVB7hlPrFWKiFba Y+Xw== 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-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=q/GK4+6m5lw1qmSosNNukTctCn2OhFMDvaxhnUz5s/E=; b=a/5JCdao3DcadYA2krHGrUfObzZsDBxKom+9qNbyqOOCzOyGX3/M1Fnhi+ukgZ+F8R zGmzgdhbJaItBgZ7afuQxO3PrBPPprRRlJ3fD9zUXp2UZuZ3Y29oD2cfdDYrRIePz0sf tKx0BirC7+tZeDvpJdkoCEBt9ggmKvDefmgURJ48EzH5yMY2+oc9YR/8Vt/AB85XooBL qFNU9T0Tpeu5xT8oFFEkq1JqQ/HGSRqEj0BoUqeTQBe2zL036bpOAFWo6/Rjt+o9jcqe oEf+ccO2o/9eF25Pq/EBA6Maa6Kk4HZ9B3aWVFoy7iDTUS49sowew5uH5CdsHpb6iYfy LbZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=TUVADCLr; 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 184si1022336oif.56.2020.03.17.05.11.35; Tue, 17 Mar 2020 05:11:49 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=TUVADCLr; 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 S1726879AbgCQMJi (ORCPT + 99 others); Tue, 17 Mar 2020 08:09:38 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:49024 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726705AbgCQMJi (ORCPT ); Tue, 17 Mar 2020 08:09:38 -0400 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; bh=q/GK4+6m5lw1qmSosNNukTctCn2OhFMDvaxhnUz5s/E=; b=TUVADCLrKEE8VyknwEYEQ0UYdT u9A/5XJjJrnMqqk+qjL1RIZthjoUtX+eBU+A7CfInYWhqGjFymvbMciO2wZSoVjMxQAdUD8OH4THK 0AkBL1KPEfz+2CzB8rMplaOk9iP8TFZ2VpEfCJiFY7ybjLpoza7xNmXcvXuPeibzE+BHKF4y8K4mN ZF1fUAxQPe49+lYj1MZm/5nsJPwZkmcHV4niOD1KJk12OyykwGR1CmTbgTBNfOv2wpeHpPwSA8j/Z IGScVWlfuQlVUMJbxVwvZJ3NRR93X8yz0NBQqDmLmTCRKYUrcS3MfMPt/tAZe1K7oOI3cnVDZf0Yu zdbk9eVw==; Received: from hch by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jEB2I-0000M8-F7; Tue, 17 Mar 2020 12:09:30 +0000 Date: Tue, 17 Mar 2020 05:09:30 -0700 From: Christoph Hellwig 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 , Jason Gunthorpe , 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: <20200317120930.GA435@infradead.org> 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> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html 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) Looks good, Reviewed-by: Christoph Hellwig