From mboxrd@z Thu Jan 1 00:00:00 1970 From: Glauber Costa Subject: [PATCH 4/8] store and set cpu affinities Date: Tue, 4 Mar 2008 13:21:57 -0300 Message-ID: <12046477422762-git-send-email-gcosta@redhat.com> References: <12046477213193-git-send-email-gcosta@redhat.com> <12046477274124-git-send-email-gcosta@redhat.com> <1204647732256-git-send-email-gcosta@redhat.com> <1204647737666-git-send-email-gcosta@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: chrisw@sous-sol.org, avi@qumranet.com, Glauber Costa To: kvm-devel@lists.sourceforge.net Return-path: In-Reply-To: <1204647737666-git-send-email-gcosta@redhat.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kvm-devel-bounces@lists.sourceforge.net Errors-To: kvm-devel-bounces@lists.sourceforge.net List-Id: kvm.vger.kernel.org This patch provides a cpu_set variable to vcpu_info structure. It stores the current cpu mask for a thread. We also provide a wrapper for storing a provided affinity, and a function to set default affinities: The default affinities are current process' Signed-off-by: Glauber Costa --- qemu/qemu-kvm.c | 17 +++++++++++++++++ 1 files changed, 17 insertions(+), 0 deletions(-) diff --git a/qemu/qemu-kvm.c b/qemu/qemu-kvm.c index 1aeb97b..a36fbf6 100644 --- a/qemu/qemu-kvm.c +++ b/qemu/qemu-kvm.c @@ -49,8 +49,25 @@ struct vcpu_info { int stop; int stopped; int thread_id; + cpu_set_t cpu_set; } vcpu_info[256]; +void kvm_store_cpu_affinity(int cpu, cpu_set_t *map) +{ + memcpy(&vcpu_info[cpu].cpu_set, map, sizeof(*map)); +} + +void kvm_register_default_affinities(void) +{ + int i; + cpu_set_t dfl; + sched_getaffinity(0, sizeof(dfl), &dfl); + + for (i = 0; i < 256; i++) { + memcpy(&vcpu_info[i].cpu_set, &dfl, sizeof(dfl)); + } +} + static inline unsigned long kvm_get_thread_id(void) { return syscall(SYS_gettid); -- 1.5.0.6 ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/