Opened 8 years ago

Closed 7 years ago

#8002 closed defect (fixed)

Mis-count of CPUs

Reported by: tmpname0901 Owned by:
Priority: Medium Milestone: Tor: 0.2.4.x-final
Component: Core Tor/Tor Version: Tor: 0.2.3.25
Severity: Keywords: SMP tor-relay easy
Cc: Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description

On start-up Tor v0.2.3.25/Linux says:

"[notice] Wow! I detected that you have 64 CPUs. I will not autodetect any more than 16, though. If you want to configure more, set NumCPUs in your torrc"

This is in a CentOS6/OpenVZ VPS with only a single virtual CPU. Tor config param NumCPUs is not used.

It turns out that OpenVZ, since version rhel6/042stab061.2, lists all the *host* CPUs in /sys/devices/system/cpu/. It is this number of processors that is returned by the sysconf(_SC_NPROCESSORS_CONF) that Tor uses in ~/tor-0.2.3.25/src/common/compat.c to determine CPU count.

From the command line:

# getconf _NPROCESSORS_ONLN
1

Programmatically:

$ /tmp/main
sysconf() says: 64
Wow, too many CPUs: 64

I know that there's not much you can do about a sysconf() that lies. I want to get this on the record, though, for the sake of Tor's future auto-scaling.

Child Tickets

Attachments (1)

main.c (570 bytes) - added by tmpname0901 8 years ago.
Test app demonstrating erroneous CPU count

Download all attachments as: .zip

Change History (4)

Changed 8 years ago by tmpname0901

Attachment: main.c added

Test app demonstrating erroneous CPU count

comment:1 Changed 8 years ago by nickm

Keywords: tor-relay easy added
Milestone: Tor: 0.2.3.x-finalTor: 0.2.4.x-final

Seems like we might want to look at _NPROCESSORS_ONLN instead to be conservative, and when the two values differ, use the ONLN one and log a notice message.

comment:2 Changed 7 years ago by nickm

Status: newneeds_review

Small fix in branch "bug8002" in my public repository.

comment:3 Changed 7 years ago by nickm

Resolution: fixed
Status: needs_reviewclosed

Andrea says it looks good; merging.

Note: See TracTickets for help on using tickets.