Skip to content

Commit 0f4bb85

Browse files
committed
addressing comments
1 parent 5b08efd commit 0f4bb85

File tree

6 files changed

+81
-21
lines changed

6 files changed

+81
-21
lines changed

sapi/fpm/fpm/fpm_unix.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -404,9 +404,7 @@ static int fpm_unix_conf_wp(struct fpm_worker_pool_s *wp) /* {{{ */
404404

405405
#if HAVE_FPM_CPUAFFINITY
406406
struct fpm_cpuaffinity_conf {
407-
#if defined(HAVE_SCHED_SETAFFINITY) || defined(HAVE_CPUSET_SETAFFINITY)
408407
cpu_set_t cset;
409-
#endif
410408
long min;
411409
long max;
412410
};
@@ -432,9 +430,7 @@ static long fpm_cpumax(void)
432430

433431
static void fpm_cpuaffinity_init(struct fpm_cpuaffinity_conf *c)
434432
{
435-
#if defined(HAVE_FPM_CPUAFFINITY)
436433
CPU_ZERO(&c->cset);
437-
#endif
438434
}
439435

440436
static void fpm_cpuaffinity_add(struct fpm_cpuaffinity_conf *c)

sapi/fpm/php-fpm.conf.in

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,13 @@
129129
; The value can be one cpu id, a range or a list thereof.
130130
;
131131
; 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
138139

139140
;;;;;;;;;;;;;;;;;;;;
140141
; Pool Definitions ;

sapi/fpm/tests/cpuaffinity-fail.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ FPM: cpu affinity test
33
--SKIPIF--
44
<?php include "skipif.inc";
55

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');
88
}
99
?>
1010
--FILE--

sapi/fpm/tests/cpuaffinity-range.phpt

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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+
?>

sapi/fpm/tests/cpuaffinity.phpt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,17 @@ FPM: cpu affinity test
33
--SKIPIF--
44
<?php include "skipif.inc";
55

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');
88
}
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));
1017
if ($nproc < 2) {
1118
die('skipped supported only on multicores environments');
1219
}

sapi/fpm/www.conf.in

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,13 @@ listen = 127.0.0.1:9000
8484
; The value can be one cpu id, a range or a list thereof.
8585
;
8686
; 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
9394

9495
; Set the process dumpable flag (PR_SET_DUMPABLE prctl for Linux or
9596
; PROC_TRACE_CTL procctl for FreeBSD) even if the process user

0 commit comments

Comments
 (0)