From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f201.google.com (mail-pg1-f201.google.com [209.85.215.201]) (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 3DD2D259CBF for ; Tue, 7 Oct 2025 22:14:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759875293; cv=none; b=IPjc7V6tmHlfSnM2qvdXjB1SDq4jS4YI7/3kAoYq6eBkwZk0qF6R5xI7ZN5o8+2n1zcpslCUlAw8VDOVvUIhyFu+FzoRzIwM0ltx+ODhBB9nuqt7Z39wG9r/Q67ahDLWeczaKYzzNRAj6FxWStemnMlej203HGhrxPZ6ZsBwps8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759875293; c=relaxed/simple; bh=5cUK2vsz2aeKXQeo1630DELsLZCEu5/ef8gHUAuGDsQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=VBkmRqXJ8ukPdyL58Ln7nQ/s90gJ+MF/6IpLegA7vlTboQU2v6v3YiL8Wlb2boUSvAXMJpGA2wY3r6ccIVeyamjMClR1v8AOyEweBkOfMpB8avvolos9mwMHJtigBbYRZotQjn6/iMOQguoheKJ9hlGNh0agBNDPZEFu8Mp/mI0= 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=l27ZxRug; arc=none smtp.client-ip=209.85.215.201 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="l27ZxRug" Received: by mail-pg1-f201.google.com with SMTP id 41be03b00d2f7-b557abaad02so8345784a12.3 for ; Tue, 07 Oct 2025 15:14:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1759875291; x=1760480091; darn=lists.linux.dev; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=rE2tP6gNwSGYC+ytU0WdagFGaT6zZ0FH31dgxqOixoc=; b=l27ZxRugrUIGU8DsroW4TmdfF6YMK5MO/ymTfXQEW4IH72PRrkoa2tyXFnLF593aqe XTvikZgErmdv+6LhjZTz+D76HZIlRx0/IRccDAM1AAS0JkRjDahjUDH2qAmzZIa+uUwI 8T+8swcazo8+2V8ToFuCGKIxSJDEq5FXWV1gyYjip/2q4TyYAAHGkF8EiBH+S3H1E2Hg qxTHXvppFdjZOkhSLJ/jWH5zBCSprbfZlfn8hQpLuIakUNQ7jBZeS4C3Cx3/YoWuWirv RJ7ELveTgNS9xrU0XCKCGsUyoWonlb02aPCeSeHUdn/S6ADkRuwontaz+pxGdirE0b6R /2Vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759875291; x=1760480091; h=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; bh=rE2tP6gNwSGYC+ytU0WdagFGaT6zZ0FH31dgxqOixoc=; b=XXII5k+Oo53P0Q9kSci4sITIiQzcaa4B842YIEKazA5qU+nFhmfy0UQ/NHZy8hBMnZ wHPC62l5RcZbIZxnsdy6FB+SAOPoMD0U0h4Gi2+YmM+l1xfid4vpqqbzSqUiuWOlmGOJ 6GarR6fZF3pTUPCvmz9qEW+JpqLsBsgCEYX/0Ea3cLnQ3Eagw7peYb9BivSWIjy7nN/W y5klHng3i5I8KcqPvqB0yb1mGE1INyFU+fHjeOjOQwWYp5SvHhcZJ1eXlST3PJf4YFHC 3eADfHKHI1j2Z4Dh8N1E1GDPs4WyQmSfExhWm0ajKocAtm8hyEeFG/TFq/qIaWKuPAuB al1w== X-Forwarded-Encrypted: i=1; AJvYcCVtPD40qVGJ1BiSlg/3Oipkte+1GsVsU7rlLtZ+G2Rnn+zhFPgMeZIsu+mY4VB+hQ/D2JhUPgA=@lists.linux.dev X-Gm-Message-State: AOJu0YzC7UmbzvGhbRDKOwTE3JV7STvz/lbHwOx5NLsxBmtMWoEIU0To /gFTR61RAxcsw8HErwqLgoOQz8T9prkRTNf0P/ZMOPJ5wfxhxuZLrtcwjUVZSEqIKO8qXpmZcDC PvHq67w== X-Google-Smtp-Source: AGHT+IHT/CfaeIxGRmxefyc3Lic0lFv3xjNb/u7y6hJFRFl3s3gaiIHFCNdvEBNOqVG5LYVtjeYwLccHX/o= X-Received: from pgkh14.prod.google.com ([2002:a63:e14e:0:b0:b4e:4eb5:3895]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:914c:b0:32b:7220:8536 with SMTP id adf61e73a8af0-32da8138b18mr1530904637.16.1759875291520; Tue, 07 Oct 2025 15:14:51 -0700 (PDT) Reply-To: Sean Christopherson Date: Tue, 7 Oct 2025 15:14:16 -0700 In-Reply-To: <20251007221420.344669-1-seanjc@google.com> Precedence: bulk X-Mailing-List: kvmarm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251007221420.344669-1-seanjc@google.com> X-Mailer: git-send-email 2.51.0.710.ga91ca5db03-goog Message-ID: <20251007221420.344669-9-seanjc@google.com> Subject: [PATCH v12 08/12] KVM: selftests: Add additional equivalents to libnuma APIs in KVM's numaif.h From: Sean Christopherson To: Marc Zyngier , Oliver Upton , Paolo Bonzini , Sean Christopherson Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, David Hildenbrand , Fuad Tabba , Ackerley Tng , Shivank Garg , Ashish Kalra , Vlastimil Babka Content-Type: text/plain; charset="UTF-8" Add APIs for all syscalls defined in the kernel's mm/mempolicy.c to match those that would be provided by linking to libnuma. Opportunistically use the recently inroduced KVM_SYSCALL_DEFINE() builders to take care of the boilderplate, and to fix a flaw where the two existing wrappers would generate multiple symbols if numaif.h were to be included multiple times. Signed-off-by: Sean Christopherson --- tools/testing/selftests/kvm/include/numaif.h | 36 +++++++++++-------- .../selftests/kvm/x86/xapic_ipi_test.c | 5 ++- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/tools/testing/selftests/kvm/include/numaif.h b/tools/testing/selftests/kvm/include/numaif.h index b020547403fd..aaa4ac174890 100644 --- a/tools/testing/selftests/kvm/include/numaif.h +++ b/tools/testing/selftests/kvm/include/numaif.h @@ -13,23 +13,29 @@ #ifndef SELFTEST_KVM_NUMAIF_H #define SELFTEST_KVM_NUMAIF_H -#define __NR_get_mempolicy 239 -#define __NR_migrate_pages 256 +#include -/* System calls */ -long get_mempolicy(int *policy, const unsigned long *nmask, - unsigned long maxnode, void *addr, int flags) -{ - return syscall(__NR_get_mempolicy, policy, nmask, - maxnode, addr, flags); -} +#include "kvm_syscalls.h" -long migrate_pages(int pid, unsigned long maxnode, - const unsigned long *frommask, - const unsigned long *tomask) -{ - return syscall(__NR_migrate_pages, pid, maxnode, frommask, tomask); -} +KVM_SYSCALL_DEFINE(get_mempolicy, 5, int *, policy, const unsigned long *, nmask, + unsigned long, maxnode, void *, addr, int, flags); + +KVM_SYSCALL_DEFINE(set_mempolicy, 3, int, mode, const unsigned long *, nmask, + unsigned long, maxnode); + +KVM_SYSCALL_DEFINE(set_mempolicy_home_node, 4, unsigned long, start, + unsigned long, len, unsigned long, home_node, + unsigned long, flags); + +KVM_SYSCALL_DEFINE(migrate_pages, 4, int, pid, unsigned long, maxnode, + const unsigned long *, frommask, const unsigned long *, tomask); + +KVM_SYSCALL_DEFINE(move_pages, 6, int, pid, unsigned long, count, void *, pages, + const int *, nodes, int *, status, int, flags); + +KVM_SYSCALL_DEFINE(mbind, 6, void *, addr, unsigned long, size, int, mode, + const unsigned long *, nodemask, unsigned long, maxnode, + unsigned int, flags); /* Policies */ #define MPOL_DEFAULT 0 diff --git a/tools/testing/selftests/kvm/x86/xapic_ipi_test.c b/tools/testing/selftests/kvm/x86/xapic_ipi_test.c index 35cb9de54a82..ae4a4b6c05ca 100644 --- a/tools/testing/selftests/kvm/x86/xapic_ipi_test.c +++ b/tools/testing/selftests/kvm/x86/xapic_ipi_test.c @@ -256,7 +256,7 @@ void do_migrations(struct test_data_page *data, int run_secs, int delay_usecs, int nodes = 0; time_t start_time, last_update, now; time_t interval_secs = 1; - int i, r; + int i; int from, to; unsigned long bit; uint64_t hlt_count; @@ -267,9 +267,8 @@ void do_migrations(struct test_data_page *data, int run_secs, int delay_usecs, delay_usecs); /* Get set of first 64 numa nodes available */ - r = get_mempolicy(NULL, &nodemask, sizeof(nodemask) * 8, + kvm_get_mempolicy(NULL, &nodemask, sizeof(nodemask) * 8, 0, MPOL_F_MEMS_ALLOWED); - TEST_ASSERT(r == 0, "get_mempolicy failed errno=%d", errno); fprintf(stderr, "Numa nodes found amongst first %lu possible nodes " "(each 1-bit indicates node is present): %#lx\n", -- 2.51.0.710.ga91ca5db03-goog