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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 96FADC433EF for ; Wed, 30 Mar 2022 21:48:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 11BEC8D0002; Wed, 30 Mar 2022 17:48:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0CBBA6B0073; Wed, 30 Mar 2022 17:48:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E87458D0002; Wed, 30 Mar 2022 17:48:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0007.hostedemail.com [216.40.44.7]) by kanga.kvack.org (Postfix) with ESMTP id DB2206B0072 for ; Wed, 30 Mar 2022 17:48:09 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 9E5A2182CA113 for ; Wed, 30 Mar 2022 21:48:09 +0000 (UTC) X-FDA: 79302391098.26.007902F Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf25.hostedemail.com (Postfix) with ESMTP id EABDCA0005 for ; Wed, 30 Mar 2022 21:48:08 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id DF36F218F8; Wed, 30 Mar 2022 21:48:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1648676887; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bWhCH76wJNOPUkyUEGjWSMW9zgCG+hN7ltEMYwIFxNA=; b=0hGaA5oUgyBUmiCvjSMdMMYK2/vVDl0Paz7oDbnNAYjh4/os8TxHqDREx2rf9SuMr7F53f PPiEMTg+AkY+dCF5urd4okHT3fXJY5I8uMymT7Dg2hlIxe0LuC7sCpets5jwYGXTrvgCFm pTXzbFqNCftxSHTEqHt3TlfiEYtKrOM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1648676887; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bWhCH76wJNOPUkyUEGjWSMW9zgCG+hN7ltEMYwIFxNA=; b=GSR7mChVNeh+pGPYpRizx3j4jedxwMLSR2xHiSKZs5M7BkTT08RBLW4XLRH7B98bcZli3o XAi0+gkLkZCBhDAA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id A6B1613AF3; Wed, 30 Mar 2022 21:48:07 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id T5nBJxfQRGJxHgAAMHmgww (envelope-from ); Wed, 30 Mar 2022 21:48:07 +0000 Message-ID: <2b84aba9-7435-0073-59f0-410fddb6df7d@suse.cz> Date: Wed, 30 Mar 2022 23:48:07 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: [BUG] Crash on x86_32 for: mm: page_alloc: avoid merging non-fallbackable pageblocks with others Content-Language: en-US To: Zi Yan , Steven Rostedt Cc: Linus Torvalds , LKML , Mel Gorman , David Hildenbrand , Mike Rapoport , Oscar Salvador , Andrew Morton , Linux-MM References: <20220330154208.71aca532@gandalf.local.home> <20220330165337.7138810e@gandalf.local.home> <733F211D-9717-46A7-A0A2-40353E12F65A@nvidia.com> From: Vlastimil Babka In-Reply-To: <733F211D-9717-46A7-A0A2-40353E12F65A@nvidia.com> Content-Type: text/plain; charset=UTF-8 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: EABDCA0005 X-Rspam-User: Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=0hGaA5oU; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=GSR7mChV; dmarc=none; spf=pass (imf25.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=vbabka@suse.cz X-Stat-Signature: q91f847txcumoftqjwpz4xqqp6pukcqr X-HE-Tag: 1648676888-352005 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 3/30/22 23:43, Zi Yan wrote: > On 30 Mar 2022, at 17:25, Zi Yan wrote: >=20 >> On 30 Mar 2022, at 16:53, Steven Rostedt wrote: >> >>> On Wed, 30 Mar 2022 16:29:28 -0400 >>> Zi Yan wrote: >>> >>>> diff --git a/mm/page_alloc.c b/mm/page_alloc.c >>>> index bdc8f60ae462..83a90e2973b7 100644 >>>> --- a/mm/page_alloc.c >>>> +++ b/mm/page_alloc.c >>>> @@ -1108,6 +1108,8 @@ static inline void __free_one_page(struct page= *page, >>>> >>>> buddy_pfn =3D __find_buddy_pfn(pfn, order); >>>> buddy =3D page + (buddy_pfn - pfn); >>>> + if (!page_is_buddy(page, buddy, order)) >>>> + goto done_merging; >>>> buddy_mt =3D get_pageblock_migratetype(buddy); >>>> >>>> if (migratetype !=3D buddy_mt >>>> >>> >>> The above did not apply to Linus's tree, nor even the problem commit >>> (before or after), but I found where the code is, and added it manual= ly. >>> >>> It does appear to allow the machine to boot. >>> >> I just pulled Linus=E2=80=99s tree and grabbed the diff. Anyway, thank= s. >> >> I would like to get more understanding of the issue before blindly sen= ding >> this as a fix. >> >> Merge the other thread: >>> >>> Not sure if this matters or not, but my kernel command line has: >>> >>> crashkernel=3D256M >>> >>> Could that have caused this to break? >> >> Unlikely, 256MB is MAX_ORDER_NR_PAGES aligned (MAX_ORDER is 11 here). >> __find_buddy_pfn() will not get any buddy_pfn from crashkernel memory >> region, since that would cross MAX_ORDER_NR_PAGES boundary. >> >> page_is_buddy() checks page_is_guard(buddy), PageBuddy(buddy), >> buddy_order(buddy), and page_zone_id(buddy), where page_is_guard(buddy= ) >> is always false since CONFIG_DEBUG_PAGEALLOC is not set in your config= . >> So either PageBuddy(buddy) is false, buddy_order(buddy) !=3D order, >> or page_zone_id(buddy) is not the same as page_zone_id(page). >> >> Do you mind adding the following code right before my fix code above >> and provide a complete boot log? I would like to understand what >> went wrong. Thanks. >> >> pr_info("buddy_pfn: %lx, PageBuddy: %d, buddy_order: %d (vs %d), page_= zone_id: %d (vs %d)\n", >> buddy_pfn, PageBuddy(buddy), buddy_order(buddy), order, page_z= one_id(buddy), >> page_zone_id(page)); >> >> >=20 > This seems to be a bug in the original code too. > But "if (unlikely(has_isolate_pageblock(zone)))" is too rare to trigger= it. > I do not see how having isolated pageblocks in a zone could get us away > from checking page_is_buddy(). IIRC the assumption was that pageblock bitmaps would always exist withing MAX_ORDER blocks. But here we are still under mem_init() where has_isolate_pageblock() couldn't happen. And the assumption could have been silently broken by subsequent memory init changes. > -- > Best Regards, > Yan, Zi