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 2E0EBC433EF for ; Thu, 28 Apr 2022 16:04:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B35596B00B5; Thu, 28 Apr 2022 12:04:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AE5726B00B8; Thu, 28 Apr 2022 12:04:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 986AB6B00B9; Thu, 28 Apr 2022 12:04:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.a.hostedemail.com [64.99.140.24]) by kanga.kvack.org (Postfix) with ESMTP id 875A46B00B5 for ; Thu, 28 Apr 2022 12:04:31 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 511922946 for ; Thu, 28 Apr 2022 16:04:31 +0000 (UTC) X-FDA: 79406760342.03.C8662B1 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf30.hostedemail.com (Postfix) with ESMTP id 851928006B for ; Thu, 28 Apr 2022 16:04:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1651161870; h=from:from:reply-to:subject:subject: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=psHJ6QTd71qnYr+S/mdp8KcY5BXeTVIfMOntCP/T2rE=; b=JD4EwpeBQTGhHdv5jCkN0J8rDCcID4H/uGV+gzLfm8ZLkBXihoUN6i9pCI5Th5w/31wo/j BFbzMayFIVrDajVGiYt/x8jGc6o8etD7oEPKMe+n+UHt7KBI2o4B25mbk40h2ixg/j+ZgS erOpBUPNcUQgVwjzEcytRH3qmT/mxPY= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-220-eVKRJvMTNoi0t_VzGkWKtw-1; Thu, 28 Apr 2022 12:04:29 -0400 X-MC-Unique: eVKRJvMTNoi0t_VzGkWKtw-1 Received: by mail-wm1-f70.google.com with SMTP id h65-20020a1c2144000000b0038e9ce3b29cso4562746wmh.2 for ; Thu, 28 Apr 2022 09:04:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:organization:in-reply-to :content-transfer-encoding; bh=psHJ6QTd71qnYr+S/mdp8KcY5BXeTVIfMOntCP/T2rE=; b=kBsZ/hDL+d7NlnTkVYHRhgnVORndRAZxM2CfzXTbeDmG70TUh/QwFO0rK5JRgkJ/VE AiESVx4pQ9+TvhB0HtiBfktuQ01RiXg7WvzH24ae2dAGh7A9Tl8W3pA01uiHIhnNXO00 fSQWmxUa5sOQqP7SXUidp9zb8k9bcrv01K5hUZZu0NoPwXN1nEnyLtjRPsB82+3tbmRH YuKdk6bcCBYPp1aCbHo+SNtR8DWerJ14i1ow7xqZqgOusqwRaFQu9SOMnrZEavUulmRC BlG+D+o9QwDLfiKtOH/fiw7HqrBIswPUBhrHHIA2kW+4P9haiXYvT7mHxuq5Z42o5QqJ zrLQ== X-Gm-Message-State: AOAM530k9BKS+se+htbkLSDVKzmVZsfSkkuG6Fgvf5X66XwzOmq/rfe0 MxpFK8Bb5SFYq1jQlwL1ZL5672Kc19bBupJ49dULCw2LBiyZv6RO/Q37VgtJEwaw2ePJwprjAbH cMXDbdwLK5nY= X-Received: by 2002:a5d:64c8:0:b0:20a:f513:8533 with SMTP id f8-20020a5d64c8000000b0020af5138533mr4162781wri.406.1651161867136; Thu, 28 Apr 2022 09:04:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwOuHAvrHelKyUo6iYYelHRf514ZaBIJVa1f1Klrzcx12LXQDcLatfDSxfSEf3R6EkJfZcskQ== X-Received: by 2002:a5d:64c8:0:b0:20a:f513:8533 with SMTP id f8-20020a5d64c8000000b0020af5138533mr4162768wri.406.1651161866849; Thu, 28 Apr 2022 09:04:26 -0700 (PDT) Received: from ?IPV6:2003:cb:c708:ef00:7443:a23c:26b8:b96? (p200300cbc708ef007443a23c26b80b96.dip0.t-ipconnect.de. [2003:cb:c708:ef00:7443:a23c:26b8:b96]) by smtp.gmail.com with ESMTPSA id r17-20020a0560001b9100b00207afaa8987sm252686wru.27.2022.04.28.09.04.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 28 Apr 2022 09:04:25 -0700 (PDT) Message-ID: <3af1e2b9-1221-5325-cc30-052b6294b5ce@redhat.com> Date: Thu, 28 Apr 2022 18:04:24 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.2 Subject: Re: [PATCH 2/2 RESEND] mm/huge_memory: do not overkill when splitting huge_zero_page To: Xu Yu , linux-mm@kvack.org Cc: akpm@linux-foundation.org, naoya.horiguchi@nec.com, shy828301@gmail.com References: From: David Hildenbrand Organization: Red Hat In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Stat-Signature: 6fpnij9htj83oidmummwm5b77szw7uhr Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=JD4EwpeB; spf=none (imf30.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 851928006B X-HE-Tag: 1651161862-263265 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 27.04.22 11:44, Xu Yu wrote: > Kernel panic when injecting memory_failure for the global > huge_zero_page, when CONFIG_DEBUG_VM is enabled, as follows. > > Injecting memory failure for pfn 0x109ff9 at process virtual address 0x20ff9000 > page:00000000fb053fc3 refcount:2 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x109e00 > head:00000000fb053fc3 order:9 compound_mapcount:0 compound_pincount:0 > flags: 0x17fffc000010001(locked|head|node=0|zone=2|lastcpupid=0x1ffff) > raw: 017fffc000010001 0000000000000000 dead000000000122 0000000000000000 > raw: 0000000000000000 0000000000000000 00000002ffffffff 0000000000000000 > page dumped because: VM_BUG_ON_PAGE(is_huge_zero_page(head)) > ------------[ cut here ]------------ > kernel BUG at mm/huge_memory.c:2499! > invalid opcode: 0000 [#1] PREEMPT SMP PTI > CPU: 6 PID: 553 Comm: split_bug Not tainted 5.18.0-rc1+ #11 > Hardware name: Alibaba Cloud Alibaba Cloud ECS, BIOS 3288b3c 04/01/2014 > RIP: 0010:split_huge_page_to_list+0x66a/0x880 > 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 > RSP: 0018:ffffc90000dcbdf8 EFLAGS: 00010246 > RAX: 000000000000003c RBX: 0000000000000001 RCX: 0000000000000000 > RDX: 0000000000000000 RSI: ffffffff823e4c4f RDI: 00000000ffffffff > RBP: ffff88843fffdb40 R08: 0000000000000000 R09: 00000000fffeffff > R10: ffffc90000dcbc48 R11: ffffffff82d68448 R12: ffffea0004278000 > R13: ffffffff823c6203 R14: 0000000000109ff9 R15: ffffea000427fe40 > FS: 00007fc375a26740(0000) GS:ffff88842fd80000(0000) knlGS:0000000000000000 > CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 > CR2: 00007fc3757c9290 CR3: 0000000102174006 CR4: 00000000003706e0 > DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 > DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 > Call Trace: > try_to_split_thp_page+0x3a/0x130 > memory_failure+0x128/0x800 > madvise_inject_error.cold+0x8b/0xa1 > __x64_sys_madvise+0x54/0x60 > do_syscall_64+0x35/0x80 > entry_SYSCALL_64_after_hwframe+0x44/0xae > RIP: 0033:0x7fc3754f8bf9 > 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 > RSP: 002b:00007ffeda93a1d8 EFLAGS: 00000217 ORIG_RAX: 000000000000001c > RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007fc3754f8bf9 > RDX: 0000000000000064 RSI: 0000000000003000 RDI: 0000000020ff9000 > RBP: 00007ffeda93a200 R08: 0000000000000000 R09: 0000000000000000 > R10: 00000000ffffffff R11: 0000000000000217 R12: 0000000000400490 > R13: 00007ffeda93a2e0 R14: 0000000000000000 R15: 0000000000000000 > > We think that raising BUG is overkilling for splitting huge_zero_page, > the huge_zero_page can't be met from normal paths other than memory > failure, but memory failure is a valid caller. So we tend to replace the > BUG to WARN + returning -EBUSY, and thus the panic above won't happen > again. > > Suggested-by: Yang Shi > Cc: Naoya Horiguchi > Reported-by: kernel test robot > Signed-off-by: Xu Yu > --- > mm/huge_memory.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/mm/huge_memory.c b/mm/huge_memory.c > index c468fee595ff..910a138e9859 100644 > --- a/mm/huge_memory.c > +++ b/mm/huge_memory.c > @@ -2495,11 +2495,16 @@ int split_huge_page_to_list(struct page *page, struct list_head *list) > struct address_space *mapping = NULL; > int extra_pins, ret; > pgoff_t end; > + bool is_hzp; > > - VM_BUG_ON_PAGE(is_huge_zero_page(head), head); > VM_BUG_ON_PAGE(!PageLocked(head), head); > VM_BUG_ON_PAGE(!PageCompound(head), head); > > + is_hzp = is_huge_zero_page(head); > + VM_WARN_ON_ONCE_PAGE(is_hzp, head); If this code is valid to be reached, VM_WARN_ON_ONCE_PAGE is most probably the wrong choice. IIUC, after patch #1 (revert) we can reach this again? -- Thanks, David / dhildenb