Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1849215

Summary: Parse the number of cpus correctly on s390
Product: Red Hat Enterprise Linux 8 Reporter: John Kacur <jkacur>
Component: python-linux-procfsAssignee: John Kacur <jkacur>
Status: CLOSED ERRATA QA Contact: Mike Stowell <mstowell>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 8.3CC: akhisti, bhu, kcarcia, qzhao, rt-maint
Target Milestone: rcFlags: pm-rhel: mirror+
Target Release: 8.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: python-linux-procfs-0.6.2-1.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-11-04 02:09:48 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1823810    
Attachments:
Description Flags
Parse the number of cpus correctly none

Description John Kacur 2020-06-19 20:50:21 UTC
bpython-linux-procfs: Parse the number of cpus correctly on s390(x)
    
    Getting the number of cpus breaks on s390 and s390x due to differences
    in /proc/cpuinfo
    
    This can cause problems in other programs such as tuna when running
    tuna --cpus=1 --isolate
    for example
    
    Fix this by testing whether we are on s390 and increasing the cpu count
    if we match "cpu number"

Comment 1 John Kacur 2020-06-19 20:58:11 UTC
Created attachment 1698175 [details]
Parse the number of cpus correctly

Comment 2 Qiao Zhao 2020-06-22 07:24:50 UTC
Hi John,

I try to reproduce/test this problem on s390x, but I met problem when use tuna command:
# tuna --cpus=1 --isolate
Function: isolate_cpus , Invalid argument

# rpm -q tuna python3-linux-procfs
tuna-0.14-4.el8.noarch
python3-linux-procfs-0.6-7.el8.noarch

Is there anything wrong with my steps?

- Qiao

Comment 3 Mike Stowell 2020-06-22 13:50:01 UTC
Hi Qiao,

I believe the tuna error in comment #2 is actually proving the issue exists, whereas the patch should fix this issue.

On this particular s390x system with 2 cores:

	# cat /proc/cpuinfo
 
	[...snip...]

	processor 0: version = FF,  identification = 3433E8,  machine = 2964
	processor 1: version = FF,  identification = 3433E8,  machine = 2964

	cpu number      : 0
	cpu MHz dynamic : 5000
	cpu MHz static  : 5000

	cpu number      : 1
	cpu MHz dynamic : 5000
	cpu MHz static  : 5000

If we look at the function in procfs.py the patch touches and have it print the cpuinfo class properties, we see:

	# tuna --cpus=1 --isolate
	self.nr_cpus = 0, self.nr_sockets = 0.0, self.nr_cores = 0.0      <----------
	Function: isolate_cpus , Invalid argument

So before the patch, python-linux-procfs tells us the system has 0 CPUs.  This is because on x86_64 systems in /proc/cpuinfo output, we count the number of times 'processor' appears before a ':' in each line output, which does not occur in above output (note for s390x it prints "processor <#>:" ...).

After the patch, nr_cpus increases for s390x systems on each occurrence of the line 'cpu number' before a ':', which in the above output, will (correctly) be 2 CPUs.  Then the tuna command should be able to proceed.

Comment 4 John Kacur 2020-06-22 16:18:16 UTC
(In reply to Qiao Zhao from comment #2)
> Hi John,
> 
> I try to reproduce/test this problem on s390x, but I met problem when use
> tuna command:
> # tuna --cpus=1 --isolate
> Function: isolate_cpus , Invalid argument
> 
> # rpm -q tuna python3-linux-procfs
> tuna-0.14-4.el8.noarch
> python3-linux-procfs-0.6-7.el8.noarch
> 
> Is there anything wrong with my steps?
> 
> - Qiao

No, you did it perfectly. You have correctly reproduced the problem. :)

Comment 5 John Kacur 2020-06-22 16:19:00 UTC
(In reply to Mike Stowell from comment #3)
> Hi Qiao,
> 
> I believe the tuna error in comment #2 is actually proving the issue exists,
> whereas the patch should fix this issue.
> 
> On this particular s390x system with 2 cores:
> 
> 	# cat /proc/cpuinfo
>  
> 	[...snip...]
> 
> 	processor 0: version = FF,  identification = 3433E8,  machine = 2964
> 	processor 1: version = FF,  identification = 3433E8,  machine = 2964
> 
> 	cpu number      : 0
> 	cpu MHz dynamic : 5000
> 	cpu MHz static  : 5000
> 
> 	cpu number      : 1
> 	cpu MHz dynamic : 5000
> 	cpu MHz static  : 5000
> 
> If we look at the function in procfs.py the patch touches and have it print
> the cpuinfo class properties, we see:
> 
> 	# tuna --cpus=1 --isolate
> 	self.nr_cpus = 0, self.nr_sockets = 0.0, self.nr_cores = 0.0     
> <----------
> 	Function: isolate_cpus , Invalid argument
> 
> So before the patch, python-linux-procfs tells us the system has 0 CPUs. 
> This is because on x86_64 systems in /proc/cpuinfo output, we count the
> number of times 'processor' appears before a ':' in each line output, which
> does not occur in above output (note for s390x it prints "processor <#>:"
> ...).
> 
> After the patch, nr_cpus increases for s390x systems on each occurrence of
> the line 'cpu number' before a ':', which in the above output, will
> (correctly) be 2 CPUs.  Then the tuna command should be able to proceed.

Yes, good analysis

Comment 13 errata-xmlrpc 2020-11-04 02:09:48 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (python-linux-procfs bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2020:4584