Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Knot DNS
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
22
Issues
22
List
Boards
Labels
Service Desk
Milestones
Merge Requests
18
Merge Requests
18
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Knot projects
Knot DNS
Commits
2765aa14
Commit
2765aa14
authored
May 11, 2012
by
Marek Vavrusa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed OS X not supporting cpu_set_t.
parent
b04dcd94
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
6 deletions
+13
-6
src/knot/server/dthreads.c
src/knot/server/dthreads.c
+5
-2
src/knot/server/dthreads.h
src/knot/server/dthreads.h
+2
-2
src/knot/server/udp-handler.c
src/knot/server/udp-handler.c
+6
-2
No files found.
src/knot/server/dthreads.c
View file @
2765aa14
...
...
@@ -854,15 +854,18 @@ int dt_stop(dt_unit_t *unit)
// return KNOTD_EOK;
//}
int
dt_setaffinity
(
dthread_t
*
thread
,
cpu_set_t
*
mask
)
int
dt_setaffinity
(
dthread_t
*
thread
,
void
*
mask
,
size_t
len
)
{
if
(
thread
==
NULL
||
mask
==
NULL
)
{
return
KNOTD_EINVAL
;
}
#ifdef HAVE_PTHREAD_SETAFFINITY_NP
if
(
len
!=
sizeof
(
cpu_set_t
))
{
return
KNOTD_EINVAL
;
}
pthread_t
tid
=
pthread_self
();
int
ret
=
pthread_setaffinity_np
(
tid
,
sizeof
(
cpu_set_t
),
mask
);
int
ret
=
pthread_setaffinity_np
(
tid
,
len
,
(
cpu_set_t
*
)
mask
);
if
(
ret
<
0
)
{
return
KNOTD_ERROR
;
}
...
...
src/knot/server/dthreads.h
View file @
2765aa14
...
...
@@ -254,12 +254,12 @@ int dt_stop(dt_unit_t *unit);
* \brief Set thread affinity to masked CPU's.
*
* \param thread Target thread instance.
* \param mask CPU mask.
* \param mask CPU mask
(should be pointer to cpu_set_t)
.
*
* \retval KNOTD_EOK on success.
* \retval KNOTD_EINVAL on invalid parameters.
*/
int
dt_setaffinity
(
dthread_t
*
thread
,
cpu_set_t
*
mask
);
int
dt_setaffinity
(
dthread_t
*
thread
,
void
*
mask
,
size_t
len
);
/*!
* \brief Set thread to execute another runnable.
...
...
src/knot/server/udp-handler.c
View file @
2765aa14
...
...
@@ -204,6 +204,7 @@ static inline int udp_master_recvfrom(dthread_t *thread, stat_t *thread_stat)
/* Set CPU affinity to improve load distribution on multicore systems.
* Partial overlapping mask to be nice to scheduler.
*/
#ifdef HAVE_PTHREAD_SETAFFINITY_NP
int
cpcount
=
dt_online_cpus
();
if
(
cpcount
>
0
)
{
unsigned
tid
=
dt_get_id
(
thread
);
...
...
@@ -211,8 +212,9 @@ static inline int udp_master_recvfrom(dthread_t *thread, stat_t *thread_stat)
CPU_ZERO
(
&
cpus
);
CPU_SET
(
tid
%
cpcount
,
&
cpus
);
CPU_SET
((
tid
+
1
)
%
cpcount
,
&
cpus
);
dt_setaffinity
(
thread
,
&
cpus
);
dt_setaffinity
(
thread
,
&
cpus
,
sizeof
(
cpu_set_t
)
);
}
#endif
knot_nameserver_t
*
ns
=
h
->
server
->
nameserver
;
...
...
@@ -405,6 +407,7 @@ static inline int udp_master_recvmmsg(dthread_t *thread, stat_t *thread_stat)
/* Set CPU affinity to improve load distribution on multicore systems.
* Partial overlapping mask to be nice to scheduler.
*/
#ifdef HAVE_PTHREAD_SETAFFINITY_NP
int
cpcount
=
dt_online_cpus
();
if
(
cpcount
>
0
)
{
unsigned
tid
=
dt_get_id
(
thread
);
...
...
@@ -412,8 +415,9 @@ static inline int udp_master_recvmmsg(dthread_t *thread, stat_t *thread_stat)
CPU_ZERO
(
&
cpus
);
CPU_SET
(
tid
%
cpcount
,
&
cpus
);
CPU_SET
((
tid
+
1
)
%
cpcount
,
&
cpus
);
dt_setaffinity
(
thread
,
&
cpus
);
dt_setaffinity
(
thread
,
&
cpus
,
sizeof
(
cpu_set_t
)
);
}
#endif
/* Loop until all data is read. */
ssize_t
n
=
0
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment