From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id E64E91FF0DE for ; Thu, 19 Nov 2026 14:16:12 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 261A0216BA; Thu, 19 Nov 2026 14:16:11 +0100 (CET) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Thu, 19 Nov 2026 14:16:02 +0100 Message-Id: To: "Dominik Csapak" , Subject: Re: [PATCH qemu-server v4 4/4] cpu: add cpu binding From: "Elias Huhsovitz" X-Mailer: aerc 0.20.0 References: <20261111152027.260117-1-e.huhsovitz@proxmox.com> <20261111152027.260117-5-e.huhsovitz@proxmox.com> <0c1ed99f-7379-4cb9-94f9-1b564b78242a@proxmox.com> <7e237b26-942c-45ba-84bf-4f2d8b5d1648@proxmox.com> In-Reply-To: <7e237b26-942c-45ba-84bf-4f2d8b5d1648@proxmox.com> X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1795094162796 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.405 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: HD3TAQBM5KFDM5V366VF7ZIKWEB2Y37D X-Message-ID-Hash: HD3TAQBM5KFDM5V366VF7ZIKWEB2Y37D X-MailFrom: e.huhsovitz@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Thu Nov 19, 2026 at 11:07 AM CET, Dominik Csapak wrote: > > > On 11/19/26 10:35 AM, Elias Huhsovitz wrote: >>>> eval { >>>> # With -blockdev, it is necessary to activate the volumes b= efore generating the command line >>>> # Plugins can safely deactivate already-active volumes here= if needed >>>> @@ -5539,10 +5548,21 @@ sub vm_start_nolock { >>>> }, >>>> ); >>>> =20 >>>> + if ($conf->{'cpu-binding-mode'}) { >>>> + $vcpu_binding_map =3D PVE::QemuServer::CPUBind::conf_to_v= cpu_bindings($conf); >>> ... but here int he crate we don't do any cpu pinning >>> >>> we could also always do it in the crate >>> >>> then the taskset call would vanish here. >>> >>> we'd have to do >>> >>> my $binding =3D parse_cpu_binding($conf-{'pcu- >>> >> I am not quite sure what is meant by this. >>=20 >> Do you mean that we simply hand all affinity related logic to the code >> responsible for the cpu pinning logic? > > yes, this. affinity only influences this one taskset call, > so having one place where we set this makes sense imo But if you omitt the tasket for the qemu command, i.e., the taskset -ac For a VM with only affinity set (no cpu pinning): * QEMU is not started with a specific affinity mask, since the cpu pinning logic applies sched_setaffinity after qemu creates the vCPUs. * So the VM has to start in a frozen state to avoid vcpus being scheduled on host cpus outside the affinity mask IMO the best three solutions are: 1) Simply move the existing logic for the `taskset -ac ` to the new module. It's not that much code, so idk if this is really worth it. 2) Do not freeze the VM at all, but start qemu with the affinity mask applied to act as an upper bound until the pinning is applied. 3) The approach of this series: just expand the if statement: only When affinity=3Dsomething, cpu-binding=3Dnone: start qemu with`taskset -ac ` (no freezing, current status quo) When cpu-binding=3Done-to-one | numa: Do not start qemu with `taskset -ac ` Freeze the VM at startup Apply CPU Pinning Resume the VM >>=20 >> Or do you mean that we should init qemu using taskset anyways and then >> later set the affinity of the vcpus again when it is time to pin? >> Since I chose to freeze the vm on startup, until pinning is applied, I >> figured the original taskset to be redundant.