Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3279259pxj; Tue, 1 Jun 2021 01:23:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzfRYLeplWTUCyP1Rq3www/vHOnl5TYOUdIGpRLSsVhXOeb0SMGlsaZk13LaZZEM8RxwuX1 X-Received: by 2002:a05:6402:1a:: with SMTP id d26mr31689926edu.105.1622535782144; Tue, 01 Jun 2021 01:23:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622535782; cv=none; d=google.com; s=arc-20160816; b=tQpTM6/8EWDWGqNdm4pvifq/5jXFO+k0osYLm7liWoKOSi0oZOGevP0CkbrxlJDt+H /PRc6TfL7lhoIUhx6hwsvgSOVhdBobT7J/R43OhhY6A2/obS0IX1/5DMIWPF7mVDO8eT PxuLaU8Mgx6sv1tIHnGVXCQw345+ORmhy9V69dyUEmEYkWKxObBMGb4jCNTu1ZWnBf9c VntzjUXEJpJABZFSmdsDoZbPFLC+/MKPfMvthqb6I5hKjmg0sYeo7fjKlRfuIw3jg48C gDxN+DfC5CyTsyKIpoRe2QsFi1/6Ge3hfrBF5FcHJ3SDemNJF7S+teBtkVoABH1Mf5Zk rTag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:organization :from:references:cc:to:subject:dkim-signature; bh=7PN8OYvVf5PYlxGFSvbIGKPtNNYZewqVjzezwL1VmKA=; b=a30xd7zy6c83Fv2IY1jqW1EFqEzV/E+qkrt5XZ+p3YIVSprc6RmQvX9QiWVdSVbRTr 4Jy7Ffq6fF7CnWeDuxNmME6BSPsRLI7wCAs3HkqpIQa8Zqxu8qSuzQK+EfohlXzd01za FuFLzhrxhTogGvPwCBkegWMHhiMlfdXm9OKLV4lRNLHFwWwFJ0ot5LJNDs1JSFylTEYs AcefkmPAnfB3e134ibBej+AeTS+P4JVLiTnjzmQpqXzp2PXs9ick6TBBRpT5imrgyLb/ AFqXDalF4VwHKae5YS0mouQ+T5/hOINT1gEwiYDTN0vOoLYpHz5doesh6xZjebf9/7t8 +RBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="H/IrEUeS"; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z16si17939253edm.391.2021.06.01.01.22.39; Tue, 01 Jun 2021 01:23:02 -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=@redhat.com header.s=mimecast20190719 header.b="H/IrEUeS"; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233295AbhFAIVV (ORCPT + 99 others); Tue, 1 Jun 2021 04:21:21 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:35713 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233406AbhFAIVQ (ORCPT ); Tue, 1 Jun 2021 04:21:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622535575; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7PN8OYvVf5PYlxGFSvbIGKPtNNYZewqVjzezwL1VmKA=; b=H/IrEUeSwuCMt7XOdptFpIv3WhXniDQBjHEDfmFxYerie4QHh8AJta0dSXhwKso5Yi/4yt qGo7L9ny+MBlIG5QhnGj8j0CEtWpxbtUOFFjpGtYQF80W78Lis9k7D60W31QgZAg26Db+b uG4iAm4EfOQ/mgKY9q9hU+qDGpU5u3g= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-419-okcQSou3MzmTO_EcxcT3IA-1; Tue, 01 Jun 2021 04:19:34 -0400 X-MC-Unique: okcQSou3MzmTO_EcxcT3IA-1 Received: by mail-wm1-f71.google.com with SMTP id z25-20020a1c4c190000b029019f15b0657dso287742wmf.8 for ; Tue, 01 Jun 2021 01:19:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=7PN8OYvVf5PYlxGFSvbIGKPtNNYZewqVjzezwL1VmKA=; b=I49JhfCjBTyFwl+3UwQSd0kwKoE4eHRsMd03N0xbmFPu/GkQO/+mMBsX0gOq9RLjyX c9hJY7OFdPhREFRH/N9QZU+jYAsqi3/6TuDyvxL7EXX4g88AdJWm1Af9sA6DviPr0+4K pVb9H7VqXYk9VWJLDG9iCSdNTIGKOMZDgdY66yjyUybC5b6I8eJwBGsxCp1KAkenhv4M CM3FJLsn1lypr1lNJwNncTcuiCsr4YFO0Iv/UXE8xZL0+c/9Buu9mRSOAvvMY4YIknfR PzmAd7gU2UwNvS/0pk3lOp/zzEQvAAOjc3NqW8i4eq8ppTdTBlf6r1ZIovuGxomQuwCY 8v8A== X-Gm-Message-State: AOAM532xcUbr0bDW9rz7P5LtAG93ofq0H8I6JVK/gogROUaFqEnvbuzB T/vfXUAoKcbD0BEqHNYPetFornM3KIWTIr/jzWJUDX6/Jtc1bojd1WjCzx4At65v54LptuE8dDW TUQ2nRNzVEEWtvlBn4rqYn8XH X-Received: by 2002:adf:a28c:: with SMTP id s12mr27767491wra.105.1622535572881; Tue, 01 Jun 2021 01:19:32 -0700 (PDT) X-Received: by 2002:adf:a28c:: with SMTP id s12mr27767482wra.105.1622535572730; Tue, 01 Jun 2021 01:19:32 -0700 (PDT) Received: from [192.168.3.132] (p5b0c69ce.dip0.t-ipconnect.de. [91.12.105.206]) by smtp.gmail.com with ESMTPSA id m132sm903398wmf.10.2021.06.01.01.19.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 01 Jun 2021 01:19:32 -0700 (PDT) Subject: Re: [PATCH V2 2/6] mm/sparse: free section usage memory in case populate_section_memmap failed To: Dong Aisheng , linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, dongas86@gmail.com, Andrew Morton , Mike Rapoport References: <20210531091908.1738465-1-aisheng.dong@nxp.com> <20210531091908.1738465-3-aisheng.dong@nxp.com> From: David Hildenbrand Organization: Red Hat Message-ID: <953557a5-f5cf-8780-ec60-73bff418650e@redhat.com> Date: Tue, 1 Jun 2021 10:19:23 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <20210531091908.1738465-3-aisheng.dong@nxp.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 31.05.21 11:19, 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 > Cc: Mike Rapoport > Signed-off-by: Dong Aisheng > --- > ChangeLog: > v1->v2: > * using goto + lable according to Mike's suggestion > --- > mm/sparse.c | 11 +++++++---- > 1 file changed, 7 insertions(+), 4 deletions(-) > > diff --git a/mm/sparse.c b/mm/sparse.c > index 7ac481353b6b..408b737e168e 100644 > --- a/mm/sparse.c > +++ b/mm/sparse.c > @@ -533,7 +533,7 @@ static void __init sparse_init_nid(int nid, unsigned long pnum_begin, > mem_section_usage_size() * map_count); > if (!usage) { > pr_err("%s: node[%d] usemap allocation failed", __func__, nid); > - goto failed; > + goto failed1; > } > sparse_buffer_init(map_count * section_map_size(), nid); > for_each_present_section_nr(pnum_begin, pnum) { > @@ -548,17 +548,20 @@ static void __init sparse_init_nid(int nid, unsigned long pnum_begin, > pr_err("%s: node[%d] memory map backing failed. Some memory will not be available.", > __func__, nid); > pnum_begin = pnum; > - sparse_buffer_fini(); > - goto failed; > + goto failed2; > } > 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; > -failed: > +failed2: > + sparse_buffer_fini(); > + memblock_free_early(__pa(usage), map_count * mem_section_usage_size()); > +failed1: > /* We failed to allocate, mark all the following pnums as not present */ > for_each_present_section_nr(pnum_begin, pnum) { > struct mem_section *ms; > I still don't think we need this. Did you even manage to trigger this to test your patch? -- Thanks, David / dhildenb