Received: by 10.223.164.202 with SMTP id h10csp4252839wrb; Mon, 20 Nov 2017 12:22:22 -0800 (PST) X-Google-Smtp-Source: AGs4zMaStkmy6flFz9r+/2iMioqXAYK2fKztg1CjKazkzRXXUukqYaqZ5fZ1mze9EOTmAo8kL8R1 X-Received: by 10.99.43.6 with SMTP id r6mr14508161pgr.353.1511209341945; Mon, 20 Nov 2017 12:22:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511209341; cv=none; d=google.com; s=arc-20160816; b=OUbYkIkhSbG2IISapEQ46//4S2nVS5c0tAalZosCeH++BvvF5En9DJsH1gO6klKw8n bxzJjbPowv81fDN/r3bDLvjmakihMNL4KBejDlnV+hYJ3TBOtrMYg3z+pD12B7I+o+B1 W0TCxoEoiDJcQjwLmyvAWTsyNv6mSeGPPcqxMrGuM5cTc6F4mXA2I8v+Eq9K8GWnQzTC qu8dZ7uwCbCtT2rydb/OH2m0a5Hi2VhgUcXpLczbc5sTsnDvji6Hi6iiVaDMRCfp7XqT 9lR+3EHoh57OfuBCUZPbflA1II2ypNV7rB1V2vrbHzRzEgHVy0RJ6Y4PKtKuUzfJEM5W EEHQ== 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 :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=AyQbOtFKq66elO3oKuDYLivGfZJgY/3k/6xbSo5r5Bk=; b=v3s3eQJSFD1aLTTKBdkmZ8+zP09R82tBezteSi2fyYhrPEPF+7j9ifB9iny1jQlI4R Y/nM3644yN4y5MLTarmHr2YWbHaEenqwhav2/WwXb3Yla+vEhbsrHx9/zTdqwCPlFhum 8V3GBdZw1dIQEebrhzFKsNRjrbFDqazWq81qG7w2X8tvv3fsJPszPTGTPBhPF2CD8NLh /XNZSRZM2EubCScm58e6To5rR1NZhn+vZuiFn0g2UW9wvxapq5KvJeoA6G69J3Fj7305 bEe93AhKSjTzm8ZnrsrmBrVh+y/NMz+QJiLLWZXSpFoZzhyJ7hK0Mw+hN/ymknFiM6fs spSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DYHmza6s; 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=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e6si8840412pls.579.2017.11.20.12.22.11; Mon, 20 Nov 2017 12:22:21 -0800 (PST) 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=@linaro.org header.s=google header.b=DYHmza6s; 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=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752640AbdKTUVg (ORCPT + 67 others); Mon, 20 Nov 2017 15:21:36 -0500 Received: from mail-qk0-f195.google.com ([209.85.220.195]:43849 "EHLO mail-qk0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751173AbdKTUVe (ORCPT ); Mon, 20 Nov 2017 15:21:34 -0500 Received: by mail-qk0-f195.google.com with SMTP id j202so9074330qke.10 for ; Mon, 20 Nov 2017 12:21:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=AyQbOtFKq66elO3oKuDYLivGfZJgY/3k/6xbSo5r5Bk=; b=DYHmza6sKD1l+gmEvpznNYdeHyk4N7qC1jtBGkHyrp56eLcYtdwXn/eYiTtY/y3c2M e79S8W9fw4Cwrg/55v7+oPrwuDHBLLik1A+wvd9303YJ/jyR/0G+wuz85UVx0rDctQEs rOsDAE6cL7r3ApfyJ+gX7EqwYu9YJqr4DumnU= 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:in-reply-to:message-id :references:user-agent:mime-version; bh=AyQbOtFKq66elO3oKuDYLivGfZJgY/3k/6xbSo5r5Bk=; b=tKWON+21o6b7jmSiu6P7OQnL0cWsbvwCzyakwOUQiHn87Y/hOMln+o6+MJKTSeHSva Dq+RJBnSe95uf8hSM9qvNuK7D/JmWwn1WqC4fm9ak9LORAwdBav+Yz2zdEeybOsmcei9 4HmHHxxibUy/LhCIUse8MfK1l96LgcKvQDGFQSSWAFxu/KTaLEKvf9xCunY9cc2scYiS V2d8mNTFtPiBMAcLfApNyXt5VfWojTJMzQLteJuPWvig3lJKg9BYhrdo6thw9CpCBqnO 11Px4PTL262+9JgzzCzO0O0/Jk2RZ6jSx/+FWP/G9SZF+n4kWu3lHEZy9rOdpdDLpM9d H69w== X-Gm-Message-State: AJaThX7yJUmdmH6dc0mHIuJBTjATl/cEFAYiQflOUbclQrxMGkBIo0YF 8vdtS7I2mBzsALWogfGdZa7Te0BqgIM= X-Received: by 10.55.221.212 with SMTP id u81mr23019571qku.174.1511209294085; Mon, 20 Nov 2017 12:21:34 -0800 (PST) Received: from xanadu.home ([2607:fa48:6c06:a2d0:feaa:14ff:fea7:ed77]) by smtp.gmail.com with ESMTPSA id 33sm3717300qts.76.2017.11.20.12.21.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Nov 2017 12:21:33 -0800 (PST) Date: Mon, 20 Nov 2017 15:21:32 -0500 (EST) From: Nicolas Pitre To: Guenter Roeck cc: Tejun Heo , Christoph Lameter , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Mikael Starvik , Jesper Nilsson , linux-cris-kernel@axis.com Subject: Re: mm/percpu.c: use smarter memory allocation for struct pcpu_alloc_info (crisv32 hang) In-Reply-To: <20171120185138.GB23789@roeck-us.net> Message-ID: References: <20171118182542.GA23928@roeck-us.net> <62a3b680-6dde-d308-3da8-9c9a2789b114@roeck-us.net> <20171120185138.GB23789@roeck-us.net> User-Agent: Alpine 2.21 (LFD 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 20 Nov 2017, Guenter Roeck wrote: > On Mon, Nov 20, 2017 at 01:18:38PM -0500, Nicolas Pitre wrote: > > On Sun, 19 Nov 2017, Guenter Roeck wrote: > > > > > On 11/19/2017 08:08 PM, Nicolas Pitre wrote: > > > > On Sun, 19 Nov 2017, Guenter Roeck wrote: > > > > > On 11/19/2017 12:36 PM, Nicolas Pitre wrote: > > > > > > On Sat, 18 Nov 2017, Guenter Roeck wrote: > > > > > > > On Tue, Oct 03, 2017 at 06:29:49PM -0400, Nicolas Pitre wrote: > > > > > > > > @@ -2295,6 +2295,7 @@ void __init setup_per_cpu_areas(void) > > > > > > > > if (pcpu_setup_first_chunk(ai, fc) < 0) > > > > > > > > panic("Failed to initialize percpu areas."); > > > > > > > > + pcpu_free_alloc_info(ai); > > > > > > > > > > > > > > This is the culprit. Everything works fine if I remove this line. > > > > > > > > > > > > Without this line, the memory at the ai pointer is leaked. Maybe this is > > > > > > modifying the memory allocation pattern and that triggers a bug later on > > > > > > in your case. > > > > > > > > > > > > At that point the console driver is not yet initialized and any error > > > > > > message won't be printed. You should enable the early console mechanism > > > > > > in your kernel (see arch/cris/arch-v32/kernel/debugport.c) and see what > > > > > > that might tell you. > > > > > > > > > > > > > > > > The problem is that BUG() on crisv32 does not yield useful output. > > > > > Anyway, here is the culprit. > > > > > > > > > > diff --git a/mm/bootmem.c b/mm/bootmem.c > > > > > index 6aef64254203..2bcc8901450c 100644 > > > > > --- a/mm/bootmem.c > > > > > +++ b/mm/bootmem.c > > > > > @@ -382,7 +382,8 @@ static int __init mark_bootmem(unsigned long start, > > > > > unsigned long end, > > > > > return 0; > > > > > pos = bdata->node_low_pfn; > > > > > } > > > > > - BUG(); > > > > > + WARN(1, "mark_bootmem(): memory range 0x%lx-0x%lx not found\n", > > > > > start, > > > > > end); > > > > > + return -ENOMEM; > > > > > } > > > > > > > > > > /** > > > > > diff --git a/mm/percpu.c b/mm/percpu.c > > > > > index 79e3549cab0f..c75622d844f1 100644 > > > > > --- a/mm/percpu.c > > > > > +++ b/mm/percpu.c > > > > > @@ -1881,6 +1881,7 @@ struct pcpu_alloc_info * __init > > > > > pcpu_alloc_alloc_info(int nr_groups, > > > > > */ > > > > > void __init pcpu_free_alloc_info(struct pcpu_alloc_info *ai) > > > > > { > > > > > + printk("pcpu_free_alloc_info(%p (0x%lx))\n", ai, __pa(ai)); > > > > > memblock_free_early(__pa(ai), ai->__ai_size); > > > > > > > > The problem here is that there is two possibilities for > > > > memblock_free_early(). From include/linux/bootmem.h: > > > > > > > > #if defined(CONFIG_HAVE_MEMBLOCK) && defined(CONFIG_NO_BOOTMEM) > > > > > > > > static inline void __init memblock_free_early( > > > > phys_addr_t base, phys_addr_t size) > > > > { > > > > __memblock_free_early(base, size); > > > > } > > > > > > > > #else > > > > > > > > static inline void __init memblock_free_early( > > > > phys_addr_t base, phys_addr_t size) > > > > { > > > > free_bootmem(base, size); > > > > } > > > > > > > > #endif > > > > > > > > It looks like most architectures use the memblock variant, including all > > > > the ones I have access to. > > > > > > > > > results in: > > > > > > > > > > pcpu_free_alloc_info(c0534000 (0x40534000)) > > > > > ------------[ cut here ]------------ > > > > > WARNING: CPU: 0 PID: 0 at mm/bootmem.c:385 mark_bootmem+0x9a/0xaa > > > > > mark_bootmem(): memory range 0x2029a-0x2029b not found > > > > > > > > Well... PFN_UP(0x40534000) should give 0x40534. How you might end up > > > > with 0x2029a in mark_bootmem(), let alone not exit on the first "if (max > > > > == end) return 0;" within the loop is rather weird. > > > > > > > pcpu_free_alloc_info: ai=c0536000, __pa(ai)=0x40536000, > > > PFN_UP(__pa(ai))=0x2029b, PFN_UP(ai)=0x6029b > > > > > > bootmem range is 0x60000..0x61000. It doesn't get to "if (max == end)" > > > because "pos (=0x2029b) < bdata->node_min_pfn (=0x60000)". > > > > OK. the 0x2029b is the result of PAGE_SIZE being 8192 in your case. > > However the bootmem allocator deals with physical addresses not virtual > > ones. So it shouldn't give you a 0x60000..0x61000 range. > > > > Would be interesting to see what result you get on line 860 of > > mm/bootmem.c. > > > Nothing; __alloc_bootmem_low_node() is not called. > > Call chain is: > pcpu_alloc_alloc_info > memblock_virt_alloc_nopanic > __alloc_bootmem_nopanic > ___alloc_bootmem_nopanic But from there it should continue with: alloc_bootmem_core() --> alloc_bootmem_bdata() --> [...] region = phys_to_virt(PFN_PHYS(bdata->node_min_pfn) + start_off); That's line 585, not 860 as I mentioned. Sorry for the confusion. Nicolas From 1584612217913467540@xxx Mon Nov 20 18:52:53 +0000 2017 X-GM-THRID: 1584466607656225114 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread