Changeset adb3ea1 for libcfa


Ignore:
Timestamp:
Mar 18, 2022, 2:55:27 PM (2 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, ast-experimental, enum, master, pthread-emulation, qualifiedEnum
Children:
98d1b90
Parents:
0b4ddb71
Message:

Some more incremental work towards using timestamps for io fairness

Location:
libcfa/src/concurrency
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/kernel.hfa

    r0b4ddb71 radb3ea1  
    108108        struct {
    109109                $io_context * ctx;
     110                unsigned id;
     111                unsigned target;
    110112                volatile bool pending;
    111113                volatile bool dirty;
     
    209211                struct {
    210212                        // Arary of subqueues
    211                         __intrusive_lane_t * volatile data;
     213                        __intrusive_lane_t * data;
    212214
    213215                        // Time since subqueues were processed
    214                         __timestamp_t * volatile tscs;
     216                        __timestamp_t * tscs;
    215217
    216218                        // Number of subqueue / timestamps
     
    219221
    220222                struct {
     223                        // Array of $io_
     224                        $io_context ** data;
     225
    221226                        // Time since subqueues were processed
    222                         __timestamp_t * volatile tscs;
     227                        __timestamp_t * tscs;
    223228
    224229                        // Number of I/O subqueues
     
    227232
    228233                // Cache each kernel thread belongs to
    229                 __cache_id_t * volatile caches;
     234                __cache_id_t * caches;
    230235        } sched;
    231236
  • libcfa/src/concurrency/kernel/cluster.cfa

    r0b4ddb71 radb3ea1  
    253253}
    254254
    255 static void assign_list(unsigned & value, dlist(processor) & list, unsigned count) {
     255static void assign_list(unsigned & valrq, unsigned & valio, dlist(processor) & list, unsigned count) {
    256256        processor * it = &list`first;
    257257        for(unsigned i = 0; i < count; i++) {
    258258                /* paranoid */ verifyf( it, "Unexpected null iterator, at index %u of %u\n", i, count);
    259                 it->rdq.id = value;
     259                it->rdq.id = valrq;
    260260                it->rdq.target = MAX;
    261                 value += __shard_factor.readyq;
     261                it->io.id = valio;
     262                it->io.target = MAX;
     263                valrq += __shard_factor.readyq;
     264                valio += __shard_factor.io;
    262265                it = &(*it)`next;
    263266        }
     
    265268
    266269static void reassign_cltr_id(struct cluster * cltr) {
    267         unsigned preferred = 0;
    268         assign_list(preferred, cltr->procs.actives, cltr->procs.total - cltr->procs.idle);
    269         assign_list(preferred, cltr->procs.idles  , cltr->procs.idle );
     270        unsigned prefrq = 0;
     271        unsigned prefio = 0;
     272        assign_list(prefrq, prefio, cltr->procs.actives, cltr->procs.total - cltr->procs.idle);
     273        assign_list(prefrq, prefio, cltr->procs.idles  , cltr->procs.idle );
     274}
     275
     276static void assign_io($io_context ** data, size_t count, dlist(processor) & list) {
     277        processor * it = &list`first;
     278        while(it) {
     279                /* paranoid */ verifyf( it, "Unexpected null iterator\n");
     280                /* paranoid */ verifyf( it->io.id < count, "Processor %p has id %u above count %zu\n", it, it->rdq.id, count);
     281                data[it->io.id] = it->io.ctx;
     282                it = &(*it)`next;
     283        }
     284}
     285
     286static void reassign_cltr_io(struct cluster * cltr) {
     287        assign_io(cltr->sched.io.data, cltr->sched.io.count, cltr->procs.actives);
     288        assign_io(cltr->sched.io.data, cltr->sched.io.count, cltr->procs.idles  );
    270289}
    271290
     
    322341
    323342        // Fix the io times
    324         cltr->sched.io.count = target;
     343        cltr->sched.io.count = target * __shard_factor.io;
    325344        fix_times(cltr->sched.io.tscs, cltr->sched.io.count);
    326345
     
    330349        // reassign the clusters.
    331350        reassign_cltr_id(cltr);
     351
     352        cltr->sched.io.data = alloc( cltr->sched.io.count, cltr->sched.io.data`realloc );
     353        reassign_cltr_io(cltr);
    332354
    333355        // Make sure that everything is consistent
     
    411433
    412434        // Fix the io times
    413         cltr->sched.io.count = target;
     435        cltr->sched.io.count = target * __shard_factor.io;
    414436        fix_times(cltr->sched.io.tscs, cltr->sched.io.count);
    415437
    416438        reassign_cltr_id(cltr);
     439
     440        cltr->sched.io.data = alloc( cltr->sched.io.count, cltr->sched.io.data`realloc );
     441        reassign_cltr_io(cltr);
    417442
    418443        // Make sure that everything is consistent
  • libcfa/src/concurrency/kernel/cluster.hfa

    r0b4ddb71 radb3ea1  
    7272static struct {
    7373        const unsigned readyq;
    74 } __shard_factor = { 2 };
     74        const unsigned io;
     75} __shard_factor = { 2, 1 };
    7576
    7677// Local Variables: //
Note: See TracChangeset for help on using the changeset viewer.