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); From patchwork Thu Aug 23 13:07:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 10573803 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 1295E13B6 for ; Thu, 23 Aug 2018 13:08:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0436A2A590 for ; Thu, 23 Aug 2018 13:08:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E76232A703; Thu, 23 Aug 2018 13:08:15 +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 7EDB12A590 for ; Thu, 23 Aug 2018 13:08:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6CDCF6B2A32; Thu, 23 Aug 2018 09:08:14 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 67B9D6B2A34; Thu, 23 Aug 2018 09:08:14 -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 56AEB6B2A35; Thu, 23 Aug 2018 09:08:14 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl0-f71.google.com (mail-pl0-f71.google.com [209.85.160.71]) by kanga.kvack.org (Postfix) with ESMTP id 16F3E6B2A32 for ; Thu, 23 Aug 2018 09:08:14 -0400 (EDT) Received: by mail-pl0-f71.google.com with SMTP id z24-v6so2537770plo.2 for ; Thu, 23 Aug 2018 06:08:14 -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=uH65SJr5TRDJ1UdXaGxjb9/m2MPypZba/Khufe29heI=; b=rSSKVnP1/B7xKWUScPON/+UTwHi/kRLB/h1Guo8I8YNd/3ma2Hemkk1W02m9zi2nBq tuYnMJbMIEVhetAl7VYPLpMR4mnBuHVEJqfqkffaZxT1eK2tfxV4Z6VzdBQBBAqymaqU 9KrOZ1pkqC8da/i58j0rN90Ri4ZoBJC+2Dx37o28w3qiIjZnwoKWFWcAs+PFrLz7t9os 4dT/kh2F2da9Bp7a8E7kWe2WuyJZnOGwUpbxbnZizPRgBeujrDSlpHKU3pGnnyFOnhFf 0Q8iLr2T4OCWAubo1d/zZK2SgkNKzUoS+CKSM/HrLfCm3d200ULiHyDz/cFpBbdZb18B Nr1g== X-Gm-Message-State: AOUpUlFWEIIu4GqBO16n27R5UyZ/BjxpLYIgEjbUHQktP76/Dg+T+q6Q GkaEwkRu3n5L04kZjL7JTMLjnnMZTsod594LP+DHllItAzqZrE0ITpP/KRxJYG8daN1KrmVzMs/ J321vZAenWHyKTYNB+NLKq1JfVmFA2sBqhJJl5j/BoWmTmGY5lRSJS4Upeznb7Gr1wQpKiz3YzR SBLFqk4xmqIfOJzFstQC5bAARQGj1uG2HFtxyBbQ4I3sQj8gJ6PntR8NXT/3E8h1mzT8/QdDuDR Yh05+bqr5Ka5hwNJFwUjyAX9r8HK8lGieDV7KuzseBg7dr36pm1aJX418Fzk4h71U2/bK2SoKvD ziwtlQqpqycW7u79Wq3Nv/B24D4v+S152R71YVZXQq1Z9nswSlF6AcvH8z1i3HOvv52yzyQVtKG R X-Received: by 2002:a63:ed4f:: with SMTP id m15-v6mr55728021pgk.147.1535029693776; Thu, 23 Aug 2018 06:08:13 -0700 (PDT) X-Received: by 2002:a63:ed4f:: with SMTP id m15-v6mr55727975pgk.147.1535029693131; Thu, 23 Aug 2018 06:08:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535029693; cv=none; d=google.com; s=arc-20160816; b=KKz2KFliHODLPmaOyvG6dqzpFwIIGrIIPhfmVPwEJfY1dCA6qaTaS9QPvDkLxIDqsZ EeYsJPfEOnOnsJq+w/kOLQyT3EWW4ZTkUspeHQ06Z2/2IRgoQ47oulZJyj8FE3q4xfPB yY3e24pLRyNjziOtAvJfKEon+V7jivJCGuQqsifNAvry8dvVe9uKJlP9S9FYSR4S1iW5 efknsZsk6KA1Z+rqxC/Qk/e7sFokdkmE4JwLYeUF6W2d3U6PP7NMGddEzawQXFi5BUX5 puTgx+47BhE1HY5NEM6+hUFRHlVgl3NY8mYtf3876jC7VuUO2EAEpnbmK4MezgmAm0It ReHQ== 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=uH65SJr5TRDJ1UdXaGxjb9/m2MPypZba/Khufe29heI=; b=vXaLO8QmxT+EXDtSL8iayMjk6L+GpWbZBT0D4EdCs0z2G2NhL4NQqfmpBAvCvsKLmd DaY8+oPlTIa2o8Yo7g3rHuY9wgWHKLmpTvvhN15hyhv9tUl2hvq8hSfGjLOhws3vhrF+ +qj9mJxIw6Tk1hVYUqT2KMYkK4GnLZo5W5KCUKQqRuycsvNlovPuIhyFnMR00JSwKveS UcT+IAsvq8+6npvppawbdUV5wLXHwjeDUuhRjijlm+n3VyV/Bqr9A7+BPwmUW6bg3DwR TncQPzYEzUEd2uQqN63GoDvMCK/+9ATPSVwR942RKGGF63gGaRgBnKybM4SYvQV0s00C kz/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=U9h1BJzt; 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 y7-v6sor1194276pgi.126.2018.08.23.06.08.13 for (Google Transport Security); Thu, 23 Aug 2018 06:08:13 -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=U9h1BJzt; 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=uH65SJr5TRDJ1UdXaGxjb9/m2MPypZba/Khufe29heI=; b=U9h1BJztmbukqQK0n5J56np4eiYs98+Bai6yTJSvYiAWx3KnBaZ7y877KtppthEXBi XXgSg22Vm+pPF4wa4y6htRdtt/SMmx5ah78MS89cytUq31iPeYrasOwYbi8dyqYqXLbs GGKjqO/c12ur+z8HnSTilwHDK9tK1iMSVB7fm+GidnKTnA4MeSOjuDDl8krPfIr52Hyr +pFmxXFSnc1lzsRTsZmdWULqyRzG06WuiEkmp+dibsCxOAAVbf6lrZZend44vR27C4JD 8+A5i9jMaXaBiYo51tp1k2ZOVYC2TSpsV93+Q0sz/+haTwV7esEk12e6Jrp7paJeekN/ Eb5g== X-Google-Smtp-Source: AA+uWPzaYZwAJzKrfFI5ieN56o7zq4YufZx5cbBwuM04XyC6V3PYlS1iUy6crVi9kSC/AJSTD7Ix5g== X-Received: by 2002:a63:e056:: with SMTP id n22-v6mr55700850pgj.205.1535029692896; Thu, 23 Aug 2018 06:08:12 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id t21-v6sm7525580pfi.73.2018.08.23.06.08.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Aug 2018 06:08:12 -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 2/3] mm/sparse: expand the CONFIG_SPARSEMEM_EXTREME range in __nr_to_section() Date: Thu, 23 Aug 2018 21:07:31 +0800 Message-Id: <20180823130732.9489-3-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.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 When CONFIG_SPARSEMEM_EXTREME is not defined, mem_section is a static two dimension array. This means !mem_section[SECTION_NR_TO_ROOT(nr)] is always true. This patch expand the CONFIG_SPARSEMEM_EXTREME range to return a proper mem_section when CONFIG_SPARSEMEM_EXTREME is not defined. Signed-off-by: Wei Yang --- include/linux/mmzone.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 32699b2dc52a..33086f86d1a7 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -1155,9 +1155,9 @@ static inline struct mem_section *__nr_to_section(unsigned long nr) #ifdef CONFIG_SPARSEMEM_EXTREME if (!mem_section) return NULL; -#endif if (!mem_section[SECTION_NR_TO_ROOT(nr)]) return NULL; +#endif return &mem_section[SECTION_NR_TO_ROOT(nr)][nr & SECTION_ROOT_MASK]; } extern int __section_nr(struct mem_section* ms); From patchwork Thu Aug 23 13:07:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 10573807 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 829E15A4 for ; Thu, 23 Aug 2018 13:08:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8DAAB2BDD8 for ; Thu, 23 Aug 2018 13:08:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 80A8B2C00B; Thu, 23 Aug 2018 13:08:25 +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 5F34B2BDD8 for ; Thu, 23 Aug 2018 13:08:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 12B416B2A35; Thu, 23 Aug 2018 09:08:23 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 088746B2A36; Thu, 23 Aug 2018 09:08:22 -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 DF7296B2A37; Thu, 23 Aug 2018 09:08:22 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by kanga.kvack.org (Postfix) with ESMTP id 958936B2A35 for ; Thu, 23 Aug 2018 09:08:22 -0400 (EDT) Received: by mail-pg1-f198.google.com with SMTP id r20-v6so2883465pgv.20 for ; Thu, 23 Aug 2018 06:08:22 -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=vdC762qOUw0lNwQ8NtRgmdcaQ3KYQZC1JLVRC9JiUic=; b=cQmLKTw56aV4PXRcnp7LzJtPfo1SB5THqtizqY0HQxogPubpqKpNAdYXm18MJvnGkg 15DE7fS8amSRTC7rnhQhvFmY94izEFXJ3JInn4tswuBQ4r29znSvtJv9WvV08QGMiu4r bnwy3AtVZ+Z0sSyUsXPAchuU3nRFC7lXhaYdTP7LlXkwdOxlDjdpxzbPUaah4EkSLvjZ 1beybFuBHVZyn56WTG1sLaycQzxUjz8fLkG+Y0myseQhFCwzPnqyFyBrnDQuXNM01Jde 1RlotoQ1ScRERZp76MeVL0L7kQuu8lrTfbjuB9juxRaEddOA4fHp1H3c4r94R2Hua8DG HUvQ== X-Gm-Message-State: APzg51CshuS7SMYL7dRJ1FkX2BXeORbuO7RQA9rXv4pjZJqkzUeqEzv4 CoUHG9JiKqgMrTepd7MApIwEmAxkJ5iZv6oIvc9GE2Nkn9uZgoB2ShD5nnv4vQ9/PAn0DSe3usT YFjgMbvA+WnJbcTh4dJggOeGnGAZ4MhZWvdQfMMi1VTqdO4ULcXhdUHDf1Ug1WhTN/wX8dk+g8c mWWXMezC5k7csPkPfUW6HsGiN5eJeVt2O4GuwNh6QPKrAWVR0/8LGd8vapUuzmH2N+/FGJYObwS dQGJSqZxSi0k8ZN3HXZRpwJ8tPwkwsl7z3KwwSJ69zA8kUdVUB2ypVyuJBhqOI0a+TzPERcEDy3 3O+hMX5PiyecxSw6DTGtDf3MSlK8fR+ZOtKJhEuPWWAX3WRvAUB3UYa8QVUhteOBWYHONBglmSR / X-Received: by 2002:a62:9e08:: with SMTP id s8-v6mr6713081pfd.23.1535029702292; Thu, 23 Aug 2018 06:08:22 -0700 (PDT) X-Received: by 2002:a62:9e08:: with SMTP id s8-v6mr6713001pfd.23.1535029701239; Thu, 23 Aug 2018 06:08:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535029701; cv=none; d=google.com; s=arc-20160816; b=FGLLAfummaY332KBpjiPTOLAsH4UO3L9jU/7p7gW+Ne6wk/+RNhgXU4vFPhFm2L8MU y5TUQr+X8SSQzmtWTbPRVZqndm5UJ+DANA5mBEqmafFzCKir9brkZPRqSEU5IO9IOfhh C6FY9cMuNkWqmU9fWV/A4ei357ktAQBbMHogdZmQPxugwt5jrGZTjcfS3oaCJ2AMtBjg khcc2k7/Wj8zsgcxeWlLsNF2kTgVv3thqpgpliZyzu40o0z357OuY9L12Q35c8u0zW+w vgLHbBBnnO0dQ78qD0kSARJycJlkp3WQRHJzXQsKi0U+NLhsoptLfeDDZRRZmHLuvLcT EmFA== 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=vdC762qOUw0lNwQ8NtRgmdcaQ3KYQZC1JLVRC9JiUic=; b=wFjLHSeSPZusUKryMV4KINskZEnvgxhwgrHaUb0PHp7FMp89MsNWQMdoNKMNCtsP/G Dl51CLb3T5EZICNJT9UwRXt/19sIpHIC6ZPKCo9oxEu0uEVfYE37JhfnMDXiVqoaJUGv w/D4Y6VmdN1V5DBxjruHZlVa62WONZ2u9MOXErit6nifhqHaF0M2AA0rQKTZw9AMSc+3 K1PlFBGRy6q5uf6EGhmR63TsVcWQh9FnizLwbosXOYjg5/tU38WNNInMhY28lsnCKfYD xQPgvL6zgE5Rswt7JlD5AD6HgH6L34o7alw3O6I/Rivqo4muaJ/ao13k1QSPHq6LAlks b0pQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=l6Iq0DzM; 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 o1-v6sor1394536pfk.89.2018.08.23.06.08.21 for (Google Transport Security); Thu, 23 Aug 2018 06:08:21 -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=l6Iq0DzM; 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=vdC762qOUw0lNwQ8NtRgmdcaQ3KYQZC1JLVRC9JiUic=; b=l6Iq0DzMokhKtLtJIXZOSbe73JNmsGx+UunFNp4BETth/7Hoh/msgHqmFO+U0yRmpX 3EOu53dW20ZnJ2PmV+2x7dtCF526IHA75kKuweAKyWMFN+8fS6ZQb2XrlcgLsS1moMhk PucSPf+lUP5SCQ4tfqRXKB1e0WxEFV7exYTv+QfdvYiZJ4rspMiTadIyW9P8K0+eb5Hp uGtfQj/EV6Lzg62A5/s5vtSxeptQ0n6cW3Hrmq8EwoaMrNnsDWCMa/JMtQ96aHhDsLs/ sVZV1Px0f0vYcWqq3xw+nPkMfb2ZMqxxCgZglWDw1sX7dPNiGBbe3EWAqSak4Br+9ltj JEWA== X-Google-Smtp-Source: AA+uWPzjzUNTxvETEwHIfUZbjgJN47Ud1BEknUWBEKlMcFKfO6+uBHtUdL8r0tlWMFAnA+CabGnDLw== X-Received: by 2002:a62:d113:: with SMTP id z19-v6mr62056329pfg.98.1535029701013; Thu, 23 Aug 2018 06:08:21 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id i26-v6sm6381736pfo.107.2018.08.23.06.08.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Aug 2018 06:08:20 -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 3/3] mm/sparse: use __highest_present_section_nr as the boundary for pfn check Date: Thu, 23 Aug 2018 21:07:32 +0800 Message-Id: <20180823130732.9489-4-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.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 And it is known, __highest_present_section_nr is a more strict boundary than NR_MEM_SECTIONS. This patch uses a __highest_present_section_nr to check a valid pfn. Signed-off-by: Wei Yang --- include/linux/mmzone.h | 4 ++-- mm/sparse.c | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 33086f86d1a7..5138efde11ae 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -1237,7 +1237,7 @@ extern int __highest_present_section_nr; #ifndef CONFIG_HAVE_ARCH_PFN_VALID static inline int pfn_valid(unsigned long pfn) { - if (pfn_to_section_nr(pfn) >= NR_MEM_SECTIONS) + if (pfn_to_section_nr(pfn) > __highest_present_section_nr) return 0; return valid_section(__nr_to_section(pfn_to_section_nr(pfn))); } @@ -1245,7 +1245,7 @@ static inline int pfn_valid(unsigned long pfn) static inline int pfn_present(unsigned long pfn) { - if (pfn_to_section_nr(pfn) >= NR_MEM_SECTIONS) + if (pfn_to_section_nr(pfn) > __highest_present_section_nr) return 0; return present_section(__nr_to_section(pfn_to_section_nr(pfn))); } diff --git a/mm/sparse.c b/mm/sparse.c index 90bab7f03757..a9c55c8da11f 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -174,6 +174,7 @@ void __meminit mminit_validate_memmodel_limits(unsigned long *start_pfn, * those loops early. */ int __highest_present_section_nr; +EXPORT_SYMBOL(__highest_present_section_nr); static void section_mark_present(struct mem_section *ms) { int section_nr = __section_nr(ms);