Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CE81CC2D0E4 for ; Fri, 27 Nov 2020 15:35:11 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E75F920795 for ; Fri, 27 Nov 2020 15:35:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="FU0vfJT7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E75F920795 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:58634 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kifm9-0007HP-9z for qemu-devel@archiver.kernel.org; Fri, 27 Nov 2020 10:35:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44332) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kifWy-0007FH-59 for qemu-devel@nongnu.org; Fri, 27 Nov 2020 10:19:28 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:29417) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kifWv-00063g-68 for qemu-devel@nongnu.org; Fri, 27 Nov 2020 10:19:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606490363; 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=xVdp0FL4fThSSUUsvncsyvW/qGP3enbR/QPcKvJ95xs=; b=FU0vfJT7GQm5X0RuwtkXnQn41TxvAWDG8xWLrcYW1m3YyShrf/Qz+sUY06NJof70r5hGyg tOWiAOlrzb2l2HxbdNmDlCa7LaJ8wi5HkrW8Qf4gy8u2ovZO0s4ve+kka3k6Y7nhLeGIgg hbqlc6AIPlPMT6oOwqkNTC2Ouq2Tbxs= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-338-zFbzmezyMWChGJ70_45ueA-1; Fri, 27 Nov 2020 10:19:21 -0500 X-MC-Unique: zFbzmezyMWChGJ70_45ueA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C17C9805C04; Fri, 27 Nov 2020 15:19:20 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-112-74.ams2.redhat.com [10.36.112.74]) by smtp.corp.redhat.com (Postfix) with ESMTP id 053285D6D5; Fri, 27 Nov 2020 15:19:19 +0000 (UTC) Subject: Re: [RFC] ich9:cpuhp: add support for cpu hot-unplug with SMI broadcast enabled To: Ankur Arora , Igor Mammedov References: <20201124122507.1014839-1-imammedo@redhat.com> <20201126213807.3205f5db@redhat.com> From: Laszlo Ersek Message-ID: Date: Fri, 27 Nov 2020 16:19:19 +0100 MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=lersek@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Received-SPF: pass client-ip=63.128.21.124; envelope-from=lersek@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On 11/27/20 05:10, Ankur Arora wrote: > Yeah I was wondering what would happen for simultaneous hot add and remove. > I guess we would always do remove first and then the add, unless we hit > the break due to max_cpus_per_pass and switch to hot-add mode. Considering the firmware only, I disagree with remove-then-add. EFI_SMM_CPU_SERVICE_PROTOCOL.AddProcessor() and EFI_SMM_CPU_SERVICE_PROTOCOL.RemoveProcessor() (implemented in SmmAddProcessor() and SmmRemoveProcessor() in "UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c", respectively) only mark the processors for addition/removal. The actual processing is done only later, in BSPHandler() --> SmmCpuUpdate(), when "all SMI handlers are finished" (see the comment in SmmRemoveProcessor()). Consequently, I would not suggest replacing a valid APIC ID in a particular mCpuHotPlugData.ApicId[Index] slot with INVALID_APIC_ID (corresponding to the unplug operation), and then possibly replacing INVALID_APIC_ID in the *same slot* with the APIC ID of the newly plugged CPU, in the exact same SMI invocation (= in the same execution of CpuHotplugMmi()). That might cause some component in edk2 to see the APIC ID in mCpuHotPlugData.ApicId[Index] to change from one valid ACPI ID to another valid APIC ID, and I don't even want to think about what kind of mess that could cause. So no, please handle plugs first, for which unused slots in mCpuHotPlugData.ApicId will be populated, and *then* handle removals (in the same invocation of CpuHotplugMmi()). By the way, for unplug, you will not have to re-set mCpuHotPlugData.ApicId[Index] to INVALID_APIC_ID, as SmmRemoveProcessor() does that internally. You just have to locate the Index for the APIC ID being removed, for calling EFI_SMM_CPU_SERVICE_PROTOCOL.RemoveProcessor(). Thanks Laszlo