Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp773031ybi; Fri, 26 Jul 2019 19:40:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqz4WbuswoLAmtJcdTKf9mEbO8ThM/CLPUm8RlEaAzX2BuocbtVsJPWjZ1ImM/ALYew/ze6l X-Received: by 2002:a65:584f:: with SMTP id s15mr77590770pgr.175.1564195211292; Fri, 26 Jul 2019 19:40:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564195211; cv=none; d=google.com; s=arc-20160816; b=B2IwBDWDWMOMjZ25oRKMBVSczns1Juy9fD0dvKfJqCP9NsMDFmIr48b9DfDyJL2ack 4b4RflZQZfkH3SOtFojOEGhR8pJXrDEBwD1dzG1MSfK9cAJxM7x/zrSPj5Q1iOZKHs+s mVyeHgWBMGfTyhDCxPA0HvnBa6lCeN7ucXe9izcduhck/A4MjD48rEvlP3V4lgogU5Il o2eOf7T5LAvCbKrKEw+uYZhLPGmuzkJ1/6SQv7bgoKbvbm92BeTFTZg4aC2StYaaj/Jg zLDXhqyheLQTYMFSIx3o/RF9+wNe5h/hDAHV+26nrAEe+f06/zQS+4jD9UjL/sQSJxCa rAoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=zpeooSg+LQdXjAAfVsZypK0AbbwUv4Ep7JcxnLVryiU=; b=etUCcdlYiWwT8o83WoEd82q+rUpwRFVSGp7eedDBbT6i8cPnHeSymaCSrf7itMEWhC y9nMZzS5G998DmxVpkfmh9X3wO8TsR+1nG9GtKF9gcFIWl6TJNrIaZIy3w0gFvqoHvRl HSSOVjKXbEWFYjlBS2o8RZG9+iKy9iKNqkPIPF7oULbZNZthdAIqXUU45o8zZCUKN0/8 hlXtTHahnllhCYP8mYGsj3C01f4px0L2T+x7sxcOwk/Xd6YKftiKtuxS4mTLm33swDAb gxDqTRGd07NRO5Ky1R+8SFT6lmh21DVrWk3sdEJeFwuWekRUgVoN++zRYIHhWa7Ma4ae LHmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=UHjHeqS7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 33si21613700ply.10.2019.07.26.19.39.56; Fri, 26 Jul 2019 19:40:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=UHjHeqS7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728033AbfG0CeR (ORCPT + 99 others); Fri, 26 Jul 2019 22:34:17 -0400 Received: from mail-ot1-f66.google.com ([209.85.210.66]:45870 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726766AbfG0CeR (ORCPT ); Fri, 26 Jul 2019 22:34:17 -0400 Received: by mail-ot1-f66.google.com with SMTP id x21so18768814otq.12 for ; Fri, 26 Jul 2019 19:34:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=zpeooSg+LQdXjAAfVsZypK0AbbwUv4Ep7JcxnLVryiU=; b=UHjHeqS7q3gd26VS+n85HRyE9GOmIkDj019sXmy+muPSPCkqtq0YR8IcQgl8cJ4hYh godJNDBFKBHweclH/CH0P/D5qASWANJ0mqOdL5sYy1fv5cyO4Q+qoy4jgV4iwaNf26z1 GlPDN12bhXuKuwwbSuvZhFvA9CXrNiu5xbewuMkdR/h1QxDZGThP5h6SHnC0f0hCRpps 0yD+tHlvgZGsyozrCivNsYxNvWhoJgskpBq7CKkgcvRzmjawYe7keGroLiy5N+I7fdx4 rM06nkLvvder5FuVPEhTB9KVPQju/81EUxqLUTNK6DEN788mGPfeK2605he49s83yTBK 8Lrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=zpeooSg+LQdXjAAfVsZypK0AbbwUv4Ep7JcxnLVryiU=; b=Kzz9DScLd7bkisA/G8pbiW3h6T9NDG9heawsJEb+QyYbSEQ62mdB9Zz/EDTHAc7x0G 7wd6jJH/6iioDf/l6isUaUxrMiuLUoLxOMOus/57/bJ5UMRf6Yd34XTcg4fxr2863+T9 GVOGl8o4D6JgYi7arUC6ND+2WqQCsjcN8ZzKeVw8KisD0sU/xczhoEokQ5KeU0pAYC96 Rea8a5ue7mZmPp2T6jWsLlTQ6Ph/1COZGtPt/p2c3wVxts1RYdTk890wF8b2Ib2bfStw H+OL0sDpwpXJtPs0LR/m+SjMTgfSI02q6dg0LxRcVdu+NbUOQ80Q7nhVBR2pVUD5c3vt ZGqg== X-Gm-Message-State: APjAAAVDgj+CqqJMqAcfh6eQkKr9/K2aeyHXtdx/JGip2mQRiy2cFLdB ZOWerGI+FMSwqZiXPh52nuxs7TijQasTiqttR4o= X-Received: by 2002:a05:6830:2098:: with SMTP id y24mr29902120otq.173.1564194856659; Fri, 26 Jul 2019 19:34:16 -0700 (PDT) MIME-Version: 1.0 References: <20190725184253.21160-1-lpf.vector@gmail.com> <20190725184253.21160-3-lpf.vector@gmail.com> In-Reply-To: From: Pengfei Li Date: Sat, 27 Jul 2019 10:34:04 +0800 Message-ID: Subject: Re: [PATCH 02/10] mm/page_alloc: use unsigned int for "order" in __rmqueue_fallback() To: Rasmus Villemoes Cc: Andrew Morton , mgorman@techsingularity.net, mhocko@suse.com, vbabka@suse.cz, Qian Cai , aryabinin@virtuozzo.com, osalvador@suse.de, rostedt@goodmis.org, mingo@redhat.com, pavel.tatashin@microsoft.com, rppt@linux.ibm.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 26, 2019 at 5:36 PM Rasmus Villemoes wrote: > > On 25/07/2019 20.42, Pengfei Li wrote: > > Because "order" will never be negative in __rmqueue_fallback(), > > so just make "order" unsigned int. > > And modify trace_mm_page_alloc_extfrag() accordingly. > > > > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > > index 75c18f4fd66a..1432cbcd87cd 100644 > > --- a/mm/page_alloc.c > > +++ b/mm/page_alloc.c > > @@ -2631,8 +2631,8 @@ static bool unreserve_highatomic_pageblock(const = struct alloc_context *ac, > > * condition simpler. > > */ > > static __always_inline bool > > -__rmqueue_fallback(struct zone *zone, int order, int start_migratetype= , > > - unsigned int alloc_flags) > > +__rmqueue_fallback(struct zone *zone, unsigned int order, > > + int start_migratetype, unsigned int alloc_flags) > > { > > Please read the last paragraph of the comment above this function, run > git blame to figure out when that was introduced, and then read the full > commit description. Thanks for your comments. I have read the commit info of commit b002529d2563 ("mm/page_alloc.c: eliminate unsigned confusion in __rmqueue_fallback"). And I looked at the discussion at https://lkml.org/lkml/2017/6/21/684 in de= tail. > Here be dragons. At the very least, this patch is > wrong in that it makes that comment inaccurate. I wonder if you noticed the commit 6bb154504f8b ("mm, page_alloc: spread allocations across zones before introducing fragmentation"). Commit 6bb154504f8b introduces a local variable min_order in __rmqueue_fallback(). And you can see for (current_order =3D MAX_ORDER - 1; current_order >=3D min_order; --current_order) { The =E2=80=9Ccurrent_order=E2=80=9D and "min_order" are int, so here is ok= . Since __rmqueue_fallback() is only called by __rmqueue() and "order" is uns= igned int in __rmqueue(), then I think that making "order" is also unsigned int is good. Maybe I should also modify the comments here? > > Rasmus Thank you again for your review. -- Pengfei