Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/BowDown097/htop into BowDow…
Browse files Browse the repository at this point in the history
…n097-main
  • Loading branch information
natoscott committed Nov 27, 2023
2 parents 8915cae + 0600ef5 commit 3d0f35c
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions linux/LinuxProcess.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
[M_VIRT] = { .name = "M_VIRT", .title = " VIRT ", .description = "Total program size in virtual memory", .flags = 0, .defaultSortDesc = true, },
[M_RESIDENT] = { .name = "M_RESIDENT", .title = " RES ", .description = "Resident set size, size of the text and data sections, plus stack usage", .flags = 0, .defaultSortDesc = true, },
[M_SHARE] = { .name = "M_SHARE", .title = " SHR ", .description = "Size of the process's shared pages", .flags = 0, .defaultSortDesc = true, },
[M_PRIV] = { .name = "M_PRIV", .title = " PRIV ", .description = "The private memory size of the process - resident set size minus shared memory", .flags = 0, .defaultSortDesc = true, },
[M_TRS] = { .name = "M_TRS", .title = " CODE ", .description = "Size of the .text segment of the process (CODE)", .flags = 0, .defaultSortDesc = true, },
[M_DRS] = { .name = "M_DRS", .title = " DATA ", .description = "Size of the .data segment plus stack usage of the process (DATA)", .flags = 0, .defaultSortDesc = true, },
[M_LRS] = { .name = "M_LRS", .title = " LIB ", .description = "The library size of the process (calculated from memory maps)", .flags = PROCESS_FLAG_LINUX_LRS_FIX, .defaultSortDesc = true, },
Expand Down Expand Up @@ -243,6 +244,7 @@ static void LinuxProcess_rowWriteField(const Row* super, RichString* str, Proces
break;
case M_TRS: Row_printBytes(str, lp->m_trs * lhost->pageSize, coloring); return;
case M_SHARE: Row_printBytes(str, lp->m_share * lhost->pageSize, coloring); return;
case M_PRIV: Row_printKBytes(str, lp->m_priv, coloring); return;
case M_PSS: Row_printKBytes(str, lp->m_pss, coloring); return;
case M_SWAP: Row_printKBytes(str, lp->m_swap, coloring); return;
case M_PSSWP: Row_printKBytes(str, lp->m_psswp, coloring); return;
Expand Down Expand Up @@ -339,6 +341,8 @@ static int LinuxProcess_compareByKey(const Process* v1, const Process* v2, Proce
return SPACESHIP_NUMBER(p1->m_trs, p2->m_trs);
case M_SHARE:
return SPACESHIP_NUMBER(p1->m_share, p2->m_share);
case M_PRIV:
return SPACESHIP_NUMBER(p1->m_priv, p2->m_priv);
case M_PSS:
return SPACESHIP_NUMBER(p1->m_pss, p2->m_pss);
case M_SWAP:
Expand Down
1 change: 1 addition & 0 deletions linux/LinuxProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ typedef struct LinuxProcess_ {
unsigned long long int cutime;
unsigned long long int cstime;
long m_share;
long m_priv;
long m_pss;
long m_swap;
long m_psswp;
Expand Down
2 changes: 2 additions & 0 deletions linux/LinuxProcessTable.c
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,8 @@ static bool LinuxProcessTable_readStatmFile(LinuxProcess* process, openat_arg_t
if (r == 7) {
process->super.m_virt *= host->pageSizeKB;
process->super.m_resident *= host->pageSizeKB;

process->m_priv = process->super.m_resident - (process->m_share * host->pageSizeKB);
}

return r == 7;
Expand Down
1 change: 1 addition & 0 deletions linux/ProcessField.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ in the source distribution for its full text.
AUTOGROUP_ID = 127, \
AUTOGROUP_NICE = 128, \
CCGROUP = 129, \
M_PRIV = 130, \
// End of list


Expand Down
4 changes: 4 additions & 0 deletions pcp/PCPProcess.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const ProcessFieldData Process_fields[] = {
[M_VIRT] = { .name = "M_VIRT", .title = " VIRT ", .description = "Total program size in virtual memory", .flags = 0, .defaultSortDesc = true, },
[M_RESIDENT] = { .name = "M_RESIDENT", .title = " RES ", .description = "Resident set size, size of the text and data sections, plus stack usage", .flags = 0, .defaultSortDesc = true, },
[M_SHARE] = { .name = "M_SHARE", .title = " SHR ", .description = "Size of the process's shared pages", .flags = 0, .defaultSortDesc = true, },
[M_PRIV] = { .name = "M_PRIV", .title = " PRIV ", .description = "The private memory size of the process - resident set size minus shared memory", .flags = 0, .defaultSortDesc = true, },
[M_TRS] = { .name = "M_TRS", .title = " CODE ", .description = "Size of the text segment of the process", .flags = 0, .defaultSortDesc = true, },
[M_DRS] = { .name = "M_DRS", .title = " DATA ", .description = "Size of the data segment plus stack usage of the process", .flags = 0, .defaultSortDesc = true, },
[M_LRS] = { .name = "M_LRS", .title = " LIB ", .description = "The library size of the process (unused since Linux 2.6; always 0)", .flags = 0, .defaultSortDesc = true, },
Expand Down Expand Up @@ -140,6 +141,7 @@ static void PCPProcess_rowWriteField(const Row* super, RichString* str, ProcessF
case M_LRS: Row_printBytes(str, pp->m_lrs, coloring); return;
case M_TRS: Row_printBytes(str, pp->m_trs, coloring); return;
case M_SHARE: Row_printBytes(str, pp->m_share, coloring); return;
case M_PRIV: Row_printBytes(str, pp->m_priv, coloring); return;
case M_PSS: Row_printKBytes(str, pp->m_pss, coloring); return;
case M_SWAP: Row_printKBytes(str, pp->m_swap, coloring); return;
case M_PSSWP: Row_printKBytes(str, pp->m_psswp, coloring); return;
Expand Down Expand Up @@ -217,6 +219,8 @@ static int PCPProcess_compareByKey(const Process* v1, const Process* v2, Process
return SPACESHIP_NUMBER(p1->m_trs, p2->m_trs);
case M_SHARE:
return SPACESHIP_NUMBER(p1->m_share, p2->m_share);
case M_PRIV:
return SPACESHIP_NUMBER(p1->m_priv, p2->m_priv);
case M_PSS:
return SPACESHIP_NUMBER(p1->m_pss, p2->m_pss);
case M_SWAP:
Expand Down
1 change: 1 addition & 0 deletions pcp/PCPProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ typedef struct PCPProcess_ {
unsigned long long int cutime;
unsigned long long int cstime;
long m_share;
long m_priv;
long m_pss;
long m_swap;
long m_psswp;
Expand Down
1 change: 1 addition & 0 deletions pcp/PCPProcessTable.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ static void PCPProcessTable_updateMemory(PCPProcess* pp, int pid, int offset) {
pp->super.m_virt = Metric_instance_u32(PCP_PROC_MEM_SIZE, pid, offset, 0);
pp->super.m_resident = Metric_instance_u32(PCP_PROC_MEM_RSS, pid, offset, 0);
pp->m_share = Metric_instance_u32(PCP_PROC_MEM_SHARE, pid, offset, 0);
pp->m_priv = pp->super.m_resident - pp->m_share;
pp->m_trs = Metric_instance_u32(PCP_PROC_MEM_TEXTRS, pid, offset, 0);
pp->m_lrs = Metric_instance_u32(PCP_PROC_MEM_LIBRS, pid, offset, 0);
pp->m_drs = Metric_instance_u32(PCP_PROC_MEM_DATRS, pid, offset, 0);
Expand Down
1 change: 1 addition & 0 deletions pcp/ProcessField.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ in the source distribution for its full text.
AUTOGROUP_ID = 127, \
AUTOGROUP_NICE = 128, \
CCGROUP = 129, \
M_PRIV = 130, \
// End of list


Expand Down

0 comments on commit 3d0f35c

Please sign in to comment.