From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 32389C7EE24 for ; Tue, 6 Jun 2023 16:30:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=8CW8O9UTqISxq0yqkSvaUMI+MkJX2CBHFhKXGBQM6PM=; b=i3xFU7Frz6Tsdo gO9L8K27p0X8ZPSEQHBQDNJpypePl9ho37DZ4kBOxMyEDpes9Pvy+0PX2r7VoaDdpUDjf4EDvOqT9 Qa9NK41L/qHmqfGCpkIyom83zuRZr8GkesSGC15iKQqWUCWFT6sXCuGJI/rsmu5LDrm5xFNtow3Ih 299C0nsoykK/nv5+3ZCs2Bg0XEpjsd/qEJtylYGKLpq1WTZr58AqkmR4uPJjB1etsB3tpnNKJg0LC mNrQknFr8N9L3sWRDsbfL+JZKrzneo64SVgAFhWbhyN4hzlGcuEHmlu+dGP3yBSBKrK6haqHl/GVz 4wZIx0M0M7j06gkiNyfA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q6ZZl-002RKw-21; Tue, 06 Jun 2023 16:30:29 +0000 Received: from out-8.mta0.migadu.com ([2001:41d0:1004:224b::8]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q6YSB-002DMg-0X for linux-arm-kernel@lists.infradead.org; Tue, 06 Jun 2023 15:18:37 +0000 Date: Tue, 6 Jun 2023 15:18:27 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1686064711; 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=a0OMKZo+jxk92OEJPdCQE4uvxPWt/l6mvkQM6RunaJQ=; b=h08XZrOM1ON+lg2vQSGmmcKMzlwr4jCaavS+zCxIxy5RmvPu/771Uy1hX2GJRTa9tA6ef+ sWk4z+GrkFdOCEjtz7Kh+gD+XLDTGoP1t0uWQJpGLIEe3mrNE4w+mpeOFxfw3Ms6YxC2Fx sVME7JfpboYEQSTfd1NSweqEBBBGI+w= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: Sean Christopherson Cc: Sebastian Ott , kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Marc Zyngier Subject: Re: [PATCH] KVM: arm64: Fix smp_processor_id() call in preemptible context Message-ID: References: <2f16f83e-ed60-fcb7-7f3d-0fa216c41cb9@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230606_081835_740397_53925BDF X-CRM114-Status: GOOD ( 19.95 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Jun 06, 2023 at 07:29:16AM -0700, Sean Christopherson wrote: > On Tue, Jun 06, 2023, Oliver Upton wrote: > > The call from a preemptible context is intentional, so this really > > should just be raw_smp_processor_id(). Do you mind if we fix it with the > > following? > > ... > > > Nonetheless, there's no functional requirement for disabling preemption, > > as the cpu # is only used to walk the arm_pmus list. Fix it by using > > raw_smp_processor_id() instead. > > As a partial outsider, that needs an explanation, and the code could really use a > comment. I assume KVM's ABI is that it's userspace's responsibility to ensure that > the CPU(s) used for KVM_RUN is compatible with the CPU used for KVM_ARM_VCPU_PMU_V3_CTRL, > but neither the original changelog nor the above state that, nor does anything > explain what happens if userspace doesn't uphold its side of things. See commit 40e54cad4540 ("KVM: arm64: Document default vPMU behavior on heterogeneous systems"), which documents the subtlety of vCPU scheduling with the 'old' ABI at the callsite of this function. I don't want to bleed any details of this crap into user documentation, since the entire scheme is irretrievably broken. See Documentation/virt/kvm/api/devices/vcpu.rst 1.4 for the 'new' ABI where userspace explicitly selects a vPMU instance. > That stuff might be covered in documentation somewhere, but for someone > just looking at git blame, this is all very magical. Personally, I find any other fix that involves disabling preemption to be quite a lot more 'magical', as there isn't any percpu data we're working with in the loop. -- Thanks, Oliver _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel