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=-10.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 65566C4361B for ; Sat, 5 Dec 2020 18:23:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 357032332A for ; Sat, 5 Dec 2020 18:23:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728105AbgLESXZ (ORCPT ); Sat, 5 Dec 2020 13:23:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726186AbgLESXU (ORCPT ); Sat, 5 Dec 2020 13:23:20 -0500 Received: from mail-lf1-x142.google.com (mail-lf1-x142.google.com [IPv6:2a00:1450:4864:20::142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72653C09426B for ; Sat, 5 Dec 2020 09:12:54 -0800 (PST) Received: by mail-lf1-x142.google.com with SMTP id t6so12063496lfl.13 for ; Sat, 05 Dec 2020 09:12:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=mxdC9nJ3E8UgLvs3Rk9lCytw5k8wmjBa4iF3dwQ+Rt4=; b=sHK3k8AdCX6k4jiRY6SdoiiARh2Zojtn832+mXeJ0+ISh9pUUjMpkCuFFfaNYYM2Af qyzhEmxNaXqeRXtsVHpYi+mSQqzbqjnTMK1BnWij1R7l+fAuk9LCDMqFwG2BZK9mPItX AZcJ7Mc9a5EYpaXbyoxZeT6dd6h3FFLqRycuh40c1iPF9/6E1p7nyP2RSpamNpd2dUaY RmfdzuVIaLDHdkbIGuhM8Fw1NQiEf3r9WOcJGJe2e4k7ysH5+YXPylXelFet7SAn4VAH +GEQRXVItSkJug/v1RnpvsxyD04y99sgVPJALAGyxu4FWHy6vlP1ZKgy9JbeN9ldKlcK hZZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=mxdC9nJ3E8UgLvs3Rk9lCytw5k8wmjBa4iF3dwQ+Rt4=; b=JZA2yHtyrwUYTUaGdA9GLGOTRBK5Ov+bWEn211v3+ZyP5XDEFfDy5ctIXUQvYm/qmY fkZVHtGWaTA4ilQ3iD2v8e5/JQ8/TkgSacd1R8cFrGgdR8RhGsBkqTX+C1D4PfXNb4WC zT0Cctz16lrojt8vxPmJ/3VJOZ0yXoxql0YGevws4AoylATnOSu7L0r78LjKR33GUqHH r96l8KHR14eAMh3PclWgFxmqZct+HAXBNQBDh90549KbadEP/ofXBRScuJUPhINRVHkI YlN0xgG6KUmFv2B7B+K5YkHanGjT9TtCdK6G6Dl+uva6uJSheB7vAcPPxDv+lIHUAELw dtUg== X-Gm-Message-State: AOAM532Y8PcpRJ50j34neEkZabqgIGibB4wm0NUx1u0+h9GDHmQBRlYc oKBy35hTnzWnS1MhSmrkumgeYLUuxusDt8Mp52WGdA== X-Google-Smtp-Source: ABdhPJwHyBZ83Wft1RikDbPvXssq7kSbQwSzdhcpRDcjx19c6pe0HapIIBpSbImoJIVYmIj/THSx9nQyFBYoAl2g8Vw= X-Received: by 2002:ac2:530b:: with SMTP id c11mr5092734lfh.185.1607188372824; Sat, 05 Dec 2020 09:12:52 -0800 (PST) MIME-Version: 1.0 References: <20201203152311.5272-1-carver4lio@163.com> <3d709122-0364-5bca-9247-3f212096b389@nvidia.com> In-Reply-To: From: Anders Roxell Date: Sat, 5 Dec 2020 18:12:42 +0100 Message-ID: Subject: Re: [PATCH] mm/memblock:use a more appropriate order calculation when free memblock pages To: Jon Hunter Cc: Marek Szyprowski , Qian Cai , carver4lio@163.com, rppt@kernel.org, Andrew Morton , Linux-MM , Linux Kernel Mailing List , Hailong Liu , Stephen Rothwell , Linux Next Mailing List , Bartlomiej Zolnierkiewicz , linux-tegra Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 5 Dec 2020 at 18:09, Anders Roxell wrote: > > On Fri, 4 Dec 2020 at 18:44, Jon Hunter wrote: > > > > > > On 04/12/2020 16:07, Marek Szyprowski wrote: > > > Hi All, > > > > > > On 04.12.2020 14:42, Qian Cai wrote: > > >> On Thu, 2020-12-03 at 23:23 +0800, carver4lio@163.com wrote: > > >>> From: Hailong Liu > > >>> > > >>> When system in the booting stage, pages span from [start, end] of a memblock > > >>> are freed to buddy in a order as large as possible (less than MAX_ORDER) at > > >>> first, then decrease gradually to a proper order(less than end) in a loop. > > >>> > > >>> However, *min(MAX_ORDER - 1UL, __ffs(start))* can not get the largest order > > >>> in some cases. > > >>> Instead, *__ffs(end - start)* may be more appropriate and meaningful. > > >>> > > >>> Signed-off-by: Hailong Liu > > >> Reverting this commit on the top of today's linux-next fixed boot crashes on > > >> multiple NUMA systems. > > > > > > I confirm. Reverting commit 4df001639c84 ("mm/memblock: use a more > > > appropriate order calculation when free memblock pages") on top of linux > > > next-20201204 fixed booting of my ARM32bit test systems. > > > > > > FWIW, I also confirm that this is causing several 32-bit Tegra platforms > > to crash on boot and reverting this fixes the problem. > > I had the same experience on an arm64 system. This is the log that I see: [ 0.000000][ T0] percpu: Embedded 507 pages/cpu s2036568 r8192 d31912 u2076672 [ 0.000000][ T0] Detected VIPT I-cache on CPU0 [ 0.000000][ T0] CPU features: detected: ARM erratum 845719 [ 0.000000][ T0] CPU features: GIC system register CPU interface present but disabled by higher exception level [ 0.000000][ T0] CPU features: kernel page table isolation forced OFF by kpti command line option [ 0.000000][ T0] Built 1 zonelists, mobility grouping on. Total pages: 516096 [ 0.000000][ T0] Policy zone: DMA [ 0.000000][ T0] Kernel command line: root=/dev/root rootfstype=9p rootflags=trans=virtio console=ttyAMA0,38400n8 earlycon=pl011,0x9000000 initcall_debug softlockup_panic=0 security=none kpti=no [ 0.000000][ T0] Dentry cache hash table entries: 262144 (order: 9, 2097152 bytes, linear) [ 0.000000][ T0] Inode-cache hash table entries: 131072 (order: 8, 1048576 bytes, linear) [ 0.000000][ T0] mem auto-init: stack:off, heap alloc:on, heap free:on [ 0.000000][ T0] mem auto-init: clearing system memory may take some time... [ 0.000000][ T0] page:(____ptrval____) refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x40010 [ 0.000000][ T0] flags: 0x1fffe0000000000() [ 0.000000][ T0] raw: 01fffe0000000000 fffffc0000000408 fffffc0000000408 0000000000000000 [ 0.000000][ T0] raw: 0000000000000000 0000000000000000 00000000ffffffff 0000000000000000 [ 0.000000][ T0] page dumped because: VM_BUG_ON_PAGE(pfn & ((1 << order) - 1)) [ 0.000000][ T0] ------------[ cut here ]------------ [ 0.000000][ T0] kernel BUG at mm/page_alloc.c:1015! [ 0.000000][ T0] Internal error: Oops - BUG: 0 [#1] PREEMPT SMP [ 0.000000][ T0] Modules linked in: [ 0.000000][ T0] CPU: 0 PID: 0 Comm: swapper Not tainted 5.10.0-rc6-next-20201204-00010-g7f8e9106f747-dirty #1 [ 0.000000][ T0] Hardware name: linux,dummy-virt (DT) [ 0.000000][ T0] pstate: 40400085 (nZcv daIf +PAN -UAO -TCO BTYPE=--) [ 0.000000][ T0] pc : __free_one_page+0x14c/0x700 [ 0.000000][ T0] lr : __free_one_page+0x14c/0x700 [ 0.000000][ T0] sp : ffff800013fd7c10 [ 0.000000][ T0] x29: ffff800013fd7c10 x28: 0000000000000000 [ 0.000000][ T0] x27: 0000000000000200 x26: 0000000000000001 [ 0.000000][ T0] x25: 0000000000000000 x24: 0000000000000009 [ 0.000000][ T0] x23: ffff00007dbfbd40 x22: fffffc0000000400 [ 0.000000][ T0] x21: 0000000000040010 x20: 0000000000000009 [ 0.000000][ T0] x19: 00000000000001ff x18: 0000000000000000 [ 0.000000][ T0] x17: 0000000000000000 x16: 0000000000000000 [ 0.000000][ T0] x15: 0000000000000000 x14: 0000000000000000 [ 0.000000][ T0] x13: 0000000000000000 x12: ffff70000281852d [ 0.000000][ T0] x11: 1ffff0000281852c x10: ffff70000281852c [ 0.000000][ T0] x9 : dfff800000000000 x8 : ffff8000140c2960 [ 0.000000][ T0] x7 : 0000000000000001 x6 : 00008ffffd7e7ad4 [ 0.000000][ T0] x5 : 0000000000000000 x4 : 0000000000000000 [ 0.000000][ T0] x3 : ffff80001400ab00 x2 : 0000000000000000 [ 0.000000][ T0] x1 : 0000000000000000 x0 : 0000000000000000 [ 0.000000][ T0] Call trace: [ 0.000000][ T0] __free_one_page+0x14c/0x700 [ 0.000000][ T0] free_one_page+0xf0/0x120 [ 0.000000][ T0] __free_pages_ok+0x720/0x780 [ 0.000000][ T0] __free_pages_core+0x240/0x280 [ 0.000000][ T0] memblock_free_pages+0x40/0x50 [ 0.000000][ T0] free_low_memory_core_early+0x230/0x2f0 [ 0.000000][ T0] memblock_free_all+0x28/0x58 [ 0.000000][ T0] mem_init+0xf0/0x10c [ 0.000000][ T0] mm_init+0xb4/0xe8 [ 0.000000][ T0] start_kernel+0x1e0/0x520 [ 0.000000][ T0] Code: 913a8021 aa1603e0 91030021 97fe7ec6 (d4210000) [ 0.000000][ T0] random: get_random_bytes called from oops_exit+0x50/0xa0 with crng_init=0 [ 0.000000][ T0] ---[ end trace 0000000000000000 ]--- [ 0.000000][ T0] Kernel panic - not syncing: Oops - BUG: Fatal exception [ 0.000000][ T0] ---[ end Kernel panic - not syncing: Oops - BUG: Fatal exception ]--- Cheers, Anders