From patchwork Mon Jul 2 15:43:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 10501943 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0D48D60325 for ; Mon, 2 Jul 2018 15:43:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F01A6287F3 for ; Mon, 2 Jul 2018 15:43:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E3DB828CFE; Mon, 2 Jul 2018 15:43:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7D563287F3 for ; Mon, 2 Jul 2018 15:43:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 736646B0006; Mon, 2 Jul 2018 11:43:41 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 6E4F56B0007; Mon, 2 Jul 2018 11:43:41 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5FBDA6B0008; Mon, 2 Jul 2018 11:43:41 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wm0-f69.google.com (mail-wm0-f69.google.com [74.125.82.69]) by kanga.kvack.org (Postfix) with ESMTP id 04E546B0006 for ; Mon, 2 Jul 2018 11:43:41 -0400 (EDT) Received: by mail-wm0-f69.google.com with SMTP id m12-v6so3177372wma.9 for ; Mon, 02 Jul 2018 08:43:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id; bh=QJ1//1YIlVLol+rxEaAWUwq+hFnvLuTp/reMU/xt8M0=; b=dR0wxXus5CzcplzEH9jvJwzD2BiygoIydJNB/TEQ6w+oa7snLFFTIF36Ms08a+jVXE xpkdwol8Z88E1Cab2K8JINimrJ0sD3lD/e8EiVcMes6iPllIW62C79YyUxqM4F9CwZ1F mHSdqsX/C7Edp95GCuOkImXS5+9d6Fe3newFhpsW/UibSGckueshYEWjRyVz5QgqsYAy R78vZyuyq2za+EFLV7wGNRooHmqLDvp+YYrG6xaf4bc+mqlvw0BQ1coGechXbQNYswe0 Hu91EwpL6fL2rFQNwRfgduY8xAPJgF3nCzkzewF3m0IDq3uuW1InhInGrkLgGVQzSgE4 /zAQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of osalvador.vilardaga@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=osalvador.vilardaga@gmail.com X-Gm-Message-State: APt69E0IiZzsZ57TgPJYcAIv8Ikbisl7kKxHcqZPbaduOgQMUPXLP9hd FJmUF47FoNY7adxybgC1ODl7MOx0jT8S4Ezakq7JGs91dbNVhpCW3pWSXvlBp8a4EdJhkvR0/D8 ZUhRno1qFf49UczTTtYneT1T0vityTw2x801VzXvah1u+jxNgBP2P7OhHT/U5k29Q4YWKrd5hf6 BqsT8emjWSST/jO9TvRIOdZHk6TkLlP2J0jEqAaMb+/OK8nv0CWBSWTbdlXCw6psyBsu3It8DbA c0eTdqW7+ENvUFo8SE3EtMB455m6QeVVKbTRRd/V6RXP2dEhv1twhYEmgoidI666zJbMjuLlbf0 TsLzum1e2DHFmpIxQEXxz8Z1QlP6hEIxziRQyorfwczW7gOc1zK+SNRwN+56/45SVtrbxb8roQ= = X-Received: by 2002:adf:ef50:: with SMTP id c16-v6mr18678398wrp.182.1530546220484; Mon, 02 Jul 2018 08:43:40 -0700 (PDT) X-Received: by 2002:adf:ef50:: with SMTP id c16-v6mr18678378wrp.182.1530546219762; Mon, 02 Jul 2018 08:43:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530546219; cv=none; d=google.com; s=arc-20160816; b=DUZsqW/9AvQjmHuYcAzt57LPOFR2TMapRy+8jYGIN0QH03A3oJFYvGVwN7Ljraqc4x Fw/S1+FZ1eNQ3tOgzPEuk+ouaH/UhbCZX03tWm0vosXmobqqQb/slv/ySHQenknZmeSU SNaEq1B+ukIt7yRGUNRdwabpncFtOIG07rg2E9wN0rVK2loVTFIoLcfnzezLjMFxsnuC Fhc1JhGUot7P6THgSEo2UzQ9NKW0UeJadE90xAVsUR7B65RsMtbOyDiF+q895Qhedt0B jGovx8YyreusB8unskMwgiVvwe/hq7I+ci6EJVLSt1KNwvg8iWzOmxw15A4kRIUTc+Ha KHNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:arc-authentication-results; bh=QJ1//1YIlVLol+rxEaAWUwq+hFnvLuTp/reMU/xt8M0=; b=H7lZJLY2Dm/FQNMTwf+4H6+oIUr7gzZhD/BprEMKzNRkS7yhkw9tIELq/15wJf70J2 N45GAumLvILTcKgo7vboc02EZoCzOA1gNr+BHOFnkDtBxtLP+k27Hh8aEJfnj5Xy78E4 iiWW7Nj+F2mMTMr1uDplkYuv9fZWiDTZI733EfGx3ba9/o6YbeLvkLDVl0Rd+rKtjQom Doova8p852PDDVtbIp/QRFwmeJKQPaQAyi+xdHsgoF/raVxXXBJRxcI7nNVVZ3UdpqYa H/uVMTHTiqnOMB3tHaaSF/OtcpZD01UjuGLEoHCVfE/jOyq8wiBDgUJ1UaQ+QP/PwtKD 0jWw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of osalvador.vilardaga@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=osalvador.vilardaga@gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id w67-v6sor863295wme.53.2018.07.02.08.43.39 for (Google Transport Security); Mon, 02 Jul 2018 08:43:39 -0700 (PDT) Received-SPF: pass (google.com: domain of osalvador.vilardaga@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; spf=pass (google.com: domain of osalvador.vilardaga@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=osalvador.vilardaga@gmail.com X-Google-Smtp-Source: AAOMgpcQjfcHtgQvHpd8nuZop+akOsMu0dllxoOj8zU3dl+0mlXXqhUDk3eLcyvOTn4JV0n8xcxw1g== X-Received: by 2002:a1c:2bc1:: with SMTP id r184-v6mr8206803wmr.13.1530546219058; Mon, 02 Jul 2018 08:43:39 -0700 (PDT) Received: from techadventures.net (techadventures.net. [62.201.165.239]) by smtp.gmail.com with ESMTPSA id v15-v6sm15437851wrq.37.2018.07.02.08.43.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Jul 2018 08:43:38 -0700 (PDT) Received: from d104.suse.de (nat.nue.novell.com [195.135.221.2]) by techadventures.net (Postfix) with ESMTPA id 76C3F123A5E; Mon, 2 Jul 2018 17:43:37 +0200 (CEST) From: osalvador@techadventures.net To: akpm@linux-foundation.org Cc: pasha.tatashin@oracle.com, mhocko@suse.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: [PATCH] mm/sparse: Make sparse_init_one_section void and remove check Date: Mon, 2 Jul 2018 17:43:25 +0200 Message-Id: <20180702154325.12196-1-osalvador@techadventures.net> X-Mailer: git-send-email 2.13.6 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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. Signed-off-by: Oscar Salvador Acked-by: Michal Hocko Reviewed-by: Pavel Tatashin --- 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); }