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=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_RED autolearn=ham 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 CDE67C433B4 for ; Tue, 18 May 2021 10:09:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7406361185 for ; Tue, 18 May 2021 10:09:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7406361185 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id F33B38D000F; Tue, 18 May 2021 06:09:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EBD5E8D0001; Tue, 18 May 2021 06:09:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D35FD8D000F; Tue, 18 May 2021 06:09:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0071.hostedemail.com [216.40.44.71]) by kanga.kvack.org (Postfix) with ESMTP id 9E2158D0001 for ; Tue, 18 May 2021 06:09:48 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 4542B7597 for ; Tue, 18 May 2021 10:09:48 +0000 (UTC) X-FDA: 78153930456.28.25AE8FA Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf12.hostedemail.com (Postfix) with ESMTP id 6BF28EF for ; Tue, 18 May 2021 10:09:45 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 2AF78611AD; Tue, 18 May 2021 10:09:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621332587; bh=zUaWX2mb0C3ryhkJQpsmWO0ofJTjLJ83Q9UbOek1xa8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=seikdRNTh/YjhJmN1mLIit2f8CzTC0hpm+j3Me1DCLIwlxL5hpJNiq7vZ7p2p2+tD oZ06ZHlF/ZXs/0uT2r1e1GKkJHQLfowmEREdxs+2xnB6V9JaBmumkdEGkfxXDcEOiH RsV9DpbM95zyW2jxzOFQ9hLEshmDcf3/70BfuSHGgZqtMluY0//x8eglF2XVNHll0U qouflSyuM8dD14CncgtOMwpLCAro5ksNWUby5Iz9fCn5Z3OwzXrD74uUZFCzIMe4hS VI5tWQok4kPubt5sNql3WPHfHil3fKmPv2GI0APWcftjkjFOgPNduBPTLmmEZKIOIt Bl6qe2U5wZr/A== Date: Tue, 18 May 2021 13:09:40 +0300 From: Mike Rapoport To: Dong Aisheng Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, dongas86@gmail.com, Andrew Morton Subject: Re: [PATCH 2/5] mm/sparse: free section usage memory in case populate_section_memmap failed Message-ID: References: <20210517112044.233138-1-aisheng.dong@nxp.com> <20210517112044.233138-3-aisheng.dong@nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210517112044.233138-3-aisheng.dong@nxp.com> Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=seikdRNT; spf=pass (imf12.hostedemail.com: domain of rppt@kernel.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 6BF28EF X-Stat-Signature: 1fhdhoiwnxhj3hp9krisjipcwyqb8fjc X-HE-Tag: 1621332585-576947 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 Mon, May 17, 2021 at 07:20:41PM +0800, Dong Aisheng wrote: > Free section usage memory in case populate_section_memmap failed. > We use map_count to track the remain unused memory to be freed. > > Cc: Andrew Morton > Signed-off-by: Dong Aisheng > --- > mm/sparse.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/mm/sparse.c b/mm/sparse.c > index 7ac481353b6b..98bfacc763da 100644 > --- a/mm/sparse.c > +++ b/mm/sparse.c > @@ -549,12 +549,14 @@ static void __init sparse_init_nid(int nid, unsigned long pnum_begin, > __func__, nid); > pnum_begin = pnum; > sparse_buffer_fini(); > + memblock_free_early(__pa(usage), map_count * mem_section_usage_size()); I'd move both sparse_buffer_fini() and freeing of 'usage' memory after the failed label. > goto failed; > } > check_usemap_section_nr(nid, usage); > sparse_init_one_section(__nr_to_section(pnum), pnum, map, usage, > SECTION_IS_EARLY); > usage = (void *) usage + mem_section_usage_size(); > + map_count--; > } > sparse_buffer_fini(); > return; > -- > 2.25.1 > > -- Sincerely yours, Mike.