Skip to content

Commit

Permalink
Rename chromeos::system::NumberOfProcessorsForCoreScheduling()
Browse files Browse the repository at this point in the history
Now that crosvm provides two modes for core scheduling (per-VM
and per-vCPU), the function name is a bit confusing. This CL renames
that to chromeos::system::NumberOfPhysicalCores() to make it less
confusing.

BUG=b:194022819
TEST=try

Change-Id: Idf719242df37fb20238a21f087acced20fcf1a5b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3215012
Reviewed-by: Lei Zhang <[email protected]>
Reviewed-by: Xiyuan Xia <[email protected]>
Reviewed-by: Joel Hockey <[email protected]>
Commit-Queue: Yusuke Sato <[email protected]>
Cr-Commit-Position: refs/heads/main@{#930279}
  • Loading branch information
yusukes authored and Chromium LUCI CQ committed Oct 11, 2021
1 parent 4e0d0c5 commit 3aee17d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
4 changes: 2 additions & 2 deletions base/threading/thread_restrictions.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class BlockingMethodCaller;
namespace system {
class StatisticsProviderImpl;
bool IsCoreSchedulingAvailable();
int NumberOfProcessorsForCoreScheduling();
int NumberOfPhysicalCores();
}
}
namespace chrome_cleaner {
Expand Down Expand Up @@ -473,7 +473,7 @@ class BASE_EXPORT ScopedAllowBlocking {
friend Profile* ::GetLastProfileMac(); // crbug.com/1176734
friend bool PathProviderWin(int, FilePath*);
friend bool chromeos::system::IsCoreSchedulingAvailable();
friend int chromeos::system::NumberOfProcessorsForCoreScheduling();
friend int chromeos::system::NumberOfPhysicalCores();

ScopedAllowBlocking(const Location& from_here = Location::Current());
~ScopedAllowBlocking();
Expand Down
2 changes: 1 addition & 1 deletion chromeos/system/core_scheduling.cc
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ bool IsCoreSchedulingAvailable() {
return has_vulns;
}

int NumberOfProcessorsForCoreScheduling() {
int NumberOfPhysicalCores() {
// cat /sys/devices/system/cpu/cpu[0-9]*/topology/thread_siblings_list |\
// sort -u | wc -l
static const int num_physical_cores = []() {
Expand Down
6 changes: 4 additions & 2 deletions chromeos/system/core_scheduling.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ void CHROMEOS_EXPORT EnableCoreSchedulingIfAvailable();
// vulnerable.
bool CHROMEOS_EXPORT IsCoreSchedulingAvailable();

// Returns number of physical cores.
int CHROMEOS_EXPORT NumberOfProcessorsForCoreScheduling();
// Returns number of physical cores. This is useful when deciding the number of
// crosvm vCPUs for devices with per-vCPU core scheduling. When the device uses
// per-VM core scheduling, use base::SysInfo::NumberOfProcessors() instead.
int CHROMEOS_EXPORT NumberOfPhysicalCores();

} // namespace system
} // namespace chromeos
Expand Down
11 changes: 5 additions & 6 deletions components/arc/session/arc_vm_client_adapter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -906,12 +906,11 @@ class ArcVmClientAdapter : public ArcClientAdapter,
// use, set |cpus| to the number of physical cores. Otherwise, set the
// variable to the number of logical cores minus the ones disabled by
// chrome://flags/#scheduler-configuration.
const int32_t cpus =
(chromeos::system::IsCoreSchedulingAvailable() &&
!use_per_vm_core_scheduling)
? chromeos::system::NumberOfProcessorsForCoreScheduling()
: base::SysInfo::NumberOfProcessors() -
start_params_.num_cores_disabled;
const int32_t cpus = (chromeos::system::IsCoreSchedulingAvailable() &&
!use_per_vm_core_scheduling)
? chromeos::system::NumberOfPhysicalCores()
: base::SysInfo::NumberOfProcessors() -
start_params_.num_cores_disabled;
DCHECK_LT(0, cpus);

std::vector<std::string> kernel_cmdline = GenerateKernelCmdline(
Expand Down

0 comments on commit 3aee17d

Please sign in to comment.