Re: [PATCH 2/3] mm/sparse: Optimize sparse_add_one_section()

From: Baoquan He
Date: Wed Mar 20 2019 - 06:13:25 EST


Hi Mike,

On 03/20/19 at 09:56am, Mike Rapoport wrote:
> @@ -697,16 +697,17 @@ int __meminit sparse_add_one_section(int nid, unsigned long start_pfn,
> > ret = sparse_index_init(section_nr, nid);
> > if (ret < 0 && ret != -EEXIST)
> > return ret;
> > - ret = 0;
> > - memmap = kmalloc_section_memmap(section_nr, nid, altmap);
> > - if (!memmap)
> > - return -ENOMEM;
> > +
> > usemap = __kmalloc_section_usemap();
> > - if (!usemap) {
> > - __kfree_section_memmap(memmap, altmap);
> > + if (!usemap)
> > + return -ENOMEM;
> > + memmap = kmalloc_section_memmap(section_nr, nid, altmap);
> > + if (!memmap) {
> > + kfree(usemap);
>
> If you are anyway changing this why not to switch to goto's for error
> handling?

I update code change as below, could you check if it's OK to you?

Thanks
Baoquan