From mboxrd@z Thu Jan 1 00:00:00 1970 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 D0D6A39EF3C for ; Fri, 6 Mar 2026 16:42:02 +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=1772815324; cv=none; b=HzZe6hf0gDIbfWaZkKkng1VHL4qeO+qZ/RtUxOJfYFQ6s0/RBmDdrlucuEVcI5oso3Jy7nB274xmLJt7nVg2+PtiwCKy4mbFl6+GAQuXmSL6ncRzq4sLGhQAGEkx0VMPPLoXT+uRSZjEvHHgXOTS1TLqyD+m2w6Bv6wpmuz7ovY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772815324; c=relaxed/simple; bh=TADcOpWEvJLAOeAtgeTIyGynHje+264iN18XJs1JvqQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=qDy/0qHQiUC19OJfx5tYvNQYI333DEmsClXSsgbVHpFNil5tGJV3br8GSqhVJhm9Z+KHbUzNdkBmbTHxYYDYjzb5UC1VEG89owLHY8Xpdvx2TsHx/DE1hcrk2pzbBkQ+Aoj4TCAZ84rb82iC7WlUpuLP9rzCBxSRewPHD+bfZaw= 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=mVliGTI5; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="mVliGTI5" Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-2ae50386da7so36857815ad.0 for ; Fri, 06 Mar 2026 08:42:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1772815322; x=1773420122; 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=rk41VVSwMD1I02bvg41LBcCUW/2xACIjrkOSKPXzHO4=; b=mVliGTI5JTgh3CAMVxKs/qq1k/DC8HxRd4OcT1gfk04ZLhQ/6UgjuwlBCJpjPrh2ox wpiE5nL7sFR8phPOer+DPLHLJg7FS9UexGGijHESDjYcQlsfoPJ0i9OZ2xOA2olxli7s Eos2aTFCE8SSkYo0yfCYB/geSIYZjGp+ae9YQnScYVWpj8bsJkIOfp7ezEZue+hX+Wg+ EGA6TjgS0OdAQ6Z8WedkqMOKrsi/86LuCM1hk55qEeMNhMHaEktu9P11I0Ircp9FLQ1H 0ybiYE8IEh5/o4LCz5J4b8Pk36Q9g2UDjys0Vsha4A85RIH3InCB0NIO92d/fqJMykHF JCHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772815322; x=1773420122; 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=rk41VVSwMD1I02bvg41LBcCUW/2xACIjrkOSKPXzHO4=; b=fFzB9H+oYeqOMZ+e/6mYXw3hBvoWi1KYAHZUJ97BlSYihb0xrJHNfyBRqSnBkO0yfs pXVE+vdbyWCHym/UpEpgpKFIGzMSXNEgWxICGyxSnG8vBfaPJzOKRHNXb+OKnNALXtcS 9d008lO6CHF3tlxFkE3raO076WKU8YFJolr3w6Bv3hklgBTcSLqAdfYhc/D7YLR4dmRq t8VwHmeWe4exY+sZ1669i5IhGe4SvsRPDGTtN1XxY5nyzZaF4wA23MsT/dNt0ZvhWhc8 CYLmWYb8rv+QvTQyGysTdgdlDPYUiYgJ2EdqRt4WrdspwVC98oUkr2TNf+cxpAvnWXVS f4Eg== X-Forwarded-Encrypted: i=1; AJvYcCWn2kbHUe9EEy5U5cKI7EE4TSc8sHGnjhuZZ5e2gsh1R1AWlBRTCTRw2/hjcXUu6kPQTGa0YPu1jXCuzb0=@vger.kernel.org X-Gm-Message-State: AOJu0Yz/DmLRuDMvK0cvP6MXq+Vh8u7wW/TjY6dJbDr3Owizxk1Ehsrh t+4a0hvA4mZn4ft1nFwCHAyubbSNY8xbXjtXL3QLsXJ6TSgOzZFSoGQJy5Vgieh6S4ISSWaulfM 2VDPvnQ== X-Received: from plch14.prod.google.com ([2002:a17:902:f2ce:b0:2ae:3b56:7c6a]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:4b2d:b0:2ae:525a:f971 with SMTP id d9443c01a7336-2ae82a0a890mr26503905ad.23.1772815321672; Fri, 06 Mar 2026 08:42:01 -0800 (PST) Date: Fri, 6 Mar 2026 08:42:00 -0800 In-Reply-To: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260209161527.31978-1-shaikhkamal2012@gmail.com> <20260211120944.-eZhmdo7@linutronix.de> Message-ID: Subject: Re: [PATCH] KVM: mmu_notifier: make mn_invalidate_lock non-sleeping for non-blocking invalidations From: Sean Christopherson To: shaikh kamaluddin Cc: Sebastian Andrzej Siewior , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rt-devel@lists.linux.dev Content-Type: text/plain; charset="us-ascii" On Wed, Mar 04, 2026, shaikh kamaluddin wrote: > On Wed, Feb 11, 2026 at 07:34:22AM -0800, Sean Christopherson wrote: > > On Wed, Feb 11, 2026, Sebastian Andrzej Siewior wrote: > > It's not at all clear to me that switching mmu_lock to a raw lock would be a net > > positive for PREEMPT_RT. OOM-killing a KVM guest in a PREEMPT_RT seems like a > > comically rare scenario. Whereas contending mmu_lock in normal operation is > > relatively common (assuming there are even use cases for running VMs with a > > PREEMPT_RT host kernel). > > > > In fact, the only reason the splat happens is because mmu_notifiers somewhat > > artificially forces an atomic context via non_block_start() since commit > > > > ba170f76b69d ("mm, notifier: Catch sleeping/blocking for !blockable") > > > > Given the massive amount of churn in KVM that would be required to fully eliminate > > the splat, and that it's not at all obvious that it would be a good change overall, > > at least for now: > > > > NAK > > > > I'm not fundamentally opposed to such a change, but there needs to be a _lot_ > > more analysis and justification beyond "fix CONFIG_DEBUG_ATOMIC_SLEEP=y". > > > Hi Sean, > Thanks for the detailed explanation and for spelling out the border > issue. > Understood on both points: > 1. The changelog wording was too strong; PREEMPT_RT changes > spin_lock() semantics, and the splat is fundamentally due to > spinlocks becoming sleepable there. > 2. Converting only mm_invalidate_lock to raw is insufficient > since KVM can still take the mmu_lock (and other sleeping locks > RT) in invalidate_range_start() when the invalidation hits a > memslot. > Given the above, it shounds like "convert locks to raw" is not the right > direction without sinificat rework and justification. > Would an acceptable direction be to handle the !blockable notifier case > by deferring the heavyweight invalidation work(anything that take > mmu_lock/may sleep on RT) to a context that may block(e.g. queued work), > while keeping start()/end() accounting consisting with memslot changes ? No, because the _only_ case where the invalidation is non-blockable is when the kernel is OOM-killing. Deferring the invalidations when we're OOM is likely to make the problem *worse*. That's the crux of my NAK. We'd be making KVM and kernel behavior worse to "fix" a largely hypothetical issue (OOM-killing a KVM guest in a RT kernel).