From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) (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 B7AB83AF65A for ; Thu, 30 Jul 2026 19:19:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.199 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785439154; cv=none; b=I2AhsIViwTzDXt9BqkaQpgqScC92pNRoNNZr2HMFoaENsMCLFTGzivia/B4/VefQVX5Ex/QG6O+LBFlyGYr0hrXrjXMFFPooCtM/M48oZNqJ8/ASELInRDnZ/3qdO+tgvNzgUhqihyXGV0jB7CKhriXdA6pIAYB18uRmYQLO4lI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785439154; c=relaxed/simple; bh=HRd/veKnQQoNlLPIk/S30A+ciXDQdelNm8xjt5JmDww=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=LaWGIX2SEga+73xLFmZCj/gahBjJbMDUe4vOZeBAL97Ar3fTucDDW7FgtgQ+pTXb0Zo5KBHv1Sb7Yc4W2RUa8unJdakoBEI3Q68j0QU72i7yZUaOPzjQMEJRIoQwUzuewGCgCcj4PbdavTg398FBYFL7/BFGxjVW3LFiwM0Ksd0= 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=Y2mK/ahC; arc=none smtp.client-ip=209.85.210.199 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="Y2mK/ahC" Received: by mail-pf1-f199.google.com with SMTP id d2e1a72fcca58-848d21bbb55so377519b3a.0 for ; Thu, 30 Jul 2026 12:19:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1785439152; x=1786043952; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:reply-to:from:to:cc:subject:date:message-id :reply-to:content-type; bh=kus6EqucfaH9HPf637yAVY0TPxuMIU/5NctVRnWGiLw=; b=Y2mK/ahCY1KyhM9T9Jlo1qcvmE1q+53KFDmeyV2wok6k85xcetzpKjSZyfemJ6P+Km yUE2v/w4A3N/8jYnDJBsXHAxjhNLS01WGvOTVau4b0iKJ9tnT4kKFvi/sOfRlStKwrm/ CgdmiNmrd9yGa7BjtXyQp894XmKoOZuDWUEZZIGgU2B5m7qNm+/1+aOGnJClXDO+THH9 HU0dmWoh9tal0ECfSQdOvo3GtJOFjrbEyYsq6LBm8ogToWJZaUb+ryX4W7Eqmmbz54ww B0FwJUStm766gPAUvdd4LVYAdBHjIwsxen0JqeftIyNVX8UAPliN6K7Gj0QVqirhAdTr 8d4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785439152; x=1786043952; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:reply-to:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to:content-type; bh=kus6EqucfaH9HPf637yAVY0TPxuMIU/5NctVRnWGiLw=; b=PU/Ynz6Pksuo+TJwcX+iBaG1ev3DZ/mnYnwmP9HHYu1Ye3JcIYEoYQpH19MJCb9qEc zaZlQk+ul/xPVMWmKZ2Qa7DgXm3ne1Gs6uc0rxp6zPUwlE8LkzZGRWuGALXYKZ5GsZtJ ILqm6gEsKKrXgsGD8QSDPoW09A7wqhLQvPB3yl/P5Mt/6wLoypPutUoH6NrJkVu3aFLg rJFs4j02XgTTEoOZzsuqZ4vXzg9hUkPYAGisYZZ7XAiCmxr2Wb58gXKaD0yoxPi2jUDt DbsFdpFGPUpBgSZtim0JDSsTetadgfnDoIuGceQdf5uSt7JP2jUpMunAEnzZe4A/9wrN 2KPw== X-Forwarded-Encrypted: i=1; AHgh+RrAh8ixv+Sv5Uo9GdAGhTBP/slbIUdcgLFZ25tNHr3RWJb5bTJ+YONNWUId6OtC0GaDiaBNM1xFnbacfeo=@vger.kernel.org X-Gm-Message-State: AOJu0Yw49a1LKL4EXxnJ07K6HVQkebJzjRHHYQv3KocXcVFIFTa4qhx8 h1ZYoIwgfgdYfDEpXgKtEMFa58b3G02zOqme4qFHlzUuHFEDB38CH5sNZ2grRB9zQ4Awz5FsBSk Mu4ypGQ== X-Received: from pfjd18.prod.google.com ([2002:a05:6a00:2452:b0:847:7599:7277]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:3020:b0:846:8b21:6304 with SMTP id d2e1a72fcca58-84ebc1fd6bemr3617195b3a.14.1785439151792; Thu, 30 Jul 2026 12:19:11 -0700 (PDT) Reply-To: Sean Christopherson Date: Thu, 30 Jul 2026 12:19:00 -0700 In-Reply-To: <20260730191908.2084803-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260730191908.2084803-1-seanjc@google.com> X-Mailer: git-send-email 2.55.0.508.g3f0d502094-goog Message-ID: <20260730191908.2084803-2-seanjc@google.com> Subject: [PATCH 1/9] KVM: selftests: Return the target CPU from pin_task_to_random_cpu() From: Sean Christopherson To: Paolo Bonzini , Marc Zyngier , Oliver Upton , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Sean Christopherson Cc: Joey Gouly , Steffen Eiden , Suzuki K Poulose , Zenghui Yu , David Hildenbrand , kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" When pinning a task to a random CPU, return which CPU the task was pinned to so that the caller can do things like avoid running other tasks on the target CPU. Signed-off-by: Sean Christopherson --- tools/testing/selftests/kvm/include/kvm_util.h | 2 +- tools/testing/selftests/kvm/lib/kvm_util.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/kvm/include/kvm_util.h b/tools/testing/selftests/kvm/include/kvm_util.h index b39e713c30a4..61d72e1e7601 100644 --- a/tools/testing/selftests/kvm/include/kvm_util.h +++ b/tools/testing/selftests/kvm/include/kvm_util.h @@ -1094,7 +1094,7 @@ static inline void pin_task_to_cpu(pthread_t task, int cpu) TEST_ASSERT(!r, "Failed to set thread affinity to pCPU '%u'", cpu); } -void pin_task_to_random_cpu(pthread_t task, cpu_set_t *possible_cpus); +int pin_task_to_random_cpu(pthread_t task, cpu_set_t *possible_cpus); static inline int pin_task_to_any_cpu(pthread_t task) { diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c index 3794575d2ca0..af2bad0553f9 100644 --- a/tools/testing/selftests/kvm/lib/kvm_util.c +++ b/tools/testing/selftests/kvm/lib/kvm_util.c @@ -668,7 +668,7 @@ void kvm_print_vcpu_pinning_help(void) " (default: no pinning)\n", name, name); } -void pin_task_to_random_cpu(pthread_t task, cpu_set_t *possible_cpus) +int pin_task_to_random_cpu(pthread_t task, cpu_set_t *possible_cpus) { int target_idx; int nr_cpus; @@ -682,11 +682,12 @@ void pin_task_to_random_cpu(pthread_t task, cpu_set_t *possible_cpus) for (cpu = 0; cpu < CPU_SETSIZE; cpu++) { if (CPU_ISSET(cpu, possible_cpus) && target_idx-- == 0) { pin_task_to_cpu(task, cpu); - return; + return cpu; } } TEST_FAIL("Failed to find random CPU in possible_cpus"); + return -1; } void kvm_parse_vcpu_pinning(const char *pcpus_string, u32 vcpu_to_pcpu[], -- 2.55.0.508.g3f0d502094-goog