Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1651150lqe; Mon, 8 Apr 2024 16:08:01 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVFGWuJkXxXPouGy03PnA5nWYWev9uC0/uWxQ2VHGeQqbzd6ruS3WAbzkEpvm5py2FHPZr1ApSmhWxjWwTmUkxWcNycdjRB2bZmpIBLrA== X-Google-Smtp-Source: AGHT+IE9INokUg5K+XyJMdc6pF4ELPI75s7ltO5IX2MDAbGOOWWpuzm4rfIhcnLjS3y5AUKgZ2kR X-Received: by 2002:a05:6a00:6581:b0:6ed:1c7:8c5e with SMTP id hd1-20020a056a00658100b006ed01c78c5emr8929111pfb.12.1712617680785; Mon, 08 Apr 2024 16:08:00 -0700 (PDT) Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id t5-20020a63f345000000b005e42b4c97f2si7318671pgj.289.2024.04.08.16.08.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 16:08:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-135996-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@google.com header.s=20230601 header.b="uXu/kHVb"; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-135996-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-135996-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=REJECT sp=REJECT dis=REJECT) header.from=google.com 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 1037BB224DB for ; Mon, 8 Apr 2024 23:06:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 73809146000; Mon, 8 Apr 2024 23:06:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="uXu/kHVb" Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.201]) (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 1FF5F127B5A for ; Mon, 8 Apr 2024 23:06:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712617585; cv=none; b=fgBLrMnP8Z4kwovlaH/INvcfFHC2HdUpFRp5jSB1WoIQAt0kJS6LczgpTi5EDHxDjsLcowFRVzxLHgwu9O377DagKUtyU03x9w764BkSFkOkn1/5NgG8+bJeSYcrXi/HxH+Pu8vdLB1wUsj9iILCoofF8wSRQF3frg0LeSzDo7A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712617585; c=relaxed/simple; bh=raNGJvl2Sk0V+Ra8kl0a7jUETMsXzW02VIRMS9MLecE=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Domg2BnPEDeVFLm4J487GIjBeBnNMeaa382/yls4VcbxrXtx9CT7N6Ym+nYcHbWW0HMrMsrRUzAlaj2ZqP+44k4NN6JytsWIql1q7QgOIJoKcqRzbVsrgiy9pmoXoWFHxywNNIQ9TR+Hfkfs8KodMUjgX+Lv9Yw6IwlcCmVDHXo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=uXu/kHVb; arc=none smtp.client-ip=209.85.214.201 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--seanjc.bounces.google.com Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-1e2a1619cfcso38652865ad.0 for ; Mon, 08 Apr 2024 16:06:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1712617583; x=1713222383; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=AzGg/0EymHzkfd/vQ5f3X3kSeFagpEymNquXWZZ9WTc=; b=uXu/kHVbKvOtQ+vZXgFCTy9AA+RZJBcXz92edp9NKVaDxHNJjQhpHydso/+blFcCXT gsfdgz4z3Ri+Jc0X7SnNoE/KqHDkdBZxylOSyMW7MAnnfLDmW5Q+GxZHdpo+w/YifpVy SHwi2WdDS23gyNnhca37Ku71LgTrfs6eb5xXF5UsFHKSDzz+wIPS2PaFnlYbL402YJnp UW1AieLCvhfUlc39tNBWFQumO5GKN+SS5jajF3H+KS3e7YDKj18Nl3egfSO6QebLueDP EefyFXb5m6rskHEYPs/wgfWRg4lBXydIKnD2UzUkDq1E48m9Z++gx9HqUoMvx5ajQITg cLoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712617583; x=1713222383; h=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; bh=AzGg/0EymHzkfd/vQ5f3X3kSeFagpEymNquXWZZ9WTc=; b=RfxFPFhylOF5upI41nfL/eIrgiyGwnzWhNRxKIst3Y7oXLEGAY/9wUGys1qxVwdzBY 3inesX9cspQ/JdAHs+5/qymRCvnLhU2wPyqJxNAijvgRSd+V0n0aaV4NcvSMSQ69nA0S teZ356LUDiQvsRHYOcdk0JGuzbx+1wIH4/+ieOyaNFiTqLqZaIT/ClQuFSSqXbBA35Y9 rVaabaJo+cFVufYWOuDIc1DcpuobwIEj0IMIcUxhmtTInrjcOnSmFjCPYaI+6JupL8qU x/qKHctBBZvSfNTGGqHXr9weVmNc4pNhKOcSM5QKcdxDXFJQLkXmrE39PxWweqToI9wK y90w== X-Forwarded-Encrypted: i=1; AJvYcCVcigci+LPzl6frTCdJgTna4iPVZUVssct/K1bdS49Xt8nyzDhnssNI6aJdb53704za8+z8oqKBj2V//taxECDnFjUVKo5rvpefvJ5l X-Gm-Message-State: AOJu0YzWUCMvMdc3ah155DtszIqs+OYuDdmBS4fEMeBylDvrREPtdO0l BoFgc5N6scMm47eHm5hMgjVgTqDfP+DQCkraDbOjR7hDmuS2ftMOMjSMF9LVk+7qWgVTjKJv0yM TUA== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:902:e547:b0:1db:f11d:fef2 with SMTP id n7-20020a170902e54700b001dbf11dfef2mr3523plf.0.1712617583226; Mon, 08 Apr 2024 16:06:23 -0700 (PDT) Date: Mon, 8 Apr 2024 16:06:22 -0700 In-Reply-To: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <414eaf1e-ca22-43f3-8dfa-0a86f5b127f5@paulmck-laptop> <44eb0d36-7454-41e7-9a16-ce92a88e568c@paulmck-laptop> Message-ID: Subject: Re: [RFC PATCH v1 0/2] Avoid rcu_core() if CPU just left guest vcpu From: Sean Christopherson To: "Paul E. McKenney" Cc: Marcelo Tosatti , Leonardo Bras , Paolo Bonzini , Frederic Weisbecker , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Zqiang , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, rcu@vger.kernel.org Content-Type: text/plain; charset="us-ascii" On Mon, Apr 08, 2024, Paul E. McKenney wrote: > On Mon, Apr 08, 2024 at 02:56:29PM -0700, Sean Christopherson wrote: > > > OK, then we can have difficulties with long-running interrupts hitting > > > this range of code. It is unfortunately not unheard-of for interrupts > > > plus trailing softirqs to run for tens of seconds, even minutes. > > > > Ah, and if that occurs, *and* KVM is slow to re-enter the guest, then there will > > be a massive lag before the CPU gets back into a quiescent state. > > Exactly! .. > OK, then is it possible to get some other indication to the > rcu_sched_clock_irq() function that it has interrupted a guest OS? It's certainly possible, but I don't think we want to go down that road. Any functionality built on that would be strictly limited to Intel CPUs, because AFAIK, only Intel VMX has the mode where an IRQ can be handled without enabling IRQs (which sounds stupid when I write it like that). E.g. on AMD SVM, if an IRQ interrupts the guest, KVM literally handles it by doing: local_irq_enable(); ++vcpu->stat.exits; local_irq_disable(); which means there's no way for KVM to guarantee that the IRQ that leads to rcu_sched_clock_irq() is the _only_ IRQ that is taken (or that what RCU sees was even the IRQ that interrupted the guest, though that probably doesn't matter much). Orthogonal to RCU, I do think it makes sense to have KVM VMX handle IRQs in its fastpath for VM-Exit, i.e. handle the IRQ VM-Exit and re-enter the guest without ever enabling IRQs. But that's purely a KVM optimization, e.g. to avoid useless work when the host has already done what it needed to do. But even then, to make it so RCU could safely skip invoke_rcu_core(), KVM would need to _guarantee_ re-entry to the guest, and I don't think we want to do that. E.g. if there is some work that needs to be done on the CPU, re-entering the guest is a huge waste of cycles, as KVM would need to do some shenanigans to immediately force a VM-Exit. It'd also require a moderate amount of complexity that I wouldn't want to maintain, particularly since it'd be Intel-only. > Not an emergency, and maybe not even necessary, but it might well be > one hole that would be good to stop up. > > Thanx, Paul