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.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham 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 E5CAAC07E9A for ; Wed, 14 Jul 2021 11:06:02 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4E51C613A9 for ; Wed, 14 Jul 2021 11:06:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4E51C613A9 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=techsingularity.net Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 619AA6B0081; Wed, 14 Jul 2021 07:06:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5C8C26B0085; Wed, 14 Jul 2021 07:06:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4B92D6B0088; Wed, 14 Jul 2021 07:06:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0028.hostedemail.com [216.40.44.28]) by kanga.kvack.org (Postfix) with ESMTP id 9D88F6B0081 for ; Wed, 14 Jul 2021 07:06:01 -0400 (EDT) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 8BDC3824C440 for ; Wed, 14 Jul 2021 11:06:00 +0000 (UTC) X-FDA: 78360913680.20.01B1392 Received: from outbound-smtp30.blacknight.com (outbound-smtp30.blacknight.com [81.17.249.61]) by imf17.hostedemail.com (Postfix) with ESMTP id 18A79F000399 for ; Wed, 14 Jul 2021 11:05:59 +0000 (UTC) Received: from mail.blacknight.com (pemlinmail02.blacknight.ie [81.17.254.11]) by outbound-smtp30.blacknight.com (Postfix) with ESMTPS id 8D17F1C005 for ; Wed, 14 Jul 2021 12:05:58 +0100 (IST) Received: (qmail 5147 invoked from network); 14 Jul 2021 11:05:58 -0000 Received: from unknown (HELO techsingularity.net) (mgorman@techsingularity.net@[84.203.17.255]) by 81.17.254.9 with ESMTPSA (AES256-SHA encrypted, authenticated); 14 Jul 2021 11:05:58 -0000 Date: Wed, 14 Jul 2021 12:05:56 +0100 From: Mel Gorman To: Dave Chinner Cc: linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH 1/3] mm: Add kvrealloc() Message-ID: <20210714110556.GK3809@techsingularity.net> References: <20210714023440.2608690-1-david@fromorbit.com> <20210714023440.2608690-2-david@fromorbit.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <20210714023440.2608690-2-david@fromorbit.com> User-Agent: Mutt/1.10.1 (2018-07-13) Authentication-Results: imf17.hostedemail.com; dkim=none; spf=pass (imf17.hostedemail.com: domain of mgorman@techsingularity.net designates 81.17.249.61 as permitted sender) smtp.mailfrom=mgorman@techsingularity.net; dmarc=none X-Stat-Signature: jff51ommmkytg5gyrpc7qiyajiunp4hk X-Rspamd-Queue-Id: 18A79F000399 X-Rspamd-Server: rspam01 X-HE-Tag: 1626260759-977800 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 Wed, Jul 14, 2021 at 12:34:38PM +1000, Dave Chinner wrote: > From: Dave Chinner > > During log recovery of an XFS filesystem with 64kB directory > buffers, rebuilding a buffer split across two log records results > in a memory allocation warning from krealloc like this: > > xfs filesystem being mounted at /mnt/scratch supports timestamps until 2038 (0x7fffffff) > XFS (dm-0): Unmounting Filesystem > XFS (dm-0): Mounting V5 Filesystem > XFS (dm-0): Starting recovery (logdev: internal) > ------------[ cut here ]------------ > WARNING: CPU: 5 PID: 3435170 at mm/page_alloc.c:3539 get_page_from_freelist+0xdee/0xe40 > ..... > RIP: 0010:get_page_from_freelist+0xdee/0xe40 > Call Trace: > ? complete+0x3f/0x50 > __alloc_pages+0x16f/0x300 > alloc_pages+0x87/0x110 > kmalloc_order+0x2c/0x90 > kmalloc_order_trace+0x1d/0x90 > __kmalloc_track_caller+0x215/0x270 > ? xlog_recover_add_to_cont_trans+0x63/0x1f0 > krealloc+0x54/0xb0 > xlog_recover_add_to_cont_trans+0x63/0x1f0 > xlog_recovery_process_trans+0xc1/0xd0 > xlog_recover_process_ophdr+0x86/0x130 > xlog_recover_process_data+0x9f/0x160 > xlog_recover_process+0xa2/0x120 > xlog_do_recovery_pass+0x40b/0x7d0 > ? __irq_work_queue_local+0x4f/0x60 > ? irq_work_queue+0x3a/0x50 > xlog_do_log_recovery+0x70/0x150 > xlog_do_recover+0x38/0x1d0 > xlog_recover+0xd8/0x170 > xfs_log_mount+0x181/0x300 > xfs_mountfs+0x4a1/0x9b0 > xfs_fs_fill_super+0x3c0/0x7b0 > get_tree_bdev+0x171/0x270 > ? suffix_kstrtoint.constprop.0+0xf0/0xf0 > xfs_fs_get_tree+0x15/0x20 > vfs_get_tree+0x24/0xc0 > path_mount+0x2f5/0xaf0 > __x64_sys_mount+0x108/0x140 > do_syscall_64+0x3a/0x70 > entry_SYSCALL_64_after_hwframe+0x44/0xae > > Essentially, we are taking a multi-order allocation from kmem_alloc() > (which has an open coded no fail, no warn loop) and then > reallocating it out to 64kB using krealloc(__GFP_NOFAIL) and that is > then triggering the above warning. > > This is a regression caused by converting this code from an open > coded no fail/no warn reallocation loop to using __GFP_NOFAIL. > > What we actually need here is kvrealloc(), so that if contiguous > page allocation fails we fall back to vmalloc() and we don't > get nasty warnings happening in XFS. > > Fixes: 771915c4f688 ("xfs: remove kmem_realloc()") > Signed-off-by: Dave Chinner Acked-by: Mel Gorman -- Mel Gorman SUSE Labs