From 8c80aee0f66f37afd4c85a97e79a188f9c055faacc5167ff386ce01179ab31bb Mon Sep 17 00:00:00 2001 From: "Dr. Werner Fink" Date: Tue, 2 Mar 2010 15:33:21 +0000 Subject: [PATCH] . OBS-URL: https://build.opensuse.org/package/show/Base:System/procps?expand=0&rev=21 --- procps-3.2.7-accuracy.dif | 2 +- procps-3.2.7-oom.diff | 226 ++++++++++++++++++++++++++++ procps-3.2.8-gcc45.diff | 17 --- procps-3.2.8-pmap-smaps-rml-2.patch | 39 +++-- procps.changes | 23 +++ procps.spec | 8 +- sysctl.conf.s390 | 5 + 7 files changed, 288 insertions(+), 32 deletions(-) create mode 100644 procps-3.2.7-oom.diff delete mode 100644 procps-3.2.8-gcc45.diff create mode 100644 sysctl.conf.s390 diff --git a/procps-3.2.7-accuracy.dif b/procps-3.2.7-accuracy.dif index 1345d87..169db61 100644 --- a/procps-3.2.7-accuracy.dif +++ b/procps-3.2.7-accuracy.dif @@ -69,7 +69,7 @@ - return snprintf(outbuf, COLWID, "%u", pcpu/10U); + jiffies = jiffies_since_boot - pp->start_time; + if(jiffies) pcpu = (total_time * 1000ULL) / jiffies; -+ if (pcpu/10U => 100U) /* do not confuse the user by scale effects */ ++ if (pcpu/10U >= 100U) /* do not confuse the user by scale effects */ + return snprintf(outbuf, COLWID, "100"); return snprintf(outbuf, COLWID, "%u.%u", pcpu/10U, pcpu%10U); } diff --git a/procps-3.2.7-oom.diff b/procps-3.2.7-oom.diff new file mode 100644 index 0000000..5ae9dc4 --- /dev/null +++ b/procps-3.2.7-oom.diff @@ -0,0 +1,226 @@ +Index: procps-3.2.7/top.c +=================================================================== +--- procps-3.2.7.orig/top.c ++++ procps-3.2.7/top.c +@@ -23,9 +23,9 @@ + #include + #include + #include + #include +-#include ++// #include + #include + #include + #include + #include +@@ -223,8 +223,11 @@ SCB_NUM1(P_SHR, share) + SCB_NUM1(P_FLT, maj_flt) + SCB_NUM1(P_DRT, dt) + SCB_NUMx(P_STA, state) + ++SCB_NUM1(P_OOM, oom_score) ++SCB_NUM1(P_OOA, oom_adj) ++ + static int sort_P_CMD (const proc_t **P, const proc_t **Q) + { + /* if a process doesn't have a cmdline, we'll consider it a kernel thread + -- since displayed tasks are given special treatment, we must too */ +@@ -315,8 +318,13 @@ static const char *tg2 (int x, int y) + { + return Cap_can_goto ? tgoto(cursor_address, x, y) : ""; + } + ++/* isupper/islower/toupper/tolower that work for '[{', '\\|', ']}', '^~' */ ++#define isupper(x) (x < 'a'? 1: 0) ++#define islower(x) (x >= 'a'? 1: 0) ++#define toupper(x) (x < 'a'? x: x-32) ++#define tolower(x) (x >= 'a'? x: x+32) + + /*###### Exit/Interrput routines #######################################*/ + + // The usual program end -- called only by functions in this section. +@@ -1220,8 +1228,9 @@ static proc_t **procs_refresh (proc_t ** + // (own identifiers as documentation and protection against changes) + #define L_stat PROC_FILLSTAT + #define L_statm PROC_FILLMEM + #define L_status PROC_FILLSTATUS ++#define L_oom PROC_FILLOOM + #define L_CMDLINE L_EITHER | PROC_FILLARG + #define L_EUSER PROC_FILLUSR + #define L_RUSER L_status | PROC_FILLUSR + #define L_GROUP L_status | PROC_FILLGRP +@@ -1273,8 +1282,10 @@ static FLD_t Fieldstab[] = { + { "XxXx", " COMMAND", " %-*.*s", -1, -1, SF(CMD), "Command name/line", L_EITHER }, + { "YyUu", " WCHAN ", " %-9.9s", -1, -1, SF(WCH), "Sleeping in Function", L_stat }, + // next entry's special: the 0's will be replaced with '.'! + { "ZzZz", " Flags ", " %08lx", -1, -1, SF(FLG), "Task Flags ", L_stat }, ++ { "[{[{", " Badness", "%8d", -1, -1, SF(OOM), "oom_score (badness)", L_oom }, ++ { "\\|\\|", " Adj", " %3d", -1, -1, SF(OOA), "oom_adjustment (2^X)", L_oom }, + #if 0 + { "..Qq", " A", " %4.4s", 4, SK_no, SF(PID), "Accessed Page count", L_stat }, + { "..Nn", " TRS", " %4.4s", 4, SK_Kb, SF(PID), "Code in memory (kb)", L_stat }, + { "..Rr", " WP", " %4.4s", 4, SK_no, SF(PID), "Unwritable Pages", L_stat }, +@@ -1285,8 +1296,10 @@ static FLD_t Fieldstab[] = { + #endif + }; + #undef SF + ++/* Last valid lowercase letter (z is folowed by {|}~, Z by [\\]^) */ ++#define LAST_CHR '|' + + /* All right, those-that-follow -- Listen Up! + * For the above table keys and the following present/future rc file + * compatibility support, you have Mr. Albert D. Cahalan to thank. +@@ -1419,8 +1432,21 @@ static int rc_read_new (const char *cons + RCW_t *ptr = &rc->win[i]; + cnt = sscanf(cp, "%3s\tfieldscur=%31s\n", ptr->winname, ptr->fieldscur); + if (cnt != 2) return 5+100*i; // OK to have less than 4 windows + if (WINNAMSIZ <= strlen(ptr->winname)) return -6; ++ /* Handle upgrade */ ++ if (strlen(DEF_FIELDS) - strlen(ptr->fieldscur) == 2) { ++ const int ln = strlen(ptr->fieldscur); ++ const unsigned char last = ptr->fieldscur[ln-1]; ++ /* If last field is command, insert two new fields prior to it */ ++ if (last == 'x' || last == 'X') { ++ ptr->fieldscur[ln-1] = '{'; ++ ptr->fieldscur[ln ] = '|'; ++ ptr->fieldscur[ln+1] = last; ++ ptr->fieldscur[ln+2] = 0; ++ } else ++ strcat(ptr->fieldscur, "{|"); ++ } + if (strlen(DEF_FIELDS) != strlen(ptr->fieldscur)) return -7; + cp = strchr(cp, '\n'); + if (!cp++) return -(8+100*i); + +@@ -1694,9 +1720,9 @@ static void confighlp (char *fields) { + else lower[c&0x1f]++; + } + + c = 'a'; +- while (c <= 'z') { ++ while (c <= LAST_CHR) { + if (upper[c&0x1f] && lower[c&0x1f]) { + lower[c&0x1f] = 0; // got both, so wipe out unseen column + for (;;) { + cp = strchr(fields, c); +@@ -3198,9 +3224,14 @@ static void task_show (const WIN_t *q, c + } else { + MKCOL(lookup_wchan(p->wchan, p->XXXID)); + } + break; +- ++ case P_OOM: ++ MKCOL(p->oom_score); ++ break; ++ case P_OOA: ++ MKCOL(p->oom_adj); ++ break; + } /* end: switch 'procflag' */ + + rp = scat(rp, cbuf+advance); + } /* end: for 'maxpflgs' */ +Index: procps-3.2.7/top.h +=================================================================== +--- procps-3.2.7.orig/top.h ++++ procps-3.2.7/top.h +@@ -250,9 +250,10 @@ enum pflag { + P_PRI, P_NCE, + P_CPN, P_CPU, P_TME, P_TM2, + P_MEM, P_VRT, P_SWP, P_RES, P_COD, P_DAT, P_SHR, + P_FLT, P_DRT, +- P_STA, P_CMD, P_WCH, P_FLG ++ P_STA, P_CMD, P_WCH, P_FLG, ++ P_OOM, P_OOA, + }; + + + /////////////////////////////////////////////////////////////////////////// +@@ -350,15 +351,15 @@ typedef struct WIN_t { + #define RCF_EYECATCHER "RCfile for " + #define RCF_DEPRECATED "Id:a, " + + // The default fields displayed and their order, +-#define DEF_FIELDS "AEHIOQTWKNMbcdfgjplrsuvyzX" ++#define DEF_FIELDS "AEHIOQTWKNMbcdfgjplrsuvyz{|X" + // Pre-configured field groupss +-#define JOB_FIELDS "ABcefgjlrstuvyzMKNHIWOPQDX" +-#define MEM_FIELDS "ANOPQRSTUVbcdefgjlmyzWHIKX" +-#define USR_FIELDS "ABDECGfhijlopqrstuvyzMKNWX" ++#define JOB_FIELDS "ABcefgjlrstuvyzMKNHIWOPQD{|X" ++#define MEM_FIELDS "ANOPQRSTUVbcdefgjlmyzWHIK{|X" ++#define USR_FIELDS "ABDECGfhijlopqrstuvyzMKNW{|X" + // Used by fields_sort, placed here for peace-of-mind +-#define NUL_FIELDS "abcdefghijklmnopqrstuvwxyz" ++#define NUL_FIELDS "abcdefghijklmnopqrstuvwxyz{|" + + + // The default values for the local config file + #define DEF_RCFILE { \ +Index: procps-3.2.7/proc/readproc.h +=================================================================== +--- procps-3.2.7.orig/proc/readproc.h ++++ procps-3.2.7/proc/readproc.h +@@ -138,9 +138,11 @@ typedef struct proc_t { + fuid, fgid, // status fs (used for file access only) + tpgid, // stat terminal process group id + exit_signal, // stat might not be SIGCHLD + processor; // stat current (or most recent?) CPU +- char **cgroup; // cgroup current cgroup, looks like a classic filepath ++ int oom_score, // oom_score (badness for OOM killer) ++ oom_adj; // oom_adj (adjustment to OOM score) ++ char **cgroup; // cgroup current cgroup, looks like a classic filepath + } proc_t; + + // PROCTAB: data structure holding the persistent information readproc needs + // from openproc(). The setup is intentionally similar to the dirent interface +@@ -240,8 +242,9 @@ extern proc_t * get_proc_stats(pid_t pid + + #define PROC_LOOSE_TASKS 0x0200 // threat threads as if they were processes + + #define PROC_FILLCGROUP 0x0400 // alloc and fill in `cgroup` ++#define PROC_FILLOOM 0x0800 // alloc and fill in oom_score, oom_adj + + // Obsolete, consider only processes with one of the passed: + #define PROC_PID 0x1000 // process id numbers ( 0 terminated) + #define PROC_UID 0x4000 // user id numbers ( length needed ) +Index: procps-3.2.7/proc/readproc.c +=================================================================== +--- procps-3.2.7.orig/proc/readproc.c ++++ procps-3.2.7/proc/readproc.c +@@ -331,8 +331,19 @@ ENTER(0x220); + LEAVE(0x220); + } + + /////////////////////////////////////////////////////////////////////// ++static void oomscore2proc(const char* S, proc_t *restrict P) ++{ ++ sscanf(S, "%d", &P->oom_score); ++} ++ ++static void oomadj2proc(const char* S, proc_t *restrict P) ++{ ++ sscanf(S, "%d", &P->oom_adj); ++} ++ ++/////////////////////////////////////////////////////////////////////// + + // Reads /proc/*/stat files, being careful not to trip over processes with + // names like ":-) 1 2 3 4 5 6". + static void stat2proc(const char* S, proc_t *restrict P) { +@@ -616,8 +627,15 @@ static proc_t* simple_readproc(PROCTAB * + p->environ = file2strvec(path, "environ"); + else + p->environ = NULL; + ++ if (unlikely(flags & PROC_FILLOOM)) { ++ if (likely( file2str(path, "oom_score", sbuf, sizeof sbuf) != -1 )) ++ oomscore2proc(sbuf, p); ++ if (likely( file2str(path, "oom_adj", sbuf, sizeof sbuf) != -1 )) ++ oomadj2proc(sbuf, p); ++ } /* struct has been zeroed out before, so no worries about clearing garbage here */ ++ + if(linux_version_code>=LINUX_VERSION(2,6,24) && (flags & PROC_FILLCGROUP)) { + p->cgroup = file2strvec(path, "cgroup"); /* read /proc/#/cgroup */ + if(p->cgroup && *p->cgroup) { + int i = strlen(*p->cgroup); diff --git a/procps-3.2.8-gcc45.diff b/procps-3.2.8-gcc45.diff deleted file mode 100644 index 198c9e2..0000000 --- a/procps-3.2.8-gcc45.diff +++ /dev/null @@ -1,17 +0,0 @@ -Index: procps-3.2.8/ps/output.c -=================================================================== ---- procps-3.2.8.orig/ps/output.c -+++ procps-3.2.8/ps/output.c -@@ -463,11 +463,11 @@ static int pr_pcpu(char *restrict const - double uptime_secs; - total_time = pp->utime + pp->stime; - if(include_dead_children) total_time += (pp->cutime + pp->cstime); - jiffies = jiffies_since_boot - pp->start_time; - if(jiffies) pcpu = (total_time * 1000ULL) / jiffies; -- if (pcpu/10U => 100U) /* do not confuse the user by scale effects */ -+ if (pcpu/10U >= 100U) /* do not confuse the user by scale effects */ - return snprintf(outbuf, COLWID, "100"); - return snprintf(outbuf, COLWID, "%u.%u", pcpu/10U, pcpu%10U); - } - /* this is a "per-mill" format, like %cpu with no decimal point */ - static int pr_cp(char *restrict const outbuf, const proc_t *restrict const pp){ diff --git a/procps-3.2.8-pmap-smaps-rml-2.patch b/procps-3.2.8-pmap-smaps-rml-2.patch index 3c7210a..a144a47 100644 --- a/procps-3.2.8-pmap-smaps-rml-2.patch +++ b/procps-3.2.8-pmap-smaps-rml-2.patch @@ -1,5 +1,5 @@ --- pmap.1 -+++ pmap.1 2009-05-11 12:14:59.377902682 +0200 ++++ pmap.1 2009-05-11 10:14:59.377902682 +0000 @@ -1,39 +1,60 @@ -'\" t -.\" (The preceding line is a note to broken versions of man to tell @@ -91,8 +91,8 @@ +The procps package is maintained by Albert Calahan. Please send +bug reports to . --- pmap.c -+++ pmap.c 2009-06-16 16:28:36.169902773 +0200 -@@ -1,372 +1,405 @@ ++++ pmap.c 2010-03-02 15:16:14.000127413 +0000 +@@ -1,372 +1,421 @@ /* - * Copyright 2002 by Albert Cahalan; all rights reserved. - * This file may be used subject to the terms and conditions of the @@ -201,9 +201,6 @@ +#define OBJECTSIZE 1024 - if(shmdt(addr)) perror("shmdt"); -- --out_destroy: -- if(shmctl(shmid, IPC_RMID, NULL)) perror("IPC_RMID"); +struct smap { + unsigned long size; + unsigned long rss; @@ -214,6 +211,8 @@ + unsigned long private_dirty; + unsigned long referenced; + unsigned long swap; ++ unsigned long kernelpagesize; ++ unsigned long mmupagesize; +}; + +static unsigned long long range_low; @@ -247,7 +246,8 @@ + "display this help\n"); +} -- return; +-out_destroy: +- if(shmctl(shmid, IPC_RMID, NULL)) perror("IPC_RMID"); +static int get_smap_data(struct smap *smap) +{ + unsigned long long data; @@ -360,10 +360,25 @@ + if (!dopage) + goto out; + ++ /* get kernel page size */ + if (!fgets(buff, BUFFERSIZE, smaps_fp)) + return 1; ++ ++ assigned = sscanf(buff, "KernelPageSize: %lld", &data); ++ if (assigned != 1) ++ return 1; ++ smap->kernelpagesize = data; ++ ++ /* get MMU page size */ + if (!fgets(buff, BUFFERSIZE, smaps_fp)) + return 1; ++ ++ assigned = sscanf(buff, "MMUPageSize: %lld", &data); ++ if (assigned != 1) ++ return 1; ++ smap->mmupagesize = data; + +- return; +out: + return 0; } @@ -419,8 +434,7 @@ -static const char *mapping_name(proc_t *p, unsigned KLONG addr, unsigned KLONG len, const char *mapbuf, unsigned showpath, unsigned dev_major, unsigned dev_minor, unsigned long long inode){ - const char *cp; -+ printf("%c%c%c%c ", read_perm, write_perm, exec_perm, access_type); - +- - if(!dev_major && dev_minor==shm_minor && strstr(mapbuf,"/SYSV")){ - static char shmbuf[64]; - snprintf(shmbuf, sizeof shmbuf, " [ shmid=0x%Lx ]", inode); @@ -443,8 +457,7 @@ - if( (p->start_stack >= addr) && (p->start_stack <= addr+len) ) cp = " [ stack ]"; - return cp; -} -+ if (show_devices) -+ printf("%0*llx %02lx:%02lx ", WDT, offset, major, minor); ++ printf("%c%c%c%c ", read_perm, write_perm, exec_perm, access_type); -static int one_proc(proc_t *p){ - char buf[32]; @@ -582,7 +595,9 @@ - else printf(" total %8ldK\n", (total_shared + total_private_writeable + total_private_readonly) >> 10); - } - } -- ++ if (show_devices) ++ printf("%0*llx %02lx:%02lx ", WDT, offset, major, minor); + - return 0; + printf("%s\n", obj_buff); } diff --git a/procps.changes b/procps.changes index 41b8c0c..100f4e2 100644 --- a/procps.changes +++ b/procps.changes @@ -1,3 +1,26 @@ +------------------------------------------------------------------- +Tue Mar 2 16:24:46 CET 2010 - werner@suse.de + +- Add three changes from SLES11-SP1 (change for bnc#576073 is + the same as for bnc#513542) +- Include patch for fate##307524 into major patch of pmap +- Inlcude patch for gcc 4.5 into major patch for accuracy + +------------------------------------------------------------------- +Wed Feb 3 11:22:54 CET 2010 - kukuk@suse.de + +- Adjust pmap for new kernel [bnc#576073] + +------------------------------------------------------------------- +Wed Jan 20 13:58:43 CET 2010 - mmarek@suse.cz + +- Tune some kernel.sched_* variables on s390(x) (bnc#557307). + +------------------------------------------------------------------- +Thu Aug 27 15:28:22 UTC 2009 - garloff@novell.com + +- Add support for displaying oom_score (fate##307524). + ------------------------------------------------------------------- Mon Feb 22 22:25:48 CET 2010 - seife@opensuse.org diff --git a/procps.spec b/procps.spec index 6e49311..f378dc9 100644 --- a/procps.spec +++ b/procps.spec @@ -35,6 +35,7 @@ Source: http://procps.sourceforge.net/procps-%version.tar.bz2 Source1: boot.sysctl Source2: systat.xinetd Source3: sysctl.conf +Source4: sysctl.conf.s390 Patch: procps-3.2.3-make.diff Patch1: procps-3.2.2-100cpus.diff Patch2: procps-3.2.5-eof.diff @@ -65,7 +66,7 @@ Patch28: procps-3.2.6-xen.dif Patch29: procps-3.2.8-fdleak.dif Patch30: procps-3.2.8-sysctlerr.dif Patch31: procps-3.2.8-columns.dif -Patch32: procps-3.2.8-gcc45.diff +Patch32: procps-3.2.7-oom.diff BuildRoot: %{_tmppath}/%{name}-%{version}-build %description @@ -136,7 +137,10 @@ make DESTDIR=$RPM_BUILD_ROOT install install -d $RPM_BUILD_ROOT/etc/init.d $RPM_BUILD_ROOT/etc/xinetd.d install -m 755 %SOURCE1 $RPM_BUILD_ROOT/etc/init.d install -m 644 %SOURCE2 $RPM_BUILD_ROOT/etc/xinetd.d/systat -install -m 644 %SOURCE3 $RPM_BUILD_ROOT/etc +case "$RPM_ARCH" in +s390*) install -m 644 %SOURCE4 $RPM_BUILD_ROOT/etc/sysctl.conf ;; +*) install -m 644 %SOURCE3 $RPM_BUILD_ROOT/etc/sysctl.conf ;; +esac # clean unwanted files (coreutils) rm -f $RPM_BUILD_ROOT/bin/kill rm -f $RPM_BUILD_ROOT/usr/bin/uptime diff --git a/sysctl.conf.s390 b/sysctl.conf.s390 new file mode 100644 index 0000000..1eaa590 --- /dev/null +++ b/sysctl.conf.s390 @@ -0,0 +1,5 @@ +# performance tuning for s390(x) +kernel.sched_min_granularity_ns = 10000000 +kernel.sched_wakeup_granularity_ns = 15000000 +kernel.sched_latency_ns = 80000000 +kernel.sched_tunable_scaling = 0