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.
Description of problem:
When matching on process owner, command name, and possibly in some other situations, pgrep and pkill enable too many / incorrect PROC_FILL* flags. This can lead to poor performance and unnecessary blocking.
Version-Release number of selected component (if applicable):
procps-3.2.8-25.el6.x86_64
How reproducible:
Always
Steps to Reproduce:
Test 1:
strace -e trace=file pgrep httpd
Test 2:
strace -e trace=file pgrep -u apache
Actual results:
In test 1, observe that /proc/<pid>/status and /proc/<pid>/cmdline are opened for processes.
In test 2, observe that /proc/<pid>/status is opened for all processes owned by apache
Expected results:
In the first case, there is no need to open /proc/<pid>/cmdline, and it may be faster to use /proc/<pid>/stat rather than status (I'm unsure on the second point).
In the second case, neither /proc/<pid>/stat nor /proc/<pid>/status is required.
Additional info:
I've tested changing the flag logic in pgrep.c:do_openproc, and the change seems trivial, but the exact patch depends on whether stat or status is really the preferred way to match process names.
The proposed modification can affect the internal logic and cause regressions in corner case scenarios. The internal filling/matching logic will have to be redesigned completely as some of the fill flags lead to duplicating/overwriting of the fields and it's difficult to track that. We (reporter and I) decided to wait till the mess is resolved upstream in order to avoid breaking things.