Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp148561imm; Mon, 2 Jul 2018 09:06:57 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL/z+0hUOUl7tySEp0yuVaa4pS92HskcvBUbV2YylE4bC2pEgISpl+sUJG9MtwdSXC7S5ao X-Received: by 2002:a17:902:b28:: with SMTP id 37-v6mr25863988plq.201.1530547617288; Mon, 02 Jul 2018 09:06:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530547617; cv=none; d=google.com; s=arc-20160816; b=wQSegDBvwc49VE3HZ5c2jFf7DQ60FTwbwBgRebD24ejgUS4Xa2U/g47b/GFOxrkP0D E+r1jzqN6X3+TVNuivoRYg+vFXlsEwMVZR+qeMaOW9HDp3DyegjDWojfWu5fhrkE2v/1 +xoMkkSQpFTHDCx7MKRemhCo5D2L3gpLJFSbvEMZkQm4gL0MdcUow06VWs/YQ4Pi0EOo ikqLnsOu6npQ/E3LkknQimpJaLXCoWJTkwfe3kuItqnxwo8f9bxNujcmG4/pHDSCxh6i wBanhs8BwKjMFAft1U9J4oZsqNKOpNlz0h6z9i7qEccqSETfpFTikz3ihc4cMO8ti9A8 +DCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=tzxVw54fkH/3vx5A97fiGS9zdXAs4C9jtNwRzchXI2k=; b=Y23WFjasmWQiWc6HEkZx6+rUezwE2w/KJKuwMhyf0djm1m4trAhilQRXdzIE8YTwwk AEIGLnxwWug/n2bWbKZzNhosa48E5A4VcWlKn1ccMfZAolDqKhpcnYufxII1CFoLHMGM Mk8pfI3QHsNj8lUOOY5krakwkn0uh+nxGXLqWL85vM2eUpUwRSV23IyqxIgXUP3MW25f hP5R571sZuac33o8Mi48bF0xS4YBx6HkvJQOhaXQekgOjDb0hEf2f4VdC/cVSv/zDGxe MTFFV6BRmSMMuG1SZogcb0/P7LWsJ34gw2OIorkm1nMj4oZnDiWjACoRv9Vi2ZwIhq9W YanA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z10-v6si12016545pgo.412.2018.07.02.09.06.42; Mon, 02 Jul 2018 09:06:57 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752774AbeGBQFQ (ORCPT + 99 others); Mon, 2 Jul 2018 12:05:16 -0400 Received: from mx2.suse.de ([195.135.220.15]:55352 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752212AbeGBQFP (ORCPT ); Mon, 2 Jul 2018 12:05:15 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id A37C7AEC8; Mon, 2 Jul 2018 16:05:13 +0000 (UTC) Date: Mon, 2 Jul 2018 18:05:12 +0200 From: Michal Hocko To: osalvador@techadventures.net Cc: akpm@linux-foundation.org, pasha.tatashin@oracle.com, vbabka@suse.cz, bhe@redhat.com, kirill.shutemov@linux.intel.com, dave.hansen@linux.intel.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Oscar Salvador Subject: Re: [PATCH] mm/sparse: Make sparse_init_one_section void and remove check Message-ID: <20180702160512.GF19043@dhcp22.suse.cz> References: <20180702154325.12196-1-osalvador@techadventures.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180702154325.12196-1-osalvador@techadventures.net> User-Agent: Mutt/1.10.0 (2018-05-17) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon 02-07-18 17:43:25, osalvador@techadventures.net wrote: > From: Oscar Salvador > > sparse_init_one_section() is being called from two sites: > sparse_init() and sparse_add_one_section(). > The former calls it from a for_each_present_section_nr() loop, > and the latter marks the section as present before calling it. > This means that when sparse_init_one_section() gets called, we already know > that the section is present. > So there is no point to double check that in the function. > > This removes the check and makes the function void. Looks good. > Signed-off-by: Oscar Salvador Acked-by: Michal Hocko > --- > mm/sparse.c | 12 +++--------- > 1 file changed, 3 insertions(+), 9 deletions(-) > > diff --git a/mm/sparse.c b/mm/sparse.c > index b2848cc6e32a..f55e79fda03e 100644 > --- a/mm/sparse.c > +++ b/mm/sparse.c > @@ -264,19 +264,14 @@ struct page *sparse_decode_mem_map(unsigned long coded_mem_map, unsigned long pn > return ((struct page *)coded_mem_map) + section_nr_to_pfn(pnum); > } > > -static int __meminit sparse_init_one_section(struct mem_section *ms, > +static void __meminit sparse_init_one_section(struct mem_section *ms, > unsigned long pnum, struct page *mem_map, > unsigned long *pageblock_bitmap) > { > - if (!present_section(ms)) > - return -EINVAL; > - > ms->section_mem_map &= ~SECTION_MAP_MASK; > ms->section_mem_map |= sparse_encode_mem_map(mem_map, pnum) | > SECTION_HAS_MEM_MAP; > ms->pageblock_flags = pageblock_bitmap; > - > - return 1; > } > > unsigned long usemap_size(void) > @@ -801,12 +796,11 @@ int __meminit sparse_add_one_section(struct pglist_data *pgdat, > #endif > > section_mark_present(ms); > - > - ret = sparse_init_one_section(ms, section_nr, memmap, usemap); > + sparse_init_one_section(ms, section_nr, memmap, usemap); > > out: > pgdat_resize_unlock(pgdat, &flags); > - if (ret <= 0) { > + if (ret < 0) { > kfree(usemap); > __kfree_section_memmap(memmap, altmap); > } > -- > 2.13.6 > -- Michal Hocko SUSE Labs