From patchwork Thu Aug 8 13:30:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 13757471 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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D8099C3DA4A for ; Thu, 8 Aug 2024 13:31:10 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.774139.1184625 (Exim 4.92) (envelope-from ) id 1sc3EM-0008S9-MX; Thu, 08 Aug 2024 13:31:02 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 774139.1184625; Thu, 08 Aug 2024 13:31:02 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sc3EM-0008S0-JL; Thu, 08 Aug 2024 13:31:02 +0000 Received: by outflank-mailman (input) for mailman id 774139; Thu, 08 Aug 2024 13:31:01 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sc3EL-0008Rq-49 for xen-devel@lists.xenproject.org; Thu, 08 Aug 2024 13:31:01 +0000 Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [2a00:1450:4864:20::233]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 72c74ea5-558a-11ef-8776-851b0ebba9a2; Thu, 08 Aug 2024 15:30:59 +0200 (CEST) Received: by mail-lj1-x233.google.com with SMTP id 38308e7fff4ca-2f16d2f2b68so13222491fa.3 for ; Thu, 08 Aug 2024 06:30:59 -0700 (PDT) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7dc9ec8860sm731607066b.209.2024.08.08.06.30.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 08 Aug 2024 06:30:58 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 72c74ea5-558a-11ef-8776-851b0ebba9a2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1723123859; x=1723728659; darn=lists.xenproject.org; h=content-transfer-encoding:autocrypt:subject:from:cc:to :content-language:user-agent:mime-version:date:message-id:from:to:cc :subject:date:message-id:reply-to; bh=c7yswg46iYRjmCAQDqekaVXbZBIqwIPJAVVIJjaG0+c=; b=Dw9czV8vXNd+f6Urp2YisuJE9iMnhpr3vwO6y6pULaqtb8tv9U6lcMaedh2HLg+guW BbYR3mhS0v+eHbp+vaIRGWg4/n+WwGrE+lIdTb3DjTvzLp+aiWREc8xod4Q6erWZZOEI DasixbedX/lIUR68lD3XfnOdKZxeaV54pSHEO5BGF/sgCaMEf2a8X947uuRhpUbZLGaX EZfHTJRYjhvCyCA2QV7LbuItkvSmCJnmE0895sMc4qhvgz8EePbVOteB6H6HypuWZp0I A4Ty0pQWwIP8GxuUDG7ZAL2YBypt+6MDL2yZ0/3r2IVcEoxaA+kKt7LaD0uGkYg78ug4 1xjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723123859; x=1723728659; h=content-transfer-encoding:autocrypt:subject:from:cc:to :content-language:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=c7yswg46iYRjmCAQDqekaVXbZBIqwIPJAVVIJjaG0+c=; b=PMa0nloKmy9Wrsf6t4Pvkj64bIon0a0v4ir/5KPZqXIUprqueSsUDvDuT/IRYA7Jk8 hohc5tYxwjZV0z70Spx6ZNZycQfKozYhowGASxYSDyQfGQh5IFJqeGjuBE3T/gWJM0ax Li1DMOgUDCgo8AmOxtZCMsljid7Gdkw+1RdRe5n4puHkfm9no/fE8nzxlY2EEaGDyfCo 36ULcXMyQis4zqt433zxFMZN3Sn/em3VPQD8iQJZyd8QC1QjLm4z/jh4wf4kYa0eWxpZ +50H0i9dfFAZ/B0cni7DHLmXomrwCK+kxWwDC6gK41h/T501MXfMojCg5EH7SJ7aCvvT 3l6w== X-Gm-Message-State: AOJu0YzZuW9jZy1WSjedTypL3V7VK3TaCy+wY4eP/vOzeiRprDGTLumd ovvlt0gf8CbR1FWjfO1oIehEpI57cS9iJ6Wc1Bs66MAgiy3KugKieO2cQ5MUqCdMgDSUFGrGa/4 = X-Google-Smtp-Source: AGHT+IFp2j1Q/KHB3Y0cT90mPoKS97XyvSAx2TSuwzQp4oqfRUfa1y8CB284P7J5K1u3evF4IZe9lw== X-Received: by 2002:a05:651c:19a6:b0:2f1:922f:8751 with SMTP id 38308e7fff4ca-2f19dd85aa8mr20555571fa.0.1723123858519; Thu, 08 Aug 2024 06:30:58 -0700 (PDT) Message-ID: <0a082833-3d52-4c9d-8ea4-5be01986cd2c@suse.com> Date: Thu, 8 Aug 2024 15:30:58 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , =?utf-8?q?Roger_Pau_Monn?= =?utf-8?q?=C3=A9?= , Marek Marczykowski From: Jan Beulich Subject: [PATCH] x86/x2APIC: correct cluster tracking upon CPUs going down for S3 Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+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ocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL Downing CPUs for S3 is somewhat special: Since we can expect the system to come back up in exactly the same hardware configuration, per-CPU data for the secondary CPUs isn't de-allocated (and then cleared upon re- allocation when the CPUs are being brought back up). Therefore the cluster_cpus per-CPU pointer will retain its value for all CPUs other than the final one in a cluster (i.e. in particular for all CPUs in the same cluster as CPU0). That, however, is in conflict with the assertion early in init_apic_ldr_x2apic_cluster(). Note that the issue is avoided on Intel hardware, where we park CPUs instead of bringing them down. Extend the bypassing of the freeing to the suspend case, thus making suspend/resume also a tiny bit faster. Fixes: 2e6c8f182c9c ("x86: distinguish CPU offlining from CPU removal") Reported-by: Marek Marczykowski-Górecki Signed-off-by: Jan Beulich Tested-by: Marek Marczykowski-Górecki Acked-by: Andrew Cooper --- a/xen/arch/x86/genapic/x2apic.c +++ b/xen/arch/x86/genapic/x2apic.c @@ -228,7 +228,8 @@ static int cf_check update_clusterinfo( case CPU_UP_CANCELED: case CPU_DEAD: case CPU_REMOVE: - if ( park_offline_cpus == (action != CPU_REMOVE) ) + if ( park_offline_cpus == (action != CPU_REMOVE) || + system_state == SYS_STATE_suspend ) break; if ( per_cpu(cluster_cpus, cpu) ) {