CpuAffinity.cc
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
3 *
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.
7 */
8
9/* DEBUG: section 54 Interprocess Communication */
10
11#include "squid.h"
12#include "base/TextException.h"
13#include "CpuAffinity.h"
14#include "CpuAffinityMap.h"
15#include "CpuAffinitySet.h"
16#include "debug/Stream.h"
17#include "globals.h"
18#include "SquidConfig.h"
19#include "tools.h"
20
21#include <algorithm>
22
24
25void
27{
30 const int processNumber = InDaemonMode() ? KidIdentifier : 1;
34 }
35}
36
37void
39{
42 delete TheCpuAffinitySet;
43 TheCpuAffinitySet = nullptr;
44 }
46}
47
48void
50{
53 const int maxProcess =
54 *std::max_element(Config.cpuAffinityMap->processes().begin(),
56
57 // in no-deamon mode, there is one process regardless of squid.conf
58 const int numberOfProcesses = InDaemonMode() ? NumberOfKids() : 1;
59
60 if (maxProcess > numberOfProcesses) {
61 debugs(54, DBG_IMPORTANT, "WARNING: 'cpu_affinity_map' has "
62 "non-existing process number(s)");
63 }
64 }
65}
66
void CpuAffinityInit()
set CPU affinity for this process on startup
Definition: CpuAffinity.cc:26
void CpuAffinityCheck()
check CPU affinity configuration and print warnings if needed
Definition: CpuAffinity.cc:49
static CpuAffinitySet * TheCpuAffinitySet
Definition: CpuAffinity.cc:23
void CpuAffinityReconfigure()
reconfigure CPU affinity for this process
Definition: CpuAffinity.cc:38
class SquidConfig Config
Definition: SquidConfig.cc:12
#define Must(condition)
Definition: TextException.h:75
const std::vector< int > & processes() const
returns list of process numbers
CpuAffinitySet * calculateSet(const int targetProcess) const
calculate CPU set for this process
cpu affinity management for a single process
void undo()
undo CPU affinity changes for this process
void apply()
set CPU affinity for this process
CpuAffinityMap * cpuAffinityMap
Definition: SquidConfig.h:519
#define DBG_IMPORTANT
Definition: Stream.h:38
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Stream.h:194
int KidIdentifier
bool InDaemonMode()
Whether we are running in daemon mode.
Definition: tools.cc:690
int NumberOfKids()
number of Kid processes as defined in src/ipc/Kid.h
Definition: tools.cc:724

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors