Loading...
Searching...
No Matches
cpuset.h File Reference

CPU set management functions. More...

Data Structures

struct  spdk_cpuset
 List of CPUs. More...
 

Macros

#define SPDK_CPUSET_SIZE   1024
 

Functions

struct spdk_cpusetspdk_cpuset_alloc (void)
 Allocate CPU set object.
 
void spdk_cpuset_free (struct spdk_cpuset *set)
 Free allocated CPU set.
 
bool spdk_cpuset_equal (const struct spdk_cpuset *set1, const struct spdk_cpuset *set2)
 Compare two CPU sets.
 
void spdk_cpuset_copy (struct spdk_cpuset *dst, const struct spdk_cpuset *src)
 Copy the content of CPU set to another.
 
void spdk_cpuset_and (struct spdk_cpuset *dst, const struct spdk_cpuset *src)
 Perform AND operation on two CPU sets.
 
void spdk_cpuset_or (struct spdk_cpuset *dst, const struct spdk_cpuset *src)
 Perform OR operation on two CPU sets.
 
void spdk_cpuset_xor (struct spdk_cpuset *dst, const struct spdk_cpuset *src)
 Perform XOR operation on two CPU sets.
 
void spdk_cpuset_negate (struct spdk_cpuset *set)
 Negate all CPUs in CPU set.
 
void spdk_cpuset_zero (struct spdk_cpuset *set)
 Clear all CPUs in CPU set.
 
void spdk_cpuset_set_cpu (struct spdk_cpuset *set, uint32_t cpu, bool state)
 Set or clear CPU state in CPU set.
 
bool spdk_cpuset_get_cpu (const struct spdk_cpuset *set, uint32_t cpu)
 Get the state of CPU in CPU set.
 
void spdk_cpuset_for_each_cpu (const struct spdk_cpuset *set, void(*fn)(void *ctx, uint32_t cpu), void *ctx)
 Call the specified function for each set cpu in the specified cpuset.
 
uint32_t spdk_cpuset_count (const struct spdk_cpuset *set)
 Get the number of CPUs that are set in CPU set.
 
const char * spdk_cpuset_fmt (struct spdk_cpuset *set)
 Convert a CPU set to hex string.
 
int spdk_cpuset_parse (struct spdk_cpuset *set, const char *mask)
 Convert a string containing a CPU core mask into a CPU set.
 

Detailed Description

CPU set management functions.

Function Documentation

◆ spdk_cpuset_alloc()

struct spdk_cpuset * spdk_cpuset_alloc ( void )

Allocate CPU set object.

Returns
a pointer to the allocated zeroed cpuset on success, or NULL on failure.

◆ spdk_cpuset_and()

void spdk_cpuset_and ( struct spdk_cpuset * dst,
const struct spdk_cpuset * src )

Perform AND operation on two CPU sets.

The result is stored in dst.

Parameters
dstFirst argument of operation. This value also stores the result of operation.
srcSecond argument of operation.

◆ spdk_cpuset_copy()

void spdk_cpuset_copy ( struct spdk_cpuset * dst,
const struct spdk_cpuset * src )

Copy the content of CPU set to another.

Parameters
dstDestination CPU set
srcSource CPU set

◆ spdk_cpuset_count()

uint32_t spdk_cpuset_count ( const struct spdk_cpuset * set)

Get the number of CPUs that are set in CPU set.

Parameters
setCPU set object.
Returns
the number of CPUs.

◆ spdk_cpuset_equal()

bool spdk_cpuset_equal ( const struct spdk_cpuset * set1,
const struct spdk_cpuset * set2 )

Compare two CPU sets.

Parameters
set1CPU set1.
set2CPU set2.
Returns
true if both CPU sets are equal.

◆ spdk_cpuset_fmt()

const char * spdk_cpuset_fmt ( struct spdk_cpuset * set)

Convert a CPU set to hex string.

Parameters
setCPU set.
Returns
a pointer to hexadecimal representation of CPU set. Buffer to store a string is dynamically allocated internally and freed with CPU set object. Memory returned by this function might be changed after subsequent calls to this function so string should be copied by user.

◆ spdk_cpuset_for_each_cpu()

void spdk_cpuset_for_each_cpu ( const struct spdk_cpuset * set,
void(*)(void *ctx, uint32_t cpu) fn,
void * ctx )

Call the specified function for each set cpu in the specified cpuset.

Parameters
setThe cpuset to iterate
fnThe function to call for each set cpu
ctxContext pointer to pass to fn

◆ spdk_cpuset_free()

void spdk_cpuset_free ( struct spdk_cpuset * set)

Free allocated CPU set.

Parameters
setCPU set to be freed.

◆ spdk_cpuset_get_cpu()

bool spdk_cpuset_get_cpu ( const struct spdk_cpuset * set,
uint32_t cpu )

Get the state of CPU in CPU set.

Parameters
setCPU set object.
cpuCPU index.
Returns
the state of selected CPU.

◆ spdk_cpuset_negate()

void spdk_cpuset_negate ( struct spdk_cpuset * set)

Negate all CPUs in CPU set.

Parameters
setCPU set to be negated. This value also stores the result of operation.

◆ spdk_cpuset_or()

void spdk_cpuset_or ( struct spdk_cpuset * dst,
const struct spdk_cpuset * src )

Perform OR operation on two CPU sets.

The result is stored in dst.

Parameters
dstFirst argument of operation. This value also stores the result of operation.
srcSecond argument of operation.

◆ spdk_cpuset_parse()

int spdk_cpuset_parse ( struct spdk_cpuset * set,
const char * mask )

Convert a string containing a CPU core mask into a CPU set.

Parameters
setCPU set.
maskString defining CPU set. By default hexadecimal value is used or as CPU list enclosed in square brackets defined as: 'c1[-c2][,c3[-c4],...]'. When hexadecimal value is passed, any commas will be ignored, to allow using this function with masks generated by Linux kernel in sysfs.
Returns
zero if success, non zero if fails.

◆ spdk_cpuset_set_cpu()

void spdk_cpuset_set_cpu ( struct spdk_cpuset * set,
uint32_t cpu,
bool state )

Set or clear CPU state in CPU set.

Parameters
setCPU set object.
cpuCPU index to be set or cleared.
statetrue to set cpu, false to clear.

◆ spdk_cpuset_xor()

void spdk_cpuset_xor ( struct spdk_cpuset * dst,
const struct spdk_cpuset * src )

Perform XOR operation on two CPU sets.

The result is stored in dst.

Parameters
dstFirst argument of operation. This value also stores the result of operation.
srcSecond argument of operation.

◆ spdk_cpuset_zero()

void spdk_cpuset_zero ( struct spdk_cpuset * set)

Clear all CPUs in CPU set.

Parameters
setCPU set to be cleared.