Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1522227pxx; Fri, 30 Oct 2020 11:59:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwgsGlhTgqsB95yJEqMG8ZZssHc/4/DE+BZii2oBfro/PHVQRIb7ASduyadm0M927m4ifA3 X-Received: by 2002:a17:906:1c83:: with SMTP id g3mr3891288ejh.168.1604084380781; Fri, 30 Oct 2020 11:59:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1604084380; cv=none; d=google.com; s=arc-20160816; b=KjQKzpeiguhPMY72ZKi0fsBAmWlObXSKlBC1DD8GLm+851zh8uv70jL+LzIZPMhR7L ql5YRSHWU4JiiRoulc4KYsMVGgJ/2pZNV6A3R5MJZKtz8qVhHv1A/8tlN0nTanEc4rAQ TWQL7+Qy7BsfPGZMvBseiCmv56wFL3s8Y2NUh5u1fdx4DJU0i9PiFG2bRwyM4fZtfmuk iqcYdKfxPR8N/VF8NwZbzJOHBp8K++bemROWib3cemGsQa0U87PffyH9LP326yWNAcG3 cJBrJAqyz8MSIC+sJTkrF8ZawyxFev54ymp62+WD2YpE2gP6PvKWNlB1NrTL6t3AWI31 wfjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=SpmAhXEjATLtxu6nBA8LZUlE07GKFiy6OiJGOpSxj8o=; b=mWS97P7AfAP/oAY/cwu3mnEVzdxj+AiLlVFgzr8MY6+R5QGvGNqKu59lRxI2BmWths ePji5os9jytmXy6StXY7tzWA+x1Vrd31mX8+4hGQZFx/j5NuOyNUhsr2hza3TCDjvnqq KYQpNjBLMvhsdQcQOZ5ik9OzuAEk8XHKVdvxiKbNmIuNwzshPvL0Ya/82E56xKURmk7V I2YOHmr4wj6rFNX0gXC0wxYlSjgFOlmgr9+Kt1xK5xkWkLmoqEge/sFSvAgb7mOCovCe LJEF5xfAWyNEBWohl92gS5jxF6VrGVFHXAqwP5w3ESoEnjvHwm3tFGGzuaJGtEVhJHGF v6gQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Fs9x9IDc; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l7si4844752ejb.373.2020.10.30.11.59.17; Fri, 30 Oct 2020 11:59:40 -0700 (PDT) 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=@gmail.com header.s=20161025 header.b=Fs9x9IDc; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727026AbgJ3Sz5 (ORCPT + 99 others); Fri, 30 Oct 2020 14:55:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726095AbgJ3Sz5 (ORCPT ); Fri, 30 Oct 2020 14:55:57 -0400 Received: from mail-ej1-x643.google.com (mail-ej1-x643.google.com [IPv6:2a00:1450:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35883C0613CF for ; Fri, 30 Oct 2020 11:55:57 -0700 (PDT) Received: by mail-ej1-x643.google.com with SMTP id p9so10028352eji.4 for ; Fri, 30 Oct 2020 11:55:57 -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=P050paS2Aac4N3KKxJ76WVFW+MDHXLpzcUDEkWUcHF2BtaoadCaXlsH/x7tsNgilfI Xf1bLJrxg4gpqPLDAfnPuqXl/kVexljrCSj8Ygt2umr3vZyaJwr8zhR3RywwCiEaptOC mg6LpzXzo2na0boWs7r6/1ZZRnAmoVlrLyVGmyJMhuthd1Z105ApZajzywNrTgWStPth CrgCGwWLymEUFwM0kOEx4KiNpI1vZNkUcknsrZgw9Q9KPXfk54RNR9Dd7Pe0f5ZlZJ2M Xjc9aRkH21098u09LI6n+6crAfgQTR+ufcYFc9zXyFGGAB0EYt8v62EF3CA3w38eu9eg JOoQ== X-Gm-Message-State: AOAM533S+wqU/Bi0hO2WGW+6wZyr01y+NSxYgdWNyA6ecSe1nZAZ2B3Z oTROo6XoXngug51YxtkS5qxVnzIKhwzV8tRLN5Q= 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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