Comments (8)
I can't find the files of interest at Savannah so let me just dump them so you can see what's in them. The macro below, __USE_GNU
, is tied to _GNU_SOURCE
and possibly _XOPEN_SOURCE
(if I recall correctly).
According to bits/cpu-set.h
, this is how cpu_set_t
is declared:
/* Data structure to describe CPU mask. */
typedef struct
{
__cpu_mask __bits[__CPU_SETSIZE / __NCPUBITS];
} cpu_set_t;
jwalton@hurd-x86:~/Build-Scripts/nsd$ cat /usr/include/sched.h
/* Definitions for POSIX 1003.1b-1993 (aka POSIX.4) scheduling interface.
Copyright (C) 1996-2019 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#ifndef _SCHED_H
#define _SCHED_H 1
#include <features.h>
/* Get type definitions. */
#include <bits/types.h>
#define __need_size_t
#define __need_NULL
#include <stddef.h>
#include <bits/types/time_t.h>
#include <bits/types/struct_timespec.h>
#ifndef __USE_XOPEN2K
# include <time.h>
#endif
#ifndef __pid_t_defined
typedef __pid_t pid_t;
# define __pid_t_defined
#endif
/* Get system specific constant and data structure definitions. */
#include <bits/sched.h>
#include <bits/cpu-set.h>
/* Backward compatibility. */
#define sched_priority sched_priority
#define __sched_priority sched_priority
__BEGIN_DECLS
/* Set scheduling parameters for a process. */
extern int sched_setparam (__pid_t __pid, const struct sched_param *__param)
__THROW;
/* Retrieve scheduling parameters for a particular process. */
extern int sched_getparam (__pid_t __pid, struct sched_param *__param) __THROW;
/* Set scheduling algorithm and/or parameters for a process. */
extern int sched_setscheduler (__pid_t __pid, int __policy,
const struct sched_param *__param) __THROW;
/* Retrieve scheduling algorithm for a particular purpose. */
extern int sched_getscheduler (__pid_t __pid) __THROW;
/* Yield the processor. */
extern int sched_yield (void) __THROW;
/* Get maximum priority value for a scheduler. */
extern int sched_get_priority_max (int __algorithm) __THROW;
/* Get minimum priority value for a scheduler. */
extern int sched_get_priority_min (int __algorithm) __THROW;
/* Get the SCHED_RR interval for the named process. */
extern int sched_rr_get_interval (__pid_t __pid, struct timespec *__t) __THROW;
#ifdef __USE_GNU
/* Access macros for `cpu_set'. */
# define CPU_SETSIZE __CPU_SETSIZE
# define CPU_SET(cpu, cpusetp) __CPU_SET_S (cpu, sizeof (cpu_set_t), cpusetp)
# define CPU_CLR(cpu, cpusetp) __CPU_CLR_S (cpu, sizeof (cpu_set_t), cpusetp)
# define CPU_ISSET(cpu, cpusetp) __CPU_ISSET_S (cpu, sizeof (cpu_set_t), \
cpusetp)
# define CPU_ZERO(cpusetp) __CPU_ZERO_S (sizeof (cpu_set_t), cpusetp)
# define CPU_COUNT(cpusetp) __CPU_COUNT_S (sizeof (cpu_set_t), cpusetp)
# define CPU_SET_S(cpu, setsize, cpusetp) __CPU_SET_S (cpu, setsize, cpusetp)
# define CPU_CLR_S(cpu, setsize, cpusetp) __CPU_CLR_S (cpu, setsize, cpusetp)
# define CPU_ISSET_S(cpu, setsize, cpusetp) __CPU_ISSET_S (cpu, setsize, \
cpusetp)
# define CPU_ZERO_S(setsize, cpusetp) __CPU_ZERO_S (setsize, cpusetp)
# define CPU_COUNT_S(setsize, cpusetp) __CPU_COUNT_S (setsize, cpusetp)
# define CPU_EQUAL(cpusetp1, cpusetp2) \
__CPU_EQUAL_S (sizeof (cpu_set_t), cpusetp1, cpusetp2)
# define CPU_EQUAL_S(setsize, cpusetp1, cpusetp2) \
__CPU_EQUAL_S (setsize, cpusetp1, cpusetp2)
# define CPU_AND(destset, srcset1, srcset2) \
__CPU_OP_S (sizeof (cpu_set_t), destset, srcset1, srcset2, &)
# define CPU_OR(destset, srcset1, srcset2) \
__CPU_OP_S (sizeof (cpu_set_t), destset, srcset1, srcset2, |)
# define CPU_XOR(destset, srcset1, srcset2) \
__CPU_OP_S (sizeof (cpu_set_t), destset, srcset1, srcset2, ^)
# define CPU_AND_S(setsize, destset, srcset1, srcset2) \
__CPU_OP_S (setsize, destset, srcset1, srcset2, &)
# define CPU_OR_S(setsize, destset, srcset1, srcset2) \
__CPU_OP_S (setsize, destset, srcset1, srcset2, |)
# define CPU_XOR_S(setsize, destset, srcset1, srcset2) \
__CPU_OP_S (setsize, destset, srcset1, srcset2, ^)
# define CPU_ALLOC_SIZE(count) __CPU_ALLOC_SIZE (count)
# define CPU_ALLOC(count) __CPU_ALLOC (count)
# define CPU_FREE(cpuset) __CPU_FREE (cpuset)
/* Set the CPU affinity for a task */
extern int sched_setaffinity (__pid_t __pid, size_t __cpusetsize,
const cpu_set_t *__cpuset) __THROW;
/* Get the CPU affinity for a task */
extern int sched_getaffinity (__pid_t __pid, size_t __cpusetsize,
cpu_set_t *__cpuset) __THROW;
#endif
__END_DECLS
#endif /* sched.h */
And:
$ cat /usr/include/i386-gnu/bits/cpu-set.h
/* Definition of the cpu_set_t structure used by the POSIX 1003.1b-1993
scheduling interface.
Copyright (C) 1996-2019 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#ifndef _BITS_CPU_SET_H
#define _BITS_CPU_SET_H 1
#ifndef _SCHED_H
# error "Never include <bits/cpu-set.h> directly; use <sched.h> instead."
#endif
/* Size definition for CPU sets. */
#define __CPU_SETSIZE 1024
#define __NCPUBITS (8 * sizeof (__cpu_mask))
/* Type for array elements in 'cpu_set_t'. */
typedef __CPU_MASK_TYPE __cpu_mask;
/* Basic access functions. */
#define __CPUELT(cpu) ((cpu) / __NCPUBITS)
#define __CPUMASK(cpu) ((__cpu_mask) 1 << ((cpu) % __NCPUBITS))
/* Data structure to describe CPU mask. */
typedef struct
{
__cpu_mask __bits[__CPU_SETSIZE / __NCPUBITS];
} cpu_set_t;
/* Access functions for CPU masks. */
#if __GNUC_PREREQ (2, 91)
# define __CPU_ZERO_S(setsize, cpusetp) \
do __builtin_memset (cpusetp, '\0', setsize); while (0)
#else
# define __CPU_ZERO_S(setsize, cpusetp) \
do { \
size_t __i; \
size_t __imax = (setsize) / sizeof (__cpu_mask); \
__cpu_mask *__bits = (cpusetp)->__bits; \
for (__i = 0; __i < __imax; ++__i) \
__bits[__i] = 0; \
} while (0)
#endif
#define __CPU_SET_S(cpu, setsize, cpusetp) \
(__extension__ \
({ size_t __cpu = (cpu); \
__cpu / 8 < (setsize) \
? (((__cpu_mask *) ((cpusetp)->__bits))[__CPUELT (__cpu)] \
|= __CPUMASK (__cpu)) \
: 0; }))
#define __CPU_CLR_S(cpu, setsize, cpusetp) \
(__extension__ \
({ size_t __cpu = (cpu); \
__cpu / 8 < (setsize) \
? (((__cpu_mask *) ((cpusetp)->__bits))[__CPUELT (__cpu)] \
&= ~__CPUMASK (__cpu)) \
: 0; }))
#define __CPU_ISSET_S(cpu, setsize, cpusetp) \
(__extension__ \
({ size_t __cpu = (cpu); \
__cpu / 8 < (setsize) \
? ((((const __cpu_mask *) ((cpusetp)->__bits))[__CPUELT (__cpu)] \
& __CPUMASK (__cpu))) != 0 \
: 0; }))
#define __CPU_COUNT_S(setsize, cpusetp) \
__sched_cpucount (setsize, cpusetp)
#if __GNUC_PREREQ (2, 91)
# define __CPU_EQUAL_S(setsize, cpusetp1, cpusetp2) \
(__builtin_memcmp (cpusetp1, cpusetp2, setsize) == 0)
#else
# define __CPU_EQUAL_S(setsize, cpusetp1, cpusetp2) \
(__extension__ \
({ const __cpu_mask *__arr1 = (cpusetp1)->__bits; \
const __cpu_mask *__arr2 = (cpusetp2)->__bits; \
size_t __imax = (setsize) / sizeof (__cpu_mask); \
size_t __i; \
for (__i = 0; __i < __imax; ++__i) \
if (__arr1[__i] != __arr2[__i]) \
break; \
__i == __imax; }))
#endif
#define __CPU_OP_S(setsize, destset, srcset1, srcset2, op) \
(__extension__ \
({ cpu_set_t *__dest = (destset); \
const __cpu_mask *__arr1 = (srcset1)->__bits; \
const __cpu_mask *__arr2 = (srcset2)->__bits; \
size_t __imax = (setsize) / sizeof (__cpu_mask); \
size_t __i; \
for (__i = 0; __i < __imax; ++__i) \
((__cpu_mask *) __dest->__bits)[__i] = __arr1[__i] op __arr2[__i]; \
__dest; }))
#define __CPU_ALLOC_SIZE(count) \
((((count) + __NCPUBITS - 1) / __NCPUBITS) * sizeof (__cpu_mask))
#define __CPU_ALLOC(count) __sched_cpualloc (count)
#define __CPU_FREE(cpuset) __sched_cpufree (cpuset)
__BEGIN_DECLS
extern int __sched_cpucount (size_t __setsize, const cpu_set_t *__setp)
__THROW;
extern cpu_set_t *__sched_cpualloc (size_t __count) __THROW __wur;
extern void __sched_cpufree (cpu_set_t *__set) __THROW;
__END_DECLS
#endif /* bits/cpu-set.h */
jwalton@hurd-x86:~/nsd$
from nsd.
See the fix for #76. That should also fix the cpuid_t issues for this one.
from nsd.
Also needs the fix for #75, but then it may compile straight away with the bsd code. That fix should also fix the link errors you reported for DragonFly (and would also appear here, I think).
from nsd.
Hi @wcawijngaards,
I'm retesting master on HURD now following a make distclean && autoreconf && ./configure
. Here is the one issue from make -k
.
gcc -I. -I/usr/local/include -g -O2 -flto -c util.c
util.c: In function ‘set_cpu_affinity’:
util.c:1194:9: warning: implicit declaration of function ‘cpuset_setaffinity’; did you mean ‘sched_setaffinity’? [-Wimplicit-function-declaration]
1194 | return cpuset_setaffinity(
| ^~~~~~~~~~~~~~~~~~
| sched_setaffinity
util.c:1195:3: error: ‘CPU_LEVEL_WHICH’ undeclared (first use in this function)
1195 | CPU_LEVEL_WHICH, CPU_WHICH_PID, -1, sizeof(*set), set);
| ^~~~~~~~~~~~~~~
util.c:1195:3: note: each undeclared identifier is reported only once for each function it appears in
util.c:1195:20: error: ‘CPU_WHICH_PID’ undeclared (first use in this function)
1195 | CPU_LEVEL_WHICH, CPU_WHICH_PID, -1, sizeof(*set), set);
| ^~~~~~~~~~~~~
And in case it helps:
$ grep -IR CPU_LEVEL_WHICH ./*
./util.c: CPU_LEVEL_WHICH, CPU_WHICH_PID, -1, sizeof(*set), set);
$ grep -IR CPU_LEVEL_WHICH /usr/include
$
And:
$ gcc -dM -E - </dev/null | sort | grep -i -E 'linux|hurd|gnu|i*86|x86|amd'
#define __GNU__ 1
#define __GNUC__ 9
#define __GNUC_MINOR__ 3
#define __GNUC_PATCHLEVEL__ 0
#define __GNUC_STDC_INLINE__ 1
#define __gnu_hurd__ 1
#define __i386 1
#define __i386__ 1
#define i386 1
#define __i586 1
#define __i586__ 1
from nsd.
I think this is the problem. First, HURD needs to be in the HAVE_SCHED_SETAFFINITY
code path:
#ifdef HAVE_SCHED_SETAFFINITY
/* Linux */
int set_cpu_affinity(cpuset_t *set)
{
assert(set != NULL);
return sched_setaffinity(getpid(), sizeof(*set), set);
}
#else
/* FreeBSD */
int set_cpu_affinity(cpuset_t *set)
{
assert(set != NULL);
return cpuset_setaffinity(
CPU_LEVEL_WHICH, CPU_WHICH_PID, -1, sizeof(*set), set);
}
#endif
Second, util.c
needs to include <sched.h>
on HURD based on HAVE_SCHED_H
:
$ grep -IR sched_setaffinity /usr/include | grep -v syscall
/usr/include/i386-gnu/gnu/stubs.h:#define __stub_sched_setaffinity
/usr/include/sched.h:extern int sched_setaffinity (__pid_t __pid, size_t __cpusetsize,
And here's the view from config.log
:
$ grep HAVE_SCHED_H config.h
#define HAVE_SCHED_H 1
$ grep HAVE_SCHED_SETAFFINITY config.h
/* #undef HAVE_SCHED_SETAFFINITY */
from nsd.
This works, but it is very hacky. We really need to figure out why HAVE_SCHED_SETAFFINITY
is not being set in configure.ac
:
$ git diff
diff --git a/util.c b/util.c
index 751d73c8..c6e89683 100644
--- a/util.c
+++ b/util.c
@@ -16,6 +16,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#ifdef HAVE_SCHED_H
+#include <sched.h>
+#endif
#ifdef HAVE_SYSLOG_H
#include <syslog.h>
#endif /* HAVE_SYSLOG_H */
@@ -24,6 +27,11 @@
#include <sys/random.h>
#endif
+#if defined(__gnu_hurd__)
+# undef HAVE_SCHED_SETAFFINITY
+# define HAVE_SCHED_SETAFFINITY
+#endif
+
#include "util.h"
#include "region-allocator.h"
#include "dname.h"
Here's what the fly-by looks like on HURD:
checking sched.h usability... yes
checking sched.h presence... yes
checking for sched.h... yes
checking sys/cpuset.h usability... no
checking sys/cpuset.h presence... no
checking for sys/cpuset.h... no
checking for cpu_set_t... yes
checking for cpuset_t... no
checking for cpuid_t... no
checking for cpuset_create... no
checking for cpuset_destroy... no
checking for cpuset_zero... no
checking for cpuset_set... no
checking for cpuset_clr... no
checking for cpuset_isset... no
checking for cpuset_size... no
checking for sysconf... yes
checking for sched_setaffinity... no
checking whether CPU_OR works with three arguments... yes
from nsd.
I spun the sched_setaffinity
problem off into Issue 82, util.c:1190: warning: sched_setaffinity is not implemented and will always fail. I wanted to document the linker warning in a separate bug report.
from nsd.
Okay sure. Yes that explains it (I read the other report first). So we need that test to be able to detect sched_setaffinity correctly, but for the linker error we end up with an ifdef in util.c I think for Hurd to have an always fail codepath. In which case we don't really need to detect sched_setaffinity any more. And it is just an ifdef check, a third case that is neither the first or second, but always fail (because Hurd does not have the functionality, that it then exports via the linux equivalent). But detecting sched_setaffinity is not a problem either, and then not using it because on Hurd.
from nsd.
Related Issues (20)
- Test cases for catalog zones HOT 1
- Dynamically Generate PTR When Queried ("On the Fly") HOT 5
- NSD: handle_tcp_reading: Assertion `buffer_remaining(data->query->packet) > 0' failed. HOT 3
- catz: <defunct> processes then under load & forking HOT 5
- restart failed
- Missing AC_SUBST(dbdir) breaks installation with 4.8.0 HOT 2
- Deprecate "multi-master-check" in favour of "multi-primary-check" HOT 1
- NSD stats contain the terms "master" and "slave" HOT 1
- dbaccess.c, dbcreate.c, difffile.c and difffile.h HOT 2
- Remove patterns and nsd-control reconfig/repattern HOT 1
- nsd 4.8 stats with implausible spikes HOT 8
- nsd should not chown its PID file HOT 25
- bundled configure file for 4.9.0 release is problematic HOT 5
- Add zones without nsd-control HOT 4
- Clarify the purpose of contrib/bug390.patch HOT 2
- Report failure of primaries with secondary zones
- Add `domain_table_insert` that takes a domain name in wire format
- build fails due to missing simdzone (git head) HOT 2
- TCP accept queues number HOT 6
- Build errors for 4.10.0rc1 HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nsd.