Changeset a85d900 in rtems-libbsd


Ignore:
Timestamp:
Aug 4, 2017, 12:32:19 PM (22 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
5cb01f277962d3127d364bf871f799b34e6b6be6, 9a4ed64d5acc20cd3488a633bd78cad7d1708081
Children:
48cbe6c
Parents:
cf447b9
git-author:
Sebastian Huber <sebastian.huber@…> (08/04/17 12:32:19)
git-committer:
Sebastian Huber <sebastian.huber@…> (09/17/18 07:12:06)
Message:

Optimize callout handline via static timer wheel

The number of callouts is a compile-time constant in libbsd. Use this
in struct callout_cpu and avoid dynamic allocation of tables. This
signficantly reduces the count of load instructions in the callout
handling.

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • freebsd/sys/kern/kern_timeout.c

    rcf447b9 ra85d900  
    129129    0, "Pin the per-CPU swis (except PCPU 0, which is also default");
    130130
     131#ifndef __rtems__
    131132/*
    132133 * TODO:
     
    134135 */
    135136u_int callwheelsize, callwheelmask;
     137#else /* __rtems__ */
     138#define callwheelsize (2 * ncallout)
     139#define callwheelmask (callwheelsize - 1)
     140#endif /* __rtems__ */
    136141
    137142/*
     
    171176#endif /* __rtems__ */
    172177        struct callout          *cc_next;
     178#ifndef __rtems__
    173179        struct callout          *cc_callout;
    174180        struct callout_list     *cc_callwheel;
    175 #ifndef __rtems__
    176181        struct callout_tailq    cc_expireq;
     182#else /* __rtems__ */
     183        struct callout          cc_callout[ncallout];
     184        struct callout_list     cc_callwheel[callwheelsize];
    177185#endif /* __rtems__ */
    178186        struct callout_slist    cc_callfree;
     
    360368         * than 'ncallout'.
    361369         */
     370#ifndef __rtems__
    362371        callwheelsize = 1 << fls(ncallout);
    363372        callwheelmask = callwheelsize - 1;
     373#endif /* __rtems__ */
    364374
    365375#ifndef __rtems__
     
    381391#endif /* __rtems__ */
    382392        cc = CC_CPU(timeout_cpu);
     393#ifndef __rtems__
    383394        cc->cc_callout = malloc(ncallout * sizeof(struct callout),
    384395            M_CALLOUT, M_WAITOK);
     396#endif /* __rtems__ */
    385397        callout_cpu_init(cc, timeout_cpu);
    386398}
     
    401413        SLIST_INIT(&cc->cc_callfree);
    402414        cc->cc_inited = 1;
     415#ifndef __rtems__
    403416        cc->cc_callwheel = malloc(sizeof(struct callout_list) * callwheelsize,
    404417            M_CALLOUT, M_WAITOK);
     418#endif /* __rtems__ */
    405419        for (i = 0; i < callwheelsize; i++)
    406420                LIST_INIT(&cc->cc_callwheel[i]);
     
    413427        snprintf(cc->cc_ktr_event_name, sizeof(cc->cc_ktr_event_name),
    414428            "callwheel cpu %d", cpu);
     429#ifndef __rtems__
    415430        if (cc->cc_callout == NULL)     /* Only cpu0 handles timeout(9) */
    416431                return;
     432#endif /* __rtems__ */
    417433        for (i = 0; i < ncallout; i++) {
    418434                c = &cc->cc_callout[i];
  • rtemsbsd/include/machine/rtems-bsd-kernel-namespace.h

    rcf447b9 ra85d900  
    473473#define _callout_stop_safe _bsd__callout_stop_safe
    474474#define callout_when _bsd_callout_when
    475 #define callwheelmask _bsd_callwheelmask
    476 #define callwheelsize _bsd_callwheelsize
    477475#define camellia_decrypt _bsd_camellia_decrypt
    478476#define camellia_decrypt128 _bsd_camellia_decrypt128
Note: See TracChangeset for help on using the changeset viewer.