Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp1264807rdb; Wed, 24 Jan 2024 09:32:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IEZCnfu7uTPSQXghyJDMjggZpu2kfyOcRJxi0ahYEL9TBtvvjXjhJPGmwBlAU1bbXZ2ZrVV X-Received: by 2002:a05:620a:20cf:b0:783:3c71:ebdf with SMTP id f15-20020a05620a20cf00b007833c71ebdfmr9306810qka.64.1706117536579; Wed, 24 Jan 2024 09:32:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706117536; cv=pass; d=google.com; s=arc-20160816; b=M9+eRYGHn5O6cS3MTpX+S7O0xQc6HdbBniZmzAcP78303c0wxkW6a9UhH5EJO151Nu j9B5zAqaWMDHqd5nxrXW9FyUDel/FMViS4/Evq6puFUaqapz4Cd12pUf1qNMLiJP+nXH BCu78YmF9PK0ZVZ1nOMnGjlTwZOB51MR0uK4/7VSzSbmwJLJ6UlvOB6TtCGME/QEMiY0 DmlCjVOUQUBeqcE2dxPGkEzi3cckhxZI6IphtI7X2A76emTrjcMhCcxaAoIjmMmZ+nKV BRxZJJZCgrMCy8T4CDqbrtUDuWX1K511DJ2dDqCdJQREtwWcK943xJphy4oNSKJ207Me gaHQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=qxKHPmrLHSpXaEhqdYvFl7e0WLs/NEDBg3zrdUtq0Qs=; fh=y3TyPIpy3sFBdx10zjcJM8gjiG0U+QuqDUXui0qtt7s=; b=CYeEWwEzOLna821RcyKQbTXXZAAmGGcq6WgGi1EaJiFfFcHgiRCPjH0W5Yljh31QCf BDN8XZM325GXZ1pvNjshLPIVPtE8jbdY8bOJLceuzhPCHmRFeEFd1mjPPQDJvUOxBj/e cYJi9kgoc3mIRatHtin//1r9iaWOFjCwp5wczmJD2csZxvgAWiZ3V/ehnIUqzZtbo+Ym reYOv81G1OyeVdgjYkRjpMC1YqbkUZMFdpst1CtNLwJujfpj0JYlHrUzPyjbF85AUg6t j4a0kIUipFEu8yUDpL+sU7nGsvciS8p6qlihF2wsCwroKm3a6uOqZOALuGJTGEfSDLLt ZZdQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=PfM9BPxR; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-37058-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-37058-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id v17-20020ae9e311000000b007836c6e0506si10737336qkf.14.2024.01.24.09.32.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 09:32:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-37058-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=PfM9BPxR; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-37058-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-37058-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 15E8B1C29081 for ; Wed, 24 Jan 2024 13:15:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2A1B777F07; Wed, 24 Jan 2024 13:15:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="PfM9BPxR" Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E156E63116 for ; Wed, 24 Jan 2024 13:15:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706102151; cv=none; b=ZhySmpYY1ytKh7vWkhFfyKqeIUS+s3rkt1TT2aTNFXmViWMA1hXOEOh+h3GLHsd5G5KWA+nA9oAxSjCzQjg/LJEJ+PJetr92N7WP518PDrayLq6982OhLeyOujXBefuc6aXgS4asd/nkWDu09cLa3NwjjYFhLAOSwFxpYAQ2Fsg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706102151; c=relaxed/simple; bh=GDgE5UmpTACnIM5ZWOIoeJNdQHYEyryeW2i+pwuhcOM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=HLkPcCXMwAeopcfq5H8OOD6YQPs5XsrU87FQStP+9vJzH5pQ4zOb75sWSPM++AsawacmSJycsPiQSZ/bcw4adhJNDOZHd+8OxXtuHZ0lYI2oDfzi3mB0E4i57GT19hqvtF8TnKT0rl1KrnmSclHGgWtVBr8vM1C5S77BKRgwFg8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=PfM9BPxR; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=qxKHPmrLHSpXaEhqdYvFl7e0WLs/NEDBg3zrdUtq0Qs=; b=PfM9BPxRRxlsXYG3xYyMev4PKV AtVrV/pFcYCvKgql1Of69rLr/2CzN3f4H9c1PHhdKWs8odnwYCpF62Sb7ReToQKA0b6q17FEz1ypR wdQlnaSVBcRnvpFsP52DEPV/NRmQnhobmhxHE4SsH+UoDiHs8jxa5tdZVKRPTY5uQouMan43JOQOn pMjTO4dTjZNEVkEmIkStlXx0R2jfIJMclkkWm4cxN1jgkhWd3Xw0eryiWS7IMn1+E5GFmQnu8zNBI QEtMBS3Y3RtMSJbaY7nrN0137/QHi9alXJGdYEtLIn5nX8+U4vfvscHXqDc9DiwBqOvJuqVDT99Jf A5uYQW7Q==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rSd6X-00000006iKy-3ewZ; Wed, 24 Jan 2024 13:15:46 +0000 Date: Wed, 24 Jan 2024 13:15:45 +0000 From: Matthew Wilcox To: Miaohe Lin Cc: naoya.horiguchi@nec.com, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] mm/memory-failure: fix crash in split_huge_page_to_list from soft_offline_page Message-ID: References: <20240124084014.1772906-1-linmiaohe@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240124084014.1772906-1-linmiaohe@huawei.com> On Wed, Jan 24, 2024 at 04:40:14PM +0800, Miaohe Lin wrote: > When I did soft offline stress test, a machine was observed to crash with > the following message: > > kernel BUG at include/linux/memcontrol.h:554! > invalid opcode: 0000 [#1] PREEMPT SMP NOPTI > CPU: 5 PID: 3837 Comm: hwpoison.sh Not tainted 6.7.0-next-20240112-00001-g8ecf3e7fb7c8-dirty #97 > Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.14.0-0-g155821a1990b-prebuilt.qemu.org 04/01/2014 > RIP: 0010:folio_memcg+0xaf/0xd0 > Code: 10 5b 5d c3 cc cc cc cc 48 c7 c6 08 b1 f2 b2 48 89 ef e8 b4 c5 f8 ff 90 0f 0b 48 c7 c6 d0 b0 f2 b2 48 89 ef e8 a2 c5 f8 ff 90 <0f> 0b 48 c7 c6 08 b1 f2 b2 48 89 ef e8 90 c5 f8 ff 90 0f 0b 66 66 > RSP: 0018:ffffb6c043657c98 EFLAGS: 00000296 > RAX: 000000000000004b RBX: ffff932bc1d1e401 RCX: ffff933abfb5c908 > RDX: 0000000000000000 RSI: 0000000000000027 RDI: ffff933abfb5c900 > RBP: ffffea6f04019080 R08: ffffffffb3338ce8 R09: 0000000000009ffb > R10: 00000000000004dd R11: ffffffffb3308d00 R12: ffffea6f04019080 > R13: ffffea6f04019080 R14: 0000000000000001 R15: ffffb6c043657da0 > FS: 00007f6c60f6b740(0000) GS:ffff933abfb40000(0000) knlGS:0000000000000000 > CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 > CR2: 0000559c3bc8b980 CR3: 0000000107f1c000 CR4: 00000000000006f0 > Call Trace: > > ? die+0x32/0x90 > ? do_trap+0xde/0x110 > ? folio_memcg+0xaf/0xd0 > ? do_error_trap+0x60/0x80 > ? folio_memcg+0xaf/0xd0 > ? exc_invalid_op+0x53/0x70 > ? folio_memcg+0xaf/0xd0 > ? asm_exc_invalid_op+0x1a/0x20 > ? folio_memcg+0xaf/0xd0 > ? folio_memcg+0xae/0xd0 I might trim these ? lines out of the backtrace ... > split_huge_page_to_list+0x4d/0x1380 > ? sysvec_apic_timer_interrupt+0xf/0x80 > try_to_split_thp_page+0x3a/0xf0 > soft_offline_page+0x1ea/0x8a0 > soft_offline_page_store+0x52/0x90 > kernfs_fop_write_iter+0x118/0x1b0 > vfs_write+0x30b/0x430 > ksys_write+0x5e/0xe0 > do_syscall_64+0xb0/0x1b0 > entry_SYSCALL_64_after_hwframe+0x6d/0x75 > RIP: 0033:0x7f6c60d14697 > Code: 10 00 f7 d8 64 89 02 48 c7 c0 ff ff ff ff eb b7 0f 1f 00 f3 0f 1e fa 64 8b 04 25 18 00 00 00 85 c0 75 10 b8 01 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 51 c3 48 83 ec 28 48 89 54 24 18 48 89 74 24 > RSP: 002b:00007ffe9b72b8d8 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 > RAX: ffffffffffffffda RBX: 000000000000000c RCX: 00007f6c60d14697 > RDX: 000000000000000c RSI: 0000559c3bc8b980 RDI: 0000000000000001 > RBP: 0000559c3bc8b980 R08: 00007f6c60dd1460 R09: 000000007fffffff > R10: 0000000000000000 R11: 0000000000000246 R12: 000000000000000c > R13: 00007f6c60e1a780 R14: 00007f6c60e16600 R15: 00007f6c60e15a00 > > The problem is that page->mapping is overloaded with slab->slab_list or > slabs fields now, so slab pages could be taken as non-LRU movable pages > if field slabs contains PAGE_MAPPING_MOVABLE or slab_list->prev is set > to LIST_POISON2. These slab pages will be treated as thp later leading > to crash in split_huge_page_to_list(). > > Signed-off-by: Miaohe Lin > Fixes: 130d4df57390 ("mm/sl[au]b: rearrange struct slab fields to allow larger rcu_head") Reviewed-by: Matthew Wilcox (Oracle)