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 F3A96C433F5 for ; Fri, 22 Apr 2022 16:04:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 698866B00A5; Fri, 22 Apr 2022 12:04:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 648FD6B00A6; Fri, 22 Apr 2022 12:04:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4E8D96B00A7; Fri, 22 Apr 2022 12:04:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.25]) by kanga.kvack.org (Postfix) with ESMTP id 39B776B00A5 for ; Fri, 22 Apr 2022 12:04:13 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id 1FD2460A20 for ; Fri, 22 Apr 2022 16:04:13 +0000 (UTC) X-FDA: 79384986786.26.8ADA36B Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) by imf26.hostedemail.com (Postfix) with ESMTP id 2B75C140029 for ; Fri, 22 Apr 2022 16:04:11 +0000 (UTC) Received: by mail-pf1-f170.google.com with SMTP id j6so6091380pfe.13 for ; Fri, 22 Apr 2022 09:04:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Kvn/nTMVcR/w6pH5k6uHLmUcoUqVA5+mf/+swphg6es=; b=HnbUIKmkkUCJJf+bUjs9fC1aTlqWlUuUD6ImBJ0Gp5vBJ9iKUFIFHNUnsqe3u6KfoT qHUqpca1fG/MYqZTwEFdbCX3U/hXLmEcNkeduTFpvnosut07hJ4CToLabLQ6WNTicQr/ 3evLjl9pMjlCrOVSpssLBR8oy6DBR92Rqo4X5XOUg7zFPM3aegdnNQAWmTH9h7dw6Czr prIEILKge11tljm2HU8ujr/2/P1CWt0NgXkTQBNqZOxc5fnLubToUvMoXJYblPu6qLC+ R3jq6511gRFjM4fsMrpb3YV2Q81g7OsvJeCRQpdkPTIewNHyKbpqCAqDxYC1mpBmtgzd Uafw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Kvn/nTMVcR/w6pH5k6uHLmUcoUqVA5+mf/+swphg6es=; b=Z4eYmRvKx2dBZrJpQd3MPVlrXz87rWduB+VI3ajE7ub5dOWWGAgQyJq6ZCOFi/IG54 /ShWgR1a5U2VCGUQ4Ljb5T4OhlAszdj1FhkMVouHzWnZ5NTsMzRFNdSD0wuxLWRc3sPQ WOkidlZonRp+aKMpp7Putd2rU7OLbuxrYZJ0NOLjFEUyRDLb8MT8A/LGGpg13ZWUGYeq L1WzWqnc7Kd9whENwyfXobIfivF1ixwi0dCeQhPwtoADC9mzwduxxiS4kKRloWi+mnXx vG81F+t0kol/HRW+jo/ZBNmWfnPkd5VHXHxNsRC7InOs2jEIsxotK8Ay4GdMAuQDzjP/ s5rA== X-Gm-Message-State: AOAM533ClIEm3rHnqJFZuH2e1qzV4UE0uHj0+MmoHX7jJeZrw6jfaFds DLoihK4Ob+G6OGybR+BKhkK692VIYgpJLZpPPkw= X-Google-Smtp-Source: ABdhPJzQNZSev1NY52zXpmDPF0NW/7qPeYQgTQHv9Ru5rSdQ8wZr7GxLMc1FQCqkVHRSfIc6EkjEsa9Zr40WMWgbfFU= X-Received: by 2002:a65:6951:0:b0:381:f10:ccaa with SMTP id w17-20020a656951000000b003810f10ccaamr4372520pgq.587.1650643451509; Fri, 22 Apr 2022 09:04:11 -0700 (PDT) MIME-Version: 1.0 References: <497d3835612610e370c74e697ea3c721d1d55b9c.1649775850.git.xuyu@linux.alibaba.com> <47144bd6-4de0-26e3-a993-6075714e7f33@redhat.com> <548416ab-1700-4e0e-5e96-e1f1432cd58b@linux.alibaba.com> In-Reply-To: <548416ab-1700-4e0e-5e96-e1f1432cd58b@linux.alibaba.com> From: Yang Shi Date: Fri, 22 Apr 2022 09:03:58 -0700 Message-ID: Subject: Re: [PATCH v2] mm/memory-failure.c: skip huge_zero_page in memory_failure() To: Yu Xu Cc: David Hildenbrand , Linux MM , =?UTF-8?B?SE9SSUdVQ0hJIE5BT1lBKOWggOWPoyDnm7TkuZ8p?= , Andrew Morton , Miaohe Lin , Oscar Salvador Content-Type: text/plain; charset="UTF-8" X-Stat-Signature: g5edr8iu4jgbbooya5bezcjmd4r78ap8 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 2B75C140029 Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=HnbUIKmk; spf=pass (imf26.hostedemail.com: domain of shy828301@gmail.com designates 209.85.210.170 as permitted sender) smtp.mailfrom=shy828301@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspam-User: X-HE-Tag: 1650643451-926956 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 Thu, Apr 21, 2022 at 8:27 PM Yu Xu wrote: > > On 4/22/22 1:53 AM, Yang Shi wrote: > > On Thu, Apr 21, 2022 at 2:03 AM David Hildenbrand wrote: > >> > >> On 21.04.22 01:38, Yang Shi wrote: > >>> On Tue, Apr 12, 2022 at 8:11 AM Xu Yu wrote: > >>>> > >>>> Kernel panic when injecting memory_failure for the global huge_zero_page, > >>>> when CONFIG_DEBUG_VM is enabled, as follows. > >>>> > >>>> [ 5.582720] Injecting memory failure for pfn 0x109ff9 at process virtual address 0x20ff9000 > >>>> [ 5.583786] page:00000000fb053fc3 refcount:2 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x109e00 > >>>> [ 5.584900] head:00000000fb053fc3 order:9 compound_mapcount:0 compound_pincount:0 > >>>> [ 5.585796] flags: 0x17fffc000010001(locked|head|node=0|zone=2|lastcpupid=0x1ffff) > >>>> [ 5.586712] raw: 017fffc000010001 0000000000000000 dead000000000122 0000000000000000 > >>>> [ 5.587640] raw: 0000000000000000 0000000000000000 00000002ffffffff 0000000000000000 > >>>> [ 5.588565] page dumped because: VM_BUG_ON_PAGE(is_huge_zero_page(head)) > >>>> [ 5.589398] ------------[ cut here ]------------ > >>>> [ 5.589952] kernel BUG at mm/huge_memory.c:2499! > >>>> [ 5.590516] invalid opcode: 0000 [#1] PREEMPT SMP PTI > >>>> [ 5.591120] CPU: 6 PID: 553 Comm: split_bug Not tainted 5.18.0-rc1+ #11 > >>>> [ 5.591904] Hardware name: Alibaba Cloud Alibaba Cloud ECS, BIOS 3288b3c 04/01/2014 > >>>> [ 5.592817] RIP: 0010:split_huge_page_to_list+0x66a/0x880 > >>>> [ 5.593469] Code: 84 9b fb ff ff 48 8b 7c 24 08 31 f6 e8 9f 5d 2a 00 b8 b8 02 00 00 e9 e8 fb ff ff 48 c7 c6 e8 47 3c 82 4c b > >>>> [ 5.595806] RSP: 0018:ffffc90000dcbdf8 EFLAGS: 00010246 > >>>> [ 5.596434] RAX: 000000000000003c RBX: 0000000000000001 RCX: 0000000000000000 > >>>> [ 5.597322] RDX: 0000000000000000 RSI: ffffffff823e4c4f RDI: 00000000ffffffff > >>>> [ 5.598162] RBP: ffff88843fffdb40 R08: 0000000000000000 R09: 00000000fffeffff > >>>> [ 5.598999] R10: ffffc90000dcbc48 R11: ffffffff82d68448 R12: ffffea0004278000 > >>>> [ 5.599849] R13: ffffffff823c6203 R14: 0000000000109ff9 R15: ffffea000427fe40 > >>>> [ 5.600693] FS: 00007fc375a26740(0000) GS:ffff88842fd80000(0000) knlGS:0000000000000000 > >>>> [ 5.601640] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 > >>>> [ 5.602304] CR2: 00007fc3757c9290 CR3: 0000000102174006 CR4: 00000000003706e0 > >>>> [ 5.603139] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 > >>>> [ 5.603977] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 > >>>> [ 5.604806] Call Trace: > >>>> [ 5.605101] > >>>> [ 5.605357] ? __irq_work_queue_local+0x39/0x70 > >>>> [ 5.605904] try_to_split_thp_page+0x3a/0x130 > >>>> [ 5.606430] memory_failure+0x128/0x800 > >>>> [ 5.606888] madvise_inject_error.cold+0x8b/0xa1 > >>>> [ 5.607444] __x64_sys_madvise+0x54/0x60 > >>>> [ 5.607915] do_syscall_64+0x35/0x80 > >>>> [ 5.608347] entry_SYSCALL_64_after_hwframe+0x44/0xae > >>>> [ 5.608949] RIP: 0033:0x7fc3754f8bf9 > >>>> [ 5.609374] Code: 01 00 48 81 c4 80 00 00 00 e9 f1 fe ff ff 0f 1f 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 8 > >>>> [ 5.611554] RSP: 002b:00007ffeda93a1d8 EFLAGS: 00000217 ORIG_RAX: 000000000000001c > >>>> [ 5.612441] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007fc3754f8bf9 > >>>> [ 5.613269] RDX: 0000000000000064 RSI: 0000000000003000 RDI: 0000000020ff9000 > >>>> [ 5.614108] RBP: 00007ffeda93a200 R08: 0000000000000000 R09: 0000000000000000 > >>>> [ 5.614946] R10: 00000000ffffffff R11: 0000000000000217 R12: 0000000000400490 > >>>> [ 5.615787] R13: 00007ffeda93a2e0 R14: 0000000000000000 R15: 0000000000000000 > >>>> [ 5.616626] > >>>> > >>>> This makes huge_zero_page bail out explicitly before split in > >>>> memory_failure(), thus the panic above won't happen again. > >>> > >>> Skipping huge_zero_page in error injection is ok to me, but I'm > >>> actually wondering whether raising BUG is overkilling for splitting > >>> huge_zero_page or not. Returning -EBUSY should be totally fine. > >> > >> I tend to agree. Just failing with -EBUSY might be cleaner. Most > >> probably we want to catch any bogus code here that does something we > >> don't really expect -- splitting the huge zeropage makes 0 sense. > > > > Yeah, the huge zero page can't be met from normal paths other than > > memory failure, but memory failure is a valid caller. So I tend to > > replace the BUG to WARN + returning -EBUSY. If we don't care about the > > reason code in memory failure, we don't have to touch memory failure. > > To make sure I understand this correctly, do you mean the following? Yes. And you should be able to drop your old patch as well. > > diff --git a/mm/huge_memory.c b/mm/huge_memory.c > index c468fee595ff..3bb464509518 100644 > --- a/mm/huge_memory.c > +++ b/mm/huge_memory.c > @@ -2496,10 +2496,12 @@ int split_huge_page_to_list(struct page *page, struct > list_head *list) > int extra_pins, ret; > pgoff_t end; > > - VM_BUG_ON_PAGE(is_huge_zero_page(head), head); > VM_BUG_ON_PAGE(!PageLocked(head), head); > VM_BUG_ON_PAGE(!PageCompound(head), head); > > + if (VM_WARN_ON_ONCE_PAGE(is_huge_zero_page(head), head)) > + return -EBUSY; > + > if (PageWriteback(head)) > return -EBUSY; > > > > > >> > >> -- > >> Thanks, > >> > >> David / dhildenb > >> > >> > > -- > Thanks, > Yu