[Oisf-devel] [PATCH 0/6] RFC: parametrable cpu affinity settings

Eric Leblond eleblond at edenwall.com
Fri Nov 12 11:05:01 UTC 2010


This patchset is a proposal of implementation which enable the
configuration of cpu affinity (and priority) settings from the
suricata.yaml configuration file.

The idea is to separate the threads info families and to be able to set
affinity and priority of the treads on a per-family basis.
Given a rapid study of different runmodes, I've created the following
families:
 - receive_cpu_set: for receive threads
 - decode_cpu_set: for decode threads
 - stream_cpu_set: for stream threads
 - detect_cpu_set: for detect threads
 - verdict_cpu_set: for verdict and reject threads
 - output_cpu_set: for output threads

For each family, it is possible to set:
 - cpu: define the cpu_set to attribute to the threads of the family
 	this is a list containing or single integer or range or the
	keyword 'all' which is use to give all CPUs to the threads.
 - mode: [exclusive|balanced] If balanced is set, the thread of the family
	are balanced on all cpus of the set. If exclusive is set, each thread
	of the family is given a specific CPU.
 - prio: [high|medium|low]

An example of obtained configuration is the following:
  cpu_affinity:
    - receive_cpu_set:
        cpu: [ 0 ]  # include only these cpus in affinity settings
        prio: "high"
    - decode_cpu_set:
        cpu: [ 0, 1 ]
        mode: "balanced"
    - stream_cpu_set:
        cpu: [ "0-1" ]
    - detect_cpu_set:
        cpu: [ "all" ]
        mode: "exclusive" # run detect threads in these cpus
    - verdict_cpu_set:
        cpu: [ 0 ]
    - output_cpu_set:
        cpu: [ "all" ]

Patchset statistics:
 src/Makefile.am     |    2 +-
 src/runmodes.c      |   80 +++++++-----------
 src/runmodes.h      |    3 +
 src/threadvars.h    |    2 +
 src/tm-threads.c    |   76 ++++++++++++++---
 src/tm-threads.h    |    1 +
 src/util-affinity.c |  234 +++++++++++++++++++++++++++++++++++++++++++++++++++
 src/util-affinity.h |   62 ++++++++++++++
 suricata.yaml       |   17 ++++
 9 files changed, 413 insertions(+), 64 deletions(-)

The patchset is not complete as :
 * The WIN32 case may not be properly handled
 * I've only converted the NFQAuto runmode to the new system
But as I'm planning to do some work other these patches, I send it to the list to
check if I'm going in the good direction.

I've done some light testing on my laptop which has only dual core. And I've been
able to gain a second out of ten in a trivial test. I thus really think that we could
have some real performance increase by tuning the introduced parameters.

BR,
--
Eric Leblond <eleblond at edenwall.com>





More information about the Oisf-devel mailing list