Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp96100pxx; Mon, 26 Oct 2020 04:20:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy/Cevx78YMQbFSGmERSGPp0IJpyIUc/Zf7g5/KqjwaZKQlJ9/gIe4Qp7RL2a1tid8m2Hqg X-Received: by 2002:a05:6402:1d2c:: with SMTP id dh12mr14764686edb.256.1603711244518; Mon, 26 Oct 2020 04:20:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603711244; cv=none; d=google.com; s=arc-20160816; b=DbacN+ibD2MF2j415xC3R+rfAQZjYv3Wiycg0J2/MeOyGEJp0jYX995JzFrKHbJysh XCuSGRpEGTFTHsCaFINvTjmWUjj9WoY1/tTjR5QWVIsrErOEbpVFl7EQy7BFPbiLXuX/ 6k6dHfL1ZIIBBoIkEg46dhVe489Vwv5Ip4CrOU73SOhpFgShaxcULeIl2zBUk9SGBgPa EyI2Nxu00Xw7x4q4ocBG2QujGQAONcTnYq7FUaGh9qYpcjbRusWUV8OxsW1u5k9+2eQv h4Og7+qaJdvfmlB5nhbKxU73RO/Av3vkq1Fv4QIRFaOgF8/YVXo5AxBz9u3yrw+BCad1 sgwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=IMl5RTGa66ottkgwGz/q1JoTUQEQwS3uu3lrbByZ4Gg=; b=EUxzsMIFl9to1M/JbaBvQEFcMG9Cw4lwMcxxbc3iVhebxothlC55cSSpFV0RWLZUgz RDOSC9HC3aiOb7qojjKDKCu8eHQ1DXuN/vWUrBkWynXiKVrU+WBxxMGTQEV4WMGoO/wv giVpd6efblk43RUsEcsheMRJGAE6B73ktd9uVgkSRj69TbB7nOqsmas4F1OH9a2G4wJd QphJxR2asXLJ7UEiD0Dq8KXXNdO8bbDhfnzgT9U2E4Gsru+tto/2MV4Y7DKcMqGq9qcu th19/i3lyywCdK3TY2gOmXaSFjQLRVLOtXEU2AQ6agm/4kxkzXp8zCgsZgKRroUrgyRD osAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gDPmyWFT; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m13si6887319ejc.539.2020.10.26.04.20.21; Mon, 26 Oct 2020 04:20:44 -0700 (PDT) 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=@kernel.org header.s=default header.b=gDPmyWFT; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1422580AbgJZJjo (ORCPT + 99 others); Mon, 26 Oct 2020 05:39:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:40754 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1422459AbgJZJjm (ORCPT ); Mon, 26 Oct 2020 05:39:42 -0400 Received: from kernel.org (unknown [87.70.96.83]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6718020874; Mon, 26 Oct 2020 09:39:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603705182; bh=9Aaz/fgIgvwzqz09IPukWhEn6OJpwI3J5aUonqRW1oI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=gDPmyWFTGsDdTkmo1PfbwI1mtXXpVmb1ycRT+r0SimHGITeyEQM8sOegLWK48pxc7 +w5eBhkaKMED9eSFCouva+Ty2bm684P95NgOzQWzf7gXwi36zTjKK6dUozBE2q04Vj Wl/XW1Db6eCnzgzl6MtUlLXK7X/gSNQ5W82uJ8wg= Date: Mon, 26 Oct 2020 11:39:34 +0200 From: Mike Rapoport To: Zhenhua Huang Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH] mm: fix page_owner initializing issue for arm32 Message-ID: <20201026093934.GD1154158@kernel.org> References: <1602839640-13125-1-git-send-email-zhenhuah@codeaurora.org> <20201025154253.GH392079@kernel.org> <20201026071255.GA31027@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201026071255.GA31027@codeaurora.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 26, 2020 at 03:12:55PM +0800, Zhenhua Huang wrote: > Hi Mike, > > On Sun, Oct 25, 2020 at 11:42:53PM +0800, Mike Rapoport wrote: > > On Fri, Oct 16, 2020 at 05:14:00PM +0800, Zhenhua Huang wrote: > > > Page owner of pages used by page owner itself used is missing on arm32 > > targets. > > > The reason is dummy_handle and failure_handle is not initialized > > correctly. > > > Buddy allocator is used to initialize these two handles. However, buddy > > > allocator is not ready when page owner calls it. This change fixed that > > by > > > initializing page owner after buddy initialization. > > > > > > The working flow before and after this change are: > > > original logic: > > > 1. allocated memory for page_ext(using memblock). > > > > Is anything that requires a memblock allocation FLATMEM? > > Any fundamental reason why wouldn't alloc_pages_exact_nid/vzalloc_node() > > work in this case? > > > > It seems to me that for FLATMEM configuration we can allocate the > > page_ext using alloc_pages() with a fallback to vzalloc_node() and then > > we can unify lot's of page_ext code and entirely drop > > page_ext_init_flatmem(). > > From comments in codes: "page_ext requires contiguous pages, bigger than > MAX_ORDER unless SPARSEMEM." > The size of page_ext for FLATMEM(which used pgdat) should be much larger than > the size for SPARSEMEM which used section. Well, the vzalloc_node() fallback in alloc_page_ext() for SPARSEMEM case implies that using pages that are not physically contiguous should be fine. So, it seems to me that the comment is stale and vzalloc_node() would work just fine for FLATMEM case if the allocation of page_ext would exceed MAX_ORDER. > > > 2. invoke the init callback of page_ext_ops like > > > page_owner(using buddy allocator). > > > 3. initialize buddy. > > > > > > after this change: > > > 1. allocated memory for page_ext(using memblock). > > > 2. initialize buddy. > > > 3. invoke the init callback of page_ext_ops like > > > page_owner(using buddy allocator). > > > > > > with the change, failure/dummy_handle can get its correct value and > > > page owner output for example has the one for page owner itself: > > > Page allocated via order 2, mask 0x6202c0(GFP_USER|__GFP_NOWARN), pid > > 1006, ts > > > 67278156558 ns > > > PFN 543776 type Unmovable Block 531 type Unmovable Flags 0x0() > > > init_page_owner+0x28/0x2f8 > > > invoke_init_callbacks_flatmem+0x24/0x34 > > > start_kernel+0x33c/0x5d8 > > > (null) > > > > > > Signed-off-by: Zhenhua Huang > > > --- > > > include/linux/page_ext.h | 8 ++++++++ > > > init/main.c | 2 ++ > > > mm/page_ext.c | 8 +++++++- > > > 3 files changed, 17 insertions(+), 1 deletion(-) > > > > > > diff --git a/include/linux/page_ext.h b/include/linux/page_ext.h > > > index cfce186..aff81ba 100644 > > > --- a/include/linux/page_ext.h > > > +++ b/include/linux/page_ext.h > > > @@ -44,8 +44,12 @@ static inline void page_ext_init_flatmem(void) > > > { > > > } > > > extern void page_ext_init(void); > > > +static inline void page_ext_init_flatmem_late(void) > > > +{ > > > +} > > > #else > > > extern void page_ext_init_flatmem(void); > > > +extern void page_ext_init_flatmem_late(void); > > > static inline void page_ext_init(void) > > > { > > > } > > > @@ -76,6 +80,10 @@ static inline void page_ext_init(void) > > > { > > > } > > > > > > +static inline void page_ext_init_flatmem_late(void) > > > +{ > > > +} > > > + > > > static inline void page_ext_init_flatmem(void) > > > { > > > } > > > diff --git a/init/main.c b/init/main.c > > > index 130376e..b34c475 100644 > > > --- a/init/main.c > > > +++ b/init/main.c > > > @@ -818,6 +818,8 @@ static void __init mm_init(void) > > > init_debug_pagealloc(); > > > report_meminit(); > > > mem_init(); > > > + /* page_owner must be initialized after buddy is ready */ > > > + page_ext_init_flatmem_late(); > > > kmem_cache_init(); > > > kmemleak_init(); > > > pgtable_init(); > > > diff --git a/mm/page_ext.c b/mm/page_ext.c > > > index a3616f7..373f7a1 100644 > > > --- a/mm/page_ext.c > > > +++ b/mm/page_ext.c > > > @@ -99,6 +99,13 @@ static void __init invoke_init_callbacks(void) > > > } > > > } > > > > > > +#if !defined(CONFIG_SPARSEMEM) > > > +void __init page_ext_init_flatmem_late(void) > > > +{ > > > + invoke_init_callbacks(); > > > +} > > > +#endif > > > + > > > static inline struct page_ext *get_entry(void *base, unsigned long > > index) > > > { > > > return base + page_ext_size * index; > > > @@ -177,7 +184,6 @@ void __init page_ext_init_flatmem(void) > > > goto fail; > > > } > > > pr_info("allocated %ld bytes of page_ext\n", total_usage); > > > - invoke_init_callbacks(); > > > return; > > > > > > fail: > > > -- > > > The Qualcomm Innovation Center, Inc. is a member of the Code Aurora > > Forum, > > > a Linux Foundation Collaborative Project > > > > > > > > > > -- > > Sincerely yours, > > Mike. > > -- Sincerely yours, Mike.