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 1C7D8C4741F for ; Fri, 30 Oct 2020 18:56:01 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5DBD3221EB for ; Fri, 30 Oct 2020 18:55:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Fs9x9IDc" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5DBD3221EB 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 64EDD6B0036; Fri, 30 Oct 2020 14:55:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5FF666B005C; Fri, 30 Oct 2020 14:55:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4EE7E6B005D; Fri, 30 Oct 2020 14:55:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0023.hostedemail.com [216.40.44.23]) by kanga.kvack.org (Postfix) with ESMTP id 21E3D6B0036 for ; Fri, 30 Oct 2020 14:55:58 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id B458D3629 for ; Fri, 30 Oct 2020 18:55:57 +0000 (UTC) X-FDA: 77429496354.06.tiger42_4f1834627298 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin06.hostedemail.com (Postfix) with ESMTP id 8CB7110040E07 for ; Fri, 30 Oct 2020 18:55:57 +0000 (UTC) X-HE-Tag: tiger42_4f1834627298 X-Filterd-Recvd-Size: 5912 Received: from mail-ej1-f67.google.com (mail-ej1-f67.google.com [209.85.218.67]) by imf36.hostedemail.com (Postfix) with ESMTP for ; Fri, 30 Oct 2020 18:55:57 +0000 (UTC) Received: by mail-ej1-f67.google.com with SMTP id j24so9956055ejc.11 for ; Fri, 30 Oct 2020 11:55:56 -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:content-transfer-encoding; bh=SpmAhXEjATLtxu6nBA8LZUlE07GKFiy6OiJGOpSxj8o=; b=Fs9x9IDcQzweGhPcbRreVMjC4xKt1zDCfWkTYNojskWNiSM6gIsaJ/m72dKBYO7L4+ 8NicyMzwVGs57bn5fNvVLIu7yQbk4FlbvenJfb+Fuq+gq1up+nEyUbneVZakzPTj+1Za EkJh8QPFJFRs8eMJ1xjzpJu/gWTTjdNV9PlPRJtn1xTmCqdkzlOQrLIeoLITCYN+ZWen hKWRzJ948pAOW8vpQe89qOm0aMUytuXoX7+Qa8a2RA8+laA7ze/gP8SKfxpcfy+ouv+6 xT1M2LiMFsyMxnQwheZ3RrJPowp0G3T801TA2ZROMAVEj8ZvDgwvla79iMxKDxl9jgB5 h1zA== 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:content-transfer-encoding; bh=SpmAhXEjATLtxu6nBA8LZUlE07GKFiy6OiJGOpSxj8o=; b=iWJ1cOQyFKNHAWsQ4qnAcDSTCXiIDHRNpfN88bLU9yGAoi++kA1PG3YEK2wA/WhYrj tuOL3bnz9wOl9csoGogUC8JomjdFTDgQDl3B3QC1oi0O/09M7YqF2CEWvIuB5/h2wsgI UDTE9I0h5P9QD5YeKkeNrb3/wB84sFKNThEz4WOvK4cvPeBQcKlWjVsg/glUb4l4/slY EVsrrukP9cWFwda8UvcixTXqdL3AO8jsUqZSeg/N/tfAdh3CiOK2i4FXtEj5lCW7RGny gFhapHLIWD436XcKSPtD/sRnZemsI3AOzOC6EYx2gL3TUXF7NkzeCJHpFZU3ahF5dQa3 TWmQ== X-Gm-Message-State: AOAM531fIvglgNQKRweo5tGYpYpw7J7N9CTm8P3HQH74mTTsqgSw4iI+ HrxdEIM3VdcDSGNve55XXdivn+ALFU9SDH/uQ5k= X-Google-Smtp-Source: ABdhPJzFHRV93uC00xVcjRy5x6wfPBGXIyYJDllHLxCr9ihxvA2R9gJUKiD/JWUlks5UjP048Qq1b5wat+9hhOdtieI= X-Received: by 2002:a17:906:d41:: with SMTP id r1mr3815005ejh.383.1604084155916; Fri, 30 Oct 2020 11:55:55 -0700 (PDT) MIME-Version: 1.0 References: <20201029200435.3386066-1-zi.yan@sent.com> <20201030094308.GG1478@dhcp22.suse.cz> <6CAAB1FC-2B41-490B-A67A-93063629C19B@nvidia.com> <20201030133625.GJ1478@dhcp22.suse.cz> In-Reply-To: From: Yang Shi Date: Fri, 30 Oct 2020 11:55:44 -0700 Message-ID: Subject: Re: [PATCH] mm/compaction: count pages and stop correctly during page isolation. To: Zi Yan Cc: Michal Hocko , Andrew Morton , Linux MM , Rik van Riel , Linux Kernel Mailing List , Vlastimil Babka Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 Fri, Oct 30, 2020 at 11:39 AM Zi Yan wrote: > > On 30 Oct 2020, at 14:33, Yang Shi wrote: > > > On Fri, Oct 30, 2020 at 6:36 AM Michal Hocko wrote: > >> > >> On Fri 30-10-20 08:20:50, Zi Yan wrote: > >>> On 30 Oct 2020, at 5:43, Michal Hocko wrote: > >>> > >>>> [Cc Vlastimil] > >>>> > >>>> On Thu 29-10-20 16:04:35, Zi Yan wrote: > >>>>> From: Zi Yan > >>>>> > >>>>> In isolate_migratepages_block, when cc->alloc_contig is true, we ar= e > >>>>> able to isolate compound pages, nr_migratepages and nr_isolated did= not > >>>>> count compound pages correctly, causing us to isolate more pages th= an we > >>>>> thought. Use thp_nr_pages to count pages. Otherwise, we might be tr= apped > >>>>> in too_many_isolated while loop, since the actual isolated pages ca= n go > >>>>> up to COMPACT_CLUSTER_MAX*512=3D16384, where COMPACT_CLUSTER_MAX is= 32, > >>>>> since we stop isolation after cc->nr_migratepages reaches to > >>>>> COMPACT_CLUSTER_MAX. > >>>>> > >>>>> In addition, after we fix the issue above, cc->nr_migratepages coul= d > >>>>> never be equal to COMPACT_CLUSTER_MAX if compound pages are isolate= d, > >>>>> thus page isolation could not stop as we intended. Change the isola= tion > >>>>> stop condition to >=3D. > >>>>> > >>>>> 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_con= trol *cc, unsigned long low_pfn, > >>>>> > >>>>> isolate_success: > >>>>> list_add(&page->lru, &cc->migratepages); > >>>>> - cc->nr_migratepages++; > >>>>> - nr_isolated++; > >>>>> + cc->nr_migratepages +=3D thp_nr_pages(page); > >>>>> + nr_isolated +=3D thp_nr_pages(page); > >>>> > >>>> Does thp_nr_pages work for __PageMovable pages? > >>> > >>> Yes. It is the same as compound_nr() but compiled > >>> to 1 when THP is not enabled. > >> > >> I am sorry but I do not follow. First of all the implementation of the > >> two is different and also I was asking about __PageMovable which shoul= d > >> never be THP IIRC. Can they be compound though? > > > > I have the same question, can they be compound? If they can be > > compound, PageTransHuge() can't tell from THP and compound movable > > page, right? > > Right. I have updated the patch and use compound_nr instead. Thanks. Actually I'm wondering what kind of movable page could be compound. Any real examples? > > =E2=80=94 > Best Regards, > Yan Zi