From: Michal Hocko <mhocko@kernel.org>
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 <osalvador@suse.de>
Subject: Re: [PATCH] mm/sparse: Make sparse_init_one_section void and remove check
Date: Mon, 2 Jul 2018 18:05:12 +0200 [thread overview]
Message-ID: <20180702160512.GF19043@dhcp22.suse.cz> (raw)
In-Reply-To: <20180702154325.12196-1-osalvador@techadventures.net>
On Mon 02-07-18 17:43:25, osalvador@techadventures.net wrote:
> From: Oscar Salvador <osalvador@suse.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@suse.de>
Acked-by: Michal Hocko <mhocko@suse.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
next prev parent reply other threads:[~2018-07-02 16:05 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-02 15:43 [PATCH] mm/sparse: Make sparse_init_one_section void and remove check osalvador
2018-07-02 16:05 ` Michal Hocko [this message]
2018-07-02 18:47 ` Pavel Tatashin
2018-07-06 18:23 ` Ross Zwisler
2018-07-06 19:06 ` [PATCH] mm/sparse.c: fix error path in sparse_add_one_section Ross Zwisler
2018-07-06 21:23 ` Oscar Salvador
2018-07-06 21:54 ` Ross Zwisler
2018-07-06 21:58 ` Andrew Morton
2018-07-06 21:32 ` Andrew Morton
2018-07-06 22:33 ` [PATCH v2] " Ross Zwisler
2018-07-07 6:01 ` Oscar Salvador
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180702160512.GF19043@dhcp22.suse.cz \
--to=mhocko@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=bhe@redhat.com \
--cc=dave.hansen@linux.intel.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=osalvador@suse.de \
--cc=osalvador@techadventures.net \
--cc=pasha.tatashin@oracle.com \
--cc=vbabka@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).