4 ## Copyright (c) 2020 Intel Corporation
6 ## Licensed under the Apache License, Version 2.0 (the "License");
7 ## you may not use this file except in compliance with the License.
8 ## You may obtain a copy of the License at
11 ## http://www.apache.org/licenses/LICENSE-2.0
13 ## Unless required by applicable law or agreed to in writing, software
14 ## distributed under the License is distributed on an "AS IS" BASIS,
15 ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 ## See the License for the specific language governing permissions and
17 ## limitations under the License.
20 from past.utils import old_div
23 from rapid_log import RapidLog
24 from rapid_test import RapidTest
26 class IrqTest(RapidTest):
28 Class to manage the irq testing
30 def __init__(self, runtime, machines):
31 self.runtime = runtime
32 self.machines = machines
35 RapidLog.info("+----------------------------------------------------------------------------------------------------------------------------")
36 RapidLog.info("| Measuring time probably spent dealing with an interrupt. Interrupting DPDK cores for more than 50us might be problematic ")
37 RapidLog.info("| and result in packet loss. The first row shows the interrupted time buckets: first number is the bucket between 0us and ")
38 RapidLog.info("| that number expressed in us and so on. The numbers in the other rows show how many times per second, the program was ")
39 RapidLog.info("| interrupted for a time as specified by its bucket. '0' is printed when there are no interrupts in this bucket throughout ")
40 RapidLog.info("| the duration of the test. 0.00 means there were interrupts in this bucket but very few. Due to rounding this shows as 0.00 ")
41 RapidLog.info("+----------------------------------------------------------------------------------------------------------------------------")
43 for machine in self.machines:
44 buckets=machine.socket.show_irq_buckets(1)
45 print('Measurement ongoing ... ',end='\r')
47 old_irq = [[0 for x in range(len(buckets)+1)] for y in range(len(machine.get_cores())+1)]
48 irq = [[0 for x in range(len(buckets)+1)] for y in range(len(machine.get_cores())+1)]
49 irq[0][0] = 'bucket us'
50 for j,bucket in enumerate(buckets,start=1):
51 irq[0][j] = '<'+ bucket
52 irq[0][-1] = '>'+ buckets [-2]
55 for j,bucket in enumerate(buckets,start=1):
56 for i,irqcore in enumerate(machine.get_cores(),start=1):
57 old_irq[i][j] = machine.socket.irq_stats(irqcore,j-1)
58 time.sleep(float(self.runtime))
60 for i,irqcore in enumerate(machine.get_cores(),start=1):
61 irq[i][0]='core %s '%irqcore
62 for j,bucket in enumerate(buckets,start=1):
63 diff = machine.socket.irq_stats(irqcore,j-1) - old_irq[i][j]
67 irq[i][j] = str(round(old_div(diff,float(self.runtime)), 2))
68 RapidLog.info('Results for PROX instance %s'%machine.name)
70 RapidLog.info(''.join(['{:>12}'.format(item) for item in row]))