From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=217.140.110.172 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796142120; b=3s5gevjTDN1MRXJrxU03dgzQBYfhUDWVjbfYHz3L7Q1p3+m+Hzq43Drk5R/iXo7OUbET +FtGMj++PymCzzCUPDCjxDtdgZ6/yMt1vVuHvFFF1bBc2srNd23+Iid4C38WxIWC60uxN po+ixWILHcOvc59Nkb1YWSydpZs4FFbZrtLWaG+oze5WEzjq0fA0SIYiBbaL6oeqH3UBz FNIo4c/Gb3kHVmytWifnl5YHW2p7dG1J/TDTbaIfni7TWtidyhxN9EU05brSSNEgUVjx7 MCy/rntc6NNRkl46RtRZ3j8VFgptktYlYQZmnD8w1LOgZGfN4bCDVL0rRM+Bf6iZBDg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796142120; h=DMARC-Filter:Received:Received:DKIM-Signature:Date:From:To:Cc: Subject:Message-ID:References:MIME-Version:Content-Type: Content-Disposition:In-Reply-To; bh=wzYFjAiDOeZgcd6bdD8q/jjuvbBlDw2LsRfvvEhkPYU=; b=C9+3J3mmmve0IXFL2d8qhN/TCd1uid0nU3EkY6LoAaSb7QSVIgZo/9Ep+Ftt+t8X1Awn 8aF2m4r0ptLx7KlDeG7Ebw6JlJkcYue/T/AoSoHrfqxVifukuazai7t6NozGh1Z11eEkF zd/+XGqZFNg2ojl80MhltDY5coLtxA1af6uMhTbeEeHxnIzm6W6+/eWV9z6kGGHUntD1F GduSZ4Ud7rPhbzzNVcYtW1mky+Lm3yMAQTnwiVbkdT8qtpgSUtB79UJqf9Ilodg49IIml xQj5WnwGlnNPMItFLVhboeacYKz1UWY/VTBH66QMlmnu1fB6I4uyRspDsqf4Y4671Yw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=foss header.b=Mg89r0qc; arc=none smtp.remote-ip=217.140.110.172 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1B58A606ABCB for ; Tue, 1 Dec 2026 16:21:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 1B58A606ABCB Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=foss header.b=Mg89r0qc Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 92C34176B; Tue, 1 Dec 2026 08:21:53 -0800 (PST) Received: from raptor (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id AFA703F86F; Tue, 1 Dec 2026 08:21:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1796142116; bh=XwAFOuZL575Txk0YGoQLtDtF0EZRblsHySW/BgGcoFI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Mg89r0qcB8fhuUZD/vxIqSsWqA/xOmm93BuDxy8aBOWkv6u1F17wFGFOkHJb8mvxJ aP/Fk5u/415JLT3+6F/j8iAYUDkVKqkYbYASgcxLkklPNeDViV4Ox7cfkpx5keI2GL tqlYwe+UKuHwCp7B/eLd1/hdJqWng4RRPe3wBmys= Date: Tue, 1 Dec 2026 16:21:53 +0000 From: Alexandru Elisei To: Mika Tammi Cc: Will Deacon , Julien Thierry , kvm@vger.kernel.org Subject: Re: [PATCH kvmtool v2 2/2] Remove kvm_create_vcpu_thread() Message-ID: References: <20261130220543.70217-1-mikatammi@gmail.com> <20261130220543.70217-2-mikatammi@gmail.com> X-Mailing-List: kvm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261130220543.70217-2-mikatammi@gmail.com> Hi Mika, On Mon, Nov 30, 2026 at 11:05:43PM +0100, Mika Tammi wrote: > The VCPU threads now set their own affinity, so > kvm_create_vcpu_thread() only wraps pthread_create(). Remove it, and > have kvm_cmd_run_work() call pthread_create() itself, as it did before > commit 4c90ccf4c593 ("Correctly apply --vcpu-affinity to the VCPU > threads"). pthread_create() doesn't set errno, so a failure is reported > with die() again, instead of die_perror(). > > Suggested-by: Alexandru Elisei > Assisted-by: Claude:claude-fable-5-2 > Signed-off-by: Mika Tammi Looks correct to me: Reviewed-by: Alexandru Elisei Also tested on an arm64 machine with CONFIG_NR_CPUS=16, checked that the VCPU threads are scheduled on the --vcpu-affinity cpulist: Tested-by: Alexandru Elisei > --- > New in v2. With both patches, lkvm builds for the same targets as with > patch 1 alone, and boots guests the same way: on x86_64 and arm64 with > and without --vcpu-affinity, with glibc and musl, and on the QEMU rv32 > and rv64 KVM hosts with --vcpu-affinity 0. > > builtin-run.c | 4 ++-- > include/kvm/util.h | 4 ---- > util/util.c | 12 ------------ > 3 files changed, 2 insertions(+), 18 deletions(-) > > diff --git a/builtin-run.c b/builtin-run.c > index ac779a4..264bf8f 100644 > --- a/builtin-run.c > +++ b/builtin-run.c > @@ -876,8 +876,8 @@ static int kvm_cmd_run_work(struct kvm *kvm) > int i; > > for (i = 0; i < kvm->nrcpus; i++) { > - if (kvm_create_vcpu_thread(kvm, &kvm->cpus[i]->thread, kvm_cpu_thread, kvm->cpus[i])) > - die_perror("unable to create KVM VCPU thread"); > + if (pthread_create(&kvm->cpus[i]->thread, NULL, kvm_cpu_thread, kvm->cpus[i]) != 0) > + die("unable to create KVM VCPU thread"); > } > > /* Only VCPU #0 is going to exit by itself when shutting down */ > diff --git a/include/kvm/util.h b/include/kvm/util.h > index dc09720..b767b77 100644 > --- a/include/kvm/util.h > +++ b/include/kvm/util.h > @@ -19,7 +19,6 @@ > #include > #include > #include > -#include > #include > #include > #include > @@ -151,9 +150,6 @@ void *mmap_hugetlbfs(struct kvm *kvm, const char *htlbfs_path, u64 size); > void *mmap_anon_or_hugetlbfs(struct kvm *kvm, const char *hugetlbfs_path, u64 size); > void *mmap_guest_memfd(struct kvm *kvm, u64 size); > > -int kvm_create_vcpu_thread(struct kvm *kvm, pthread_t *thread, > - void *(*start_routine)(void *), void *arg); > - > unsigned long host_page_size(void); > > #ifndef PAGE_SIZE > diff --git a/util/util.c b/util/util.c > index 59855d6..9baef5d 100644 > --- a/util/util.c > +++ b/util/util.c > @@ -207,18 +207,6 @@ void *mmap_guest_memfd(struct kvm *kvm, u64 size) > return addr; > } > > -int kvm_create_vcpu_thread(struct kvm *kvm, pthread_t *thread, > - void *(*start_routine)(void *), void *arg) > -{ > - int ret; > - > - ret = pthread_create(thread, NULL, start_routine, arg); > - if (ret) > - errno = ret; > - > - return -ret; > -} > - > unsigned long host_page_size(void) > { > static long page_size; > -- > 2.54.0 (Apple Git-157) >