From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.4 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69412C43331 for ; Sat, 28 Mar 2020 00:51:56 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1ECA6206F1 for ; Sat, 28 Mar 2020 00:51:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="YXFopKyE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1ECA6206F1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id BB9836B0010; Fri, 27 Mar 2020 20:51:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B6A986B0032; Fri, 27 Mar 2020 20:51:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A58BA6B0036; Fri, 27 Mar 2020 20:51:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0055.hostedemail.com [216.40.44.55]) by kanga.kvack.org (Postfix) with ESMTP id 8C1C56B0010 for ; Fri, 27 Mar 2020 20:51:55 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 59691180AD815 for ; Sat, 28 Mar 2020 00:51:55 +0000 (UTC) X-FDA: 76642943790.14.burn63_680ebd759f455 X-HE-Tag: burn63_680ebd759f455 X-Filterd-Recvd-Size: 4026 Received: from us-smtp-delivery-74.mimecast.com (us-smtp-delivery-74.mimecast.com [216.205.24.74]) by imf30.hostedemail.com (Postfix) with ESMTP for ; Sat, 28 Mar 2020 00:51:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585356714; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=AfM5YElagMxU4jLZCXpRalvLQEr9T943a/2CkE+p0+U=; b=YXFopKyELcr8CdYO9bqv4rEas6AfrKUcAxx34sX5bfoW5EqU37VKQdIaTrv0u3l2cMTurz NpGQqvH4OKAUwQvikxjYeIymo7BkDVoyHP6lfWeH/RHd0xBq99c71RRpP5wILhs27Ls3+i W1Yis9MY1EdRe6J/JocyM0UxtyK4akM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-67-RMN3DDxlMZGzXBqdzhX_SA-1; Fri, 27 Mar 2020 20:51:52 -0400 X-MC-Unique: RMN3DDxlMZGzXBqdzhX_SA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CA4931937FCE; Sat, 28 Mar 2020 00:51:50 +0000 (UTC) Received: from localhost (ovpn-12-36.pek2.redhat.com [10.72.12.36]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5563B60304; Sat, 28 Mar 2020 00:51:47 +0000 (UTC) Date: Sat, 28 Mar 2020 08:51:44 +0800 From: Baoquan He To: Wei Yang Cc: John Hubbard , akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, jgg@ziepe.ca, david@redhat.com Subject: Re: [Patch v2 2/2] mm/page_alloc.c: define node_order with all zero Message-ID: <20200328005144.GQ3039@MiWiFi-R3L-srv> References: <20200327220121.27823-1-richard.weiyang@gmail.com> <20200327220121.27823-2-richard.weiyang@gmail.com> <4c9d8138-d379-810f-64e7-0d018ed019df@nvidia.com> <20200328002616.kjtf7dpkqbugyzi2@master> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200328002616.kjtf7dpkqbugyzi2@master> User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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: On 03/28/20 at 12:26am, Wei Yang wrote: > On Fri, Mar 27, 2020 at 03:37:57PM -0700, John Hubbard wrote: > >On 3/27/20 3:01 PM, Wei Yang wrote: > >> Since we always clear node_order before getting it, we can leverage > >> compiler to do this instead of at run time. > >> > >> Signed-off-by: Wei Yang > >> --- > >> mm/page_alloc.c | 3 +-- > >> 1 file changed, 1 insertion(+), 2 deletions(-) > >> > >> diff --git a/mm/page_alloc.c b/mm/page_alloc.c > >> index dfcf2682ed40..49dd1f25c000 100644 > >> --- a/mm/page_alloc.c > >> +++ b/mm/page_alloc.c > >> @@ -5585,7 +5585,7 @@ static void build_thisnode_zonelists(pg_data_t *pgdat) > >> static void build_zonelists(pg_data_t *pgdat) > >> { > >> - static int node_order[MAX_NUMNODES]; > >> + static int node_order[MAX_NUMNODES] = {0}; > > > > > >Looks wrong: now the single instance of node_order is initialized just once by > >the compiler. And that means that only the first caller of this function > >gets a zeroed node_order array... > > > > What a shame on me. You are right, I miss the static word. > > Well, then I am curious about why we want to define it as static. Each time we > call this function, node_order would be set to 0 and find_next_best_node() > would sort a proper value into it. I don't see the reason to reserve it in a > global area and be used next time. > > My suggestion is to remove the static and define it {0} instead of memset > every time. Is my understanding correct here? Removing static looks good, the node_order is calculated on the basis of each node, it's useless for other node. It may be inherited from the old code where it's a static global variable.