Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset df908b3 in mainline


Ignore:
Timestamp:
2010-08-27T17:04:29Z (11 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master
Children:
3249673, ecd2775
Parents:
ddd7118
Message:

Use async relations introduced in the previous changeset to implement
vfs_grab_phone() and vfs_release_phone().

With this change, VFS will not be pointlessly connecting and disconnecting
phones on each VFS request.

Judging from the output of the top utility, this reduces the share of VFS on
kernel time by about 7% (from 25% down to 18%) and DEVFS kernel time by about 5%
(from 28% to 23%). This also makes CONSOLE the biggest consumer of kernel time,
while it used to be third after DEVFS and VFS.

Location:
uspace
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/libc.c

    rddd7118 rdf908b3  
    5050#include <ipc/ipc.h>
    5151#include <async.h>
     52#include <async_rel.h>
    5253#include <as.h>
    5354#include <loader/pcb.h>
     
    6566        __heap_init();
    6667        __async_init();
     68        (void) async_rel_init();
    6769        fibril_t *fibril = fibril_setup();
    6870        __tcb_set(fibril->tcb);
  • uspace/srv/vfs/vfs.h

    rddd7118 rdf908b3  
    169169
    170170extern int vfs_grab_phone(fs_handle_t);
    171 extern void vfs_release_phone(int);
     171extern void vfs_release_phone(fs_handle_t, int);
    172172
    173173extern fs_handle_t fs_name_to_handle(char *, bool);
  • uspace/srv/vfs/vfs_lookup.c

    rddd7118 rdf908b3  
    168168        ipcarg_t rc;
    169169        async_wait_for(req, &rc);
    170         vfs_release_phone(phone);
     170        vfs_release_phone(root->fs_handle, phone);
    171171       
    172172        fibril_mutex_lock(&plb_mutex);
     
    215215        ipcarg_t rc;
    216216        async_wait_for(req, &rc);
    217         vfs_release_phone(phone);
     217        vfs_release_phone(result->triplet.fs_handle, phone);
    218218       
    219219        if (rc == EOK) {
  • uspace/srv/vfs/vfs_node.c

    rddd7118 rdf908b3  
    133133                    (ipcarg_t)node->dev_handle, (ipcarg_t)node->index);
    134134                assert(rc == EOK);
    135                 vfs_release_phone(phone);
     135                vfs_release_phone(node->fs_handle, phone);
    136136        }
    137137        if (free_vfs_node)
  • uspace/srv/vfs/vfs_ops.c

    rddd7118 rdf908b3  
    131131                        if (rc != EOK) {
    132132                                async_wait_for(msg, NULL);
    133                                 vfs_release_phone(phone);
     133                                vfs_release_phone(fs_handle, phone);
    134134                                fibril_rwlock_write_unlock(&namespace_rwlock);
    135135                                ipc_answer_0(rid, rc);
     
    137137                        }
    138138                        async_wait_for(msg, &rc);
    139                         vfs_release_phone(phone);
     139                        vfs_release_phone(fs_handle, phone);
    140140                       
    141141                        if (rc != EOK) {
     
    196196        if (rc != EOK) {
    197197                async_wait_for(msg, NULL);
    198                 vfs_release_phone(mountee_phone);
    199                 vfs_release_phone(phone);
     198                vfs_release_phone(fs_handle, mountee_phone);
     199                vfs_release_phone(mp_res.triplet.fs_handle, phone);
    200200                /* Mount failed, drop reference to mp_node. */
    201201                if (mp_node)
     
    206206        }
    207207
    208         vfs_release_phone(mountee_phone);
     208        vfs_release_phone(fs_handle, mountee_phone);
    209209       
    210210        /* send the mount options */
     
    212212        if (rc != EOK) {
    213213                async_wait_for(msg, NULL);
    214                 vfs_release_phone(phone);
     214                vfs_release_phone(mp_res.triplet.fs_handle, phone);
    215215                /* Mount failed, drop reference to mp_node. */
    216216                if (mp_node)
     
    221221        }
    222222        async_wait_for(msg, &rc);
    223         vfs_release_phone(phone);
     223        vfs_release_phone(mp_res.triplet.fs_handle, phone);
    224224       
    225225        if (rc == EOK) {
     
    423423                rc = async_req_1_0(phone, VFS_OUT_UNMOUNTED,
    424424                    mr_node->dev_handle);
    425                 vfs_release_phone(phone);
     425                vfs_release_phone(mr_node->fs_handle, phone);
    426426                if (rc != EOK) {
    427427                        fibril_rwlock_write_unlock(&namespace_rwlock);
     
    460460                rc = async_req_2_0(phone, VFS_OUT_UNMOUNT, mp_node->dev_handle,
    461461                    mp_node->index);
    462                 vfs_release_phone(phone);
     462                vfs_release_phone(mp_node->fs_handle, phone);
    463463                if (rc != EOK) {
    464464                        fibril_rwlock_write_unlock(&namespace_rwlock);
     
    716716        async_wait_for(msg, &rc);
    717717       
    718         vfs_release_phone(fs_phone);
     718        vfs_release_phone(file->node->fs_handle, fs_phone);
    719719        fibril_mutex_unlock(&file->lock);
    720720       
     
    747747                async_wait_for(msg, &rc);
    748748               
    749                 vfs_release_phone(fs_phone);
     749                vfs_release_phone(file->node->fs_handle, fs_phone);
    750750                fibril_mutex_unlock(&file->lock);
    751751               
     
    846846        }
    847847       
    848         vfs_release_phone(fs_phone);
     848        vfs_release_phone(file->node->fs_handle, fs_phone);
    849849       
    850850        size_t bytes = IPC_GET_ARG1(answer);
     
    970970        rc = async_req_4_0(fs_phone, VFS_OUT_TRUNCATE, (ipcarg_t) dev_handle,
    971971            (ipcarg_t) index, LOWER32(size), UPPER32(size));
    972         vfs_release_phone(fs_phone);
     972        vfs_release_phone(fs_handle, fs_phone);
    973973        return (int)rc;
    974974}
     
    10261026        ipc_forward_fast(callid, fs_phone, 0, 0, 0, IPC_FF_ROUTE_FROM_ME);
    10271027        async_wait_for(msg, &rc);
    1028         vfs_release_phone(fs_phone);
     1028        vfs_release_phone(file->node->fs_handle, fs_phone);
    10291029
    10301030        fibril_mutex_unlock(&file->lock);
     
    10771077        ipcarg_t rv;
    10781078        async_wait_for(msg, &rv);
    1079         vfs_release_phone(fs_phone);
     1079        vfs_release_phone(node->fs_handle, fs_phone);
    10801080
    10811081        ipc_answer_0(rid, rv);
  • uspace/srv/vfs/vfs_register.c

    rddd7118 rdf908b3  
    3939#include <ipc/services.h>
    4040#include <async.h>
     41#include <async_rel.h>
    4142#include <fibril.h>
     43#include <fibril_synch.h>
    4244#include <errno.h>
    4345#include <stdio.h>
     
    4648#include <ctype.h>
    4749#include <bool.h>
    48 #include <fibril_synch.h>
    4950#include <adt/list.h>
    5051#include <as.h>
     
    252253int vfs_grab_phone(fs_handle_t handle)
    253254{
     255        link_t *cur;
     256        fs_info_t *fs;
    254257        int phone;
    255258
     
    262265         */
    263266        fibril_mutex_lock(&fs_head_lock);
    264         link_t *cur;
    265         fs_info_t *fs;
    266267        for (cur = fs_head.next; cur != &fs_head; cur = cur->next) {
    267268                fs = list_get_instance(cur, fs_info_t, fs_link);
     
    269270                        fibril_mutex_unlock(&fs_head_lock);
    270271                        fibril_mutex_lock(&fs->phone_lock);
    271                         phone = ipc_connect_me_to(fs->phone, 0, 0, 0);
     272                        phone = async_relation_create(fs->phone);
    272273                        fibril_mutex_unlock(&fs->phone_lock);
    273274
     
    284285 * @param phone         Phone to FS task.
    285286 */
    286 void vfs_release_phone(int phone)
    287 {
    288         /* TODO: implement connection caching */
    289         ipc_hangup(phone);
     287void vfs_release_phone(fs_handle_t handle, int phone)
     288{
     289        link_t *cur;
     290        fs_info_t *fs;
     291
     292        fibril_mutex_lock(&fs_head_lock);
     293        for (cur = fs_head.next; cur != &fs_head; cur = cur->next) {
     294                fs = list_get_instance(cur, fs_info_t, fs_link);
     295                if (fs->fs_handle == handle) {
     296                        fibril_mutex_unlock(&fs_head_lock);
     297                        fibril_mutex_lock(&fs->phone_lock);
     298                        async_relation_destroy(fs->phone, phone);
     299                        fibril_mutex_unlock(&fs->phone_lock);
     300                        return;
     301                }
     302        }
     303        /* should not really get here */
     304        abort();
     305        fibril_mutex_unlock(&fs_head_lock);
    290306}
    291307
Note: See TracChangeset for help on using the changeset viewer.