[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180702160512.GF19043@dhcp22.suse.cz>
Date: Mon, 2 Jul 2018 18:05:12 +0200
From: Michal Hocko <mhocko@...nel.org>
To: osalvador@...hadventures.net
Cc: akpm@...ux-foundation.org, pasha.tatashin@...cle.com,
vbabka@...e.cz, bhe@...hat.com, kirill.shutemov@...ux.intel.com,
dave.hansen@...ux.intel.com, linux-mm@...ck.org,
linux-kernel@...r.kernel.org, Oscar Salvador <osalvador@...e.de>
Subject: Re: [PATCH] mm/sparse: Make sparse_init_one_section void and remove
check
On Mon 02-07-18 17:43:25, osalvador@...hadventures.net wrote:
> From: Oscar Salvador <osalvador@...e.de>
>
> 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 <osalvador@...e.de>
Acked-by: Michal Hocko <mhocko@...e.com>
> ---
> 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
Powered by blists - more mailing lists