Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4713214ybv; Wed, 26 Feb 2020 01:50:21 -0800 (PST) X-Google-Smtp-Source: APXvYqx7K39y6F2MIIEfkyc9Rjg2V6bFvFoOSx7tQVR2Vf7eNnYh5kqaMxSx6eXl4nXuoAe+jcdc X-Received: by 2002:a9d:6288:: with SMTP id x8mr2253549otk.2.1582710621073; Wed, 26 Feb 2020 01:50:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582710621; cv=none; d=google.com; s=arc-20160816; b=TANlT14I0/3XLAKjcGNlcwZi5XCq6hsWGu35zvkigHa8SSWYp5NkbScYOKZQEmfTeT gmfgJrByBAfYKDfMOHFZbySVRIJZRNH/9yHzuMjkrsMUudvStByXTRQVD7HKAsI2BmCk 9ss0NkxsusLNy2CByAn7jMsEuvLBeDbjA/KqkJWk3Ptlf2UofVbYhD5nRfsNDfocLjl7 NckVWOkbBT6YZuoHXNfg6BVFRrihEPVSmwUXmk5bjBecXpjxcW8AsVgpcsXOK92yBr/Y k54bqaa9Z6tjJK+dzG3gPocw2QWf6ge3q/vOVnjFWrBU0UaMnzlW7BhQD8JnxNKru6yb 4yng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:subject:from; bh=9f86cDzbv0u8t5bS4reWGmZ6PUYaDhS6qiI6OYmUkxA=; b=hCs4Z+FTvmg/IyfcnSAx0bzMLGLopRbOWx4hF7HV4Iof7OItbKg73P3Fm1zcZ3PRAa LT8tTvMsPWpOKpdydcAOY2AHwNcU3YXteRzgsk3o9pL6BCjl6Danlyo/jR9RDTU/6b0h 7jRRv13tRrnGF+1nF+SdXeSRC4/4vcTCZIlc26Mh6vpvHhojQmy8CVRh068W3jZbUNZY jqEM5noeb2mExjsepl6yV0LqohlcyVP3xaG5xxJymDkjgZbMcl8G61kTFRaG/eCQuht2 O0mvb+Iu89wlTeBxSeBZ7owcT7+TLMi/sd8tPBIq4fc7oyG7+rTRQgC8CWvNeUT7FAHl X87w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w2si944399otq.31.2020.02.26.01.50.09; Wed, 26 Feb 2020 01:50:21 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727815AbgBZJsm (ORCPT + 99 others); Wed, 26 Feb 2020 04:48:42 -0500 Received: from mx2.suse.de ([195.135.220.15]:39982 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726764AbgBZJsm (ORCPT ); Wed, 26 Feb 2020 04:48:42 -0500 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); >> > >> >> >