Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp269164pxb; Thu, 12 Nov 2020 03:27:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJyesDx3MhckGo/+OYoptVMQc6FAim3FF7LvFGmco+45j+QSM15WgqiB5JPsroLBnH0x7o+p X-Received: by 2002:a17:906:4944:: with SMTP id f4mr27944994ejt.231.1605180472395; Thu, 12 Nov 2020 03:27:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605180472; cv=none; d=google.com; s=arc-20160816; b=LYQjMjlB51qyhjzYk6D+MipHGWrXg1uOwqt0qa94//L1SDvZmsKfT7SPpfL3tF+FiH fiv5DcSNdOR4mbvZz/N9OLPhmi4GHM4I3KZuZIJdxcQ7VO33DtwMwGnN+YYJP1CkpTdO SGYnoXjP6vD64iZUR1+fmiWKwKOUVRO2JCASu4POZZMcJx+8qhQ9Lkzuw1Qc9issvSEV rm3WksHi6SiotJd3bAfQsxYMWiBVprKnBW/BSf5Tr2NCmZwz3SB9FzpvytXBV8RT+5Um 8yA59CqjLl1o3VQoBFgntMYlOf0z+D52d1T+PShJQBGWRQXHiE9Ma45scWVaRynY5fuq dByA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=6D5PqpVP5MjJAAdnjBpn2FlCQjUYT4ofMjtBDxKmDr4=; b=L4NBBjnBlqFwOKtfHC6Rx1a6BJCtKHbPf36CVd3L5wCumzL21/cUV8qCegpluQ8DwJ jpknUEq+3sZrL+huZpCLLBVfKSt7EYz15LJ3Cmo9AlgeaZAANr5Pa9lbw7NDSt5h9/8D kchXwysokRsBtw7T2gh58qdLQQp+Zwis5eJHN2k7XEYnFXDKzpTV71cnVJnhY6gLMq5B f+ByZw+/nDNnLjOav5xpqKwS5XPMhKNLk1bw1qhDrVw5yAoYGDHZA4l4VwGmYf4pG2Vh 5zavY6PIS5HU6F82WuBgkbfxXrkbvki3EjHmEwVujr1wPqgueWjGi98UVwJ2VcQCgppK EDlg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d1si3471162ejj.113.2020.11.12.03.27.29; Thu, 12 Nov 2020 03:27: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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728149AbgKLLZf (ORCPT + 99 others); Thu, 12 Nov 2020 06:25:35 -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 >