Skip to content

Commit

Permalink
Re-org qat_adjust_thread_affinity function
Browse files Browse the repository at this point in the history
Change-Id: I4464cd26f117fa19bd917862f35427d2b389fb95
Signed-off-by: Steve Linsell <stevenx.linsell@intel.com>
  • Loading branch information
Yogaraj-Alamenda authored and stevelinsell committed Aug 9, 2017
1 parent c8383f5 commit b7824d2
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 29 deletions.
29 changes: 0 additions & 29 deletions e_qat.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,35 +226,6 @@ static CpaPhysicalAddr virtualToPhysical(void *virtualAddr)
return qaeCryptoMemV2P(virtualAddr);
}

int qat_adjust_thread_affinity(pthread_t threadptr)
{
#ifdef QAT_POLL_CORE_AFFINITY
int coreID = 0;
int sts = 1;
cpu_set_t cpuset;
CPU_ZERO(&cpuset);
CPU_SET(coreID, &cpuset);

sts = pthread_setaffinity_np(threadptr, sizeof(cpu_set_t), &cpuset);
if (sts != 0) {
WARN("pthread_setaffinity_np error, status = %d\n", sts);
QATerr(QAT_F_QAT_ADJUST_THREAD_AFFINITY, QAT_R_PTHREAD_SETAFFINITY_FAILURE);
return 0;
}
sts = pthread_getaffinity_np(threadptr, sizeof(cpu_set_t), &cpuset);
if (sts != 0) {
WARN("pthread_getaffinity_np error, status = %d\n", sts);
QATerr(QAT_F_QAT_ADJUST_THREAD_AFFINITY, QAT_R_PTHREAD_GETAFFINITY_FAILURE);
return 0;
}

if (CPU_ISSET(coreID, &cpuset)) {
DEBUG("Polling thread assigned on CPU core %d\n", coreID);
}
#endif
return 1;
}

int qat_engine_init(ENGINE *e)
{
int instNum, err;
Expand Down
29 changes: 29 additions & 0 deletions qat_polling.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,35 @@ int qat_join_thread(pthread_t threadId, void **retval)
return pthread_join(threadId, retval);
}

int qat_adjust_thread_affinity(pthread_t threadptr)
{
#ifdef QAT_POLL_CORE_AFFINITY
int coreID = 0;
int sts = 1;
cpu_set_t cpuset;
CPU_ZERO(&cpuset);
CPU_SET(coreID, &cpuset);

sts = pthread_setaffinity_np(threadptr, sizeof(cpu_set_t), &cpuset);
if (sts != 0) {
WARN("pthread_setaffinity_np error, status = %d\n", sts);
QATerr(QAT_F_QAT_ADJUST_THREAD_AFFINITY, QAT_R_PTHREAD_SETAFFINITY_FAILURE);
return 0;
}
sts = pthread_getaffinity_np(threadptr, sizeof(cpu_set_t), &cpuset);
if (sts != 0) {
WARN("pthread_getaffinity_np error, status = %d\n", sts);
QATerr(QAT_F_QAT_ADJUST_THREAD_AFFINITY, QAT_R_PTHREAD_GETAFFINITY_FAILURE);
return 0;
}

if (CPU_ISSET(coreID, &cpuset)) {
DEBUG("Polling thread assigned on CPU core %d\n", coreID);
}
#endif
return 1;
}

void *timer_poll_func(void *ih)
{
CpaStatus status = 0;
Expand Down
13 changes: 13 additions & 0 deletions qat_polling.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,19 @@ int qat_create_thread(pthread_t *pThreadId, const pthread_attr_t *attr,
******************************************************************************/
int qat_join_thread(pthread_t threadId, void **retval);


/******************************************************************************
* function:
* int qat_adjust_thread_affinity(pthread_t threadptr);
*
* @param threadptr[IN ] - Thread ID
*
* description:
* Sets the CPU affinity mask using pthread_setaffinity_np
* and returns the CPU affinity mask using pthread_getaffinity_np
******************************************************************************/
int qat_adjust_thread_affinity(pthread_t threadptr);

/******************************************************************************
* function:
* void *timer_poll_func(void *ih)
Expand Down

0 comments on commit b7824d2

Please sign in to comment.