Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests: concurrency: add test to verify parallel add/delete

Implement test that runs 5 instances of tc add filter in parallel with 5
instances of tc del filter from same tp instance. Each instance uses its
own filter handle and key range.

Extend tdc_multibatch.py with additional options required to implement the
test: common prefix for all generated batch files, first value of filter
handle range, MAC address prefix modifier. These are necessary to allow
creating batch files with unique keys and handle ranges with multiple
invocation of tdc_multibatch.py helper script.

Signed-off-by: Vlad Buslov <vladbu@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Vlad Buslov and committed by
David S. Miller
be6b294d a788b302

+49 -3
+26
tools/testing/selftests/tc-testing/tc-tests/filters/concurrency.json
··· 121 121 "$TC qdisc del dev $DEV2 ingress", 122 122 "/bin/rm -rf $BATCH_DIR" 123 123 ] 124 + }, 125 + { 126 + "id": "ab62", 127 + "name": "Add and delete from same tp with 10 tc instances", 128 + "category": [ 129 + "filter", 130 + "flower", 131 + "concurrency" 132 + ], 133 + "setup": [ 134 + "/bin/mkdir $BATCH_DIR", 135 + "$TC qdisc add dev $DEV2 ingress", 136 + "./tdc_multibatch.py -x init_ $DEV2 $BATCH_DIR 100000 5 add", 137 + "find $BATCH_DIR/init_* -print | xargs -n 1 -P 5 $TC -b", 138 + "./tdc_multibatch.py -x par_ -a 500001 -m 5 $DEV2 $BATCH_DIR 100000 5 add", 139 + "./tdc_multibatch.py -x par_ $DEV2 $BATCH_DIR 100000 5 del" 140 + ], 141 + "cmdUnderTest": "find $BATCH_DIR/par_* -print | xargs -n 1 -P 10 $TC -b", 142 + "expExitCode": "0", 143 + "verifyCmd": "$TC -s filter show dev $DEV2 ingress", 144 + "matchPattern": "filter protocol ip pref 1 flower chain 0 handle", 145 + "matchCount": "500000", 146 + "teardown": [ 147 + "$TC qdisc del dev $DEV2 ingress", 148 + "/bin/rm -rf $BATCH_DIR" 149 + ] 124 150 } 125 151 ]
+23 -3
tools/testing/selftests/tc-testing/tdc_multibatch.py
··· 22 22 choices=['add', 'del', 'replace'], 23 23 help="operation to perform on filters") 24 24 parser.add_argument( 25 + "-x", 26 + "--file_prefix", 27 + default="", 28 + help="prefix for generated batch file names") 29 + parser.add_argument( 25 30 "-d", 26 31 "--duplicate_handles", 27 32 action="store_true", 28 33 help="duplicate filter handle range in all files") 34 + parser.add_argument( 35 + "-a", 36 + "--handle_start", 37 + type=int, 38 + default=1, 39 + help="start handle range from (default: 1)") 40 + parser.add_argument( 41 + "-m", 42 + "--mac_prefix", 43 + type=int, 44 + default=0, 45 + choices=range(0, 256), 46 + help="add this value to third byte of source MAC address of flower filter" 47 + "(default: 0)") 29 48 args = parser.parse_args() 30 49 31 50 device = args.device 32 51 dir = args.dir 33 - file_prefix = args.operation + "_" 52 + file_prefix = args.file_prefix + args.operation + "_" 34 53 num_filters = args.num_filters 35 54 num_files = args.num_files 36 55 operation = args.operation 37 56 duplicate_handles = args.duplicate_handles 38 - handle = 1 57 + handle = args.handle_start 58 + mac_prefix = args.mac_prefix 39 59 40 60 for i in range(num_files): 41 61 file = dir + '/' + file_prefix + str(i) 42 62 os.system("./tdc_batch.py -n {} -a {} -e {} -m {} {} {}".format( 43 - num_filters, handle, operation, i, device, file)) 63 + num_filters, handle, operation, i + mac_prefix, device, file)) 44 64 if not duplicate_handles: 45 65 handle += num_filters