~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/lib/dim/dim.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /lib/dim/dim.c (Architecture ppc) and /lib/dim/dim.c (Architecture mips)


  1 // SPDX-License-Identifier: GPL-2.0 OR Linux-O      1 // SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
  2 /*                                                  2 /*
  3  * Copyright (c) 2019, Mellanox Technologies i      3  * Copyright (c) 2019, Mellanox Technologies inc.  All rights reserved.
  4  */                                                 4  */
  5                                                     5 
  6 #include <linux/dim.h>                              6 #include <linux/dim.h>
  7                                                     7 
  8 bool dim_on_top(struct dim *dim)                    8 bool dim_on_top(struct dim *dim)
  9 {                                                   9 {
 10         switch (dim->tune_state) {                 10         switch (dim->tune_state) {
 11         case DIM_PARKING_ON_TOP:                   11         case DIM_PARKING_ON_TOP:
 12         case DIM_PARKING_TIRED:                    12         case DIM_PARKING_TIRED:
 13                 return true;                       13                 return true;
 14         case DIM_GOING_RIGHT:                      14         case DIM_GOING_RIGHT:
 15                 return (dim->steps_left > 1) &     15                 return (dim->steps_left > 1) && (dim->steps_right == 1);
 16         default: /* DIM_GOING_LEFT */              16         default: /* DIM_GOING_LEFT */
 17                 return (dim->steps_right > 1)      17                 return (dim->steps_right > 1) && (dim->steps_left == 1);
 18         }                                          18         }
 19 }                                                  19 }
 20 EXPORT_SYMBOL(dim_on_top);                         20 EXPORT_SYMBOL(dim_on_top);
 21                                                    21 
 22 void dim_turn(struct dim *dim)                     22 void dim_turn(struct dim *dim)
 23 {                                                  23 {
 24         switch (dim->tune_state) {                 24         switch (dim->tune_state) {
 25         case DIM_PARKING_ON_TOP:                   25         case DIM_PARKING_ON_TOP:
 26         case DIM_PARKING_TIRED:                    26         case DIM_PARKING_TIRED:
 27                 break;                             27                 break;
 28         case DIM_GOING_RIGHT:                      28         case DIM_GOING_RIGHT:
 29                 dim->tune_state = DIM_GOING_LE     29                 dim->tune_state = DIM_GOING_LEFT;
 30                 dim->steps_left = 0;               30                 dim->steps_left = 0;
 31                 break;                             31                 break;
 32         case DIM_GOING_LEFT:                       32         case DIM_GOING_LEFT:
 33                 dim->tune_state = DIM_GOING_RI     33                 dim->tune_state = DIM_GOING_RIGHT;
 34                 dim->steps_right = 0;              34                 dim->steps_right = 0;
 35                 break;                             35                 break;
 36         }                                          36         }
 37 }                                                  37 }
 38 EXPORT_SYMBOL(dim_turn);                           38 EXPORT_SYMBOL(dim_turn);
 39                                                    39 
 40 void dim_park_on_top(struct dim *dim)              40 void dim_park_on_top(struct dim *dim)
 41 {                                                  41 {
 42         dim->steps_right  = 0;                     42         dim->steps_right  = 0;
 43         dim->steps_left   = 0;                     43         dim->steps_left   = 0;
 44         dim->tired        = 0;                     44         dim->tired        = 0;
 45         dim->tune_state   = DIM_PARKING_ON_TOP     45         dim->tune_state   = DIM_PARKING_ON_TOP;
 46 }                                                  46 }
 47 EXPORT_SYMBOL(dim_park_on_top);                    47 EXPORT_SYMBOL(dim_park_on_top);
 48                                                    48 
 49 void dim_park_tired(struct dim *dim)               49 void dim_park_tired(struct dim *dim)
 50 {                                                  50 {
 51         dim->steps_right  = 0;                     51         dim->steps_right  = 0;
 52         dim->steps_left   = 0;                     52         dim->steps_left   = 0;
 53         dim->tune_state   = DIM_PARKING_TIRED;     53         dim->tune_state   = DIM_PARKING_TIRED;
 54 }                                                  54 }
 55 EXPORT_SYMBOL(dim_park_tired);                     55 EXPORT_SYMBOL(dim_park_tired);
 56                                                    56 
 57 bool dim_calc_stats(struct dim_sample *start,      57 bool dim_calc_stats(struct dim_sample *start, struct dim_sample *end,
 58                     struct dim_stats *curr_sta     58                     struct dim_stats *curr_stats)
 59 {                                                  59 {
 60         /* u32 holds up to 71 minutes, should      60         /* u32 holds up to 71 minutes, should be enough */
 61         u32 delta_us = ktime_us_delta(end->tim     61         u32 delta_us = ktime_us_delta(end->time, start->time);
 62         u32 npkts = BIT_GAP(BITS_PER_TYPE(u32)     62         u32 npkts = BIT_GAP(BITS_PER_TYPE(u32), end->pkt_ctr, start->pkt_ctr);
 63         u32 nbytes = BIT_GAP(BITS_PER_TYPE(u32     63         u32 nbytes = BIT_GAP(BITS_PER_TYPE(u32), end->byte_ctr,
 64                              start->byte_ctr);     64                              start->byte_ctr);
 65         u32 ncomps = BIT_GAP(BITS_PER_TYPE(u32     65         u32 ncomps = BIT_GAP(BITS_PER_TYPE(u32), end->comp_ctr,
 66                              start->comp_ctr);     66                              start->comp_ctr);
 67                                                    67 
 68         if (!delta_us)                             68         if (!delta_us)
 69                 return false;                      69                 return false;
 70                                                    70 
 71         curr_stats->ppms = DIV_ROUND_UP(npkts      71         curr_stats->ppms = DIV_ROUND_UP(npkts * USEC_PER_MSEC, delta_us);
 72         curr_stats->bpms = DIV_ROUND_UP(nbytes     72         curr_stats->bpms = DIV_ROUND_UP(nbytes * USEC_PER_MSEC, delta_us);
 73         curr_stats->epms = DIV_ROUND_UP(DIM_NE     73         curr_stats->epms = DIV_ROUND_UP(DIM_NEVENTS * USEC_PER_MSEC,
 74                                         delta_     74                                         delta_us);
 75         curr_stats->cpms = DIV_ROUND_UP(ncomps     75         curr_stats->cpms = DIV_ROUND_UP(ncomps * USEC_PER_MSEC, delta_us);
 76         if (curr_stats->epms != 0)                 76         if (curr_stats->epms != 0)
 77                 curr_stats->cpe_ratio = DIV_RO     77                 curr_stats->cpe_ratio = DIV_ROUND_DOWN_ULL(
 78                         curr_stats->cpms * 100     78                         curr_stats->cpms * 100, curr_stats->epms);
 79         else                                       79         else
 80                 curr_stats->cpe_ratio = 0;         80                 curr_stats->cpe_ratio = 0;
 81                                                    81 
 82         return true;                               82         return true;
 83 }                                                  83 }
 84 EXPORT_SYMBOL(dim_calc_stats);                     84 EXPORT_SYMBOL(dim_calc_stats);
 85                                                    85 
 86 MODULE_DESCRIPTION("Dynamic Interrupt Moderati     86 MODULE_DESCRIPTION("Dynamic Interrupt Moderation (DIM) library");
 87 MODULE_LICENSE("Dual BSD/GPL");                    87 MODULE_LICENSE("Dual BSD/GPL");
 88                                                    88 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php