Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp1006685pxu; Mon, 26 Oct 2020 01:20:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzlKa+gH8Q0WhQtQvs1Jm1E5rqmCv96lYWsQeEpdCo7kYHJ+n71z0g7r7dyy/e8aFDbQq+3 X-Received: by 2002:a17:906:1150:: with SMTP id i16mr15014246eja.90.1603700405279; Mon, 26 Oct 2020 01:20:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603700405; cv=none; d=google.com; s=arc-20160816; b=IRC35oUh6EUtkW/JAxldLlSXubvFS900IaVKPqB1VXJuNhewlgZMW6N+jS+fJZnYbn sRtGgx5IjfAoWK3ayLt4jf+wXYR796h05a09Nz90tOQkQf7kCwRMSCnLYrqxvl2rVPVH mGAJl3qSePc78lpvkwv+P8Y9XQiS6axh/No876PkaspmrJ970R7t/djI52iFf/TzkBkb v2qHidbwdY99753oBeWWIMng8luRTE+39eH1vEyL7U2tbXTS36iXEiPK4sxZ/Eut7ted 3zU75mCxa8gb6LbTd9YMWn8E+dFy+bi+2f5C+ulLErTB6KK9zV/WxfjPCufwz1yTEoyS 6XSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dmarc-filter:sender:dkim-signature; bh=GHfN7fYWDbuLs8xbW/pt52/UcT5BFPrPOlOi4iKGWQs=; b=JlEMWV/5G6weo9RGHV91G9OJLP3GftYvmYI/9TTKnCFMpxZi1pYv0dFEZDnSMzYq7Y Djdc1enqh4VdtPcvqEDSOiOjqojiCNX86ukPs9d04or11etyItfKe3bva81EZccqqUAu +yISA8xKjIq87iHfkJ6lkTVDM0Wv7idIqqc5WTlM32FClen28Q7CF/FYaDRD59/LNiaI l70AmD3+GQnQ5sU/ZIHG7lluXJltR0k7t3HmrFMEiTeWbkqDNATYCYtBbRm4fA2N6nfI nFWgU1twC/v3pgVTEwOKl9Wfao2JdafCoGNaSGdM2/P5neK1VHj1tl5MBM9SOhrL/TAl otYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b="m8Yn9/9a"; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u24si5065105eje.619.2020.10.26.01.19.42; Mon, 26 Oct 2020 01:20:05 -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=@mg.codeaurora.org header.s=smtp header.b="m8Yn9/9a"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1768897AbgJZHNY (ORCPT + 99 others); Mon, 26 Oct 2020 03:13:24 -0400 Received: from z5.mailgun.us ([104.130.96.5]:43446 "EHLO z5.mailgun.us" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729568AbgJZHNY (ORCPT ); Mon, 26 Oct 2020 03:13:24 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1603696403; h=In-Reply-To: Content-Type: MIME-Version: References: Message-ID: Subject: Cc: To: From: Date: Sender; bh=GHfN7fYWDbuLs8xbW/pt52/UcT5BFPrPOlOi4iKGWQs=; b=m8Yn9/9awKvh7/VybW8HaNzfRzGGu/dZMyDJJi1o63ejLmGyXA86ehm/iTLO5FSCCpSwKR5h SHf78lMy8kl2opUXOyiRVG8Z9dEpMwysUwR7eYBVrSAGnol7+CbpuutgFhWokCHSlpbay0ap PQbdW+pTWm/ilv+UbJpDJ9/khG0= X-Mailgun-Sending-Ip: 104.130.96.5 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n06.prod.us-west-2.postgun.com with SMTP id 5f96770bd183303e72d98644 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Mon, 26 Oct 2020 07:13:15 GMT Sender: zhenhuah=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 4F8B1C433FF; Mon, 26 Oct 2020 07:13:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00,SPF_FAIL, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from codeaurora.org (unknown [180.166.53.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: zhenhuah) by smtp.codeaurora.org (Postfix) with ESMTPSA id 7F7DFC433CB; Mon, 26 Oct 2020 07:13:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 7F7DFC433CB Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=zhenhuah@codeaurora.org Date: Mon, 26 Oct 2020 15:12:55 +0800 From: Zhenhua Huang To: Mike Rapoport 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: <20201026071255.GA31027@codeaurora.org> References: <1602839640-13125-1-git-send-email-zhenhuah@codeaurora.org> <20201025154253.GH392079@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201025154253.GH392079@kernel.org> User-Agent: Mutt/1.5.24 (2015-08-30) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > > > 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. >