Neil Horman 3252189949 Add back improved affinity_hint handling
The new balancer can now deal with affintiy hinting again, this time in a
reasonably sane manner.  Whereas before having an affintiy hint caused
irqbalance to just assign that hint as the affinity, we now have a policy based
operation, controlled by the hintpolicy option.  The policy can be one of:

exact - affinity_hint is applied for that irq without balancing consideration
subset - balancing takes place, but assigned affinity will be a subset of the
ignore - affinity_hint is ignored entirely
2011-10-06 13:53:07 -04:00

72 lines
1.8 KiB

* Copyright (C) 2006, Intel Corporation
* This file is part of irqbalance
* This program file is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; version 2 of the License.
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
* You should have received a copy of the GNU General Public License
* along with this program in a file named COPYING; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
* This file contains the code to communicate a selected distribution / mapping
* of interrupts to the kernel.
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdint.h>
#include "irqbalance.h"
static void activate_mapping(struct irq_info *info, void *data __attribute__((unused)))
char buf[PATH_MAX];
FILE *file;
cpumask_t applied_mask;
* only activate mappings for irqs that have moved
if (!info->moved)
if (!info->assigned_obj)
sprintf(buf, "/proc/irq/%i/smp_affinity", info->irq);
file = fopen(buf, "w");
if (!file)
if ((hint_policy == HINT_POLICY_EXACT) &&
applied_mask = info->affinity_hint;
applied_mask = info->assigned_obj->mask;
cpumask_scnprintf(buf, PATH_MAX, applied_mask);
fprintf(file, "%s", buf);
info->moved = 0; /*migration is done*/
void activate_mappings(void)
for_each_irq(NULL, activate_mapping, NULL);