Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp375774lqp; Thu, 21 Mar 2024 04:15:38 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWVwcUHmfUq+qJ3aynsl3R+g29RGLn/DALI19b3Sp09Q9N2s78PsflS8QK5+Ds01jZaQ/QzzOpm5VIfUFSTYe6SUNRkV2tiqFzk6YMrOw== X-Google-Smtp-Source: AGHT+IEAEm2sQKkxCmzznG/3X5IG71KmIuDPt/ADwUjN+zqlxrH/07GmnV+hHwiXQeUINNXcIQ3u X-Received: by 2002:a05:620a:40c1:b0:788:2f70:a1a1 with SMTP id g1-20020a05620a40c100b007882f70a1a1mr11141675qko.15.1711019738455; Thu, 21 Mar 2024 04:15:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711019738; cv=pass; d=google.com; s=arc-20160816; b=zud9079deNrFhuzyyLLJjBMeQ6cQWTzdGx2kz9pFHyZDteekT9SvJcgzP2VhWLIIHQ aX0ZglmdHJA3MD1DmYbE3m3silOzGAZKpMFdgOS67qexd1XLFpPmoboqlZVryJmqlK90 rhmsNsjggxv5TtSYw6iosyw1nD4d3XJ0IaiqNHmoReR+mh36tcqciA/b7qqCuQ/Ofslr /UDjGBCYWgSfyc+5Cpear2e6JZRtuGmlL0pqxNaqDWXfEn1G0HNX7QIip7gGUnRgUcOb VB1Bs8Lp9YzAE9L1S67E81OBehkqSJ8GHhsOAbntPNm2URCq64ojpafsEDs9JSztFJGn plFA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:date:references:in-reply-to:subject:cc:to:dkim-signature :dkim-signature:from; bh=c8obbwSnzuUFaxqMybHilSrOftM5wBOHep+jfUErEiQ=; fh=h+fvY0h+H1rtgGZyhuiIQy0ztNSBu8o14pkpE8/bWlw=; b=rUc1o5kvc31qoNtVPn+x0eBp0ELsseVNvSJG7TAPCFwgy1T1weT0Fz/BzB0p7JhEZS ILyYyJt03kzoZKhu/sXw1JOq/pj8Gy+TbQNWd4d23v0wg2+8S4VCiq6zAWwWHEe63z7T I2XN2D16P38sil6IWSOByRCZzFzEhcINCYua5d28UELJ0hpWgCWCp7pCwiCjeqoNN/OL vzAzPzrcLdJX+cKTmnYdHs5mpvl9iuquGCeSmb+P1TwiNDXLEajj1n5t5cnn7ycTZVch HJhuZMZdiDCV4otHJ/2x/U8Vmgh2Ql4G/02dIOv6BrxVwwoXE40oTzPnam3VVs/jS4Sr lVVA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=yyoPSu+z; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-109933-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109933-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id n16-20020a05620a295000b0078a31b69c58si735223qkp.251.2024.03.21.04.15.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 04:15:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-109933-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=@linutronix.de header.s=2020 header.b=yyoPSu+z; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-109933-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109933-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de 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 307141C2167A for ; Thu, 21 Mar 2024 11:15:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EBF6E58226; Thu, 21 Mar 2024 11:14:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="yyoPSu+z"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="RFAXhyJ3" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 6A3B15812F; Thu, 21 Mar 2024 11:14:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711019674; cv=none; b=W0HlBmRbiZRRRNcP+uKFjNcMlTNPGFowYHeEMcnFwmDUqKtDLTZ/wJm+aiMHSUPeFB9aekfBNh/4CtPS/1cXzmxSqvRPr6Nen8G511uzqP48fsqZuUwujalTy88ZW4G32YvwqWFg4N1dTCbCDW/6kOJcotFDDe2IWuWMZeXzDOc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711019674; c=relaxed/simple; bh=2QjovQg5WKK+1OaQxPTlBgZTKhFNsOA5kuD5wd/TvHY=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=kaj3w4o/tduqy/eYedFYWa0RRStbUEts7upugufL6LOsvLFtUqRdkn0SL6yho3mcruQ4drRRtKWOtoXtlde+8QGU2agde6Kv9c1e5nGF2+IGW/AZtmCB+NdKuZJU1oV10lXUyZGgc7tycH/U4JHBJa0qvHfBJlif3IgEU++D/d0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=yyoPSu+z; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=RFAXhyJ3; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1711019667; 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=c8obbwSnzuUFaxqMybHilSrOftM5wBOHep+jfUErEiQ=; b=yyoPSu+zdY75RKZVMLCRhmMaavjaWyrO142Aq8qF2Cupvs+qcumSgHrouFexuQdRbHl96B Ownj7W9StJ9vuhILTFl+uKs05qCBED2200VfqnoQfSFVyXyDLQW1gpGCFnKBU/joJKd4Qt ZASe9rLu6V6izS6trlZoULsh5K9gB1UaEjm7DFxjItgzmBclYXmSXIv3MCrVeypc/0vfoX yREvpoJJD/Sw8OtoZsNrvLjBQV4D7N9rnBMsPq48To0OW0MbcHpzpq5rcZMjNUrnlas0Vi Y7JyFiAG47+YsDUg2B6VIDGjhM+ysuUueA6Qf/1fCW4G029E4KH6ZvOzVR9Z2Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1711019667; 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=c8obbwSnzuUFaxqMybHilSrOftM5wBOHep+jfUErEiQ=; b=RFAXhyJ34HelHYfVFB/xaFUMP4ULdgFVuAq2z9BYyvKTFJchwJ4vZVdnDfGU0Xc0Wdtc3d 4RhP9hGYjz6dv5BQ== To: Guenter Roeck Cc: LKML , x86@kernel.org, Linus Torvalds , Uros Bizjak , linux-sparse@vger.kernel.org, lkp@intel.com, oe-kbuild-all@lists.linux.dev Subject: Re: [patch 5/9] x86: Cure per CPU madness on UP In-Reply-To: References: <20240303235029.555787150@linutronix.de> <20240304005104.622511517@linutronix.de> <87bk79i8km.ffs@tglx> Date: Thu, 21 Mar 2024 12:14:27 +0100 Message-ID: <87r0g3hm5o.ffs@tglx> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain On Wed, Mar 20 2024 at 08:46, Guenter Roeck wrote: > On 3/20/24 01:58, Thomas Gleixner wrote: >> On Fri, Mar 15 2024 at 09:17, Guenter Roeck wrote: >>> I don't know the code well enough to determine what is wrong. >>> Please let me know what I can do to help debugging the problem. >> >> Could you provide me the config and the qemu command line? >> > > defconfig-CONFIG_SMP and > > qemu-system-x86_64 -kernel arch/x86/boot/bzImage -cpu Haswell \ > --append "console=ttyS0" -nographic -monitor none > > The cpu doesn't really matter as long as it is an Intel CPU. > A root file system isn't needed since the boot doesn't get that far. Now it get's interesting because I can't reproduce it with that setup at all. What's weird is that I saw it exactly once on 64-bit in a VM with a UP config two days ago, but when I started to add instrumentation it never came back even after backing the instrumentation changes out. I have seriously no idea what's going on there. Is it fully reproducible on your side? If so can you please provide a full dmesg and then apply the patch below and provide the resulting full dmesg too? I found two other issues while trying to find a way to reproduce, but those are completely unrelated to the problem you are observing. Thanks, tglx --- arch/x86/kernel/cpu/topology.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) --- a/arch/x86/kernel/cpu/topology.c +++ b/arch/x86/kernel/cpu/topology.c @@ -176,6 +176,8 @@ static __init void topo_register_apic(u3 { int cpu, dom; + pr_info("APIC: %x %d\n", apic_id, present); + if (present) { set_bit(apic_id, phys_cpu_present_map); @@ -277,10 +279,23 @@ int topology_get_logical_id(u32 apicid, /* Remove the bits below @at_level to get the proper level ID of @apicid */ unsigned int lvlid = topo_apicid(apicid, at_level); - if (lvlid >= MAX_LOCAL_APIC) + pr_info("APIC logical ID: %x %x %d\n", apicid, lvlid, at_level); + + if (WARN_ON_ONCE(lvlid >= MAX_LOCAL_APIC)) return -ERANGE; - if (!test_bit(lvlid, apic_maps[at_level].map)) + + /* + * If there was no APIC registered, then the map check below would + * fail. With no APIC this is guaranteed to be an UP system and + * therefore all topology levels have only one entry and their + * logical ID is obviously 0. + */ + if (topo_info.boot_cpu_apic_id == BAD_APICID) + return 0; + + if (WARN_ON_ONCE(!test_bit(lvlid, apic_maps[at_level].map))) return -ENODEV; + /* Get the number of set bits before @lvlid. */ return bitmap_weight(apic_maps[at_level].map, lvlid); }