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 73A011FF0DA for ; Thu, 19 Nov 2026 18:08:58 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 62802216BF; Thu, 19 Nov 2026 18:08:55 +0100 (CET) Message-ID: <00b7c303-d963-4c08-8341-01b1274f0253@proxmox.com> Date: Thu, 19 Nov 2026 18:08:48 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Beta Subject: Re: [PATCH qemu-server v4 4/4] cpu: add cpu binding To: Elias Huhsovitz , pve-devel@lists.proxmox.com 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> Content-Language: en-US From: Dominik Csapak In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1795108129277 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.274 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: ECQYFRCCAXVEHO33CUMNOFY3MH37LCAA X-Message-ID-Hash: ECQYFRCCAXVEHO33CUMNOFY3MH37LCAA X-MailFrom: d.csapak@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 11/19/26 2:16 PM, Elias Huhsovitz wrote: > 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 before generating the command line >>>>> # Plugins can safely deactivate already-active volumes here if needed >>>>> @@ -5539,10 +5548,21 @@ sub vm_start_nolock { >>>>> }, >>>>> ); >>>>> >>>>> + if ($conf->{'cpu-binding-mode'}) { >>>>> + $vcpu_binding_map = PVE::QemuServer::CPUBind::conf_to_vcpu_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 = parse_cpu_binding($conf-{'pcu- >>>> >>> I am not quite sure what is meant by this. >>> >>> 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=something, cpu-binding=none: > start qemu with`taskset -ac ` (no freezing, current status > quo) > > When cpu-binding=one-to-one | numa: > Do not start qemu with `taskset -ac ` > Freeze the VM at startup > Apply CPU Pinning > Resume the VM > mhmm maybe then it'd make sense to always do the taskset command even when we have a binding ? the binding code can only narrow it down anyway? >>> >>> 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. >