Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755602AbcLVJGy (ORCPT ); Thu, 22 Dec 2016 04:06:54 -0500 Received: from mx2.suse.de ([195.135.220.15]:55006 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751393AbcLVJGw (ORCPT ); Thu, 22 Dec 2016 04:06:52 -0500 Date: Thu, 22 Dec 2016 10:06:48 +0100 From: Michal Hocko To: Wei Yang Cc: trivial@kernel.org, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH V3 1/2] mm/memblock.c: trivial code refine in memblock_is_region_memory() Message-ID: <20161222090648.GB6048@dhcp22.suse.cz> References: <1482363033-24754-1-git-send-email-richard.weiyang@gmail.com> <1482363033-24754-2-git-send-email-richard.weiyang@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1482363033-24754-2-git-send-email-richard.weiyang@gmail.com> User-Agent: Mutt/1.6.0 (2016-04-01) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1255 Lines: 42 On Wed 21-12-16 23:30:32, Wei Yang wrote: > memblock_is_region_memory() invoke memblock_search() to see whether the > base address is in the memory region. If it fails, idx would be -1. Then, > it returns 0. > > If the memblock_search() returns a valid index, it means the base address > is guaranteed to be in the range memblock.memory.regions[idx]. Because of > this, it is not necessary to check the base again. > > This patch removes the check on "base". OK, the patch looks correct. I doubt it makes any real difference but I do not see it being harmful. > Signed-off-by: Wei Yang Acked-by: Michal Hocko > --- > mm/memblock.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/mm/memblock.c b/mm/memblock.c > index 7608bc3..4929e06 100644 > --- a/mm/memblock.c > +++ b/mm/memblock.c > @@ -1615,8 +1615,7 @@ int __init_memblock memblock_is_region_memory(phys_addr_t base, phys_addr_t size > > if (idx == -1) > return 0; > - return memblock.memory.regions[idx].base <= base && > - (memblock.memory.regions[idx].base + > + return (memblock.memory.regions[idx].base + > memblock.memory.regions[idx].size) >= end; > } > > -- > 2.5.0 -- Michal Hocko SUSE Labs