File tree Expand file tree Collapse file tree 6 files changed +81
-21
lines changed Expand file tree Collapse file tree 6 files changed +81
-21
lines changed Original file line number Diff line number Diff line change @@ -404,9 +404,7 @@ static int fpm_unix_conf_wp(struct fpm_worker_pool_s *wp) /* {{{ */
404
404
405
405
#if HAVE_FPM_CPUAFFINITY
406
406
struct fpm_cpuaffinity_conf {
407
- #if defined(HAVE_SCHED_SETAFFINITY ) || defined(HAVE_CPUSET_SETAFFINITY )
408
407
cpu_set_t cset ;
409
- #endif
410
408
long min ;
411
409
long max ;
412
410
};
@@ -432,9 +430,7 @@ static long fpm_cpumax(void)
432
430
433
431
static void fpm_cpuaffinity_init (struct fpm_cpuaffinity_conf * c )
434
432
{
435
- #if defined(HAVE_FPM_CPUAFFINITY )
436
433
CPU_ZERO (& c -> cset );
437
- #endif
438
434
}
439
435
440
436
static void fpm_cpuaffinity_add (struct fpm_cpuaffinity_conf * c )
Original file line number Diff line number Diff line change 129
129
; The value can be one cpu id, a range or a list thereof.
130
130
;
131
131
; Default Value: not set
132
- ; the master process could be bound to a single core
133
- ; process.cpu_list = "4"
134
- ; a range from the minimum cpuid to the max required
135
- ; process.cpu_list = "0-3"
136
- ; or multiple ranges separated by a comma
137
- ; process.cpu_list = "1-4,8-16,32-48"
132
+ ; Valid syntaxes are:
133
+ ; process.cpu_list = "cpu id" - to bind to a single core
134
+ ; process.cpu_list = "min cpu id-max cpu id" - to bind to a core range
135
+ from minimum cpu id to max
136
+ ; process.cpu_list = "[min cpu id-max cpu id],[min cpu id-max cpu id],..."
137
+ - to bind to multiple ranges
138
+ separated by a comma
138
139
139
140
;;;;;;;;;;;;;;;;;;;;
140
141
; Pool Definitions ;
Original file line number Diff line number Diff line change @@ -3,8 +3,8 @@ FPM: cpu affinity test
3
3
--SKIPIF--
4
4
<?php include "skipif.inc " ;
5
5
6
- if (!str_contains (PHP_OS , 'Linux ' )) {
7
- die ('skipped supported only on Linux ' );
6
+ if (!str_contains (PHP_OS , 'Linux ' ) && ! str_contains ( PHP_OS , ' FreeBSD ' ) ) {
7
+ die ('skipped supported only on Linux and FreeBSD ' );
8
8
}
9
9
?>
10
10
--FILE--
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ FPM: cpu affinity test, range
3
+ --SKIPIF--
4
+ <?php include "skipif.inc " ;
5
+
6
+ if (!str_contains (PHP_OS , 'Linux ' ) && !str_contains (PHP_OS , 'FreeBSD ' )) {
7
+ die ('skipped supported only on Linux and FreeBSD ' );
8
+ }
9
+
10
+ if (str_contains (PHP_OS , 'Linux ' )) {
11
+ $ cmd = 'nproc ' ;
12
+ } else {
13
+ $ cmd = 'sysctl hw.ncpus ' ;
14
+ }
15
+
16
+ $ nproc = intval (exec ($ cmd ));
17
+ if ($ nproc < 4 ) {
18
+ die ('skipped supported only on 4 cores or more environments ' );
19
+ }
20
+ ?>
21
+ --FILE--
22
+ <?php
23
+
24
+ require_once "tester.inc " ;
25
+
26
+ $ cfg = <<<EOT
27
+ [global]
28
+ error_log = {{FILE:LOG}}
29
+ pid = {{FILE:PID}}
30
+ [unconfined]
31
+ listen = {{ADDR:IPv4}}
32
+ pm = dynamic
33
+ pm.max_children = 1
34
+ pm.start_servers = 1
35
+ pm.min_spare_servers = 1
36
+ pm.max_spare_servers = 1
37
+ process.cpu_list = 0-1,2-3
38
+ EOT ;
39
+
40
+ $ tester = new FPM \Tester ($ cfg );
41
+ $ tester ->start ();
42
+ $ tester ->expectLogStartNotices ();
43
+ $ tester ->terminate ();
44
+ $ tester ->expectLogTerminatingNotices ();
45
+ $ tester ->close ();
46
+
47
+ ?>
48
+ Done
49
+ --EXPECT--
50
+ Done
51
+ --CLEAN--
52
+ <?php
53
+ require_once "tester.inc " ;
54
+ FPM \Tester::clean ();
55
+ ?>
Original file line number Diff line number Diff line change @@ -3,10 +3,17 @@ FPM: cpu affinity test
3
3
--SKIPIF--
4
4
<?php include "skipif.inc " ;
5
5
6
- if (!str_contains (PHP_OS , 'Linux ' )) {
7
- die ('skipped supported only on Linux ' );
6
+ if (!str_contains (PHP_OS , 'Linux ' ) && ! str_contains ( PHP_OS , ' FreeBSD ' ) ) {
7
+ die ('skipped supported only on Linux and FreeBSD ' );
8
8
}
9
- $ nproc = intval (exec ("nproc " ));
9
+
10
+ if (str_contains (PHP_OS , 'Linux ' )) {
11
+ $ cmd = 'nproc ' ;
12
+ } else {
13
+ $ cmd = 'sysctl hw.ncpus ' ;
14
+ }
15
+
16
+ $ nproc = intval (exec ($ cmd ));
10
17
if ($ nproc < 2 ) {
11
18
die ('skipped supported only on multicores environments ' );
12
19
}
Original file line number Diff line number Diff line change @@ -84,12 +84,13 @@ listen = 127.0.0.1:9000
84
84
; The value can be one cpu id, a range or a list thereof.
85
85
;
86
86
; Default Value: inherits master's cpu affinity
87
- ; the pool process could be bound to a single core
88
- ; process.cpu_list = "8"
89
- ; a range from the minimum cpuid to the max required
90
- ; process.cpu_list = "0-3"
91
- ; or multiple ranges separated by a comma
92
- ; process.cpu_list = "4-7,10-12"
87
+ ; Valid syntaxes are:
88
+ ; process.cpu_list = "cpu id" - to bind to a single core
89
+ ; process.cpu_list = "min cpu id-max cpu id" - to bind to a core range
90
+ from minimum cpu id to max
91
+ ; process.cpu_list = "[min cpu id-max cpu id],[min cpu id-max cpu id],..."
92
+ - to bind to multiple ranges
93
+ separated by a comma
93
94
94
95
; Set the process dumpable flag (PR_SET_DUMPABLE prctl for Linux or
95
96
; PROC_TRACE_CTL procctl for FreeBSD) even if the process user
You can’t perform that action at this time.
0 commit comments