From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8A4D2C3F2CD for ; Tue, 3 Mar 2020 13:38:45 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4E25920717 for ; Tue, 3 Mar 2020 13:38:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="n44gaBx7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4E25920717 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D6F496B0005; Tue, 3 Mar 2020 08:38:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D1F476B0006; Tue, 3 Mar 2020 08:38:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C0EF56B0007; Tue, 3 Mar 2020 08:38:44 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0125.hostedemail.com [216.40.44.125]) by kanga.kvack.org (Postfix) with ESMTP id AA26C6B0005 for ; Tue, 3 Mar 2020 08:38:44 -0500 (EST) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 748D9180AD801 for ; Tue, 3 Mar 2020 13:38:44 +0000 (UTC) X-FDA: 76554156168.09.dime77_695fede897816 X-HE-Tag: dime77_695fede897816 X-Filterd-Recvd-Size: 5808 Received: from mail-io1-f65.google.com (mail-io1-f65.google.com [209.85.166.65]) by imf27.hostedemail.com (Postfix) with ESMTP for ; Tue, 3 Mar 2020 13:38:43 +0000 (UTC) Received: by mail-io1-f65.google.com with SMTP id d15so3597645iog.3 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=nr/XsEP54O0dIlPNiMHQlqU6KfmXgJ+tSPVuiBugh+ZR+EUpk7HDWyGsRTAkJx0KZo iRG/rwWm0jbDP45V25vG82/Xn39GpJSwCA/uMOLbOK/ZiPowcWWgNILe+y00bIu3xxXI dkDnoNGbnY89NzI+EKG2R75AlOfJgtq0qH4cgitwYRsMgjCVVcZdkHFxQmaDZlasnU+N tOSqbZGmyHLncaji47Ut5EV5wCIOORhd+PlBDGhgF+Qds4f9db0Ut7AtcR04GTPXm7IT XuX+V5vqAU7N74XIpxsOL/KeZpltd2+6ivjilD57oeazwKr5CTHY+HtN/XAxDoqMD/Ib zD2A== X-Gm-Message-State: ANhLgQ2z+W7PVJbsLjMzLY+jgckgt10eS0N//EppJT4hyRz9okLMSsh9 WUcIgBQHKuAHV6y1j+A2/AaJ412DwMcyg9pVFQ== X-Google-Smtp-Source: ADFU+vt4acEi2rH4gaRHNqkKwa1P0yr+sPIbgUyPKs0Ei5EeGEkmnjhXuMHANnRWBsK11F38ccB5yPzOz9SmGb/O5Vs= 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" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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