Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp3420425ybf; Tue, 3 Mar 2020 05:46:52 -0800 (PST) X-Google-Smtp-Source: ADFU+vu5l2GkdB5ROlov9lragUMM9a1ASydR4Sbej1dc3bCBfLRJwIV45QSrcpHqjvkl7AtMcOzc X-Received: by 2002:a05:6808:b23:: with SMTP id t3mr2514647oij.88.1583243212122; Tue, 03 Mar 2020 05:46:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583243212; cv=none; d=google.com; s=arc-20160816; b=W2le9CaYgdIDAvtLWJiA0Jp0rD02hbW1+oGNV083bJU9CA+kZD3fTyhFHm0ZQe/V50 Mz+ljTuJCoPEL7ZuljfjxCyzVQi5jjnzt49cUyrmMU6U+x+OhPMQN8M8tHrtaCVJ+CEF UTEw899A6+RT6/P3TcdCcllcw+5uaJe/6lW12RD+GeCerdJYkKuMKXFUngpUXHu82MII H+AiOfHKnIiPSiy+qDGRXkUbYRrzonq/roQQrgxT+V6GArrVDXw05vKPv61cutzIFGI2 q6a+SkK+itX4OuJoDouAnmS4MdI490fWozCoVCXeJH6dY+CT0Gv/UWfz9t6ICmFI0lcI ge7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=JYvtLVzi18cIH6u0PRaiZ+x+kMrKvMGPICXTKLEmlk4=; b=ECQaZC7WKEsgjpN0o/RmoX59k++3vA3Tp0Ql7S963kf2UAA77poQAnwjyILypNHIl4 SM1YdcZUrZ1P73BMUQW0Bb8AHWYzEMm7dof2TjfPVLlyCQeGT+vvffCqpooK8gqkzzx8 PC2OF0PMbGUsGG2XDtRbtqFCgVOD18wn28BhvQIwMpDrWE8bqez0of26ujX6BJBJJSj7 OEPbH92HbBiioF9mRoU22O6Y4k1Y9EBnQ/2vTPChvzks7ITceGUNTlkiyXwQGJTZGR0l NBPxR1K2hND7OIyKkL2VSIYXgxB/Vt8kpgeJAcweZov+fel2WbLiX+/U3NtKol/zrE75 0Omw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=n44gaBx7; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n11si8677648otf.36.2020.03.03.05.46.35; Tue, 03 Mar 2020 05:46:52 -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=@gmail.com header.s=20161025 header.b=n44gaBx7; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728762AbgCCNio (ORCPT + 99 others); Tue, 3 Mar 2020 08:38:44 -0500 Received: from mail-io1-f68.google.com ([209.85.166.68]:34154 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727175AbgCCNio (ORCPT ); Tue, 3 Mar 2020 08:38:44 -0500 Received: by mail-io1-f68.google.com with SMTP id z190so3600754iof.1 for ; Tue, 03 Mar 2020 05:38:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=JYvtLVzi18cIH6u0PRaiZ+x+kMrKvMGPICXTKLEmlk4=; b=n44gaBx7J09bO0aLDcRtttMXYmMiYYEMy7D8QsoilKQYF/NcqQlhD8Z+kjxuhKBSSu Wl3s5P5ZgXFmSe/6IFfmOEyzCksX0OeaIyOw8gM1eVBr5IS4rFViV4YnJD5f8zguw8d4 BY7hLvhyYGG3HpyoSeDYAvNfsAwV/ZWwfDuEpAntd5kBmv0/RY88cAGJrvYbKfoGpRuo OwlgJXgDBOF11BpDmdn3NG0wPH1ocEKxE2n0bY9ewqnA1OR38lSTQSzFTmZezw5I3V+w LFh9aNc+jMuj0lUpJU24gIEul247Ug9i1VZ84vlDzZ9/kHodRXbJE9BCdjiEP2XSBKig 4bLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=JYvtLVzi18cIH6u0PRaiZ+x+kMrKvMGPICXTKLEmlk4=; b=KAvRYGRC2g1ZfpL7urHmEC1EfgeYwwc3k+e0cv3tsgK5ZbbRAkQpC6PxJNxl6dTc7H 05Md4O+c2L2KCrZFN+p82oYDH5Yyg1wrbyrncR2o82WYPeSaD/Z66qTWgdZuciVmwy+b q0GqHAHzxoxGbM2Y74zySBLFANFTmFz/xzH1UMhcveIwKn6qnHuAlinvpyyblJgyRNfF zILbqDpgv6cBSi4l+Abh7MN5mah+hFTkbmBsTiizUIQbKl8bdmIIs0DtEHyXUxy/CRjr 4PHam3BCo4SuPMBN282T91MY0UgXuAWIGNsy4G7chduNpeel8XYqji9y+Bdac0Si7euh YwmA== X-Gm-Message-State: ANhLgQ2RzPT2xx9ozcTx9HD+5t4MiDMSTdu0cjO/XrLZafkLO/3gLk6C ULXQgxZtD5fh7K3rV5pFzTwv+xiiu194pSr1Vg== X-Received: by 2002:a02:3093:: with SMTP id q141mr3343332jaq.121.1583242723230; Tue, 03 Mar 2020 05:38:43 -0800 (PST) MIME-Version: 1.0 References: <1582889550-9101-1-git-send-email-kernelfans@gmail.com> <1582889550-9101-3-git-send-email-kernelfans@gmail.com> <1433456b-733c-02dc-d4fd-50e5b2be50bc@nvidia.com> In-Reply-To: <1433456b-733c-02dc-d4fd-50e5b2be50bc@nvidia.com> From: Pingfan Liu Date: Tue, 3 Mar 2020 21:38:31 +0800 Message-ID: Subject: Re: [PATCHv5 2/3] mm/gup: fix omission of check on FOLL_LONGTERM in gup fast path To: John Hubbard Cc: Linux-MM , Ira Weiny , Andrew Morton , Mike Rapoport , Dan Williams , Matthew Wilcox , "Aneesh Kumar K.V" , Christoph Hellwig , Shuah Khan , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 3, 2020 at 7:51 AM John Hubbard wrote: > > On 2/28/20 3:32 AM, Pingfan Liu wrote: > > FOLL_LONGTERM suggests a pin which is going to be given to hardware and > > can't move. It would truncate CMA permanently and should be excluded. > > > > FOLL_LONGTERM has already been checked in the slow path, but not checked in > > the fast path, which means a possible leak of CMA page to longterm pinned > > requirement through this crack. > > > > Place a check in try_get_compound_head() in the fast path. > > > > 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: Keith Busch > > Cc: Christoph Hellwig > > Cc: Shuah Khan > > To: linux-mm@kvack.org > > Cc: linux-kernel@vger.kernel.org > > --- > > mm/gup.c | 26 +++++++++++++++++++------- > > 1 file changed, 19 insertions(+), 7 deletions(-) > > > > diff --git a/mm/gup.c b/mm/gup.c > > index cd8075e..f0d6804 100644 > > --- a/mm/gup.c > > +++ b/mm/gup.c > > @@ -33,9 +33,21 @@ struct follow_page_context { > > * Return the compound head page with ref appropriately incremented, > > * or NULL if that failed. > > */ > > -static inline struct page *try_get_compound_head(struct page *page, int refs) > > +static inline struct page *try_get_compound_head(struct page *page, int refs, > > + unsigned int flags) > > > ohhh...please please look at the latest gup.c in mmotm, and this one in particular: > > commit 0ea2781c3de4 mm/gup: track FOLL_PIN pages > > ...where you'll see that there is a concept of "try_get*" vs. "try_grab*"). This is going > to be a huge mess if we do it as above, from a code structure point of view. > > The "grab" functions take gup flags, the "get" functions do not. > > Anyway, as I said in reply to the cover letter, I'm really uncomfortable with this > being applied to linux.git. So maybe if we see a fix to mmotm, it will be clearer how > to port that back to linux.git (assuming that you need 5.6 fixed--do you though?) Sure, I will read your series and figure out the way to rebase my patches on mmotm at first. Thanks, Pingfan