From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) (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 34770198E99 for ; Thu, 7 Nov 2024 23:38:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=150.107.74.76 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731022724; cv=none; b=jnLPlZzMBvqXhXStOvQssqebt1QRygixmkvmkJahkRgS13soDox2avXroUPUC+lfoS7+S4ruMpm+A/TUpYo/X2W32ixzI/w1DoMOnQsGG1VhQPYeydEizlt3b1H1kSVSj3bTrddrBHa3yAcEf4dNGUwrwWvsKfauua7NAa8rOfo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731022724; c=relaxed/simple; bh=3V/CokK+h1n9R7Yo6jlevBapt790SuZpi3OUZYbbXek=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=tyDM9q4i6ZGKHp+SUfnWWajfqeF1Ua+eYiP+Kw+2OntMzJFPzXaokoBCZIcgG0qNT3AVX213yv6D8P8UYCYSXq/XmLakO2HIb6PN0w3uikzUwwp1nrWK00hZqp5fFYjv3sMDvk7SWBDosliyHj7CpL9reAPQ6tlnL6JQBcH9hII= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ellerman.id.au; spf=pass smtp.mailfrom=ellerman.id.au; dkim=pass (2048-bit key) header.d=ellerman.id.au header.i=@ellerman.id.au header.b=TUPLNbxo; arc=none smtp.client-ip=150.107.74.76 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ellerman.id.au Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ellerman.id.au Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ellerman.id.au header.i=@ellerman.id.au header.b="TUPLNbxo" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ellerman.id.au; s=201909; t=1731022716; bh=ZzWkR0GOngNSUwjx4cfHDpPa+S6pHkHSoGBdXkewqpY=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=TUPLNbxonwdujxVvjGiB9u3JX5yMx2bSI7r2PEI3wl/8STSxyFRJiaJSul3H3+OE6 D/ETUYjuL9vVMb8LqpIL0LoYs5VWEo4oQ2BHEoahj5KKLxrEjOWM1dOJvjXEh3grXR o5Gk7Dh1/LczHZ2usP5wjNpFYgahMsd+0vkBMkW2lYc1EupHChirwWYnYDv4vLH55v FWXirblpQpd8nS3UAqaZo10sKqHusY56PQ1LoiJJavzCNu8Eqb8EGMedkdCzP+hZ7U qkigV4cA5xgodFFf6+jSY5R4+5eCCKkYlpVdKuV4NqZb3yTlY4846cd44BLwIx3g+S BIs8M7u9+SJOg== Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mail.ozlabs.org (Postfix) with ESMTPSA id 4Xkz6N35JYz4wcy; Fri, 8 Nov 2024 10:38:36 +1100 (AEDT) From: Michael Ellerman To: Gautam Menghani Cc: npiggin@gmail.com, christophe.leroy@csgroup.eu, naveen@kernel.org, maddy@linux.ibm.com, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] arch/powerpc/pseries: Fix KVM guest detection for disabling hardlockup detector In-Reply-To: <2kkln3emctf7ewsh3eysujid2e7jel7yjtscfxmqeymeo5bjxf@7yzi5eye2n5j> References: <20241105132734.499506-1-gautam@linux.ibm.com> <87ed3ncl8q.fsf@mpe.ellerman.id.au> <2kkln3emctf7ewsh3eysujid2e7jel7yjtscfxmqeymeo5bjxf@7yzi5eye2n5j> Date: Fri, 08 Nov 2024 10:38:36 +1100 Message-ID: <87bjyqd37n.fsf@mpe.ellerman.id.au> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain Gautam Menghani writes: > On Thu, Nov 07, 2024 at 10:54:29PM +1100, Michael Ellerman wrote: >> Gautam Menghani writes: >> > As per the kernel documentation[1], hardlockup detector should be >> > disabled in KVM guests as it may give false positives. On PPC, hardlockup >> > detector is broken inside KVM guests because disable_hardlockup_detector() >> >> Isn't it the opposite? Inside KVM guests, the hardlockup detector should >> be *disabled*, but it's not it's *enabled*, due to this bug. >> >> ie. it's not broken, it's working, but that's the bug. > > Yes right, will change the description in v2. Thanks. >> > is marked as early_initcall and it uses is_kvm_guest(), which is >> > initialized by check_kvm_guest() later during boot as it is a >> > core_initcall. check_kvm_guest() is also called in pSeries_smp_probe(), >> > which is called before initcalls, but it is skipped if KVM guest does >> > not have doorbell support or if the guest is launched with SMT=1. >> >> I'm wondering how no one has noticed. Most KVM guests have SMT=1. > > Looking at the commit history, code around hardlockups and > pSeries_smp_probe() was changed around 2021/2022 timeframe, and I > believe KVM wasn't being actively tested at the time. > Even I noticed this only after coming across the documentation that said > hardlockups should be disabled. So probably this feature decision isn't > widely known. I do test KVM but probably not under enough load to notice something like that. >> > Move the check_kvm_guest() call in pSeries_smp_probe() to the initial >> > part of function before doorbell/SMT checks so that "kvm_guest" static >> > key is initialized by the time disable_hardlockup_detector() runs. >> >> check_kvm_guest() is safe to be called multiple times so >> disable_hardlockup_detector() should just call it before it calls >> is_kvm_guest(). That should avoid future breakage when the order of >> calls changes, or someone refactors pSeries_smp_probe(). > > Yeah I did that initially but in the worst case, that results in 3 calls > to check_kvm_guest() - the core_initcall, pseries_smp_probe() call and > then disable_hardlockup_detector(). Will that be fine? Yeah it's fine. It's not pretty, maybe we can come up with something cleaner in future, but it's fine for a bug fix. cheers