From patchwork Wed Dec 26 13:14:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fengguang Wu X-Patchwork-Id: 10743149 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3956391E for ; Wed, 26 Dec 2018 13:39:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 285282846D for ; Wed, 26 Dec 2018 13:39:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1C58728481; Wed, 26 Dec 2018 13:39:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C71472846D for ; Wed, 26 Dec 2018 13:39:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726865AbeLZNj1 (ORCPT ); Wed, 26 Dec 2018 08:39:27 -0500 Received: from mga12.intel.com ([192.55.52.136]:31975 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726908AbeLZNhF (ORCPT ); Wed, 26 Dec 2018 08:37:05 -0500 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Dec 2018 05:37:05 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,400,1539673200"; d="scan'208";a="113358926" Received: from wangdan1-mobl1.ccr.corp.intel.com (HELO wfg-t570.sh.intel.com) ([10.254.210.154]) by orsmga003.jf.intel.com with ESMTP; 26 Dec 2018 05:37:02 -0800 Received: from wfg by wfg-t570.sh.intel.com with local (Exim 4.89) (envelope-from ) id 1gc9Mr-0005O3-8C; Wed, 26 Dec 2018 21:37:01 +0800 Message-Id: <20181226133351.229014333@intel.com> User-Agent: quilt/0.65 Date: Wed, 26 Dec 2018 21:14:49 +0800 From: Fengguang Wu To: Andrew Morton cc: Linux Memory Management List , Fan Du cc: kvm@vger.kernel.org Cc: LKML cc: Yao Yuan cc: Peng Dong cc: Huang Ying CC: Liu Jingqi cc: Dong Eddie cc: Dave Hansen cc: Zhang Yi cc: Dan Williams cc: Fengguang Wu Subject: [RFC][PATCH v2 03/21] x86/numa_emulation: fix fake NUMA in uniform case References: <20181226131446.330864849@intel.com> MIME-Version: 1.0 Content-Disposition: inline; filename=fix-fake-numa.patch Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Fan Du The index of numa_meminfo is expected to the same as of numa_meminfo.blk[]. and numa_remove_memblk_from break the expectation. 2S system does not break, because before numa_remove_memblk_from index nid 0 0 1 1 after numa_remove_memblk_from index nid 0 1 1 1 If you try to configure uniform fake node in 4S system. index nid 0 0 1 1 2 2 3 3 node 3 will be removed by numa_remove_memblk_from when iterate index 2. so we only create fake node for 3 physcial node, and a portion of memroy wasted as much as it hit lost pages checking in numa_meminfo_cover_memory. Signed-off-by: Fan Du --- arch/x86/mm/numa_emulation.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) --- linux.orig/arch/x86/mm/numa_emulation.c 2018-12-23 19:20:51.570664269 +0800 +++ linux/arch/x86/mm/numa_emulation.c 2018-12-23 19:20:51.566664364 +0800 @@ -381,7 +381,21 @@ void __init numa_emulation(struct numa_m goto no_emu; memset(&ei, 0, sizeof(ei)); - pi = *numa_meminfo; + + { + /* Make sure the index is identical with nid */ + struct numa_meminfo *mi = numa_meminfo; + int nid; + + for (i = 0; i < mi->nr_blks; i++) { + nid = mi->blk[i].nid; + pi.blk[nid].nid = nid; + pi.blk[nid].start = mi->blk[i].start; + pi.blk[nid].end = mi->blk[i].end; + } + pi.nr_blks = mi->nr_blks; + + } for (i = 0; i < MAX_NUMNODES; i++) emu_nid_to_phys[i] = NUMA_NO_NODE;