Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp102494pxb; Wed, 11 Nov 2020 21:38:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJwDtDdz4T6A4ziyBvCujuhxzx+Fk0ltwTQ3c2dS8KIpmsWN1UTLWD7jeKq9XX/bFhEG8LLP X-Received: by 2002:a17:906:37d2:: with SMTP id o18mr16281794ejc.379.1605159517758; Wed, 11 Nov 2020 21:38:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605159517; cv=none; d=google.com; s=arc-20160816; b=sV2//78a1gu73FHP1fuBYxtonOtYd+THBFw4YgaVSbD3wiRlTT68sIQQPrbxqCA8b4 5I0/XyiUgGndCFJAfmjsbu/bgM01KIZ745hgBQeHY2GPW4b7Vvplq0Xr1ktrcF1RjKdl AyxIqzJ01x/KDYxS3QO0wAWUsi3649P601IyrpIvMI5tJzHdkID7yCRzUafOuH/Tps2o gh6gjNBOSVi8102M1tgpeM32KNMWL0k1n7K0yjs9kZpuiBxnF+dUCSTC2qyKGbYSUXkg yndP+Il0yDqLdKNcmcJup8tfcXK93YP8r0p6APx3VT247/YMCU7dWYp56X1PFA3lZ065 lLXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date:dkim-signature; bh=AvwRUTHJ9jTp1FV7SvxjXPTpodIViw+Olzzn0cdboYg=; b=C/K2GF/NxA1g5owC9y9rb35+VzCVYICauv5a9OLASropIZjIFRFBPJ8hZDeHRvDjGH n5lldw+Novvczji8Xx6pH2WISZjG2yBIrzYtl4pLzwxHo+4FM8i2AK63YmWkXNwXlLIc uadltEYsOldhxwoV/Lft6AoyRyDepENtYIw+DUr06NP1fEHJMSBgWpd4weZoWI62jCc9 Fgy7v8zS+4aUwvg/aHVDNUtuZ/Gg7OIvxKjPGOIPyb0ekoSlki9zDufu5NHtTptBRtKv qezQu9c7/+WQySdZni49o/Ne80GH9u6C3IaSldX/u3Xk0OmK3/MMJLm3zKzRo/K/1zZE ycxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=lMyQa3Ho; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a15si3519391eju.388.2020.11.11.21.38.14; Wed, 11 Nov 2020 21:38:37 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=lMyQa3Ho; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728736AbgKLFec (ORCPT + 99 others); Thu, 12 Nov 2020 00:34:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727672AbgKLC2o (ORCPT ); Wed, 11 Nov 2020 21:28:44 -0500 Received: from mail-ot1-x342.google.com (mail-ot1-x342.google.com [IPv6:2607:f8b0:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0244C0613D1 for ; Wed, 11 Nov 2020 18:28:42 -0800 (PST) Received: by mail-ot1-x342.google.com with SMTP id n89so4189168otn.3 for ; Wed, 11 Nov 2020 18:28:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=AvwRUTHJ9jTp1FV7SvxjXPTpodIViw+Olzzn0cdboYg=; b=lMyQa3HoSGrWwK8T9kKUMIlmfO5rgLpJnycM2uiTklWJC1raq7dGrWwm2m9/O/if2P 3n7ga50tjyyPXWvWHiYwKwgL71HOGc0UsHfCamf5Lb/v6jwKiGtkZaV+P/Wht/+eQ0gk 72CTbdBOF5eQeyXTRetfdXuu3yjIbyVQER+3mo8NswaNnZCCSwUw3+GXKNdL+WpEJPsc ZiloYfx5zK7I6BMUOJdaXePB/dRGYPw1vVDN88kE+Fh7udX6Jzsp3ynwIwSGo4T8Wq8k XyE0c8ANci/qxhmbZ7uB9liD3aqNmaCP5Ne/bJd5re/Pi7/eHeAqVlF05mv7yH2RRQyu ZXKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=AvwRUTHJ9jTp1FV7SvxjXPTpodIViw+Olzzn0cdboYg=; b=pNsYdV4YE29XpkfcxPfXEXIFhj0ktLtsnqVZOInIbmNVSA+QVzff3GU9b9gXmbtfS0 QSsabkNnj4rUFDpZJPCtBvnCvTvlPtsyzBzCK+shE1a8TiJEt38/PDVBNhXlY8207ofI eHCz8Fng6ajExBQ9BJVEnxf+VIg3eII2S1JpClb6jrOYkrIZzBvdK6FR9HZwX9ayBBWe zUNd048G9lsKEWUrnZyjyb2RBYX+3c3wmJTPMcYy5bpmThAPUWjeifXtwQKnsnyBebyH EOi7of5fOXkbesMj7HwuFyPZEB/iZf1XJutTgUIZK0pitli53xlzzlUjW/BKlbOVuxA3 dTfQ== X-Gm-Message-State: AOAM531BYcJmxA+TcZUQ210scCbYPYxjE/hsqASfSE0/5IRUcC/FJjxo xWkSADjKdQac9opSVHFI2gYJvg== X-Received: by 2002:a9d:6a96:: with SMTP id l22mr4298651otq.156.1605148121715; Wed, 11 Nov 2020 18:28:41 -0800 (PST) Received: from eggly.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id s14sm851761oij.4.2020.11.11.18.28.39 (version=TLS1 cipher=ECDHE-ECDSA-AES128-SHA bits=128/128); Wed, 11 Nov 2020 18:28:40 -0800 (PST) Date: Wed, 11 Nov 2020 18:28:38 -0800 (PST) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Vlastimil Babka cc: Alex Shi , akpm@linux-foundation.org, mgorman@techsingularity.net, tj@kernel.org, hughd@google.com, 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 Subject: Re: [PATCH v21 15/19] mm/compaction: do page isolation first in compaction In-Reply-To: Message-ID: References: <1604566549-62481-1-git-send-email-alex.shi@linux.alibaba.com> <1604566549-62481-16-git-send-email-alex.shi@linux.alibaba.com> User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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). Hugh