OpenVZ / Virtuozzo kernel development (devel@openvz.org)
 help / color / mirror / Atom feed
From: Konstantin Khorenko <khorenko@virtuozzo.com>
To: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
Cc: devel@openvz.org
Subject: Re: [Devel] [PATCH hci-8.1 2/2] KVM: remove the VM's debugfs directory when its fd is released
Date: Thu, 05 Nov 2026 13:54:22 +0100	[thread overview]
Message-ID: <179388326206.2823727.14139220407513128940.b4-review@b4> (raw)
In-Reply-To: <20261105121733.643754-3-andrey.drobyshev@virtuozzo.com>

I won't apply this version, please send v3 with the changes below.

On Thu, 5 Nov 2026 14:17:33 +0200, Andrey Drobyshev wrote:
> removed only together with the VM. A VM can outlive its fd: VFIO keeps
> a reference to it for an open passthrough device, and QEMU's cpr-exec
> closes the fd and creates a new VM in the same process, often on the
> same fd number. The new VM then finds its directory taken, logs
> "duplicate directory" and runs without debugfs stats. Seen on every
> other live update of a vGPU VM.

Item 3 of the cover letter reply: test patch 1 alone. If the duplicate
directory is gone, drop this patch. If not, name in the message what
still holds the old VM.

Why: with patch 1, VFIO takes no kvm reference for nvidia-vgpu-vfio.
The VM fd, the vcpu fds and the device fds are all close-on-exec. So
on cpr-exec the old VM is destroyed, and its directory removed, before
the new QEMU creates its VM. What can still hold a VM past its fd is
KVMGT, vfio_ap, zdev, a guest_memfd fd or an open stats file, and
none of the three drivers is built in our x86_64 kernels.

> +	/* The directory is named after this fd, which is free to reuse now */
> +	kvm_remove_vm_debugfs(kvm);

Item 4 of the cover letter reply: if the patch stays, rename the
directory with debugfs_change_name() to a name that cannot clash,
instead of removing it. Then drop the "Two things change" paragraph.

Why: on powerpc the XICS and XIVE devices create a file in this
directory and remove it when their device fd is released. If the VM fd
is closed first, the recursive removal here frees that dentry, and the
device release then removes freed memory. Our x86_64 kernels are not
hit, but the code should not carry that. My v1 reply asked to remove
only the directory and missed this case, sorry. A rename keeps every
child dentry valid until kvm_destroy_vm(), and STATS_PATH and the vcpu
stats keep working.

> Feature: fix ms/kvm
>
> Assisted-by: LLM

Item 5 of the cover letter reply: drop the Assisted-by line here, it
goes into the cover letter. Put a blank line before Feature:.

-- 
Konstantin Khorenko,
Virtuozzo Linux Kernel Team

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

  parent reply	other threads:[~2026-11-05 12:55 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-05 12:17 [Devel] [PATCH hci-8.1 v2 0/2] vfio, KVM: kvm reference leak and debugfs clash on live update Andrey Drobyshev
2026-11-05 12:17 ` [Devel] [PATCH hci-8.1 1/2] vfio: take the kvm reference only for drivers that read device->kvm Andrey Drobyshev
2026-11-05 12:23   ` no-reply
2026-11-05 12:54   ` Konstantin Khorenko
2026-11-05 12:17 ` [Devel] [PATCH hci-8.1 2/2] KVM: remove the VM's debugfs directory when its fd is released Andrey Drobyshev
2026-11-05 12:24   ` no-reply
2026-11-05 12:54   ` Konstantin Khorenko [this message]
2026-11-05 12:54 ` [Devel] [PATCH hci-8.1 v2 0/2] vfio, KVM: kvm reference leak and debugfs clash on live update Konstantin Khorenko
  -- strict thread matches above, loose matches on Subject: below --
2026-10-30 14:49 [Devel] [PATCH hci-8.1 0/2] vfio: prevent kvm reference leak on qemu-update Andrey Drobyshev
2026-10-30 14:49 ` [Devel] [PATCH hci-8.1 2/2] KVM: remove the VM's debugfs directory when its fd is released Andrey Drobyshev
2026-11-04 20:08   ` Konstantin Khorenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179388326206.2823727.14139220407513128940.b4-review@b4 \
    --to=khorenko@virtuozzo.com \
    --cc=andrey.drobyshev@virtuozzo.com \
    --cc=devel@openvz.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox