Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753656AbdFSTFq (ORCPT ); Mon, 19 Jun 2017 15:05:46 -0400 Received: from mail-wm0-f53.google.com ([74.125.82.53]:34937 "EHLO mail-wm0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753073AbdFSTFn (ORCPT ); Mon, 19 Jun 2017 15:05:43 -0400 From: Rasmus Villemoes To: Vlastimil Babka Cc: Hao Lee , akpm@linux-foundation.org, mgorman@techsingularity.net, mhocko@suse.com, hannes@cmpxchg.org, iamjoonsoo.kim@lge.com, minchan@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm: remove a redundant condition in the for loop Organization: D03 References: <20170619135418.8580-1-haolee.swjtu@gmail.com> X-Hashcash: 1:20:170619:linux-mm@kvack.org::beZ8n4wyUDN6kmXO:000000000000000000000000000000000000000000012hT X-Hashcash: 1:20:170619:minchan@kernel.org::ff2TtLJCeM2n+69s:000000000000000000000000000000000000000000013ME X-Hashcash: 1:20:170619:iamjoonsoo.kim@lge.com::OQQDFKkuPa5BFANd:0000000000000000000000000000000000000000Av9 X-Hashcash: 1:20:170619:mhocko@suse.com::6LZyBZoOyDiCT0cq:001dQg X-Hashcash: 1:20:170619:mgorman@techsingularity.net::vfBmo/ilNGQMKgSG:00000000000000000000000000000000002yb/ X-Hashcash: 1:20:170619:haolee.swjtu@gmail.com::Rb1qlmHmvpKjqHx/:0000000000000000000000000000000000000003KLM X-Hashcash: 1:20:170619:vbabka@suse.cz::gwGnNYessNyuyLIa:0004p9P X-Hashcash: 1:20:170619:linux-kernel@vger.kernel.org::vKOxWGP50yPea5ZQ:0000000000000000000000000000000003g8N X-Hashcash: 1:20:170619:hannes@cmpxchg.org::C9kj31Iy5qSdcrle:00000000000000000000000000000000000000000004Bg1 X-Hashcash: 1:20:170619:akpm@linux-foundation.org::1uebCC4sTFw10jMP:0000000000000000000000000000000000006PPc Date: Mon, 19 Jun 2017 21:05:29 +0200 In-Reply-To: (Vlastimil Babka's message of "Mon, 19 Jun 2017 16:17:01 +0200") Message-ID: <87y3snajd2.fsf@rasmusvillemoes.dk> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1371 Lines: 38 On Mon, Jun 19 2017, Vlastimil Babka wrote: > On 06/19/2017 03:54 PM, Hao Lee wrote: >> The variable current_order decreases from MAX_ORDER-1 to order, so the >> condition current_order <= MAX_ORDER-1 is always true. >> >> Signed-off-by: Hao Lee > > Sounds right. > > Acked-by: Vlastimil Babka current_order and order are both unsigned, and if order==0, current_order >= order is always true, and we may decrement current_order past 0 making it UINT_MAX... A comment would be in order, though. >> --- >> mm/page_alloc.c | 5 ++--- >> 1 file changed, 2 insertions(+), 3 deletions(-) >> >> diff --git a/mm/page_alloc.c b/mm/page_alloc.c >> index 2302f25..9120c2b 100644 >> --- a/mm/page_alloc.c >> +++ b/mm/page_alloc.c >> @@ -2215,9 +2215,8 @@ __rmqueue_fallback(struct zone *zone, unsigned int order, int start_migratetype) >> bool can_steal; >> >> /* Find the largest possible block of pages in the other list */ >> - for (current_order = MAX_ORDER-1; >> - current_order >= order && current_order <= MAX_ORDER-1; >> - --current_order) { >> + for (current_order = MAX_ORDER-1; current_order >= order; >> + --current_order) { >> area = &(zone->free_area[current_order]); >> fallback_mt = find_suitable_fallback(area, current_order, >> start_migratetype, false, &can_steal); >>