1. 26 Mar, 2019 2 commits
    • jim warner's avatar
      library: tweak that lxc container support a final time · 2e7f3870
      jim warner authored
      Since the patch referenced below traded a compile-time
      'sizeof' directive for a run-time 'strlen' call, there
      is no need to declare lxc patterns as explicit arrays.
      
      We'll also use the actual lxc patterns by omitting the
      beginning slashes ('/') for both of those definitions.
      
      And, looking to the future when most/all lxc users are
      using the most recent lxc release, we will make things
      slightly more efficient by reversing those two pattern
      literals so the most recent pattern was checked first.
      
      Of course, such a change only benefits tasks which are
      running in a container. For the majority of processes,
      both literals will be compared in that 'if' statement,
      assuming the 'LXC' field is currently being displayed.
      
      [ plus, a leftover parenthesis pair has been removed ]
      
      Reference(s):
      commit f67127e7Signed-off-by: jim warner's avatarJim Warner <james.warner@comcast.net>
      2e7f3870
    • jim warner's avatar
  2. 04 Mar, 2019 8 commits
  3. 22 Jan, 2019 2 commits
    • jim warner's avatar
      top: improve logic surrounding 'smp_num_cpus' variable · 893793a8
      jim warner authored
      I thank Guido Jäkel for raising the issue cited in the
      merge request referenced below. While restoring 1 line
      of code would produce the desired results, it does not
      address the root cause of that problem he experienced.
      
      The variable 'smp_num_cpus' was set by libprocps via a
      sysconf(_SC_NPROCESSORS_ONLN) call. It was supposed to
      represent total number of processors currently online.
      It also served as the position in the Cpu_tics[] array
      where the /proc/stat line #1 (cpu summary) was stored.
      
      The variable 'Cpu_faux_tot' was valued by top based on
      total individual cpus parsed from the /proc/stat file.
      It serves as a fence post for Cpu_tics[] array access.
      
      The problem Guido experienced results from a disparity
      between those 2 variables, plus one instance where the
      wrong variable was used in the summary_show() routine.
      
      . Here is the real culprit, the actual incorrect code:
      . summary_hlp(&Cpu_tics[Cpu_faux_tot], N_txt(WORD_a...
      
      Which always should have been represented in this way:
      . summary_hlp(&Cpu_tics[smp_num_cpus], N_txt(WORD_a...
      
      ------------------------------------------------------
      The above 'disparity' might arise in any system when a
      cpu is taken offline since there's a 3 second delay in
      cpu and memory refreshes in an effort to reduce costs.
      Usually this particular condition will be short lived.
      
      However, there is a more persistent problem under lxc.
      
      If a host cpu is taken offline and then brought online
      again, within the container sysconf returns the proper
      number of online processors. But, /proc/stat does not!
      Sadly, I've yet to find a way to coax a container into
      refreshing its /proc/stat, short of reboting the host.
      
      [ might that represent a potential bug in lxc logic? ]
      
      Reference(s):
      !82Signed-off-by: jim warner's avatarJim Warner <james.warner@comcast.net>
      With-thanks-to: Guido Jäkel <G.Jaekel@DNB.DE>
      893793a8
    • jim warner's avatar
      library: adapt readproc for the latest lxc conventions · f67127e7
      jim warner authored
      The merge request shown below prompted (thankfully) an
      examination of our lxc containers logic in readproc.c.
      
      As it turns out, the lxc folks changed that eyecatcher
      used to identify containers within a task cgroup file.
      
      So this patch, with little extra cost, will enable the
      libprocps lxc_containers() guy to handle both strings.
      
      [ additionally, I was shocked to find lxc allows the ]
      [ eyecatcher to be changed at ./configure time. such ]
      [ a provision has always existed. unfortunately, the ]
      [ changed value was only available to root, assuming ]
      [ one wished to tackle that undocumented liblxc api. ]
      
      Reference(s):
      . what prompted lxc support reevaluation
      !82
      . original lxc support introduced
      commit 0557504fSigned-off-by: jim warner's avatarJim Warner <james.warner@comcast.net>
      f67127e7
  4. 02 Jan, 2019 3 commits
    • jim warner's avatar
      top: harden management of 'Hide_pid' array allocations · dbe12b54
      jim warner authored
      While setting the size of that Hide_pid array to equal
      total pids high water mark was probably safe, in truth
      there is no real relationship. At some point one could
      exceed that HWM if the 'v' toggle was used extensively
      and at least 1 of those entries remained non-negative.
      
      This commit simply divorces Hide_tot from the pids HWM
      and bases Hide_pid array size on actual run-time need.
      Signed-off-by: jim warner's avatarJim Warner <james.warner@comcast.net>
      dbe12b54
    • jim warner's avatar
      top: enable alternate '+' placement with collapsed pid · d8a0ab8b
      jim warner authored
      Currently, except for tasks that have no parents, when
      a process' children are collapsed the '+' indicator is
      shown in the first position within that COMMAND field.
      
      This commit simply provides for indenting the '+' char
      so it displays next to that program name/command line.
      Signed-off-by: jim warner's avatarJim Warner <james.warner@comcast.net>
      d8a0ab8b
    • jim warner's avatar
      top: plug a minor hole in the vertical scrolling logic · 664d2517
      jim warner authored
      In that commit referenced below, a few edge cases were
      addressed regarding vertical positioning involving any
      'hidden' tasks. But, 2 additional edge cases remained.
      
      In a running top, if the user employed 'other filters'
      (o/O) or 'user filters' (u/U) proper vertical position
      was not ensured. And, while this could be easily fixed
      by striking the home/end or up/down arrow keys, it was
      very poor etiquette to shift this burden to the users.
      
      So, this patch plugs that gap, automating the process.
      
      Reference(s):
      commit c6e68e2fSigned-off-by: jim warner's avatarJim Warner <james.warner@comcast.net>
      664d2517
  5. 12 Sep, 2018 3 commits
    • jim warner's avatar
      top: a tweak to the forest view collapsed code (again) · b3b7a350
      jim warner authored
      From the outset, top has tried to provide some minimal
      garbage collection in support of forest view collapse.
      For example, with every 'v' keystroke, a check is made
      of the currently targeted pids.  If all were negative,
      which means expanded, that Hide_pid array was emptied.
      
      Recently, yet another efficiency was added wherein the
      continuing scan for a targeted pid was terminated when
      a match was found. But, one more inefficiency existed.
      
      When a task which was subject to collapse under forest
      view mode has disappeared (ended), repeatedly scanning
      for such a pid with each iteration makes little sense.
      
      So this commit will negate such targeted pids and thus
      avoid scanning every current task looking for a match.
      Then, if 'v' is ever stuck at some point in the future
      there will be a chance to empty that Hide_pid[] array.
      
      [ hopefully this will be a final tweak of the forest ]
      [ view collapse stuff, but cross your fingers anyway ]
      Signed-off-by: jim warner's avatarJim Warner <james.warner@comcast.net>
      b3b7a350
    • jim warner's avatar
      top: the '#define PRETEND2_5_X' was found to be broken · 2b82cbfc
      jim warner authored
      Our newlib branch has already dropped support for such
      old kernels. However, the master branch still supports
      them. So this patch will correct a broken #define that
      is used to influence the top Summary Area information.
      Signed-off-by: jim warner's avatarJim Warner <james.warner@comcast.net>
      2b82cbfc
    • jim warner's avatar
      top: the '#define SCROLLVAR_NO' is bent but not broken · 86611b46
      jim warner authored
      This patch simply avoids an 'unused' variable warning.
      Signed-off-by: jim warner's avatarJim Warner <james.warner@comcast.net>
      86611b46
  6. 13 Aug, 2018 2 commits
  7. 08 Aug, 2018 5 commits
  8. 01 Aug, 2018 3 commits
  9. 18 Jul, 2018 3 commits
  10. 17 Jul, 2018 3 commits
    • jim warner's avatar
    • jim warner's avatar
      top: parent total cpu includes collapsed children, pgm · 3da73186
      jim warner authored
      Now, when a parent's children have been collapsed, the
      cpu used by those unseen tasks will disappear no more.
      Instead such tics will be added to the parent's total.
      
      [ if one wished a return to the 'land of lost tics', ]
      [ the '#define TREE_VCPUOFF' directive is available. ]
      
      ------------------------------------------------------
      Note: With collapsible parents now displaying children
      cpu usage, it will eventually be noticed the cpu stats
      for the summary area and task areas often vary widely.
      
      It's worth a reminder that for top's summary area each
      individual cpu and the cpu summary is limited to 100%,
      regardless of how many tics a linux kernel may export.
      
      An individual task is limited to 100% times the number
      of threads. But, in no case will cpu usage ever exceed
      100% times total number of processors. Such limits are
      further reduced under 'Solaris' mode ('I' toggle off).
      In this mode, a task cpu usage will never exceed 100%.
      These limits will now also apply to collapsed parents.
      
      In addition to those influences, results are subjected
      to kernel timer sampling anomalies and the distortions
      inherent in a small sample size, made worse by smaller
      delay intervals. Often there is just 1 or 2 tics for a
      few tasks at smaller intervals such as: 1/10th second.
      
      Anyway, should questions on this subject arise, a good
      starting point, beyond the reminders above, is the 1st
      link listed below. Those other links were derivatives.
      
      Reference(s):
      . from the kernel documentation
      https://www.kernel.org/doc/Documentation/cpu-load.txt
      . as mentioned in the above kernel documentation
      https://lkml.org/lkml/2007/2/12/6
      . from above, with many more links on the subject
      https://www.boblycat.org/~malc/apc/Signed-off-by: jim warner's avatarJim Warner <james.warner@comcast.net>
      
      top: parent total cpu includes collapsed children, pgm
      3da73186
    • jim warner's avatar
      top: a refactor to prepare for including collapsed cpu · e66c3679
      jim warner authored
      So that the impact (minimal) of the next commit can be
      isolated, this commit just involves a little renaming,
      reformat plus a refactor of some proc_t pointer logic.
      
      [ renaming, relocation and changes to 'user_matched' ]
      [ wasn't strictly necessary, but now mirrors newlib. ]
      Signed-off-by: jim warner's avatarJim Warner <james.warner@comcast.net>
      e66c3679
  11. 26 Jun, 2018 1 commit
    • jim warner's avatar
      top: a few tweaks for those scrolling (mostly) changes · c6e68e2f
      jim warner authored
      This patch just addresses some edge cases with respect
      to 'unseen' tasks. Given the ability to preserve other
      filters in the rcfile, it's entirely possible the very
      first task(s) may not be visible at top startup. Also,
      when switching between windows ('a'/'w') we should try
      to always position its row #1 on some visible process.
      
      Lastly, a window might have *NO* visible tasks at all.
      Therefore, protect 'window_hlp' from an infinite loop.
      Signed-off-by: jim warner's avatarJim Warner <james.warner@comcast.net>
      c6e68e2f
  12. 23 Jun, 2018 5 commits