Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp5926780imm; Mon, 23 Jul 2018 08:23:01 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe24yrkQ9yvmK9WdkhduuzH7tUKzNHNmZ1bYmvQtPZr7wlvzbXRog6FvlFLHRkucllFIV6v X-Received: by 2002:a17:902:4c88:: with SMTP id b8-v6mr12830636ple.285.1532359381674; Mon, 23 Jul 2018 08:23:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532359381; cv=none; d=google.com; s=arc-20160816; b=0ieh3497rfIYPxWNlDRXFdbQLqMHL80b2OyB3RCuaXkLNRqNMIvAMxXcNBALT0iMxx gEy1jsGiyMDp+ojM+jrTzMw+Bc/qPaxz/uuhoW6yZU9oxqd4PPvF5Pgj0/Trpr6j+bvp rP3sYqgn51/6J8ZlFG5sdDaIN8PNRpCS0np4TKNPlx6aGygj+QIVGpo9OLbLxRLGo0JZ kvJ+QiberSUiQjOlm/xlJe/OCzBUICL7lq0gAEwifZRkr/kkvGFAV9JVckefOPkbJPMZ 1KlgFKyxZTLyhHN4sICawrPXcAYEBgHQdiS3YTC083RFM24cMKWQiLLypA+iHlQoTqgC 4Usw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=8gUbTY31L9jtetP0QKK3YjtiDCim5q5h65mAiTslKbw=; b=UmW3GDOuq47z3aKNrzvKpNTnPF//xXG9SnlNw067E7UOzgFD6rDnpJ5Jb/z3uMLrvA u7uhZ40/JSHCnd153BITe63liiudeTzMP3EbWQctB6YMGqDUSQXdOmEBdqJ0+DqOnFRV Az6+iJVWULWqCzW5CFo2DkVWZQ+lCrCUL2PQHIXmSM93Y6656pI+qjfZ/HiJBHd1Wi9d Hu0yOWURXLvBCjpgiYa1Bp10yiBvzBNk4dnw2Z0xareW5mQhbec++SB7bMQ2mzVST7uW VPcAy4KOVshbOeUy71dYc+/jRI6LZMbEsx6tdMUAZWLVdyiRD/kaXCLRX/0d+Qezmnsm rk2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=p7XI6YoK; 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=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m26-v6si8327266pge.353.2018.07.23.08.22.46; Mon, 23 Jul 2018 08:23:01 -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=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=p7XI6YoK; 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=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388524AbeGWQWS (ORCPT + 99 others); Mon, 23 Jul 2018 12:22:18 -0400 Received: from mail-yb0-f194.google.com ([209.85.213.194]:37017 "EHLO mail-yb0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388130AbeGWQWR (ORCPT ); Mon, 23 Jul 2018 12:22:17 -0400 Received: by mail-yb0-f194.google.com with SMTP id r3-v6so380307ybo.4 for ; Mon, 23 Jul 2018 08:20:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=8gUbTY31L9jtetP0QKK3YjtiDCim5q5h65mAiTslKbw=; b=p7XI6YoKQwZcvFSJmHIXpvLWyj5yI6RiKM4gZmxuCD0IVsLKLG0lw/eDMDfwPGL63F iZ3COdpapwZgJ9MlXlPUSW1TBb0wgrG//Uoo8qiXgQa0xofMyjl+HoZNCIvgosV2VOQY uavcNM/30Xnw2t2qQM61jJY7zQ7rJ7jFb21hyvgqp8uP2MFCJyXnf4QBpwHgJ/wHCKUJ 4oPh86PH2c6wGHFMIqk61SaeqVlW8r8kA1CAfrUxqVAJn7h3XSLtXl8+QFHIa4rrbrzU CIv2XdUpir8J9aaadztO5V0ziRqzlanyhcMLLoXCH8D4m1iuRp3XEdEyhBQKd0wW/ch1 5Xgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=8gUbTY31L9jtetP0QKK3YjtiDCim5q5h65mAiTslKbw=; b=iT45B9y0mZp6y5E6IFOBIQN5OXsIu2aUijK7XN5Vu0yS+WYXMtzw+g7v0vtee2yEIS 4+jxSShmr2ujrXYXRG6mdU9VNrmk/dJKRrDdUWokptShVkLYzMzSi9nctIpMnxykC27M 1cFubO7VeSqifCLlkIz/EXK5ykilnaQKvOf7mOrHpyltK11VZ6EDyU9lTBF+rEJwoLAv xQwVeNy5vE92QHv5VCsQGF7k6J49IiiN7oSlv5M/txSTT/Gf7sG17zJZGd5HKh9i7QRD bLPimLZFm0A6/JCDFJM6Su1wVF6IsVAvOSi2+Ro9nTJ16a7oiMmEXJaAEFoc+d3p/cu/ I0hA== X-Gm-Message-State: AOUpUlE+Dr3rvNog/5UfnmCODfSQTbkxCiAcb1BAr+p9k0luEyQLvMPP tgNuJbbfNeBAp8hydkBORqbu9g== X-Received: by 2002:a25:ae5b:: with SMTP id g27-v6mr7079766ybe.351.1532359234011; Mon, 23 Jul 2018 08:20:34 -0700 (PDT) Received: from localhost ([2620:10d:c091:180::1:3a18]) by smtp.gmail.com with ESMTPSA id f137-v6sm7774584ywb.52.2018.07.23.08.20.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 08:20:32 -0700 (PDT) Date: Mon, 23 Jul 2018 11:23:23 -0400 From: Johannes Weiner To: Arnd Bergmann Cc: Ingo Molnar , Peter Zijlstra , Andrew Morton , Linus Torvalds , Tejun Heo , Suren Baghdasaryan , Vinayak Menon , Christopher Lameter , Mike Galbraith , Shakeel Butt , Linux-MM , cgroups@vger.kernel.org, Linux Kernel Mailing List , kernel-team@fb.com, Catalin Marinas , Will Deacon , Linux ARM Subject: Re: [PATCH 02/10] mm: workingset: tell cache transitions from workingset thrashing Message-ID: <20180723152323.GA3699@cmpxchg.org> References: <20180712172942.10094-1-hannes@cmpxchg.org> <20180712172942.10094-3-hannes@cmpxchg.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.0 (2018-05-17) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Arnd, On Mon, Jul 23, 2018 at 03:36:09PM +0200, Arnd Bergmann wrote: > On Thu, Jul 12, 2018 at 7:29 PM, Johannes Weiner wrote: > > How many page->flags does this leave us with on 32-bit? > > > > 20 bits are always page flags > > > > 21 if you have an MMU > > > > 23 with the zone bits for DMA, Normal, HighMem, Movable > > > > 29 with the sparsemem section bits > > > > 30 if PAE is enabled > > > > 31 with this patch. > > > > So on 32-bit PAE, that leaves 1 bit for distinguishing two NUMA > > nodes. If that's not enough, the system can switch to discontigmem and > > re-gain the 6 or 7 sparsemem section bits. > > > > Signed-off-by: Johannes Weiner > > It seems we ran out of bits on arm64 in randconfig builds: > > In file included from /git/arm-soc/include/linux/kernel.h:10, > from /git/arm-soc/arch/arm64/mm/init.c:20: > /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) This BUILD_BUG_ON() is to make sure we're sizing the VMEMMAP struct page array properly (address space divided by struct page size). From the code: /* * Log2 of the upper bound of the size of a struct page. Used for sizing * the vmemmap region only, does not affect actual memory footprint. * We don't use sizeof(struct page) directly since taking its size here * requires its definition to be available at this point in the inclusion * chain, and it may not be a power of 2 in the first place. */ #define STRUCT_PAGE_MAX_SHIFT 6 > Apparently this triggered > > #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 > > and in turn > > #if defined(CONFIG_NUMA_BALANCING) && LAST_CPUPID_WIDTH == 0 > #define LAST_CPUPID_NOT_IN_PAGE_FLAGS > #endif > > and that _last_cpupid in struct page made sizeof(struct page) larger than 64. > > This is for a randconfig build, see https://pastebin.com/YuwSTah3 > for the configuration file, some of the relevant options are > > CONFIG_64BIT=y > CONFIG_MEMCG=y > CONFIG_SPARSEMEM=y > CONFIG_ARM64_PA_BITS=52 > CONFIG_ARM64_64K_PAGES=y > CONFIG_NR_CPUS=64 > CONFIG_NUMA_BALANCING=y > # CONFIG_SPARSEMEM_VMEMMAP is not set However, the check isn't conditional on that config option. And when VMEMMAP is disabled, we need 22 additional bits to identify the sparse memory sections in page->flags as well: > CONFIG_NODES_SHIFT=2 > # CONFIG_ARCH_USES_PG_UNCACHED is not set > CONFIG_MEMORY_FAILURE=y > CONFIG_IDLE_PAGE_TRACKING=y > > #define MAX_NR_ZONES 3 > #define ZONES_SHIFT 2 > #define MAX_PHYSMEM_BITS 52 > #define SECTION_SIZE_BITS 30 > #define SECTIONS_WIDTH 22 ^^^ Those we get back with VMEMMAP enabled. So for configs for which the check is intended, it passes. We just need to make it conditional to those. --- From 1d24635a6c7cd395bad5c29a3b9e5d2e98d9ab84 Mon Sep 17 00:00:00 2001 From: Johannes Weiner Date: Mon, 23 Jul 2018 10:18:23 -0400 Subject: [PATCH] arm64: fix vmemmap BUILD_BUG_ON() triggering on !vmemmap setups 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. Reported-by: Arnd Bergmann Signed-off-by: Johannes Weiner --- arch/arm64/mm/init.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 1b18b4722420..72c9b6778b0a 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -611,11 +611,13 @@ void __init mem_init(void) BUILD_BUG_ON(TASK_SIZE_32 > TASK_SIZE_64); #endif +#ifndef 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; -- 2.18.0