Received: by 2002:a17:90a:37e8:0:0:0:0 with SMTP id v95csp206834pjb; Thu, 3 Oct 2019 05:02:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqybrZDKvXzsaoRADU51bNT8e/tC4ccDJQPfwmvE3o4q9GK2smy787F57BLHB6T0tGWrwsSZ X-Received: by 2002:a17:906:7a0d:: with SMTP id d13mr7363121ejo.242.1570104142850; Thu, 03 Oct 2019 05:02:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570104142; cv=none; d=google.com; s=arc-20160816; b=j22oc09+HEvu0DYf2y2SBmlDQtMEZgleTL63NuEru/kyXOjixcXrf6PxGMPZcnEJRu n8Hzlt2XPT4dlr8pjx3eR0of93NwVW4Nl6Rpn6ehbScp9V8qwgMAZHeBxmyeP9sVP/z3 iTzyMFHxHg8Z3c+AKnJ0RJ42sZ80vPO8SrKi0X9MfodCfHwd9dXueNQT9HrjTf3X/Hjo GwgHct8SUBRTATUb/gHvjkeFaHEscQXeGWV4aO7E5Oe5xybLo7OxoElW3lDmZ1Qp/eIw OaemrkQAtioRaf/N3TXgfH5XnEiTC5bAmTrFaBnEEWwUM06xQbeyKE+6JYmiDpWSZca1 SPZQ== 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:from:references:cc:to:subject; bh=wOKRL9DnMXPQX3cFQjLmQU1r7+7ALJT5XaY8bw7D16U=; b=0kWh/hhS/h0Z4EHhVXyaFMP0QSsU46HgBHDoq0wdAH02ZMA0AzRQqHEgkrZfy2w7EQ bdMSHwEhoRhD/OYmAX5ufyD0QwMSorB6EJyS2H7buPIJ8hkzirEljTitfPzu2bVvL14D ZORH/5aSX4bzQfzSztoYCsGmeS8P2Vxoc3PFiPcJHdg6Y9qcOH5QQmf8OPCM3vsYqAgB DO5KMcMUt/PkfWXMeCQXAw+s7WrqJ2BlYbP9hrKwIhQPrREMYAIU+kZFW4jn0IIkLAnI dR9ISACJNJltaar7Phm6OV8owPDIszGXC3Pqcbc1sc9wETKPHvryppAm7bn5mXja0hbH SgWg== 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 rl13si1021996ejb.228.2019.10.03.05.01.51; Thu, 03 Oct 2019 05:02:22 -0700 (PDT) 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 S1727758AbfJCMBp (ORCPT + 99 others); Thu, 3 Oct 2019 08:01:45 -0400 Received: from foss.arm.com ([217.140.110.172]:43092 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725827AbfJCMBp (ORCPT ); Thu, 3 Oct 2019 08:01:45 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 12729337; Thu, 3 Oct 2019 05:01:44 -0700 (PDT) Received: from [10.162.40.180] (p8cg001049571a15.blr.arm.com [10.162.40.180]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0C6203F534; Thu, 3 Oct 2019 05:01:40 -0700 (PDT) Subject: Re: [PATCH] mm/page_alloc: Add a reason for reserved pages in has_unmovable_pages() To: Qian Cai Cc: linux-mm@kvack.org, Andrew Morton , Michal Hocko , Vlastimil Babka , Oscar Salvador , Mel Gorman , Mike Rapoport , Dan Williams , Pavel Tatashin , linux-kernel@vger.kernel.org References: <983E7EA4-A022-448C-B11D-8C10441A2E07@lca.pw> From: Anshuman Khandual Message-ID: <49fa7dea-00ac-155f-e7b7-eeca206556b5@arm.com> Date: Thu, 3 Oct 2019 17:32:02 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <983E7EA4-A022-448C-B11D-8C10441A2E07@lca.pw> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/03/2019 05:20 PM, Qian Cai wrote: > > >> On Oct 3, 2019, at 7:31 AM, Anshuman Khandual wrote: >> >> Ohh, never meant that the 'Reserved' bit is anything special here but it >> is a reason to make a page unmovable unlike many other flags. > > But dump_page() is used everywhere, and it is better to reserve “reason” to indicate something more important rather than duplicating the page flags. > > Especially, it is trivial enough right now for developers look in the page flags dumping from has_unmovable_pages(), and figure out the exact branching in the code. > Will something like this be better ? hugepage_migration_supported() has got uncertainty depending on platform and huge page size. diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 15c2050c629b..8dbc86696515 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -8175,7 +8175,7 @@ bool has_unmovable_pages(struct zone *zone, struct page *page, int count, unsigned long found; unsigned long iter = 0; unsigned long pfn = page_to_pfn(page); - const char *reason = "unmovable page"; + const char *reason; /* * TODO we could make this much more efficient by not checking every @@ -8194,7 +8194,7 @@ bool has_unmovable_pages(struct zone *zone, struct page *page, int count, if (is_migrate_cma(migratetype)) return false; - reason = "CMA page"; + reason = "Unmovable CMA page"; goto unmovable; } @@ -8206,8 +8206,10 @@ bool has_unmovable_pages(struct zone *zone, struct page *page, int count, page = pfn_to_page(check); - if (PageReserved(page)) + if (PageReserved(page)) { + reason = "Unmovable reserved page"; goto unmovable; + } /* * If the zone is movable and we have ruled out all reserved @@ -8226,8 +8228,10 @@ bool has_unmovable_pages(struct zone *zone, struct page *page, int count, struct page *head = compound_head(page); unsigned int skip_pages; - if (!hugepage_migration_supported(page_hstate(head))) + if (!hugepage_migration_supported(page_hstate(head))) { + reason = "Unmovable HugeTLB page"; goto unmovable; + } skip_pages = compound_nr(head) - (page - head); iter += skip_pages - 1; @@ -8271,8 +8275,10 @@ bool has_unmovable_pages(struct zone *zone, struct page *page, int count, * is set to both of a memory hole page and a _used_ kernel * page at boot. */ - if (found > count) + if (found > count) { + reason = "Unmovable non-LRU page"; goto unmovable; + } } return false; unmovable: