]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/CpuAffinity.cc
2 * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
9 /* DEBUG: section 54 Interprocess Communication */
12 #include "base/TextException.h"
13 #include "CpuAffinity.h"
14 #include "CpuAffinityMap.h"
15 #include "CpuAffinitySet.h"
16 #include "debug/Stream.h"
18 #include "SquidConfig.h"
23 static CpuAffinitySet
*TheCpuAffinitySet
= nullptr;
28 Must(!TheCpuAffinitySet
);
29 if (Config
.cpuAffinityMap
) {
30 const int processNumber
= InDaemonMode() ? KidIdentifier
: 1;
31 TheCpuAffinitySet
= Config
.cpuAffinityMap
->calculateSet(processNumber
);
32 if (TheCpuAffinitySet
)
33 TheCpuAffinitySet
->apply();
38 CpuAffinityReconfigure()
40 if (TheCpuAffinitySet
) {
41 TheCpuAffinitySet
->undo();
42 delete TheCpuAffinitySet
;
43 TheCpuAffinitySet
= nullptr;
51 if (Config
.cpuAffinityMap
) {
52 Must(!Config
.cpuAffinityMap
->processes().empty());
53 const int maxProcess
=
54 *std::max_element(Config
.cpuAffinityMap
->processes().begin(),
55 Config
.cpuAffinityMap
->processes().end());
57 // in no-deamon mode, there is one process regardless of squid.conf
58 const int numberOfProcesses
= InDaemonMode() ? NumberOfKids() : 1;
60 if (maxProcess
> numberOfProcesses
) {
61 debugs(54, DBG_IMPORTANT
, "WARNING: 'cpu_affinity_map' has "
62 "non-existing process number(s)");