From patchwork Thu Aug 23 13:07:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 10573797 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 71EA1679F for ; Thu, 23 Aug 2018 13:08:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 551F42B278 for ; Thu, 23 Aug 2018 13:08:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2878B2A7BB; Thu, 23 Aug 2018 13:08:13 +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=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 C5C702B278 for ; Thu, 23 Aug 2018 13:08:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BFC466B2A31; Thu, 23 Aug 2018 09:08:06 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id BABAB6B2A32; Thu, 23 Aug 2018 09:08:06 -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 AC3826B2A33; Thu, 23 Aug 2018 09:08:06 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by kanga.kvack.org (Postfix) with ESMTP id 6C3136B2A31 for ; Thu, 23 Aug 2018 09:08:06 -0400 (EDT) Received: by mail-pf1-f198.google.com with SMTP id d22-v6so3198543pfn.3 for ; Thu, 23 Aug 2018 06:08:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=tF3U3N2D/9rRObHznwvkCAP77fHSFELMw1RBK8dN6oA=; b=skaUfonCH5yKEd/oJIgtOsTce5JLVjVyoxJt/2TuiYYTEMasRcflxwsz3GbDYnqq5n 13eLCTVSpRbbpD5/ESH30mcTGy8RT/QdbVCOVxVm0uJg5oZ5tb+q0XBhzYOE6xqS9VNB stwP5bFJFI/RHBrs3EQaCiidfBfiTOWwqA9LbbIAhErsTJ2t9h6JeqIRuHC/iAmI1LTO qbB7kzw/rqFfMqAY0iL9bURaZF+XUM7g5xMBb7kTelwe1sVvurxhcwPBKtUhkpjAVgpq qJgr6JEjSfjVQBDugfaBEQiGWFA6w/KVueYv+R7xzIVOggWGmDHnJde1n6u8WVM0K2aX fhaA== X-Gm-Message-State: APzg51Bk/Xyo+99J9Q8S0xYbNUIOZ8yDjvSpe64dPBu5bgLqqRZz+6Mj up7YChKUW9NPX0Iw4E6KGxjk+srYTINkIdiLNDRfrubieZSJm661sy58MjL0dZSt7VSXeW/TIo3 EoF3UNcnlZkzhuB3kXFMp6WdPXVpcJEzU0AQkUarjhx1s8sIiYv8KFV68LcRAgAoWdFZFNd/biM NMcvYcW3ZMb/kj+J+/mLscTwcEcyoUimzztrKTq6ia715MU0a0RcdFhdW24kpyosS4EgwaOc5Mz jdysvLna2KVHhFf3kxG1bHo9MAps4SK5xgOXB1GAw79FUNwkAa8fmbY8q7DdHcGaNdS6oXg7mQE 49lJSlFw9IcMSIqdsUJeeAR7UtNrk4nlji6iuPsxh/yf0EPAR785O0l96pdD3f6c4J+7HYJfbYg n X-Received: by 2002:a62:e11:: with SMTP id w17-v6mr7146816pfi.242.1535029686139; Thu, 23 Aug 2018 06:08:06 -0700 (PDT) X-Received: by 2002:a62:e11:: with SMTP id w17-v6mr7146753pfi.242.1535029685414; Thu, 23 Aug 2018 06:08:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535029685; cv=none; d=google.com; s=arc-20160816; b=HUV7Kf5jn528Ks+yv2JDP5Il55HXf47LTNa2EhsWEwi84mI1500Aay59/STrmvkcCq 4UlRH2b2UcQU+zb6QUQAiOkYMAbI/TO9m2NIUceQbkPESDaxL+J14sXf9aAxw+hcJjKo ca0ib6lisavR4KXGcIL8/Puu8YhZlmMhjqSyGusxWSgFXtUq9sfluJ2PQL4JhuOGI1u8 ECJMQ1BLvIU0nD6bOwiD2bVqgKUS4B7Pp1ae4+Vw6T0ePoaX8YusfdwWt7I71zVyhJ/Z LoEgUXLfiYMMWPKaDXpnmr7MBgkDk2fZUlIMLhYXanPr5MF6cXLunmayYWI8M7QQJL6l TxAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=tF3U3N2D/9rRObHznwvkCAP77fHSFELMw1RBK8dN6oA=; b=SMnOFGsbSSjegDL6Bq7/rU1pbhndJd/hGoAkRjZK4ax5lsVbzy7ITKx4vChmOIPpj+ 6j48KAgqIcyJDibTY3jzzmn4P3teKAN9vqc34DP/2/QOEqimbHloHLa7rMjqASGKxRBv TLnCKETto8j908DPKQOt/oIB+qnK9QlcgSxVgEoSHJyW3LytxUarLBjLWy08KDpmZ0r1 aACxyE6B/Y87fdbzHUtddhhWZ3iRm4WqncEKZ42ch6vLV3aoV3PfeLwSy4wcALNPrvZN 2JwCCSjaZhxsJKnhrLGVUN5Ih09pvW0I6ZdAHaE7FMqs18BTDIRkmlQz7a22k69OFG5I 66Pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=D32Bek+I; spf=pass (google.com: domain of richard.weiyang@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=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 g12-v6sor250853pgr.8.2018.08.23.06.08.05 for (Google Transport Security); Thu, 23 Aug 2018 06:08:05 -0700 (PDT) Received-SPF: pass (google.com: domain of richard.weiyang@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=D32Bek+I; spf=pass (google.com: domain of richard.weiyang@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=tF3U3N2D/9rRObHznwvkCAP77fHSFELMw1RBK8dN6oA=; b=D32Bek+IY3q0Yk6UwyZFdlU1Os7teSxiWsZ8VNnjg5Ex70s/rEfhnFhpOujTbNmToO Nt8qMHI+Rome5GR6hWZ4kr+1pnUuxGLJEpPJrfwr06vgZfONPAPAuZBMYHBZislYbBmX cFPpCCrZPXNWSJbrfvBMxDyxUwbh0dAdtvzcGLtsIcataf1Q7QJqXQy2pxol1GuXRORs cy3GhsNc7bjKGdqYTCiQgHBnXMbpLVaL97Lno+X4P80O4iwOUtc9zyyEZBNcT4JqEpRI A5NLw719e6P6/YGcnzz4nlW99Au0S52NjCeS0IPV1GORQQMidiiye0wJDx2s867BgVl2 UEqQ== X-Google-Smtp-Source: AA+uWPwcbktma3saUy3xhClTh526rWNU9KrB5MZRn6NJ+PwhXnJKLuSbAHSebuACudwhGoaJNuUzTg== X-Received: by 2002:a63:1618:: with SMTP id w24-v6mr29599343pgl.43.1535029685158; Thu, 23 Aug 2018 06:08:05 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id t1-v6sm4335016pgp.32.2018.08.23.06.08.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Aug 2018 06:08:04 -0700 (PDT) From: Wei Yang To: akpm@linux-foundation.org, mhocko@suse.com, rientjes@google.com Cc: linux-mm@kvack.org, kirill.shutemov@linux.intel.com, bob.picco@hp.com, Wei Yang Subject: [PATCH 1/3] mm/sparse: add likely to mem_section[root] check in sparse_index_init() Date: Thu, 23 Aug 2018 21:07:30 +0800 Message-Id: <20180823130732.9489-2-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180823130732.9489-1-richard.weiyang@gmail.com> References: <20180823130732.9489-1-richard.weiyang@gmail.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000372, 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 Each time SECTIONS_PER_ROOT number of mem_section is allocated when mem_section[root] is null. This means only (1 / SECTIONS_PER_ROOT) chance of the mem_section[root] check is false. This patch adds likely to the if check to optimize this a little. Signed-off-by: Wei Yang --- mm/sparse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/sparse.c b/mm/sparse.c index 10b07eea9a6e..90bab7f03757 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -78,7 +78,7 @@ static int __meminit sparse_index_init(unsigned long section_nr, int nid) unsigned long root = SECTION_NR_TO_ROOT(section_nr); struct mem_section *section; - if (mem_section[root]) + if (likely(mem_section[root])) return -EEXIST; section = sparse_index_alloc(nid);