Changeset b0f00a9 in mainline for kernel/generic/src/mm


Ignore:
Timestamp:
2011-11-06T22:21:05Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/fix-logger-deadlock, topic/msim-upgrade, topic/simplify-dev-export
Children:
898e847
Parents:
2bdf8313 (diff), 7b5f4c9 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

Location:
kernel/generic/src/mm
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/mm/as.c

    r2bdf8313 rb0f00a9  
    9494 *
    9595 * This lock protects:
    96  * - inactive_as_with_asid_head list
     96 * - inactive_as_with_asid_list
    9797 * - as->asid for each as of the as_t type
    9898 * - asids_allocated counter
     
    105105 * that have valid ASID.
    106106 */
    107 LIST_INITIALIZE(inactive_as_with_asid_head);
     107LIST_INITIALIZE(inactive_as_with_asid_list);
    108108
    109109/** Kernel address space. */
     
    235235        bool cond = true;
    236236        while (cond) {
    237                 ASSERT(!list_empty(&as->as_area_btree.leaf_head));
     237                ASSERT(!list_empty(&as->as_area_btree.leaf_list));
    238238               
    239239                btree_node_t *node =
    240                     list_get_instance(as->as_area_btree.leaf_head.next,
     240                    list_get_instance(list_first(&as->as_area_btree.leaf_list),
    241241                    btree_node_t, leaf_link);
    242242               
     
    602602                bool cond = true;
    603603                while (cond) {
    604                         ASSERT(!list_empty(&area->used_space.leaf_head));
     604                        ASSERT(!list_empty(&area->used_space.leaf_list));
    605605                       
    606606                        btree_node_t *node =
    607                             list_get_instance(area->used_space.leaf_head.prev,
     607                            list_get_instance(list_last(&area->used_space.leaf_list),
    608608                            btree_node_t, leaf_link);
    609609                       
     
    675675               
    676676                /*
    677                  * Invalidate software translation caches (e.g. TSB on sparc64).
     677                 * Invalidate software translation caches
     678                 * (e.g. TSB on sparc64, PHT on ppc32).
    678679                 */
    679680                as_invalidate_translation_cache(as, area->base + P2SZ(pages),
     
    726727        if (--sh_info->refcount == 0) {
    727728                dealloc = true;
    728                 link_t *cur;
    729729               
    730730                /*
     
    732732                 * reference from all frames found there.
    733733                 */
    734                 for (cur = sh_info->pagemap.leaf_head.next;
    735                     cur != &sh_info->pagemap.leaf_head; cur = cur->next) {
     734                list_foreach(sh_info->pagemap.leaf_list, cur) {
    736735                        btree_node_t *node
    737736                            = list_get_instance(cur, btree_node_t, leaf_link);
     
    785784         * Visit only the pages mapped by used_space B+tree.
    786785         */
    787         link_t *cur;
    788         for (cur = area->used_space.leaf_head.next;
    789             cur != &area->used_space.leaf_head; cur = cur->next) {
     786        list_foreach(area->used_space.leaf_list, cur) {
    790787                btree_node_t *node;
    791788                btree_key_t i;
     
    823820       
    824821        /*
    825          * Invalidate potential software translation caches (e.g. TSB on
    826          * sparc64).
     822         * Invalidate potential software translation caches
     823         * (e.g. TSB on sparc64, PHT on ppc32).
    827824         */
    828825        as_invalidate_translation_cache(as, area->base, area->pages);
     
    10641061         */
    10651062        size_t used_pages = 0;
    1066         link_t *cur;
    1067        
    1068         for (cur = area->used_space.leaf_head.next;
    1069             cur != &area->used_space.leaf_head; cur = cur->next) {
     1063       
     1064        list_foreach(area->used_space.leaf_list, cur) {
    10701065                btree_node_t *node
    10711066                    = list_get_instance(cur, btree_node_t, leaf_link);
     
    10931088        size_t frame_idx = 0;
    10941089       
    1095         for (cur = area->used_space.leaf_head.next;
    1096             cur != &area->used_space.leaf_head; cur = cur->next) {
     1090        list_foreach(area->used_space.leaf_list, cur) {
    10971091                btree_node_t *node = list_get_instance(cur, btree_node_t,
    10981092                    leaf_link);
     
    11261120       
    11271121        /*
    1128          * Invalidate potential software translation caches (e.g. TSB on
    1129          * sparc64).
     1122         * Invalidate potential software translation caches
     1123         * (e.g. TSB on sparc64, PHT on ppc32).
    11301124         */
    11311125        as_invalidate_translation_cache(as, area->base, area->pages);
     
    11461140        frame_idx = 0;
    11471141       
    1148         for (cur = area->used_space.leaf_head.next;
    1149             cur != &area->used_space.leaf_head; cur = cur->next) {
     1142        list_foreach(area->used_space.leaf_list, cur) {
    11501143                btree_node_t *node
    11511144                    = list_get_instance(cur, btree_node_t, leaf_link);
     
    12911284 * thing which is forbidden in this context is locking the address space.
    12921285 *
    1293  * When this function is enetered, no spinlocks may be held.
     1286 * When this function is entered, no spinlocks may be held.
    12941287 *
    12951288 * @param old Old address space or NULL.
     
    13331326                       
    13341327                        list_append(&old_as->inactive_as_with_asid_link,
    1335                             &inactive_as_with_asid_head);
     1328                            &inactive_as_with_asid_list);
    13361329                }
    13371330               
     
    20262019       
    20272020        /* Eventually check the addresses behind each area */
    2028         link_t *cur;
    2029         for (cur = AS->as_area_btree.leaf_head.next;
    2030             (ret == 0) && (cur != &AS->as_area_btree.leaf_head);
    2031             cur = cur->next) {
     2021        list_foreach(AS->as_area_btree.leaf_list, cur) {
     2022                if (ret != 0)
     2023                        break;
     2024
    20322025                btree_node_t *node =
    20332026                    list_get_instance(cur, btree_node_t, leaf_link);
     
    20712064       
    20722065        size_t area_cnt = 0;
    2073         link_t *cur;
    2074        
    2075         for (cur = as->as_area_btree.leaf_head.next;
    2076             cur != &as->as_area_btree.leaf_head; cur = cur->next) {
     2066       
     2067        list_foreach(as->as_area_btree.leaf_list, cur) {
    20772068                btree_node_t *node =
    20782069                    list_get_instance(cur, btree_node_t, leaf_link);
     
    20872078        size_t area_idx = 0;
    20882079       
    2089         for (cur = as->as_area_btree.leaf_head.next;
    2090             cur != &as->as_area_btree.leaf_head; cur = cur->next) {
     2080        list_foreach(as->as_area_btree.leaf_list, cur) {
    20912081                btree_node_t *node =
    20922082                    list_get_instance(cur, btree_node_t, leaf_link);
     
    21242114       
    21252115        /* Print out info about address space areas */
    2126         link_t *cur;
    2127         for (cur = as->as_area_btree.leaf_head.next;
    2128             cur != &as->as_area_btree.leaf_head; cur = cur->next) {
     2116        list_foreach(as->as_area_btree.leaf_list, cur) {
    21292117                btree_node_t *node
    21302118                    = list_get_instance(cur, btree_node_t, leaf_link);
  • kernel/generic/src/mm/backend_anon.c

    r2bdf8313 rb0f00a9  
    9797void anon_share(as_area_t *area)
    9898{
    99         link_t *cur;
    100 
    10199        ASSERT(mutex_locked(&area->as->lock));
    102100        ASSERT(mutex_locked(&area->lock));
     
    106104         */
    107105        mutex_lock(&area->sh_info->lock);
    108         for (cur = area->used_space.leaf_head.next;
    109             cur != &area->used_space.leaf_head; cur = cur->next) {
     106        list_foreach(area->used_space.leaf_list, cur) {
    110107                btree_node_t *node;
    111108                unsigned int i;
  • kernel/generic/src/mm/backend_elf.c

    r2bdf8313 rb0f00a9  
    139139         */
    140140        if (area->flags & AS_AREA_WRITE) {
    141                 node = list_get_instance(area->used_space.leaf_head.next,
     141                node = list_get_instance(list_first(&area->used_space.leaf_list),
    142142                    btree_node_t, leaf_link);
    143143        } else {
     
    153153         */
    154154        mutex_lock(&area->sh_info->lock);
    155         for (cur = &node->leaf_link; cur != &area->used_space.leaf_head;
     155        for (cur = &node->leaf_link; cur != &area->used_space.leaf_list.head;
    156156            cur = cur->next) {
    157157                unsigned int i;
  • kernel/generic/src/mm/buddy.c

    r2bdf8313 rb0f00a9  
    8282         * Use memory after our own structure.
    8383         */
    84         b->order = (link_t *) (&b[1]);
     84        b->order = (list_t *) (&b[1]);
    8585       
    8686        for (i = 0; i <= max_order; i++)
     
    176176         * the request can be immediatelly satisfied.
    177177         */
    178         if (!list_empty(&b->order[i])) {
    179                 res = b->order[i].next;
     178        res = list_first(&b->order[i]);
     179        if (res != NULL) {
    180180                list_remove(res);
    181181                b->op->mark_busy(b, res);
  • kernel/generic/src/mm/frame.c

    r2bdf8313 rb0f00a9  
    11421142        size_t znum = find_zone(pfn, 1, 0);
    11431143
    1144        
    11451144        ASSERT(znum != (size_t) -1);
    11461145       
  • kernel/generic/src/mm/page.c

    r2bdf8313 rb0f00a9  
    6060
    6161#include <mm/page.h>
     62#include <genarch/mm/page_ht.h>
     63#include <genarch/mm/page_pt.h>
    6264#include <arch/mm/page.h>
    6365#include <arch/mm/asid.h>
     
    7072#include <debug.h>
    7173#include <arch.h>
     74#include <syscall/copy.h>
     75#include <errno.h>
    7276
    7377/** Virtual operations for page subsystem. */
     
    172176}
    173177
     178/** Syscall wrapper for getting mapping of a virtual page.
     179 *
     180 * @retval EOK Everything went find, @p uspace_frame and @p uspace_node
     181 *             contains correct values.
     182 * @retval ENOENT Virtual address has no mapping.
     183 */
     184sysarg_t sys_page_find_mapping(uintptr_t virt_address,
     185    uintptr_t *uspace_frame)
     186{
     187        mutex_lock(&AS->lock);
     188       
     189        pte_t *pte = page_mapping_find(AS, virt_address, false);
     190        if (!PTE_VALID(pte) || !PTE_PRESENT(pte)) {
     191                mutex_unlock(&AS->lock);
     192               
     193                return (sysarg_t) ENOENT;
     194        }
     195       
     196        uintptr_t phys_address = PTE_GET_FRAME(pte);
     197       
     198        mutex_unlock(&AS->lock);
     199       
     200        int rc = copy_to_uspace(uspace_frame,
     201            &phys_address, sizeof(phys_address));
     202        if (rc != EOK) {
     203                return (sysarg_t) rc;
     204        }
     205       
     206        return EOK;
     207}
     208
    174209/** @}
    175210 */
  • kernel/generic/src/mm/slab.c

    r2bdf8313 rb0f00a9  
    180180    unsigned int flags)
    181181{
    182        
    183        
    184182        size_t zone = 0;
    185183       
     
    317315                spinlock_lock(&cache->slablock);
    318316        } else {
    319                 slab = list_get_instance(cache->partial_slabs.next, slab_t,
    320                     link);
     317                slab = list_get_instance(list_first(&cache->partial_slabs),
     318                    slab_t, link);
    321319                list_remove(&slab->link);
    322320        }
     
    360358        if (!list_empty(&cache->magazines)) {
    361359                if (first)
    362                         cur = cache->magazines.next;
     360                        cur = list_first(&cache->magazines);
    363361                else
    364                         cur = cache->magazines.prev;
     362                        cur = list_last(&cache->magazines);
    365363               
    366364                mag = list_get_instance(cur, slab_magazine_t, link);
     
    812810       
    813811        size_t frames = 0;
    814         link_t *cur;
    815         for (cur = slab_cache_list.next; cur != &slab_cache_list;
    816             cur = cur->next) {
     812        list_foreach(slab_cache_list, cur) {
    817813                slab_cache_t *cache = list_get_instance(cur, slab_cache_t, link);
    818814                frames += _slab_reclaim(cache, flags);
     
    861857                link_t *cur;
    862858                size_t i;
    863                 for (i = 0, cur = slab_cache_list.next;
    864                     (i < skip) && (cur != &slab_cache_list);
     859                for (i = 0, cur = slab_cache_list.head.next;
     860                    (i < skip) && (cur != &slab_cache_list.head);
    865861                    i++, cur = cur->next);
    866862               
    867                 if (cur == &slab_cache_list) {
     863                if (cur == &slab_cache_list.head) {
    868864                        irq_spinlock_unlock(&slab_cache_lock, true);
    869865                        break;
     
    940936        irq_spinlock_lock(&slab_cache_lock, false);
    941937       
    942         link_t *cur;
    943         for (cur = slab_cache_list.next; cur != &slab_cache_list;
    944             cur = cur->next) {
     938        list_foreach(slab_cache_list, cur) {
    945939                slab_cache_t *slab = list_get_instance(cur, slab_cache_t, link);
    946940                if ((slab->flags & SLAB_CACHE_MAGDEFERRED) !=
Note: See TracChangeset for help on using the changeset viewer.