Bug 231732

Summary: net-mgmt/net-snmp: hrSWRunEntry, don't list kernel threads
Product: Ports & Packages Reporter: Ben RUBSON <ben.rubson>
Component: Individual Port(s)Assignee: Ryan Steinmetz <zi>
Status: Closed Overcome By Events    
Severity: Affects Some People CC: pi
Priority: --- Flags: bugzilla: maintainer-feedback? (zi)
Version: Latest   
Hardware: Any   
OS: Any   

Description Ben RUBSON 2018-09-26 11:04:08 UTC

When browsing hrSWRunEntry (, many "kernel" processes are returned.
I have servers with around 100 user processes, and 1000 kernel threads, making hrSWRunEntry SNMP requests very slow.

KVM_GETPROCS(3) helped me to find the following solution :
find /usr/ports/net-mgmt/net-snmp -type f \
    -exec grep -q KERN_PROC_ALL {} \; -ls \
    -exec sed -i "" 's/KERN_PROC_ALL/KERN_PROC_PROC/g' {} \;

hrSWRunEntry requests now take around 0.5 second instead of sometimes more than 20 !

Could we then think about disabling kernel threads in hrSWRunEntry ?
I see no reason to keep them.

Thank you very much !

Comment 1 Ryan Steinmetz freebsd_committer freebsd_triage 2018-09-26 13:36:15 UTC
Did you find a configure option or the like that accomplishes what you're after?
Comment 2 Ben RUBSON 2018-09-26 13:50:59 UTC
No, I had to recompile the net-snmp package after having modified the sources with the command above.
It replaces the hard-coded op parameter to kvm_getprocs(), from KERN_PROC_ALL to KERN_PROC_PROC.

  struct kinfo_proc * kvm_getprocs(kvm_t *kd, int op, int arg, int *cnt);
  The value of op describes the filtering predicate as follows:
    KERN_PROC_ALL    all processes and kernel visible threads
    KERN_PROC_PROC   all processes, without threads
Comment 3 Ryan Steinmetz freebsd_committer freebsd_triage 2018-09-26 16:48:55 UTC
I think the best next steps for this are to submit a patch upstream to the net-snmp developers.  Potentially making this a configure knob, if we think there are people that would want to see the kernel threads as well.

Once they've committed something, I'm happy to backport it into the port.  However, I'd prefer to avoid having additional locally-maintained-only patches.
Comment 4 Ben RUBSON 2018-09-30 16:35:31 UTC
Thank you Ryan for your feedback, you're right.
I then just opened an upstream bug / feature request :
Comment 5 Ben RUBSON 2018-12-31 19:37:06 UTC
So, a patch has been pushed upstream, in 5.8 version.
Current port version seems to be 5.7.

We'll then be able to close this bug report once port updated to 5.8.
Thank you !
Comment 6 Kurt Jaeger freebsd_committer 2019-09-28 18:47:07 UTC
The patch was added to upstream after the 5.8 release, so it's still pending.
Comment 7 Ryan Steinmetz freebsd_committer freebsd_triage 2020-09-12 13:00:41 UTC
Handled as part of the 5.9 update