From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oi1-f198.google.com (mail-oi1-f198.google.com [209.85.167.198]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4CC1B49B443 for ; Thu, 1 Oct 2026 21:34:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.198 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790890445; cv=none; b=iOYceghGdPwgM+wU4Ne726G1yqBenVv6p7ZIkCrmeRMt/yp0zzTW30aM/S0MCDtl2hitgUCA73kOrr7r6ZwBNKX8cmv7jJP5GEIF0R/t1HPh+lTKCUbDF6oU6RbdvzxGauFhfN63zDY554nasTDJgtXM3Ksx4ZW8huu1zGHH0DM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790890445; c=relaxed/simple; bh=aIbawXPVSEHJ0DscG76tmh9vZXpkAHRdIDz4TIVMzco=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=OOJmrYe9YD4HKMap/Rx7ee4OGnEpRlmj6oXKKtV/fDwTwtinOcnfNQoh6y0hAlARGGJuXkZ+NK5Yy43rFvPTy+jKuk4oPndIszFQ4fsh5Kp9tlajnyZtDzHqxV6d77Z4K9o0C74YyL58sY0a9Nn+b264e1DT9T6pJ0iaFV40QDw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--coltonlewis.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=boKQkQy/; arc=none smtp.client-ip=209.85.167.198 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--coltonlewis.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="boKQkQy/" Received: by mail-oi1-f198.google.com with SMTP id 5614622812f47-4b1bc2e44e0so10829444b6e.0 for ; Thu, 01 Oct 2026 14:34:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1790890440; x=1791495240; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=aIbawXPVSEHJ0DscG76tmh9vZXpkAHRdIDz4TIVMzco=; b=boKQkQy/fz28Xxju7V9yf/r1v3muO9vuW8iub1LH0Bqun/fKl1N3uTn+dYgOksswlM +wgI56EJ9zDa62YaMPd7H3+1WHTt/S2ayjNIEfWf5o08aRrMZMPvRXL3awQxupifx+yp 2/73Bla8Yej6UHnMOakEVOaTkz5EJCwerZdkIGduFdcYyiv4naUWABD3dvW3LpQkygaB kiGb6d+VN+Lrlmh5neRjwWT61McYKzAjyOT4JYMyXFMh6gRZ2VbK7pv8AHfeZbhYHrln 34ginvXjIkstxJaaG+TRFEZINScgv7KZA3ssois+zz9yrUzB9FGShoh1arvpRwKTfmSm /uZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790890440; x=1791495240; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=aIbawXPVSEHJ0DscG76tmh9vZXpkAHRdIDz4TIVMzco=; b=n5jGWtUljBpMcWycp8KcoZ1hl52WkeoW99eT5Bovgl7acf4Cm4tBgdz5xeJkPI37/P 2QCdwObtK188tU1TYI1Z+SqtaIwM3IjTQ+j1lt9M22+hzx5cSCDOTmBfEqeU/zNzUsXo jvSIGgCChLm2kC/xrGJjTz6/4kxPQMvWqCnM25NetThMi36XoJ9ez+5Z8TIfVINwPIP0 mFaeHUyKErdV7hTDzerSlxd744NyTkGYX8W6D8ypg344lU/jZ/Hh1lE9Y2Qm8La5hv3D pUwXDy0kcsAXmK3LHUU60WdRry7HZOo3bUYf/wUAqR4Pbfrvmxub05PIbmV0FFFWsXaz jB1Q== X-Forwarded-Encrypted: i=1; AKwUvBwh4yOzqqbR7JNhC5xOQ3m2fXqV0OiQF27ACtomRnym+cviLnm5riXXMrG9PeYbIpGAv7Df+LB25l2+QnA=@vger.kernel.org X-Gm-Message-State: AFuF++mvZGJ1k/68R3Ryu1POCwBo7473ZbrFoswKukwh5s57VvRwvT7g 3Rw4/X/u8UQBz8NKREcamnx9RdM/Gua1OE99f3Y5bMwJUadJa65P0p88/SH10SLBYv68YFuBlrX IKUSus4Vo//aPiZRi4Gsg7Jf/JQ== X-Received: from ilbby7.prod.google.com ([2002:a05:6e02:2607:b0:50f:46b5:b429]) (user=coltonlewis job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6808:2219:b0:4e6:6079:c33d with SMTP id 5614622812f47-4f5292ffc0amr467127b6e.10.1790890439463; Thu, 01 Oct 2026 14:33:59 -0700 (PDT) Date: Thu, 1 Oct 2026 21:33:57 +0000 In-Reply-To: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260924172928.2110956-1-coltonlewis@google.com> <20260924172928.2110956-17-coltonlewis@google.com> X-Mailer: git-send-email 2.56.0.rc1.315.gc6ed9934b7-goog Message-ID: <20261001213357.2088894-3-coltonlewis@google.com> Subject: Re: [PATCH v9 16/22] KVM: arm64: Apply dynamic guest counter reservations From: Colton Lewis To: James Clark Cc: Colton Lewis , Marc Zyngier , Oliver Upton , Oliver Upton , Joey Gouly , Suzuki K Poulose , Zenghui Yu , Fuad Tabba , Catalin Marinas , Will Deacon , Mark Rutland , Paolo Bonzini , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Robin Murphy , Zide Chen , Alexandru Elisei , Ganapatrao Kulkarni , Mingwei Zhang , Jonathan Corbet , Russell King , Shuah Khan , linux-perf-users@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="UTF-8" Hi James, On Wed, Sep 30, 2026 at 04:28:37PM +0100, James Clark wrote: > If you enable pseudo-NMIs, watchdog_hardlockup_enable() installs the > watchdog using a pinned PMU event. If host userspace also has a pinned event > on the mandatory 1 PMU counter assigned to the host, then a guest could > potentially squeeze out the watchdog. > > I'm wondering if we need to prioritise kernel owned events? Or we just treat > them the same as any other event, and with PMU partitioning assume they > can't be guaranteed to be running? I feel like you would expect a watchdog > to be a bit more than best effort though, especially if there was always a > guaranteed counter available to put it on. > > I didn't follow it through completely, but it also looks like if the event > gets squeezed it would enter an error state and then never be re-enabled, > even after the guest stops running. > > Note, that I think the current ordering means that the watchdog won't > actually get squeezed out because it's created first. But I don't think we > can rely on the ordering as a strong guarantee, and it might get broken by > refactoring in the future. Good catch. Even without future refactoring, creation order can be defeated today if /proc/sys/kernel/nmi_watchdog is toggled off and back on at runtime while a userspace per-CPU pinned event is already open, giving the re-created watchdog a higher group_index and causing merge_sched_in() to put it into PERF_EVENT_STATE_ERROR when a partitioned guest takes PMCCNTR_EL0. Prioritizing kernel-owned events (!event->owner) ahead of userspace events in perf_event_groups_cmp() and perf_less_group_idx() guarantees that a kernel-pinned watchdog always wins the mandatory host counter over userspace pinned events regardless of creation order. I will look into adding that for v10. Thanks, Colton