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=-2.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,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 82CDAC4BA0E for ; Wed, 26 Feb 2020 09:48:43 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4F51F24673 for ; Wed, 26 Feb 2020 09:48:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4F51F24673 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id EE6ED6B0003; Wed, 26 Feb 2020 04:48:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E984D6B0005; Wed, 26 Feb 2020 04:48:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DACCD6B0006; Wed, 26 Feb 2020 04:48:42 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0083.hostedemail.com [216.40.44.83]) by kanga.kvack.org (Postfix) with ESMTP id C093B6B0003 for ; Wed, 26 Feb 2020 04:48:42 -0500 (EST) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 91DC1181AC9C6 for ; Wed, 26 Feb 2020 09:48:42 +0000 (UTC) X-FDA: 76531803684.11.slope31_4bf9fc432d65d X-HE-Tag: slope31_4bf9fc432d65d X-Filterd-Recvd-Size: 3342 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf01.hostedemail.com (Postfix) with ESMTP for ; Wed, 26 Feb 2020 09:48:41 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 8A9FFAC91; Wed, 26 Feb 2020 09:48:39 +0000 (UTC) From: Vlastimil Babka Subject: Re: [PATCH 2/2] mm,thp,compaction,cma: allow THP migration for CMA allocations To: Rik van Riel , linux-kernel@vger.kernel.org Cc: kernel-team@fb.com, akpm@linux-foundation.org, linux-mm@kvack.org, mhocko@kernel.org, mgorman@techsingularity.net, rientjes@google.com, aarcange@redhat.com References: <3289dc5e6c4c3174999598d8293adf8ed3e93b57.1582321645.git.riel@surriel.com> <05027092-a43e-756f-4fee-78f29a048ca1@suse.cz> Message-ID: <81c8d2fa-a8ae-82b8-f359-bba055fbff68@suse.cz> Date: Wed, 26 Feb 2020 10:48:37 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit 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 2/25/20 7:44 PM, Rik van Riel wrote: >> Also PageTransHuge() is basically just a PageHead() so for each >> non-hugetlbfs compound page this will assume it's a THP, while >> correctly >> it should reach the __PageMovable() || PageLRU(page) tests below. >> >> So probably this should do something like. >> >> if (PageHuge(page) || PageTransCompound(page)) { >> ... >> if (PageHuge(page) && !hpage_migration_supported)) return page. > > So far so good. > >> if (!PageLRU(head) && !__PageMovable(head)) return page > > I don't get this one, though. What about a THP that has > not made it onto the LRU list yet for some reason? Uh, is it any different from base pages which have to pass the same check? I guess the caller could do e.g. lru_add_drain_all() first. > I don't think anonymous pages are marked __PageMovable, > are they? It looks like they only have the PAGE_MAPPING_ANON > flag set, not the PAGE_MAPPING_MOVABLE one. > > What am I missing? My point is that we should not accept compound pages that are neither a migratable hugetlbfs page nor a THP, as movable. And your PageTransHuge() test and my PageTransCompound() is really just a test for all compound pages, not "hugetlbfs or THP only". I should have perhaps suggested PageCompound() instead of the PageTransCompound() wrapper, to make it more obvious. So we should test non-hugetlbfs pages first whether they are the kind of compound pages that are migratable. THP's should pass this test by PageLRU(), other compound movable pages by __PageMovable(head). > >> ... >> >> > struct page *head = compound_head(page); >> > unsigned int skip_pages; >> > >> > - if >> > (!hugepage_migration_supported(page_hstate(head))) >> > + if (PageHuge(page) && >> > + !hugepage_migration_supported(page_hstate(h >> > ead))) >> > return page; >> > >> > skip_pages = compound_nr(head) - (page - head); >> > >> >> >