Uploaded image for project: 'RHEL'
  1. RHEL
  2. RHEL-79923

lsof takes forever spinning on the CPU when having a high "nofile" limit

Linking RHIVOS CVEs to...Migration: Automation ...SWIFT: POC ConversionSync from "Extern...XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Undefined Undefined
    • None
    • rhel-9.5
    • lsof
    • None
    • No
    • Important
    • rhel-plumbers
    • ssg_core_services
    • 24
    • 26
    • 3
    • False
    • False
    • Hide

      None

      Show
      None
    • None
    • None
    • None
    • None
    • Unspecified
    • Unspecified
    • Unspecified
    • None

      What were you trying to do that didn't work?

      When having a high nofile limit, lsof spends its time closing non-existent file descriptors before proceeding. The operation can take several minutes and consumes a single CPU entirely, generating unnecessary load.

      This got fixed Upstream through following commit:

      commit b953ba3b1a93fc44771b900ff519931e3380aa82
      Author: Marc <34656315+MarcT512@users.noreply.github.com>
      Date:   Wed May 15 11:33:23 2024 +0100
      
          Add files via upload
          
          Add an optimized fallback in closefrom_shim() for Linux, if the platform doesn't support closefrom or close_range.
          Iterate /proc/self/fd and close anything which is not that directory itself.
      

      What is the impact of this issue to you?

      Cannot execute lsof in a timely manner

      Please provide the package NVR for which the bug is seen:

      lsof-4.94.0-3

      How reproducible is this bug?:

      Always

      Steps to reproduce

      1. Execute lsof after changing the nofile limit
        # ulimit -n 1073741816
        # lsof
        

      Expected results

      Almost immediate return.

      Actual results

      100% CPU consumed for several minutes.

              jrybar@redhat.com Jan Rybar
              rhn-support-rmetrich Renaud Métrich
              Jan Rybar Jan Rybar
              RHEL CS Plumbers QE Bot RHEL CS Plumbers QE Bot
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated: