Changeset a0ce870 in mainline


Ignore:
Timestamp:
2011-01-25T18:11:17Z (13 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
6265a2b, bf75e3cb
Parents:
311bc25
Message:

statistics: provide resident (actually used) memory of tasks

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/sysinfo/abi.h

    r311bc25 ra0ce870  
    104104        char name[TASK_NAME_BUFLEN];  /**< Task name (in kernel) */
    105105        size_t virtmem;               /**< Size of VAS (bytes) */
     106        size_t resmem;                /**< Size of resident (used) memory (bytes) */
    106107        size_t threads;               /**< Number of threads */
    107108        uint64_t ucycles;             /**< Number of CPU cycles in user space */
  • kernel/generic/src/mm/backend_phys.c

    r311bc25 ra0ce870  
    8181        page_mapping_insert(AS, addr, base + (addr - area->base),
    8282            as_area_get_flags(area));
    83         if (!used_space_insert(area, ALIGN_DOWN(addr, PAGE_SIZE), 1))
    84                 panic("Cannot insert used space.");
     83       
     84        if (!used_space_insert(area, ALIGN_DOWN(addr, PAGE_SIZE), 1))
     85                panic("Cannot insert used space.");
    8586
    8687        return AS_PF_OK;
  • kernel/generic/src/sysinfo/stats.c

    r311bc25 ra0ce870  
    170170         * Note that it may be infinitely better to let the address space
    171171         * management code compute these statistics as it proceeds instead of
    172          * having them calculated here over and over again here.
     172         * having them calculated over and over again here.
    173173         */
    174174
     
    199199}
    200200
     201/** Get the resident (used) size of a virtual address space
     202 *
     203 * @param as Address space.
     204 *
     205 * @return Size of the resident (used) virtual address space (bytes).
     206 *
     207 */
     208static size_t get_task_resmem(as_t *as)
     209{
     210        size_t result = 0;
     211       
     212        /*
     213         * We are holding some spinlocks here and therefore are not allowed to
     214         * block. Only attempt to lock the address space and address space area
     215         * mutexes conditionally. If it is not possible to lock either object,
     216         * allow the statistics to be inexact by skipping the respective object.
     217         *
     218         * Note that it may be infinitely better to let the address space
     219         * management code compute these statistics as it proceeds instead of
     220         * having them calculated over and over again here.
     221         */
     222       
     223        if (SYNCH_FAILED(mutex_trylock(&as->lock)))
     224                return result * PAGE_SIZE;
     225       
     226        /* Walk the B+ tree of AS areas */
     227        link_t *cur;
     228        for (cur = as->as_area_btree.leaf_head.next;
     229            cur != &as->as_area_btree.leaf_head; cur = cur->next) {
     230                btree_node_t *node =
     231                    list_get_instance(cur, btree_node_t, leaf_link);
     232               
     233                unsigned int i;
     234                for (i = 0; i < node->keys; i++) {
     235                        as_area_t *area = node->value[i];
     236                       
     237                        if (SYNCH_FAILED(mutex_trylock(&area->lock)))
     238                                continue;
     239                       
     240                        /* Walk the B+ tree of resident pages */
     241                        link_t *rcur;
     242                        for (rcur = area->used_space.leaf_head.next;
     243                            rcur != &area->used_space.leaf_head; rcur = rcur->next) {
     244                                btree_node_t *rnode =
     245                                    list_get_instance(rcur, btree_node_t, leaf_link);
     246                               
     247                                unsigned int j;
     248                                for (j = 0; j < rnode->keys; j++)
     249                                        result += (size_t) rnode->value[i];
     250                        }
     251                       
     252                        mutex_unlock(&area->lock);
     253                }
     254        }
     255       
     256        mutex_unlock(&as->lock);
     257       
     258        return result * PAGE_SIZE;
     259}
     260
    201261/* Produce task statistics
    202262 *
     
    215275        str_cpy(stats_task->name, TASK_NAME_BUFLEN, task->name);
    216276        stats_task->virtmem = get_task_virtmem(task->as);
     277        stats_task->resmem = get_task_resmem(task->as);
    217278        stats_task->threads = atomic_get(&task->refcount);
    218279        task_get_accounting(task, &(stats_task->ucycles),
  • uspace/app/top/screen.c

    r311bc25 ra0ce870  
    274274{
    275275        screen_style_inverted();
    276         printf("[taskid] [threads] [virtual] [%%virt] [%%user]"
    277             " [%%kernel] [name");
     276        printf("[taskid] [threads] [resident] [%%resi] [virtual] [%%virt]"
     277            " [%%user] [%%kern] [name");
    278278        screen_newline();
    279279        screen_style_normal();
     
    295295                perc_task_t *perc = data->tasks_perc + data->tasks_map[i];
    296296               
     297                uint64_t resmem;
     298                char resmem_suffix;
     299                order_suffix(task->resmem, &resmem, &resmem_suffix);
     300               
    297301                uint64_t virtmem;
    298302                char virtmem_suffix;
    299303                order_suffix(task->virtmem, &virtmem, &virtmem_suffix);
    300304               
    301                 printf("%-8" PRIu64 " %9zu %8" PRIu64 "%c ", task->task_id,
    302                     task->threads, virtmem, virtmem_suffix);
     305                printf("%-8" PRIu64 " %9zu %9" PRIu64 "%c ",
     306                    task->task_id, task->threads, resmem, resmem_suffix);
     307                print_percent(perc->resmem, 2);
     308                printf(" %8" PRIu64 "%c ", virtmem, virtmem_suffix);
    303309                print_percent(perc->virtmem, 2);
    304310                puts(" ");
    305311                print_percent(perc->ucycles, 2);
    306                 puts("   ");
     312                puts(" ");
    307313                print_percent(perc->kcycles, 2);
    308314                puts(" ");
  • uspace/app/top/top.c

    r311bc25 ra0ce870  
    195195       
    196196        uint64_t virtmem_total = 0;
     197        uint64_t resmem_total = 0;
    197198        uint64_t ucycles_total = 0;
    198199        uint64_t kcycles_total = 0;
     
    223224               
    224225                virtmem_total += new_data->tasks[i].virtmem;
     226                resmem_total += new_data->tasks[i].resmem;
    225227                ucycles_total += new_data->ucycles_diff[i];
    226228                kcycles_total += new_data->kcycles_diff[i];
     
    232234                FRACTION_TO_FLOAT(new_data->tasks_perc[i].virtmem,
    233235                    new_data->tasks[i].virtmem * 100, virtmem_total);
     236                FRACTION_TO_FLOAT(new_data->tasks_perc[i].resmem,
     237                    new_data->tasks[i].resmem * 100, resmem_total);
    234238                FRACTION_TO_FLOAT(new_data->tasks_perc[i].ucycles,
    235239                    new_data->ucycles_diff[i] * 100, ucycles_total);
  • uspace/app/top/top.h

    r311bc25 ra0ce870  
    7777typedef struct {
    7878        fixed_float virtmem;
     79        fixed_float resmem;
    7980        fixed_float ucycles;
    8081        fixed_float kcycles;
Note: See TracChangeset for help on using the changeset viewer.