Received: by 2002:a19:ef0c:0:0:0:0:0 with SMTP id n12csp952878lfh; Tue, 1 Feb 2022 12:58:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJx+nqgfqxUmzJEWjwfNW3vsh2Z+IUMMEHFgIUPnaT3tQYNjhRqZ2vaAc6Zz/1nlVhMmOC9y X-Received: by 2002:a17:902:d486:: with SMTP id c6mr26842171plg.133.1643748652439; Tue, 01 Feb 2022 12:50:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643748652; cv=none; d=google.com; s=arc-20160816; b=bXr4TfBwbZLxgVanRdpRcUhOuJfXWanpFE2DHpwmDoDFdsIfLjJV03JoybxKYIVoHI 8nEN7gX/9zW2xH2mpEHyT9b3aea9kuMyloCdFi9iZ8oHU35GMfWDDYkrO5xWSaZYrhKh wmBvSeD4R3xNlONTuDvoE64dzw02tPdfez9SdIe3n5edTFWmR/i9qaskWg35SHlGfn0z ZkFUEUVLDBFYyvyyftbOK15T7wCT/YvvFqZxzD/B+R8sM3KOeQvZ0lcwMbXzJUJhDvcE 47NIOh1VMASdqTY7+Jo3A+w+q6FgsO4ePi+HuQhTEooFZ0o0FnCBsr1V2nLmpQ3e/Oig ZgoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=9eAtHYfw+/lT8OWoIpphlqOzT4nSqWECsjs9ahLjkbw=; b=KHYJjEHmrdFfIUDk1wt6WBjrSrN/KqKGnRWTaOzhcIkHaZJSFxbDgszWVsGavnapsA mxjIijIzbKsDCvlOZ+eB3i5RvJccnr8kMwVSQIgdquZxzk0CcaHuvwTjDIR0pyayR8Va s3JCTupEXf393HHY639aBSUvZa9RUG9ZxUGm05kwOCZAgqnj4vHRji2leX4+Ou6qiIW0 hqa0D3WEnJNOFFCCBTd8ChPlqunQgGKzC9f2tSo9wq5OWDLA+WbQqEgH0I6wa3waH297 Q1sTEvnHTIJGpTvq5sk7CWHt3F+WKRZKYx+yWa3mt12ow5+vuKu2qc5P36Mf2rNvpVpH OI3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="s/Bxs4zd"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bj7si18551688plb.408.2022.02.01.12.50.40; Tue, 01 Feb 2022 12:50:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="s/Bxs4zd"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380665AbiAaVh3 (ORCPT + 99 others); Mon, 31 Jan 2022 16:37:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358076AbiAaVh1 (ORCPT ); Mon, 31 Jan 2022 16:37:27 -0500 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11BF4C061714 for ; Mon, 31 Jan 2022 13:37:27 -0800 (PST) Received: by mail-ej1-x631.google.com with SMTP id k25so46922146ejp.5 for ; Mon, 31 Jan 2022 13:37:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=9eAtHYfw+/lT8OWoIpphlqOzT4nSqWECsjs9ahLjkbw=; b=s/Bxs4zdolC7/C0cnjeR6DBgNzcmI/HhxGvzNgg0QUH7B/R3JRWVYyUi4i8NRwgwtb bOfBerN+MxfcWU7s+3cir8msw2qpYcRdcmcEebZA5uXNeY0HWy6osbR7Xxi2tMHNdchL Z1pof6grX5bhk0/Mi4cp6PgYhHh7Tk7TrWFD7qYu4rDrcV9HWdLB9FdfNIcshtDy/ONa VZ48tGWZptTW8mYOyiB2+Rage6XmCIksZ3ZczLQcrmhAMPImixlcU4L7W0e+Fm7ppo2+ EvTMwGq26okhfqJ7wGne5ZshpXZIlDNQZZQmbIR/GFAb6j8SHP1pAYC+pAfemPaOYHHy kOBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=9eAtHYfw+/lT8OWoIpphlqOzT4nSqWECsjs9ahLjkbw=; b=Dpm6Wm8w6p7Aq5vaX5FRC7uOC4U1ZJfwAfhlEl3Lw4dNapYTCOzR8rd0rmdL52/Odr ykkVY5jDG/Rn/Pztntp+tofFLEcr6JgyQtCnXWvfvZynaBvQhj2mvBTgY6jnqR75FBja jmyyZV9NPY/DtFCS3lMcA2CmurXdlI8OJpcUc9NtKOYiZNQ3XRVpsF9UqdW+iR28rmKb UF2OtcduzrLnd5pEl1N69NIhdi+S/xfUQocwQQWp7kAmzvngMyVf4JY/aUDKBoGzQ6O3 W0Bq50r9kc+6JRXJKMT4yk2wy9h4YCiv8/NUs94yed3AGzQt9hSUcql1BecBhsoLD8wg rekw== X-Gm-Message-State: AOAM531AXNqPtIhsv+Ql07CLuJgt2pMy4vMoLhtzZUvhK3C+4XajdZjr g87qMCR/XyfyTzr6N5zWPdzzmuAvOB3mA9rVKuCAiQ== X-Received: by 2002:a17:907:608f:: with SMTP id ht15mr18617793ejc.484.1643665045448; Mon, 31 Jan 2022 13:37:25 -0800 (PST) MIME-Version: 1.0 References: <20220131203504.3458775-1-willmcvicker@google.com> <27e5f98a-0709-1a80-18ed-e4ccaaf39fe6@nvidia.com> In-Reply-To: <27e5f98a-0709-1a80-18ed-e4ccaaf39fe6@nvidia.com> From: Will McVicker Date: Mon, 31 Jan 2022 13:37:09 -0800 Message-ID: Subject: Re: [PATCH v1 1/1] mm/gup: skip pinnable check for refs==1 To: John Hubbard Cc: Andrew Morton , "Cc: Android Kernel" , Minchan Kim , linux-mm@kvack.org, Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 31, 2022 at 12:49 PM John Hubbard wrote: > > On 1/31/22 12:35, Will McVicker wrote: > > This fixes commit 54d516b1d62f ("mm/gup: small refactoring: simplify > > try_grab_page()") which refactors try_grab_page() to call > > try_grab_compound_head() with refs=1. The refactor commit is causing > > pin_user_pages() to return -ENOMEM when we try to pin one user page that > > is migratable and not in the movable zone. Previously, try_grab_page() > > didn't check if the page was pinnable for FOLL_PIN. To match the same > > functionality, this fix adds the check `refs > 1 &&` to skip the call to > > is_pinnable_page(). > > > > That's a clear write-up of what you're seeing, what caused it, and how > you'd like to correct it. The previous code had a loophole, and you want > to keep that loophole. More below... > > > This issue is reproducible with the Pixel 6 on the 5.15 LTS kernel. Here > > is the call stack to reproduce the -ENOMEM error: > ... > > Fixes: 54d516b1d62f ("mm/gup: small refactoring: simplify try_grab_page()") > > Cc: John Hubbard > > Cc: Minchan Kim > > Signed-off-by: Will McVicker > > --- > > mm/gup.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/mm/gup.c b/mm/gup.c > > index f0af462ac1e2..0509c49c46a3 100644 > > --- a/mm/gup.c > > +++ b/mm/gup.c > > @@ -135,7 +135,7 @@ struct page *try_grab_compound_head(struct page *page, > > * right zone, so fail and let the caller fall back to the slow > > * path. > > */ > > - if (unlikely((flags & FOLL_LONGTERM) && > > + if (refs > 1 && unlikely((flags & FOLL_LONGTERM) && > > !is_pinnable_page(page))) > > return NULL; > > > > ...but are you really sure that this is the best way to "fix" the > problem? This trades correctness for "bug-for-bug compatibility" with > the previous code. It says, "it's OK to violate the pinnable and > longterm checks, as long as you do it one page at a time, rather than in > larger chunks. > > Wouldn't it be better to try to fix up the calling code so that it's > not in violation of these zone rules? > > > thanks, > -- > John Hubbard > NVIDIA Hi John, Thanks for the prompt response! I'm not super familiar with what PIN+LONGTERM conditions require, but if this was previously a bug, then I definitely don't want to re-introduce it. Since you're confirming that, let me sync-up with the driver owner to see how I can fix this on the side. Thanks! Will