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=-9.6 required=3.0 tests=BAYES_00,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,URIBL_BLOCKED autolearn=unavailable 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 B64E4C2D0A3 for ; Thu, 29 Oct 2020 21:14:24 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EE2AC20791 for ; Thu, 29 Oct 2020 21:14:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nERaiAC/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EE2AC20791 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 0927F6B005D; Thu, 29 Oct 2020 17:14:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 043476B006C; Thu, 29 Oct 2020 17:14:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EC2276B0070; Thu, 29 Oct 2020 17:14:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0197.hostedemail.com [216.40.44.197]) by kanga.kvack.org (Postfix) with ESMTP id BD3C76B005D for ; Thu, 29 Oct 2020 17:14:20 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 69AAC8249980 for ; Thu, 29 Oct 2020 21:14:20 +0000 (UTC) X-FDA: 77426216280.03.rifle99_20122d227290 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin03.hostedemail.com (Postfix) with ESMTP id 462B328A4E9 for ; Thu, 29 Oct 2020 21:14:20 +0000 (UTC) X-HE-Tag: rifle99_20122d227290 X-Filterd-Recvd-Size: 5481 Received: from mail-ej1-f67.google.com (mail-ej1-f67.google.com [209.85.218.67]) by imf16.hostedemail.com (Postfix) with ESMTP for ; Thu, 29 Oct 2020 21:14:19 +0000 (UTC) Received: by mail-ej1-f67.google.com with SMTP id o9so3689716ejg.1 for ; Thu, 29 Oct 2020 14:14:19 -0700 (PDT) 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=Ns7Do31zu+WAaODzf+zkTDRFUp0x2smNF88wKpHakF8=; b=nERaiAC/yKHy4l59kMbmue2TP0eYV07yG8tRzyOe5ZSnrN+PZZ6lzQgUmergpp9Xvx OKLBUMuWsUZMLgyvU+m2/FAwJYXVtlBY4O4vLyi9jywLdI8btYCMvDdbDZDSKXqOyO+K nxeWQS1wamoq+xyWm3t7T+01TULg7W5gT+ZfuFkpLZG+4pJeuaHSiN6VPvAZ9US6mauR K/N5rPkAh/s1N/VlE9l7cykIutOB9GflFSCa90fZHYkwTXTyTqjXbIl+KINljecetX// D+2uq96Rus5UzxNBCvF7sIHvnnD37AL3805RKrB/oq0uiMH7f74ViGybSA82WdrkHIqk eK3g== 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=Ns7Do31zu+WAaODzf+zkTDRFUp0x2smNF88wKpHakF8=; b=P3fUqXW1EjOcQcgO4hAZq79bsh+OYm6VnTF3QIOQlS8j+P5T3r2gXINJzlUqtCVzRW TGpgUmrDzdnAtUl4jrUcVm58JTW6lneg0Kz1Abx5GiD3C9pfIoI/Ct94aYsP+dLfz42D uYrNb7Iu3pJWhheqSaiYv8P74AUDppd6hysBkK6Jpm3X7eZWALPXRHapt2qR53BleRo8 PkB/sK+0nVnEC/j1/VGQAtBvHkOC1ZirwmIB3DnVspFfUYU+X66FgG1ikInuomzf8LBp JgXN7gaf8AmLRWs7WxdQPoq/aEI6HfOfrZKQhIypZ6lWWK0ocJ2O5ONUGBn15WA9xiW8 K3MQ== X-Gm-Message-State: AOAM530QbLyrag0GNhQR3zS/COHiq674hxaRAZ/muC+KGKt63s6oRPKl K20WteToCcC4Uc0dRykvaiuP04vYbu8ezsWoy90= X-Google-Smtp-Source: ABdhPJxIZF0tNTvtC3V38dLAnOEjKCTAGoMaYCM6ci0TKD+GrrwgFW4yHGsswzIXzMRRHIeMPT/ymA5kFT9Qw3/5V60= X-Received: by 2002:a17:906:68a:: with SMTP id u10mr5865435ejb.507.1604006058250; Thu, 29 Oct 2020 14:14:18 -0700 (PDT) MIME-Version: 1.0 References: <20201029200435.3386066-1-zi.yan@sent.com> In-Reply-To: <20201029200435.3386066-1-zi.yan@sent.com> From: Yang Shi Date: Thu, 29 Oct 2020 14:14:05 -0700 Message-ID: Subject: Re: [PATCH] mm/compaction: count pages and stop correctly during page isolation. To: Zi Yan Cc: Andrew Morton , Linux MM , Rik van Riel , Linux Kernel Mailing List 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 Thu, Oct 29, 2020 at 1:04 PM Zi Yan wrote: > > From: Zi Yan > > In isolate_migratepages_block, when cc->alloc_contig is true, we are > able to isolate compound pages, nr_migratepages and nr_isolated did not > count compound pages correctly, causing us to isolate more pages than we > thought. Use thp_nr_pages to count pages. Otherwise, we might be trapped > in too_many_isolated while loop, since the actual isolated pages can go > up to COMPACT_CLUSTER_MAX*512=16384, where COMPACT_CLUSTER_MAX is 32, Is it that easy to run into? 16384 doesn't seem like too many pages, just 64MB. > since we stop isolation after cc->nr_migratepages reaches to > COMPACT_CLUSTER_MAX. > > In addition, after we fix the issue above, cc->nr_migratepages could > never be equal to COMPACT_CLUSTER_MAX if compound pages are isolated, > thus page isolation could not stop as we intended. Change the isolation > stop condition to >=. The fix looks sane to me. Reviewed-by: Yang Shi Shall you add Fixes tag to commit 1da2f328fa643bd72197dfed0c655148af31e4eb? And may cc stable. > > Signed-off-by: Zi Yan > --- > mm/compaction.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/mm/compaction.c b/mm/compaction.c > index ee1f8439369e..0683a4999581 100644 > --- a/mm/compaction.c > +++ b/mm/compaction.c > @@ -1012,8 +1012,8 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn, > > isolate_success: > list_add(&page->lru, &cc->migratepages); > - cc->nr_migratepages++; > - nr_isolated++; > + cc->nr_migratepages += thp_nr_pages(page); > + nr_isolated += thp_nr_pages(page); > > /* > * Avoid isolating too much unless this block is being > @@ -1021,7 +1021,7 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn, > * or a lock is contended. For contention, isolate quickly to > * potentially remove one source of contention. > */ > - if (cc->nr_migratepages == COMPACT_CLUSTER_MAX && > + if (cc->nr_migratepages >= COMPACT_CLUSTER_MAX && > !cc->rescan && !cc->contended) { > ++low_pfn; > break; > @@ -1132,7 +1132,7 @@ isolate_migratepages_range(struct compact_control *cc, unsigned long start_pfn, > if (!pfn) > break; > > - if (cc->nr_migratepages == COMPACT_CLUSTER_MAX) > + if (cc->nr_migratepages >= COMPACT_CLUSTER_MAX) > break; > } > > -- > 2.28.0 > >