Le 28/11/2012 14:16, Aurélien a écrit :
Allez, câdo, drop in /etc/network/if-up.d et chmod +x, et ifdown/ifup
une des cartes. Y'a sûrement mieux à faire, mais ça marche bien pour
moi. Le mieux que j'ai trouvé c'est 3 cartes réseaux intel 8 files en
LAG LACP pour 24 coeurs sur mon matériel. La regex est sûrement à
tuner.

#!/bin/bash

# This script balances the interrupts statically.

# It only touches the interrupts specified by this regular expressions
(grepped in /proc/interrupts)
# Only active interrupts will be grepped, so please re-run the script
on post-up.

NETWORK_INTERRUPTS=' (gbe|bnx|eth|igb)[0-9]+(-TxRx)?-[0-7]$'

# Balance the interrupts on all the cores, in round-robin fashion.
total_cores=$(cat /proc/cpuinfo | grep '^processor' | wc -l)
interrupts=$(cat /proc/interrupts | egrep "${NETWORK_INTERRUPTS}" |
awk -F: "{ print \$1 }" | tr '\n' ' ')

let current_core=0;
for irq in ${interrupts};
do
         affinity="$(printf "%08x" $((1 << ($current_core % $total_cores))))"
         # echo "IRQ #${irq} will have affinity to ${affinity}"
         echo "${affinity}" > "/proc/irq/${irq}/smp_affinity"
         let current_core=$(($current_core+1))
done
Une alternative en mksh qui doit aussi marcher sous ksh93 mais à vérifier ne faisant appel qu'à egrep en commande externe pour récupérer le nombre de coeurs physiques du CPU, en codant le script proprement on peux également se débarrasser de l'utilisation de egrep :

   #!/bin/mksh
   IFS=" "
   set -A MAXCORE $(egrep -m1 "^cpu cores" /proc/cpuinfo)
   MAXCORE="${MAXCORE[2]}"
   c=0
   l=0
   IFS=$'\n'
   while (( ++l < 100 )); do
        IFS=" "
        read -t2 -A || break
        if [[ "$l" = 1 ]]; then
            COLNUM="$((${#REPLY[*]}+2))"
        else
            if [[ "${REPLY[${COLNUM}]}" = @(gbe|bnx|eth|igb)+([0-9])*
   ]]; then
                printf "%08x" $((1 << ($c % ${MAXCORE}))) >
   /proc/irq/${REPLY[0]%:}/smp_affinity
                ((++c))
            fi
        fi
   done < "/proc/interrupts"


Par contre, le maxcore ne prends pas en compte la possibilité d'avoir plusieurs CPU physiques sur une même machine.
_______________________________________________
Liste de diffusion du FRsAG
http://www.frsag.org/

Répondre à