]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/CpuAffinityMap.cc
2 * Copyright (C) 1996-2022 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 "CpuAffinityMap.h"
14 #include "CpuAffinitySet.h"
15 #include "debug/Stream.h"
18 CpuAffinityMap::add(const std::vector
<int> &aProcesses
, const std::vector
<int> &aCores
)
20 if (aProcesses
.size() != aCores
.size())
23 for (size_t i
= 0; i
< aProcesses
.size(); ++i
) {
24 const int process
= aProcesses
[i
];
25 const int core
= aCores
[i
];
26 if (process
<= 0 || core
<= 0)
28 theProcesses
.push_back(process
);
29 theCores
.push_back(core
);
36 CpuAffinityMap::calculateSet(const int targetProcess
) const
38 Must(theProcesses
.size() == theCores
.size());
40 for (size_t i
= 0; i
< theProcesses
.size(); ++i
) {
41 const int process
= theProcesses
[i
];
42 if (process
== targetProcess
) {
44 debugs(54, DBG_CRITICAL
, "WARNING: conflicting "
45 "'cpu_affinity_map' for process number " << process
<<
46 ", using the last core seen: " << theCores
[i
]);
51 CpuAffinitySet
*cpuAffinitySet
= nullptr;
53 cpuAffinitySet
= new CpuAffinitySet
;
56 CPU_SET(core
- 1, &cpuSet
);
57 cpuAffinitySet
->set(cpuSet
);
59 return cpuAffinitySet
;