Changeset d69f959 in mainline


Ignore:
Timestamp:
2010-04-25T19:25:07Z (15 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
170332d
Parents:
aa028db
Message:

Take the address space and address space area mutexes conditionally in
get_task_virtmem() so that we never block while holding the tasks and TASK
spinlocks.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/sysinfo/stats.c

    raa028db rd69f959  
    156156static size_t get_task_virtmem(as_t *as)
    157157{
    158         mutex_lock(&as->lock);
    159        
    160158        size_t result = 0;
     159
     160        /*
     161         * We are holding some spinlocks here and therefore are not allowed to
     162         * block. Only attempt to lock the address space and address space area
     163         * mutexes conditionally. If it is not possible to lock either object,
     164         * allow the statistics to be inexact by skipping the respective object.
     165         *
     166         * Note that it may be infinitely better to let the address space
     167         * management code compute these statistics as it proceeds instead of
     168         * having them calculated here over and over again here.
     169         */
     170
     171        if (!mutex_trylock(&as->lock))
     172                return result * PAGE_SIZE;
    161173       
    162174        /* Walk the B+ tree and count pages */
     
    171183                        as_area_t *area = node->value[i];
    172184                       
    173                         mutex_lock(&area->lock);
     185                        if (!mutex_trylock(&area->lock))
     186                                continue;
    174187                        result += area->pages;
    175188                        mutex_unlock(&area->lock);
Note: See TracChangeset for help on using the changeset viewer.