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=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no 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 ECDAEC2D0A3 for ; Thu, 12 Nov 2020 11:25:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9E0CC221FE for ; Thu, 12 Nov 2020 11:25:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728152AbgKLLZh (ORCPT ); Thu, 12 Nov 2020 06:25:37 -0500 Received: from mx2.suse.de ([195.135.220.15]:59338 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727646AbgKLLZa (ORCPT ); Thu, 12 Nov 2020 06:25:30 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 63172AF74; Thu, 12 Nov 2020 11:25:27 +0000 (UTC) Subject: Re: [PATCH v21 15/19] mm/compaction: do page isolation first in compaction To: Hugh Dickins Cc: Alex Shi , akpm@linux-foundation.org, mgorman@techsingularity.net, tj@kernel.org, khlebnikov@yandex-team.ru, daniel.m.jordan@oracle.com, willy@infradead.org, hannes@cmpxchg.org, lkp@intel.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, shakeelb@google.com, iamjoonsoo.kim@lge.com, richard.weiyang@gmail.com, kirill@shutemov.name, alexander.duyck@gmail.com, rong.a.chen@intel.com, mhocko@suse.com, vdavydov.dev@gmail.com, shy828301@gmail.com References: <1604566549-62481-1-git-send-email-alex.shi@linux.alibaba.com> <1604566549-62481-16-git-send-email-alex.shi@linux.alibaba.com> From: Vlastimil Babka Message-ID: <85a40d01-09b6-1647-4ca0-7a83efdd9cbf@suse.cz> Date: Thu, 12 Nov 2020 12:25:26 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/12/20 3:28 AM, Hugh Dickins wrote: > On Wed, 11 Nov 2020, Vlastimil Babka wrote: >> On 11/5/20 9:55 AM, Alex Shi wrote: >> >> > @@ -979,10 +995,6 @@ static bool too_many_isolated(pg_data_t *pgdat) >> > goto isolate_abort; >> > } >> > - /* Recheck PageLRU and PageCompound under lock */ >> > - if (!PageLRU(page)) >> > - goto isolate_fail; >> > - >> > /* >> > * Page become compound since the non-locked check, >> > * and it's on LRU. It can only be a THP so the order >> > @@ -990,16 +1002,13 @@ static bool too_many_isolated(pg_data_t *pgdat) > > Completely off-topic, and won't matter at all when Andrew rediffs into > mmotm: but isn't it weird that this is showing "too_many_isolated(", > when actually the function is isolate_migratepages_block()? > >> > */ >> > if (unlikely(PageCompound(page) && >> > !cc->alloc_contig)) { >> > low_pfn += compound_nr(page) - 1; >> > - goto isolate_fail; >> > + SetPageLRU(page); >> > + goto isolate_fail_put; >> > } >> >> IIUC the danger here is khugepaged will collapse a THP. For that, >> __collapse_huge_page_isolate() has to succeed isolate_lru_page(). Under the >> new scheme, it shouldn't be possible, right? If that's correct, we can remove >> this part? > > I don't think so. A preliminary check for PageCompound was made much > higher up, before taking a reference on the page, but it can easily have > become PageCompound since then (when racing prep_new_page() calls > prep_compound_page()). > > And __collapse_huge_page_isolate() does not turn a non-compound page > into a compound page: it isolates small pages before copying them into > the compound page (in the usual case: I can see there's also allowance > for PageCompound there too, which will do something different). Right, on both points, got too confused. > Hugh > From mboxrd@z Thu Jan 1 00:00:00 1970 From: Vlastimil Babka Subject: Re: [PATCH v21 15/19] mm/compaction: do page isolation first in compaction Date: Thu, 12 Nov 2020 12:25:26 +0100 Message-ID: <85a40d01-09b6-1647-4ca0-7a83efdd9cbf@suse.cz> References: <1604566549-62481-1-git-send-email-alex.shi@linux.alibaba.com> <1604566549-62481-16-git-send-email-alex.shi@linux.alibaba.com> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: Content-Language: en-US List-ID: Content-Type: text/plain; charset="us-ascii"; format="flowed" To: Hugh Dickins Cc: Alex Shi , akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org, mgorman-3eNAlZScCAx27rWaFMvyedHuzzzSOjJt@public.gmane.org, tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org, khlebnikov-XoJtRXgx1JseBXzfvpsJ4g@public.gmane.org, daniel.m.jordan-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org, willy-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org, hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org, lkp-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org, linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, shakeelb-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org, iamjoonsoo.kim-Hm3cg6mZ9cc@public.gmane.org, richard.weiyang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, kirill-oKw7cIdHH8eLwutG50LtGA@public.gmane.org, alexander.duyck-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, rong.a.chen-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org, mhocko-IBi9RG/b67k@public.gmane.org, vdavydov.dev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, shy828301-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org On 11/12/20 3:28 AM, Hugh Dickins wrote: > On Wed, 11 Nov 2020, Vlastimil Babka wrote: >> On 11/5/20 9:55 AM, Alex Shi wrote: >> >> > @@ -979,10 +995,6 @@ static bool too_many_isolated(pg_data_t *pgdat) >> > goto isolate_abort; >> > } >> > - /* Recheck PageLRU and PageCompound under lock */ >> > - if (!PageLRU(page)) >> > - goto isolate_fail; >> > - >> > /* >> > * Page become compound since the non-locked check, >> > * and it's on LRU. It can only be a THP so the order >> > @@ -990,16 +1002,13 @@ static bool too_many_isolated(pg_data_t *pgdat) > > Completely off-topic, and won't matter at all when Andrew rediffs into > mmotm: but isn't it weird that this is showing "too_many_isolated(", > when actually the function is isolate_migratepages_block()? > >> > */ >> > if (unlikely(PageCompound(page) && >> > !cc->alloc_contig)) { >> > low_pfn += compound_nr(page) - 1; >> > - goto isolate_fail; >> > + SetPageLRU(page); >> > + goto isolate_fail_put; >> > } >> >> IIUC the danger here is khugepaged will collapse a THP. For that, >> __collapse_huge_page_isolate() has to succeed isolate_lru_page(). Under the >> new scheme, it shouldn't be possible, right? If that's correct, we can remove >> this part? > > I don't think so. A preliminary check for PageCompound was made much > higher up, before taking a reference on the page, but it can easily have > become PageCompound since then (when racing prep_new_page() calls > prep_compound_page()). > > And __collapse_huge_page_isolate() does not turn a non-compound page > into a compound page: it isolates small pages before copying them into > the compound page (in the usual case: I can see there's also allowance > for PageCompound there too, which will do something different). Right, on both points, got too confused. > Hugh >