Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp2952790rwb; Mon, 16 Jan 2023 01:29:58 -0800 (PST) X-Google-Smtp-Source: AMrXdXvyHDk04fqZkGfmUmXepfaBTMM+3hry/O3dcDIL0sjk0E+lJGmISH0VLpBgpVNP9G/FAXx4 X-Received: by 2002:a17:90a:ea85:b0:227:ca8:4ec8 with SMTP id h5-20020a17090aea8500b002270ca84ec8mr30931406pjz.17.1673861397958; Mon, 16 Jan 2023 01:29:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673861397; cv=none; d=google.com; s=arc-20160816; b=KUU9HLyNEv5vmyJCgWLldF05sNBYOwqXmbIxIAEFwzs2KcAQNnh5n4Nk/VPmBNj4no ySiPYr3MWLuMQY8jcArkDnLjQHizrOVv2K1A1xt1W2yd8cR/r4jqW1uEuyH4ElCaHb3m ueNOcteCej95eV9ixewK2k6536nL8zibhS+gTdeM2dstrx7z1oZm3mDkFICCVr2O1YiT JsUDcCaiiyu1I1nPuRTv99WuHsmV/8LybzLW4WpjqYg6aHN4j95vFi2uSKYU46xEqtNm +o8ulP/rnPkB3t2CN19LBC17wwV8PUgH+H87/J+IPyo5G09S6/0zC/Fd2XTGmagEhU/p wPJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=EhNtDGcG//mdtydJKucfV/j4UIPaaTtUrl93zQqW3/Q=; b=QxgRlSLDJi+AlSDFb+DvFDyAqhM+AAA/GSLs3M51BV0GvLRRUGF0sqomGOjVMTZWo3 OHPOk+3p4OrKkgw0MZfDd963jPRQ53DQJTka5t9yGOvo+BMbDzHpI94q6yETeINf8PJ/ 8SMNwxMbkigH9qlucX3J/golh7FJ+TaEh0aRd4Y/J0Fr8jOTsiI82UoG/btIRN8awyJK 62zYOr6SFKhNWyU+4mQrFGJ1jXA6LH9YoG5VTASXSBuxMSrBCY9mFyu+W/+jFXSvRT5E ahuxGJcED8iMokFfBoP5saPJZeexamZfyTcc/5QylaAfT22X1BvC9C1ccNWZ4KiJJ8+I KYqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=BVhqiQkL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v8-20020a63bf08000000b00477bf7b0c43si18808831pgf.458.2023.01.16.01.29.51; Mon, 16 Jan 2023 01:29:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=BVhqiQkL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232447AbjAPJL2 (ORCPT + 51 others); Mon, 16 Jan 2023 04:11:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232193AbjAPJKs (ORCPT ); Mon, 16 Jan 2023 04:10:48 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 872C115543 for ; Mon, 16 Jan 2023 01:08:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673860093; 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: in-reply-to:in-reply-to:references:references; bh=EhNtDGcG//mdtydJKucfV/j4UIPaaTtUrl93zQqW3/Q=; b=BVhqiQkLEFHlhrCVnkTWKdA97zP8RcOtd9GxzJIgQ1I2Iz9c2VVHrQj/tbUqXqVeSedRON xoXkd/aueNRIJP6ZarkSvfxNoy7iKdO6VJkyuh5v2te6bAvZck8CCkY/G41RW1LdBICOo/ eEiDUE6RSk9gZraVs18bIMC6A0d2eIs= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-459-L03yREz4NIyoNfyqJcejvg-1; Mon, 16 Jan 2023 04:08:10 -0500 X-MC-Unique: L03yREz4NIyoNfyqJcejvg-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A3229183B3C0; Mon, 16 Jan 2023 09:08:09 +0000 (UTC) Received: from localhost (ovpn-12-229.pek2.redhat.com [10.72.12.229]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C9DED492B10; Mon, 16 Jan 2023 09:08:08 +0000 (UTC) Date: Mon, 16 Jan 2023 17:08:05 +0800 From: Baoquan He To: Thomas Gleixner Cc: linux-kernel@vger.kernel.org, x86@kernel.org, kexec@lists.infradead.org Subject: Re: kdump kernel randomly hang with tick_periodic call trace on bare metal system Message-ID: References: <87mt6rjrra.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87mt6rjrra.ffs@tglx> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Thomas, On 01/09/23 at 10:57pm, Thomas Gleixner wrote: > On Tue, Dec 20 2022 at 13:41, Baoquan He wrote: > > On one intel bare metal system, I can randomly reproduce the kdump hang > > as below with tick_periodic call trace. Attach the kernel config for > > reference. > > This has absolutely nothing to do with x2apic IPI shorthands > > > [ 0.045980] Spurious LAPIC timer interrupt on cpu 0 > > So here the CPU receives a spurious Local APIC timer interrupt, but > that's a red herring. > > > [ 1.152690] BUG: kernel NULL pointer dereference, address: 0000000000000088 > > [ 1.159634] #PF: supervisor read access in kernel mode > > [ 1.164757] #PF: error_code(0x0000) - not-present page > > [ 1.169882] PGD 0 P4D 0 > > [ 1.172407] Oops: 0000 [#1] PREEMPT SMP PTI > > [ 1.176578] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 6.0.11-300.fc37.x86_64 #1 > > [ 1.183870] Hardware name: Dell Inc. PowerEdge R410/0N051F, BIOS 1.11.0 07/20/2012 > > [ 1.191420] RIP: 0010:tick_periodic+0x23/0x80 > > I'm willing to bet that this is caused by the following line in tick_periodic(): > > update_process_times(user_mode(get_irq_regs())); > > user_mode() is invoked with a NULL pointer. user_mode() accesses > regs->cs. CS is at offset 0x88.... > > The reason for this is here: > > > [ 1.280648] tick_handle_periodic+0x1f/0x70 > > [ 1.284821] timer_interrupt+0x14/0x20 > > [ 1.288561] __handle_irq_event_percpu+0x46/0x190 > > [ 1.293253] handle_irq_event+0x34/0x70 > > [ 1.297080] handle_level_irq+0xa8/0x180 > > [ 1.300993] resend_irqs+0x5d/0x70 > > [ 1.304386] tasklet_action_common.constprop.0+0xab/0xe0 > > [ 1.309686] __do_softirq+0xfb/0x319 > > [ 1.313254] __irq_exit_rcu+0xd7/0x140 > > [ 1.316993] common_interrupt+0xb9/0xd0 > > For some reason the timer interrupt is resent in software. I assume it is > the HPET interrupt because that's what just got initialized. > > > [ 1.143537] clocksource: hpet: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 133484882848 ns > > and the callchain below just confirms that: > > > [ 1.393315] _raw_spin_unlock_irqrestore+0x19/0x40 > > [ 1.398093] __setup_irq+0x443/0x6d0 > > [ 1.401659] request_threaded_irq+0x109/0x170 > > [ 1.406005] hpet_time_init+0x2d/0x4b > > [ 1.409661] x86_late_time_init+0x17/0x34 > > [ 1.413658] start_kernel+0x8cf/0x97f > > The software resend code does not go through the regular interrupt entry > path which explains why get_irq_regs() returns NULL. > > That software resend is bogus especially since the timer interrupt is > a level interrupt. As dmesg does not say anything about the APIC > delivery mode I assume this goes through i8259, which fails to set the > IRQ_LEVEL flag on all interrupt lines. > > The below should fix this. I got the machine where this random hang often happen, and built the latest upstream kernel to test. W/o this fix, kdump kernel will hang when calling tick_periodic 6 of 10 times. With this patch applied, I tried about 30 times, kdump kernel all booted up and vmcore dumping succeeded. So this patch fix the issue I met, thanks a lot. And please feel free to add: Tested-by: Baoquan He > > --- > --- a/arch/x86/kernel/i8259.c > +++ b/arch/x86/kernel/i8259.c > @@ -114,6 +114,7 @@ static void make_8259A_irq(unsigned int > disable_irq_nosync(irq); > io_apic_irqs &= ~(1< irq_set_chip_and_handler(irq, &i8259A_chip, handle_level_irq); > + irq_set_status_flags(irq, IRQ_LEVEL); > enable_irq(irq); > lapic_assign_legacy_vector(irq, true); > } > --- a/arch/x86/kernel/irqinit.c > +++ b/arch/x86/kernel/irqinit.c > @@ -65,8 +65,10 @@ void __init init_ISA_irqs(void) > > legacy_pic->init(0); > > - for (i = 0; i < nr_legacy_irqs(); i++) > + for (i = 0; i < nr_legacy_irqs(); i++) { > irq_set_chip_and_handler(i, chip, handle_level_irq); > + irq_set_status_flags(i, IRQ_LEVEL); > + } > } > > void __init init_IRQ(void) >