Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2863021ybl; Mon, 19 Aug 2019 08:32:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqyfBowjDYG0CBs3p8EynoHd46ahPXwUZpfwq4+DNOofbt6oHcO9JkXnLDBRopq0W4Mo1uBG X-Received: by 2002:aa7:9473:: with SMTP id t19mr25558810pfq.141.1566228744268; Mon, 19 Aug 2019 08:32:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566228744; cv=none; d=google.com; s=arc-20160816; b=1IzeMXsFCwl+sNoAfVCp8j+pTEkm3jvyBEKcEN1W6fXOJs1uBjvSZLPk6xQeQA/bOy 3YkRuEBcbAf7WOpxfYPZiDo9jx1TEWL095Rbvj7uWLGNwEErGYeU7MBtkw/LGj5/fS0v EsIlZzG9natL9dlinA6CuMjztQrwDApV/3Xr+LNBLIArXm/kT/ZiIlsQQvkdilPb7KmT Bqecs/vKGMrjnFiE984Kr1fJVh3eMzVSeBK3xVTil1JE4IJAR6ORgc2YlDmFf+k2jB3K L75hcTHSlBUP6g2vsOD5oAkRv98SGeQtvP1Tiy3SRqh5Q0DN6fM1alrv+5wjFYC3dL1o ZFxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=j8ka/lSpx7x87DLc83+R4USIti/BoN9Ffmdc3jaOX2Q=; b=uzf+cqqA2yC+E4hLuUC5A5KoDDvbbtb3SKZEQkFzY6XJhcTDYBIBX0XrdnINWF6rgi 36AyaxnZcqemGVKaS8PsDEt8iDbEeQkqKdq00bTTe2c7zzBEwE5hDwedrrbgV2frQfBR +W1QeJV23SV9nmgGbkwbcRZ5Jp2Dn53skArYKvhqS/e4DBsKVZ8orai2HExu1EEY5zbi tJDziWoF7AjW708aeKGhOU6gvfqCpV0uPfWZ15aqPmpxVyiPpgjTEkIXsrjOoCS4eenQ Sx4+TXdezabzVs4vdGpaNAUNw7eXeXgQRnPE/UbhEYY4BLm5DbfMCwUpp6znOotlsskc KLIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="YbCC/THX"; 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 u12si10505238pfh.6.2019.08.19.08.32.08; Mon, 19 Aug 2019 08:32:24 -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="YbCC/THX"; 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 S1726949AbfHSPaF (ORCPT + 99 others); Mon, 19 Aug 2019 11:30:05 -0400 Received: from mail-oi1-f194.google.com ([209.85.167.194]:32805 "EHLO mail-oi1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726373AbfHSPaE (ORCPT ); Mon, 19 Aug 2019 11:30:04 -0400 Received: by mail-oi1-f194.google.com with SMTP id q10so1611277oij.0 for ; Mon, 19 Aug 2019 08:30:04 -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; bh=j8ka/lSpx7x87DLc83+R4USIti/BoN9Ffmdc3jaOX2Q=; b=YbCC/THXJ+jW3CX9FXHClKXeCtKiLUPIuAcslTQaG+QSmimIH99mMK/nFW7Ftl9eQF eDMyAMXlqQzz2qS3NvwOgii1mrdv2rMg1HXXyOTcx1usHidRZyFkmVtsY2ySgpvSqJoa KWUXVre94APcbRzJkR+LWl13Ufg4AltWnGGhsH7wnaPpjq1C2F2QPm8prfNSK9zaCb19 WQjUQ5Sioh4i9AkdytmGK5ClbiZRAvEnmdnvGxIQibMG6B0E+VuBhLlTbsyHUEBvy5rp 37Gx4fOMHkBIAF9u1Oo5vGmA54Ue429pgpP7/99V+YFAu2vyPhif9dvma00qVEFSWmPz R6xw== 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; bh=j8ka/lSpx7x87DLc83+R4USIti/BoN9Ffmdc3jaOX2Q=; b=OmewtUSVJV6R0t3jPfBTUn2UsMBoD7y7wL0j95RwZMpznjmIUKuGSqXWx6TP+QRjhy THn0d/7CWRk47+rumWwWFDKOPQQX6Q4Sx67fsnHWJuRK3w7apfruPqg0n/sCNWDjayAl kggKVX3yZ4tBqcBT6EGTLWdU+FENc6TqLC9Y1T/K5ERX8BQylgE/orUGgLD3ibjCFXrD lumV8g4x+IuF+IaJ/FUxcbPKX6XR5no05yHKxMY9kmGuqMhknzBLDLn+PQTgbTAP31si EX1BZhJ2btjP5DElTpI34icj+myHi96DvAnHFT0KFw/tmI/iixOIih69ubUNrg4jxd6r 6DxA== X-Gm-Message-State: APjAAAWmGAornS0cEERhfgkKda9wK4wfeR3BK27L4OXpbSl8w/dWLWzT M4Hl7o+F6+KX+h7ICUMVQHPjbW520Hg4PZKGJJbAHYL9 X-Received: by 2002:aca:d60b:: with SMTP id n11mr13195651oig.22.1566228603622; Mon, 19 Aug 2019 08:30:03 -0700 (PDT) MIME-Version: 1.0 References: <20190817105102.11732-1-lpf.vector@gmail.com> In-Reply-To: From: Pengfei Li Date: Mon, 19 Aug 2019 23:29:51 +0800 Message-ID: Subject: Re: [PATCH] mm/page_alloc: cleanup __alloc_pages_direct_compact() To: Vlastimil Babka Cc: Andrew Morton , mhocko@suse.com, osalvador@suse.de, pavel.tatashin@microsoft.com, Mel Gorman , linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 19, 2019 at 9:50 PM Vlastimil Babka wrote: > > On 8/17/19 12:51 PM, Pengfei Li wrote: > > This patch cleans up the if(page). > > > > No functional change. > > > > Signed-off-by: Pengfei Li > > I don't see much benefit here. The indentation wasn't that bad that it > had to be reduced using goto. But the patch is not incorrect so I'm not > NACKing. > Thanks for your review and comments. This patch reduces the number of times the if(page) (as the compiler does), and the downside is that there is a goto. If this improves readability, accept it. Otherwise, leave it as it is. Thanks again. --- Pengfei > > --- > > mm/page_alloc.c | 28 ++++++++++++++++------------ > > 1 file changed, 16 insertions(+), 12 deletions(-) > > > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > > index 272c6de1bf4e..51f056ac09f5 100644 > > --- a/mm/page_alloc.c > > +++ b/mm/page_alloc.c > > @@ -3890,6 +3890,7 @@ __alloc_pages_direct_compact(gfp_t gfp_mask, unsigned int order, > > enum compact_priority prio, enum compact_result *compact_result) > > { > > struct page *page = NULL; > > + struct zone *zone; > > unsigned long pflags; > > unsigned int noreclaim_flag; > > > > @@ -3911,23 +3912,26 @@ __alloc_pages_direct_compact(gfp_t gfp_mask, unsigned int order, > > */ > > count_vm_event(COMPACTSTALL); > > > > - /* Prep a captured page if available */ > > - if (page) > > + if (page) { > > + /* Prep a captured page if available */ > > prep_new_page(page, order, gfp_mask, alloc_flags); > > - > > - /* Try get a page from the freelist if available */ > > - if (!page) > > + } else { > > + /* Try get a page from the freelist if available */ > > page = get_page_from_freelist(gfp_mask, order, alloc_flags, ac); > > > > - if (page) { > > - struct zone *zone = page_zone(page); > > - > > - zone->compact_blockskip_flush = false; > > - compaction_defer_reset(zone, order, true); > > - count_vm_event(COMPACTSUCCESS); > > - return page; > > + if (!page) > > + goto failed; > > } > > > > + zone = page_zone(page); > > + zone->compact_blockskip_flush = false; > > + compaction_defer_reset(zone, order, true); > > + > > + count_vm_event(COMPACTSUCCESS); > > + > > + return page; > > + > > +failed: > > /* > > * It's bad if compaction run occurs and fails. The most likely reason > > * is that pages exist, but not enough to satisfy watermarks. > > >