Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1163060imm; Wed, 1 Aug 2018 11:13:29 -0700 (PDT) X-Google-Smtp-Source: AAOMgpflHII3w3T2YMmljSYPJ7x+3YOcyZwx2mHR4Tg+gVSmFknXRwWhiDUkOnb3IDtB4l0BR/Y6 X-Received: by 2002:a62:dc8f:: with SMTP id c15-v6mr27830497pfl.155.1533147209403; Wed, 01 Aug 2018 11:13:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533147209; cv=none; d=google.com; s=arc-20160816; b=bBX89noNfPQLr3AKZ35fr7fqq8ZI7mgj5cPwmoXYNbLYt12gZKmQgRxFAqN6QFT7mS +MuASaqZhOga289fCxNjyqDbtX5BT9kYAu7rTEzKU1goYbBqt6Y31AhkCteZh/rbb4TS OIdtcaqRx9/pCfZ7cU4lA58wPCeJ/c99N5eimwjo5PqnK/3kRsOWk98+65o4JqSeVTLk kfwvJAXgzkU7/q682Hx5litQH4+xYCEwXabcWlczjXjt0gQ337ttxcXeGBRlQN17a5Gu T+4vfa0gQP7+C1WjOd21iaTxfQrhsMhhu28PluQF5qYz+YAJCe8SqjqG4oO8CQhXoorn D/+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=irdRaAX5JwYAO8Y7RC2EFohbmnnZ6KuTLqwG5mux6ZY=; b=hlsCynYeuWZIbjVfXo9DUe1B3jXNsTQFUQAgoeJIbBU70LAob7XSDeSMgjQXRoddnF T5509DW9TKkmy4gLeY4wr+tlv+jDQh7fiGj7RWRJqspCCuMMoHh31UC/gDi37tpkgiRA xms2HeLRoNxjh+jZ/CldjWfn3GuZ3Q0VptVs1qDUChliC3IQeDVUMMJV+78AqbRHbcvE zXg2k66BluQ9FttPkBDbhGq5G5dDr2smXE/zMOKQmzmwbEVJAyvZluTViRxuMracjU/m utVVOQP0/ZsimQ7LI7LCNq+qXdXMNATKPR6iPilH8UUKncq9dCUv/GjZlGqBRcW0l07l OuJw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t18-v6si17281684pga.301.2018.08.01.11.13.14; Wed, 01 Aug 2018 11:13:29 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732842AbeHAT6u (ORCPT + 99 others); Wed, 1 Aug 2018 15:58:50 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:49794 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405690AbeHATIf (ORCPT ); Wed, 1 Aug 2018 15:08:35 -0400 Received: from localhost (D57E6652.static.ziggozakelijk.nl [213.126.102.82]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 395F01338; Wed, 1 Aug 2018 17:12:17 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arnd Bergmann , Johannes Weiner , Will Deacon Subject: [PATCH 4.14 018/246] arm64: fix vmemmap BUILD_BUG_ON() triggering on !vmemmap setups Date: Wed, 1 Aug 2018 18:48:48 +0200 Message-Id: <20180801165012.573453540@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180801165011.700991984@linuxfoundation.org> References: <20180801165011.700991984@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 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 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Johannes Weiner commit 7b0eb6b41a08fa1fa0d04b1c53becd62b5fbfaee upstream. Arnd reports the following arm64 randconfig build error with the PSI patches that add another page flag: /git/arm-soc/arch/arm64/mm/init.c: In function 'mem_init': /git/arm-soc/include/linux/compiler.h:357:38: error: call to '__compiletime_assert_618' declared with attribute error: BUILD_BUG_ON failed: sizeof(struct page) > (1 << STRUCT_PAGE_MAX_SHIFT) The additional page flag causes other information stored in page->flags to get bumped into their own struct page member: #if SECTIONS_WIDTH+ZONES_WIDTH+NODES_SHIFT+LAST_CPUPID_SHIFT <= BITS_PER_LONG - NR_PAGEFLAGS #define LAST_CPUPID_WIDTH LAST_CPUPID_SHIFT #else #define LAST_CPUPID_WIDTH 0 #endif #if defined(CONFIG_NUMA_BALANCING) && LAST_CPUPID_WIDTH == 0 #define LAST_CPUPID_NOT_IN_PAGE_FLAGS #endif which in turn causes the struct page size to exceed the size set in STRUCT_PAGE_MAX_SHIFT. This value is an an estimate used to size the VMEMMAP page array according to address space and struct page size. However, the check is performed - and triggers here - on a !VMEMMAP config, which consumes an additional 22 page bits for the sparse section id. When VMEMMAP is enabled, those bits are returned, cpupid doesn't need its own member, and the page passes the VMEMMAP check. Restrict that check to the situation it was meant to check: that we are sizing the VMEMMAP page array correctly. Says Arnd: Further experiments show that the build error already existed before, but was only triggered with larger values of CONFIG_NR_CPU and/or CONFIG_NODES_SHIFT that might be used in actual configurations but not in randconfig builds. With longer CPU and node masks, I could recreate the problem with kernels as old as linux-4.7 when arm64 NUMA support got added. Reported-by: Arnd Bergmann Tested-by: Arnd Bergmann Cc: stable@vger.kernel.org Fixes: 1a2db300348b ("arm64, numa: Add NUMA support for arm64 platforms.") Fixes: 3e1907d5bf5a ("arm64: mm: move vmemmap region right below the linear region") Signed-off-by: Johannes Weiner Signed-off-by: Will Deacon Signed-off-by: Greg Kroah-Hartman --- arch/arm64/mm/init.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -651,11 +651,13 @@ void __init mem_init(void) BUILD_BUG_ON(TASK_SIZE_32 > TASK_SIZE_64); #endif +#ifdef CONFIG_SPARSEMEM_VMEMMAP /* * Make sure we chose the upper bound of sizeof(struct page) - * correctly. + * correctly when sizing the VMEMMAP array. */ BUILD_BUG_ON(sizeof(struct page) > (1 << STRUCT_PAGE_MAX_SHIFT)); +#endif if (PAGE_SIZE >= 16384 && get_num_physpages() <= 128) { extern int sysctl_overcommit_memory;