netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/8] Add tests for unlocked flower classifier implementation
@ 2019-02-22 14:00 Vlad Buslov
  2019-02-22 14:00 ` [PATCH net-next 1/8] selftests: tdc_batch.py: add options needed for concurrency tests Vlad Buslov
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: Vlad Buslov @ 2019-02-22 14:00 UTC (permalink / raw)
  To: netdev
  Cc: jhs, xiyou.wangcong, davem, shuah, batuhanosmantaskaya, lucasb,
	dcaratti, marcelo.leitner, chrism, Vlad Buslov

Implement tests for tdc testsuite to verify concurrent rules update with
rtnl-unlocked flower classifier implementation. The goal of these tests
is to verify general flower classifier correctness by updating filters
on same classifier instance in parallel and to verify its atomicity by
concurrently updating filters in same handle range. All three filter
update operations (add, replace, delete) are tested.

Existing script tdc_batch.py is re-used for batch file generation. It is
extended with several optional CLI arguments that are needed for
concurrency tests. Thin wrapper tdc_multibatch.py is implemented on top
of tdc_batch.py to simplify its usage when generating multiple batch
files for several test configurations.

Parallelism in tests is implemented by running multiple instances of tc
in batch mode with xargs tool. Xargs is chosen for its ease of use and
because it is available by default on most modern Linux distributions.

Vlad Buslov (8):
  selftests: tdc_batch.py: add options needed for concurrency tests
  selftests: concurrency: add test to verify parallel rules insertion
  selftests: concurrency: add test to verify parallel rules deletion
  selftests: concurrency: add test to verify parallel rules replace
  selftests: concurrency: add test to verify concurrent replace
  selftests: concurrency: add test to verify concurrent delete
  selftests: concurrency: add test to verify parallel add/delete
  selftests: concurrency: add test to verify parallel replace/delete

 .../tc-testing/tc-tests/filters/concurrency.json   | 177 +++++++++++++++++++++
 tools/testing/selftests/tc-testing/tdc_batch.py    |  58 ++++++-
 tools/testing/selftests/tc-testing/tdc_config.py   |   1 +
 .../testing/selftests/tc-testing/tdc_multibatch.py |  65 ++++++++
 4 files changed, 297 insertions(+), 4 deletions(-)
 create mode 100644 tools/testing/selftests/tc-testing/tc-tests/filters/concurrency.json
 create mode 100755 tools/testing/selftests/tc-testing/tdc_multibatch.py

-- 
2.13.6


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH net-next 1/8] selftests: tdc_batch.py: add options needed for concurrency tests
  2019-02-22 14:00 [PATCH net-next 0/8] Add tests for unlocked flower classifier implementation Vlad Buslov
@ 2019-02-22 14:00 ` Vlad Buslov
  2019-02-22 14:00 ` [PATCH net-next 2/8] selftests: concurrency: add test to verify parallel rules insertion Vlad Buslov
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Vlad Buslov @ 2019-02-22 14:00 UTC (permalink / raw)
  To: netdev
  Cc: jhs, xiyou.wangcong, davem, shuah, batuhanosmantaskaya, lucasb,
	dcaratti, marcelo.leitner, chrism, Vlad Buslov

Extend tdc_batch.py with several optional CLI arguments that are used for
implementation of concurrency tests in following patches in this set:

- Add optional argument to specify range of filter handles used in batch
  file [fitler_handle, filter_handle+number). This is needed for testing
  filter deletion where it is necessary to know exact handles of configured
  filters.

- Add optional argument to specify filter operation type (possible values
  are ['add', 'del', 'replace']) instead of hardcoded "add" value. This
  allows generation of batches for filter addition, deletion and
  replacement.

- Add optional argument to allow user to change mac address prefix that is
  used for all filters in batch. This is necessary to allow generating
  multiple batches with unique flower classifier keys.

Signed-off-by: Vlad Buslov <vladbu@mellanox.com>
---
 tools/testing/selftests/tc-testing/tdc_batch.py | 58 +++++++++++++++++++++++--
 1 file changed, 54 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/tc-testing/tdc_batch.py b/tools/testing/selftests/tc-testing/tdc_batch.py
index 52fa539dc662..6a2bd2cf528e 100755
--- a/tools/testing/selftests/tc-testing/tdc_batch.py
+++ b/tools/testing/selftests/tc-testing/tdc_batch.py
@@ -13,6 +13,12 @@ parser.add_argument("device", help="device name")
 parser.add_argument("file", help="batch file name")
 parser.add_argument("-n", "--number", type=int,
                     help="how many lines in batch file")
+parser.add_argument(
+    "-a",
+    "--handle_start",
+    type=int,
+    default=1,
+    help="start handle range from (default: 1)")
 parser.add_argument("-o", "--skip_sw",
                     help="skip_sw (offload), by default skip_hw",
                     action="store_true")
@@ -22,6 +28,21 @@ parser.add_argument("-s", "--share_action",
 parser.add_argument("-p", "--prio",
                     help="all filters have different prio",
                     action="store_true")
+parser.add_argument(
+    "-e",
+    "--operation",
+    choices=['add', 'del', 'replace'],
+    default='add',
+    help="operation to perform on filters"
+    "(default: add filter)")
+parser.add_argument(
+    "-m",
+    "--mac_prefix",
+    type=int,
+    default=0,
+    choices=range(0, 256),
+    help="third byte of source MAC address of flower filter"
+    "(default: 0)")
 args = parser.parse_args()
 
 device = args.device
@@ -31,6 +52,8 @@ number = 1
 if args.number:
     number = args.number
 
+handle_start = args.handle_start
+
 skip = "skip_hw"
 if args.skip_sw:
     skip = "skip_sw"
@@ -45,16 +68,43 @@ if args.prio:
     if number > 0x4000:
         number = 0x4000
 
+mac_prefix = args.mac_prefix
+
+def format_add_filter(device, prio, handle, skip, src_mac, dst_mac,
+                      share_action):
+    return ("filter add dev {} {} protocol ip parent ffff: handle {} "
+            " flower {} src_mac {} dst_mac {} action drop {}".format(
+                device, prio, handle, skip, src_mac, dst_mac, share_action))
+
+
+def format_rep_filter(device, prio, handle, skip, src_mac, dst_mac,
+                      share_action):
+    return ("filter replace dev {} {} protocol ip parent ffff: handle {} "
+            " flower {} src_mac {} dst_mac {} action drop {}".format(
+                device, prio, handle, skip, src_mac, dst_mac, share_action))
+
+
+def format_del_filter(device, prio, handle, skip, src_mac, dst_mac,
+                      share_action):
+    return ("filter del dev {} {} protocol ip parent ffff: handle {} "
+            "flower".format(device, prio, handle))
+
+
+formatter = format_add_filter
+if args.operation == "del":
+    formatter = format_del_filter
+elif args.operation == "replace":
+    formatter = format_rep_filter
+
 index = 0
 for i in range(0x100):
     for j in range(0x100):
         for k in range(0x100):
             mac = ("{:02x}:{:02x}:{:02x}".format(i, j, k))
-            src_mac = "e4:11:00:" + mac
+            src_mac = "e4:11:{:02x}:{}".format(mac_prefix, mac)
             dst_mac = "e4:12:00:" + mac
-            cmd = ("filter add dev {} {} protocol ip parent ffff: flower {} "
-                   "src_mac {} dst_mac {} action drop {}".format
-                   (device, prio, skip, src_mac, dst_mac, share_action))
+            cmd = formatter(device, prio, handle_start + index, skip, src_mac,
+                            dst_mac, share_action)
             file.write("{}\n".format(cmd))
             index += 1
             if index >= number:
-- 
2.13.6


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH net-next 2/8] selftests: concurrency: add test to verify parallel rules insertion
  2019-02-22 14:00 [PATCH net-next 0/8] Add tests for unlocked flower classifier implementation Vlad Buslov
  2019-02-22 14:00 ` [PATCH net-next 1/8] selftests: tdc_batch.py: add options needed for concurrency tests Vlad Buslov
@ 2019-02-22 14:00 ` Vlad Buslov
  2019-02-22 14:00 ` [PATCH net-next 3/8] selftests: concurrency: add test to verify parallel rules deletion Vlad Buslov
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Vlad Buslov @ 2019-02-22 14:00 UTC (permalink / raw)
  To: netdev
  Cc: jhs, xiyou.wangcong, davem, shuah, batuhanosmantaskaya, lucasb,
	dcaratti, marcelo.leitner, chrism, Vlad Buslov

Implement test that verifies parallel rules insertion by adding 1 million
flower filters with 10 concurrent tc instances. Put it to standalone
'concurrency' category.

Implement tdc_multibatch.py helper script that is used to generate multiple
batch files for concurrent tc execution. Extend config with new 'BATCH_DIR'
variable to specify temporary output directory that is used to store batch
files generated by tdc_multibatch.py.

Signed-off-by: Vlad Buslov <vladbu@mellanox.com>
---
 .../tc-testing/tc-tests/filters/concurrency.json   | 25 ++++++++++++++
 tools/testing/selftests/tc-testing/tdc_config.py   |  1 +
 .../testing/selftests/tc-testing/tdc_multibatch.py | 38 ++++++++++++++++++++++
 3 files changed, 64 insertions(+)
 create mode 100644 tools/testing/selftests/tc-testing/tc-tests/filters/concurrency.json
 create mode 100755 tools/testing/selftests/tc-testing/tdc_multibatch.py

diff --git a/tools/testing/selftests/tc-testing/tc-tests/filters/concurrency.json b/tools/testing/selftests/tc-testing/tc-tests/filters/concurrency.json
new file mode 100644
index 000000000000..adb14e944594
--- /dev/null
+++ b/tools/testing/selftests/tc-testing/tc-tests/filters/concurrency.json
@@ -0,0 +1,25 @@
+[
+    {
+        "id": "e41d",
+        "name": "Add 1M flower filters with 10 parallel tc instances",
+        "category": [
+            "filter",
+            "flower",
+            "concurrency"
+        ],
+        "setup": [
+            "/bin/mkdir $BATCH_DIR",
+            "$TC qdisc add dev $DEV2 ingress",
+            "./tdc_multibatch.py $DEV2 $BATCH_DIR 100000 10 add"
+        ],
+        "cmdUnderTest": "find $BATCH_DIR/add* -print | xargs -n 1 -P 10 $TC -b",
+        "expExitCode": "0",
+        "verifyCmd": "$TC -s filter show dev $DEV2 ingress",
+        "matchPattern": "filter protocol ip pref 1 flower chain 0 handle",
+        "matchCount": "1000000",
+        "teardown": [
+            "$TC qdisc del dev $DEV2 ingress",
+            "/bin/rm -rf $BATCH_DIR"
+        ]
+    }
+]
diff --git a/tools/testing/selftests/tc-testing/tdc_config.py b/tools/testing/selftests/tc-testing/tdc_config.py
index 6d91e48c2625..942c70c041be 100644
--- a/tools/testing/selftests/tc-testing/tdc_config.py
+++ b/tools/testing/selftests/tc-testing/tdc_config.py
@@ -15,6 +15,7 @@ NAMES = {
           'DEV1': 'v0p1',
           'DEV2': '',
           'BATCH_FILE': './batch.txt',
+          'BATCH_DIR': 'tmp',
           # Length of time in seconds to wait before terminating a command
           'TIMEOUT': 12,
           # Name of the namespace to use
diff --git a/tools/testing/selftests/tc-testing/tdc_multibatch.py b/tools/testing/selftests/tc-testing/tdc_multibatch.py
new file mode 100755
index 000000000000..cd980d1785bb
--- /dev/null
+++ b/tools/testing/selftests/tc-testing/tdc_multibatch.py
@@ -0,0 +1,38 @@
+#!/usr/bin/python3
+# SPDX-License-Identifier: GPL-2.0
+"""
+tdc_multibatch.py - a thin wrapper over tdc_batch.py to generate multiple batch
+files
+
+Copyright (C) 2019 Vlad Buslov <vladbu@mellanox.com>
+"""
+
+import argparse
+import os
+
+parser = argparse.ArgumentParser(
+    description='TC multiple batch file generator')
+parser.add_argument("device", help="device name")
+parser.add_argument("dir", help="where to put batch files")
+parser.add_argument(
+    "num_filters", type=int, help="how many lines per batch file")
+parser.add_argument("num_files", type=int, help="how many batch files")
+parser.add_argument(
+    "operation",
+    choices=['add', 'del', 'replace'],
+    help="operation to perform on filters")
+args = parser.parse_args()
+
+device = args.device
+dir = args.dir
+file_prefix = args.operation + "_"
+num_filters = args.num_filters
+num_files = args.num_files
+operation = args.operation
+handle = 1
+
+for i in range(num_files):
+    file = dir + '/' + file_prefix + str(i)
+    os.system("./tdc_batch.py -n {} -a {} -e {} -m {} {} {}".format(
+        num_filters, handle, operation, i, device, file))
+    handle += num_filters
-- 
2.13.6


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH net-next 3/8] selftests: concurrency: add test to verify parallel rules deletion
  2019-02-22 14:00 [PATCH net-next 0/8] Add tests for unlocked flower classifier implementation Vlad Buslov
  2019-02-22 14:00 ` [PATCH net-next 1/8] selftests: tdc_batch.py: add options needed for concurrency tests Vlad Buslov
  2019-02-22 14:00 ` [PATCH net-next 2/8] selftests: concurrency: add test to verify parallel rules insertion Vlad Buslov
@ 2019-02-22 14:00 ` Vlad Buslov
  2019-02-22 14:00 ` [PATCH net-next 4/8] selftests: concurrency: add test to verify parallel rules replace Vlad Buslov
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Vlad Buslov @ 2019-02-22 14:00 UTC (permalink / raw)
  To: netdev
  Cc: jhs, xiyou.wangcong, davem, shuah, batuhanosmantaskaya, lucasb,
	dcaratti, marcelo.leitner, chrism, Vlad Buslov

Implement test that verifies parallel rules deletion by adding 1 million
flower filters and then deleting them with 10 concurrent tc instances.

Signed-off-by: Vlad Buslov <vladbu@mellanox.com>
---
 .../tc-testing/tc-tests/filters/concurrency.json   | 25 ++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/tools/testing/selftests/tc-testing/tc-tests/filters/concurrency.json b/tools/testing/selftests/tc-testing/tc-tests/filters/concurrency.json
index adb14e944594..d26fa47844f1 100644
--- a/tools/testing/selftests/tc-testing/tc-tests/filters/concurrency.json
+++ b/tools/testing/selftests/tc-testing/tc-tests/filters/concurrency.json
@@ -21,5 +21,30 @@
             "$TC qdisc del dev $DEV2 ingress",
             "/bin/rm -rf $BATCH_DIR"
         ]
+    },
+    {
+        "id": "6f52",
+        "name": "Delete 1M flower filters with 10 parallel tc instances",
+        "category": [
+            "filter",
+            "flower",
+            "concurrency"
+        ],
+        "setup": [
+            "/bin/mkdir $BATCH_DIR",
+            "$TC qdisc add dev $DEV2 ingress",
+            "./tdc_multibatch.py $DEV2 $BATCH_DIR 1000000 1 add",
+            "$TC -b $BATCH_DIR/add_0",
+            "./tdc_multibatch.py $DEV2 $BATCH_DIR 100000 10 del"
+        ],
+        "cmdUnderTest": "find $BATCH_DIR/del* -print | xargs -n 1 -P 10 $TC -b",
+        "expExitCode": "0",
+        "verifyCmd": "$TC -s filter show dev $DEV2 ingress",
+        "matchPattern": "filter protocol ip pref 1 flower chain 0 handle",
+        "matchCount": "0",
+        "teardown": [
+            "$TC qdisc del dev $DEV2 ingress",
+            "/bin/rm -rf $BATCH_DIR"
+        ]
     }
 ]
-- 
2.13.6


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH net-next 4/8] selftests: concurrency: add test to verify parallel rules replace
  2019-02-22 14:00 [PATCH net-next 0/8] Add tests for unlocked flower classifier implementation Vlad Buslov
                   ` (2 preceding siblings ...)
  2019-02-22 14:00 ` [PATCH net-next 3/8] selftests: concurrency: add test to verify parallel rules deletion Vlad Buslov
@ 2019-02-22 14:00 ` Vlad Buslov
  2019-02-22 14:00 ` [PATCH net-next 5/8] selftests: concurrency: add test to verify concurrent replace Vlad Buslov
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Vlad Buslov @ 2019-02-22 14:00 UTC (permalink / raw)
  To: netdev
  Cc: jhs, xiyou.wangcong, davem, shuah, batuhanosmantaskaya, lucasb,
	dcaratti, marcelo.leitner, chrism, Vlad Buslov

Implement test that verifies parallel rules replacement by adding 1 million
flower filters and then replacing them with 10 concurrent tc instances.

Signed-off-by: Vlad Buslov <vladbu@mellanox.com>
---
 .../tc-testing/tc-tests/filters/concurrency.json   | 25 ++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/tools/testing/selftests/tc-testing/tc-tests/filters/concurrency.json b/tools/testing/selftests/tc-testing/tc-tests/filters/concurrency.json
index d26fa47844f1..57ed29eb58bf 100644
--- a/tools/testing/selftests/tc-testing/tc-tests/filters/concurrency.json
+++ b/tools/testing/selftests/tc-testing/tc-tests/filters/concurrency.json
@@ -46,5 +46,30 @@
             "$TC qdisc del dev $DEV2 ingress",
             "/bin/rm -rf $BATCH_DIR"
         ]
+    },
+    {
+        "id": "c9da",
+        "name": "Replace 1M flower filters with 10 parallel tc instances",
+        "category": [
+            "filter",
+            "flower",
+            "concurrency"
+        ],
+        "setup": [
+            "/bin/mkdir $BATCH_DIR",
+            "$TC qdisc add dev $DEV2 ingress",
+            "./tdc_multibatch.py $DEV2 $BATCH_DIR 1000000 1 add",
+            "$TC -b $BATCH_DIR/add_0",
+            "./tdc_multibatch.py $DEV2 $BATCH_DIR 100000 10 replace"
+        ],
+        "cmdUnderTest": "find $BATCH_DIR/replace* -print | xargs -n 1 -P 10 $TC -b",
+        "expExitCode": "0",
+        "verifyCmd": "$TC -s filter show dev $DEV2 ingress",
+        "matchPattern": "filter protocol ip pref 1 flower chain 0 handle",
+        "matchCount": "1000000",
+        "teardown": [
+            "$TC qdisc del dev $DEV2 ingress",
+            "/bin/rm -rf $BATCH_DIR"
+        ]
     }
 ]
-- 
2.13.6


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH net-next 5/8] selftests: concurrency: add test to verify concurrent replace
  2019-02-22 14:00 [PATCH net-next 0/8] Add tests for unlocked flower classifier implementation Vlad Buslov
                   ` (3 preceding siblings ...)
  2019-02-22 14:00 ` [PATCH net-next 4/8] selftests: concurrency: add test to verify parallel rules replace Vlad Buslov
@ 2019-02-22 14:00 ` Vlad Buslov
  2019-02-22 14:00 ` [PATCH net-next 6/8] selftests: concurrency: add test to verify concurrent delete Vlad Buslov
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Vlad Buslov @ 2019-02-22 14:00 UTC (permalink / raw)
  To: netdev
  Cc: jhs, xiyou.wangcong, davem, shuah, batuhanosmantaskaya, lucasb,
	dcaratti, marcelo.leitner, chrism, Vlad Buslov

Implement test that verifies concurrent replacement of rules by executing
10 tc instances that replace flower filters in same handle range.

Extend tdc_multibatch.py script with new optional CLI argument that is used
to generate all batch files with same filter handle range.

Signed-off-by: Vlad Buslov <vladbu@mellanox.com>
---
 .../tc-testing/tc-tests/filters/concurrency.json   | 25 ++++++++++++++++++++++
 .../testing/selftests/tc-testing/tdc_multibatch.py |  9 +++++++-
 2 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/tc-testing/tc-tests/filters/concurrency.json b/tools/testing/selftests/tc-testing/tc-tests/filters/concurrency.json
index 57ed29eb58bf..3c49fca7e76c 100644
--- a/tools/testing/selftests/tc-testing/tc-tests/filters/concurrency.json
+++ b/tools/testing/selftests/tc-testing/tc-tests/filters/concurrency.json
@@ -71,5 +71,30 @@
             "$TC qdisc del dev $DEV2 ingress",
             "/bin/rm -rf $BATCH_DIR"
         ]
+    },
+    {
+        "id": "14be",
+        "name": "Concurrently replace same range of 100k flower filters from 10 tc instances",
+        "category": [
+            "filter",
+            "flower",
+            "concurrency"
+        ],
+        "setup": [
+            "/bin/mkdir $BATCH_DIR",
+            "$TC qdisc add dev $DEV2 ingress",
+            "./tdc_multibatch.py $DEV2 $BATCH_DIR 100000 1 add",
+            "$TC -b $BATCH_DIR/add_0",
+            "./tdc_multibatch.py -d $DEV2 $BATCH_DIR 100000 10 replace"
+        ],
+        "cmdUnderTest": "find $BATCH_DIR/replace* -print | xargs -n 1 -P 10 $TC -b",
+        "expExitCode": "0",
+        "verifyCmd": "$TC -s filter show dev $DEV2 ingress",
+        "matchPattern": "filter protocol ip pref 1 flower chain 0 handle",
+        "matchCount": "100000",
+        "teardown": [
+            "$TC qdisc del dev $DEV2 ingress",
+            "/bin/rm -rf $BATCH_DIR"
+        ]
     }
 ]
diff --git a/tools/testing/selftests/tc-testing/tdc_multibatch.py b/tools/testing/selftests/tc-testing/tdc_multibatch.py
index cd980d1785bb..0d8be39b5580 100755
--- a/tools/testing/selftests/tc-testing/tdc_multibatch.py
+++ b/tools/testing/selftests/tc-testing/tdc_multibatch.py
@@ -21,6 +21,11 @@ parser.add_argument(
     "operation",
     choices=['add', 'del', 'replace'],
     help="operation to perform on filters")
+parser.add_argument(
+    "-d",
+    "--duplicate_handles",
+    action="store_true",
+    help="duplicate filter handle range in all files")
 args = parser.parse_args()
 
 device = args.device
@@ -29,10 +34,12 @@ file_prefix = args.operation + "_"
 num_filters = args.num_filters
 num_files = args.num_files
 operation = args.operation
+duplicate_handles = args.duplicate_handles
 handle = 1
 
 for i in range(num_files):
     file = dir + '/' + file_prefix + str(i)
     os.system("./tdc_batch.py -n {} -a {} -e {} -m {} {} {}".format(
         num_filters, handle, operation, i, device, file))
-    handle += num_filters
+    if not duplicate_handles:
+        handle += num_filters
-- 
2.13.6


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH net-next 6/8] selftests: concurrency: add test to verify concurrent delete
  2019-02-22 14:00 [PATCH net-next 0/8] Add tests for unlocked flower classifier implementation Vlad Buslov
                   ` (4 preceding siblings ...)
  2019-02-22 14:00 ` [PATCH net-next 5/8] selftests: concurrency: add test to verify concurrent replace Vlad Buslov
@ 2019-02-22 14:00 ` Vlad Buslov
  2019-02-22 14:00 ` [PATCH net-next 7/8] selftests: concurrency: add test to verify parallel add/delete Vlad Buslov
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Vlad Buslov @ 2019-02-22 14:00 UTC (permalink / raw)
  To: netdev
  Cc: jhs, xiyou.wangcong, davem, shuah, batuhanosmantaskaya, lucasb,
	dcaratti, marcelo.leitner, chrism, Vlad Buslov

Implement test that verifies concurrent deletion of rules by executing 10
tc instances that delete flower filters in same handle range. In this case
only one tc instance succeeds in deleting a filter with particular handle.
To mitigate expected failures of all other instances, run tc with 'force'
option to continue processing batch file in case of errors and expect xargs
to return code '123' that indicates that invocation of command(s) exited
with error in range 1-125.

Signed-off-by: Vlad Buslov <vladbu@mellanox.com>
---
 .../tc-testing/tc-tests/filters/concurrency.json   | 25 ++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/tools/testing/selftests/tc-testing/tc-tests/filters/concurrency.json b/tools/testing/selftests/tc-testing/tc-tests/filters/concurrency.json
index 3c49fca7e76c..102a6a3f08df 100644
--- a/tools/testing/selftests/tc-testing/tc-tests/filters/concurrency.json
+++ b/tools/testing/selftests/tc-testing/tc-tests/filters/concurrency.json
@@ -96,5 +96,30 @@
             "$TC qdisc del dev $DEV2 ingress",
             "/bin/rm -rf $BATCH_DIR"
         ]
+    },
+    {
+        "id": "0c44",
+        "name": "Concurrently delete same range of 100k flower filters from 10 tc instances",
+        "category": [
+            "filter",
+            "flower",
+            "concurrency"
+        ],
+        "setup": [
+            "/bin/mkdir $BATCH_DIR",
+            "$TC qdisc add dev $DEV2 ingress",
+            "./tdc_multibatch.py $DEV2 $BATCH_DIR 100000 1 add",
+            "$TC -b $BATCH_DIR/add_0",
+            "./tdc_multibatch.py -d $DEV2 $BATCH_DIR 100000 10 del"
+        ],
+        "cmdUnderTest": "find $BATCH_DIR/del* -print | xargs -n 1 -P 10 $TC -f -b",
+        "expExitCode": "123",
+        "verifyCmd": "$TC -s filter show dev $DEV2 ingress",
+        "matchPattern": "filter protocol ip pref 1 flower chain 0 handle",
+        "matchCount": "0",
+        "teardown": [
+            "$TC qdisc del dev $DEV2 ingress",
+	    "/bin/rm -rf $BATCH_DIR"
+        ]
     }
 ]
-- 
2.13.6


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH net-next 7/8] selftests: concurrency: add test to verify parallel add/delete
  2019-02-22 14:00 [PATCH net-next 0/8] Add tests for unlocked flower classifier implementation Vlad Buslov
                   ` (5 preceding siblings ...)
  2019-02-22 14:00 ` [PATCH net-next 6/8] selftests: concurrency: add test to verify concurrent delete Vlad Buslov
@ 2019-02-22 14:00 ` Vlad Buslov
  2019-02-22 14:00 ` [PATCH net-next 8/8] selftests: concurrency: add test to verify parallel replace/delete Vlad Buslov
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Vlad Buslov @ 2019-02-22 14:00 UTC (permalink / raw)
  To: netdev
  Cc: jhs, xiyou.wangcong, davem, shuah, batuhanosmantaskaya, lucasb,
	dcaratti, marcelo.leitner, chrism, Vlad Buslov

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>
---
 .../tc-testing/tc-tests/filters/concurrency.json   | 26 ++++++++++++++++++++++
 .../testing/selftests/tc-testing/tdc_multibatch.py | 26 +++++++++++++++++++---
 2 files changed, 49 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/tc-testing/tc-tests/filters/concurrency.json b/tools/testing/selftests/tc-testing/tc-tests/filters/concurrency.json
index 102a6a3f08df..8316634a0cd7 100644
--- a/tools/testing/selftests/tc-testing/tc-tests/filters/concurrency.json
+++ b/tools/testing/selftests/tc-testing/tc-tests/filters/concurrency.json
@@ -121,5 +121,31 @@
             "$TC qdisc del dev $DEV2 ingress",
 	    "/bin/rm -rf $BATCH_DIR"
         ]
+    },
+    {
+        "id": "ab62",
+        "name": "Add and delete from same tp with 10 tc instances",
+        "category": [
+            "filter",
+            "flower",
+            "concurrency"
+        ],
+        "setup": [
+            "/bin/mkdir $BATCH_DIR",
+            "$TC qdisc add dev $DEV2 ingress",
+            "./tdc_multibatch.py -x init_ $DEV2 $BATCH_DIR 100000 5 add",
+            "find $BATCH_DIR/init_* -print | xargs -n 1 -P 5 $TC -b",
+            "./tdc_multibatch.py -x par_ -a 500001 -m 5 $DEV2 $BATCH_DIR 100000 5 add",
+            "./tdc_multibatch.py -x par_ $DEV2 $BATCH_DIR 100000 5 del"
+        ],
+        "cmdUnderTest": "find $BATCH_DIR/par_* -print | xargs -n 1 -P 10 $TC -b",
+        "expExitCode": "0",
+        "verifyCmd": "$TC -s filter show dev $DEV2 ingress",
+        "matchPattern": "filter protocol ip pref 1 flower chain 0 handle",
+        "matchCount": "500000",
+        "teardown": [
+            "$TC qdisc del dev $DEV2 ingress",
+            "/bin/rm -rf $BATCH_DIR"
+        ]
     }
 ]
diff --git a/tools/testing/selftests/tc-testing/tdc_multibatch.py b/tools/testing/selftests/tc-testing/tdc_multibatch.py
index 0d8be39b5580..5e7237952e49 100755
--- a/tools/testing/selftests/tc-testing/tdc_multibatch.py
+++ b/tools/testing/selftests/tc-testing/tdc_multibatch.py
@@ -22,24 +22,44 @@ parser.add_argument(
     choices=['add', 'del', 'replace'],
     help="operation to perform on filters")
 parser.add_argument(
+    "-x",
+    "--file_prefix",
+    default="",
+    help="prefix for generated batch file names")
+parser.add_argument(
     "-d",
     "--duplicate_handles",
     action="store_true",
     help="duplicate filter handle range in all files")
+parser.add_argument(
+    "-a",
+    "--handle_start",
+    type=int,
+    default=1,
+    help="start handle range from (default: 1)")
+parser.add_argument(
+    "-m",
+    "--mac_prefix",
+    type=int,
+    default=0,
+    choices=range(0, 256),
+    help="add this value to third byte of source MAC address of flower filter"
+    "(default: 0)")
 args = parser.parse_args()
 
 device = args.device
 dir = args.dir
-file_prefix = args.operation + "_"
+file_prefix = args.file_prefix + args.operation + "_"
 num_filters = args.num_filters
 num_files = args.num_files
 operation = args.operation
 duplicate_handles = args.duplicate_handles
-handle = 1
+handle = args.handle_start
+mac_prefix = args.mac_prefix
 
 for i in range(num_files):
     file = dir + '/' + file_prefix + str(i)
     os.system("./tdc_batch.py -n {} -a {} -e {} -m {} {} {}".format(
-        num_filters, handle, operation, i, device, file))
+        num_filters, handle, operation, i + mac_prefix, device, file))
     if not duplicate_handles:
         handle += num_filters
-- 
2.13.6


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH net-next 8/8] selftests: concurrency: add test to verify parallel replace/delete
  2019-02-22 14:00 [PATCH net-next 0/8] Add tests for unlocked flower classifier implementation Vlad Buslov
                   ` (6 preceding siblings ...)
  2019-02-22 14:00 ` [PATCH net-next 7/8] selftests: concurrency: add test to verify parallel add/delete Vlad Buslov
@ 2019-02-22 14:00 ` Vlad Buslov
  2019-02-22 17:35 ` [PATCH net-next 0/8] Add tests for unlocked flower classifier implementation Cong Wang
  2019-02-24 20:50 ` David Miller
  9 siblings, 0 replies; 11+ messages in thread
From: Vlad Buslov @ 2019-02-22 14:00 UTC (permalink / raw)
  To: netdev
  Cc: jhs, xiyou.wangcong, davem, shuah, batuhanosmantaskaya, lucasb,
	dcaratti, marcelo.leitner, chrism, Vlad Buslov

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

Signed-off-by: Vlad Buslov <vladbu@mellanox.com>
---
 .../tc-testing/tc-tests/filters/concurrency.json   | 26 ++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/tools/testing/selftests/tc-testing/tc-tests/filters/concurrency.json b/tools/testing/selftests/tc-testing/tc-tests/filters/concurrency.json
index 8316634a0cd7..9002714b1851 100644
--- a/tools/testing/selftests/tc-testing/tc-tests/filters/concurrency.json
+++ b/tools/testing/selftests/tc-testing/tc-tests/filters/concurrency.json
@@ -147,5 +147,31 @@
             "$TC qdisc del dev $DEV2 ingress",
             "/bin/rm -rf $BATCH_DIR"
         ]
+    },
+    {
+        "id": "6e8f",
+        "name": "Replace and delete from same tp with 10 tc instances",
+        "category": [
+            "filter",
+            "flower",
+            "concurrency"
+        ],
+        "setup": [
+            "/bin/mkdir $BATCH_DIR",
+            "$TC qdisc add dev $DEV2 ingress",
+            "./tdc_multibatch.py -x init_ $DEV2 $BATCH_DIR 100000 10 add",
+            "find $BATCH_DIR/init_* -print | xargs -n 1 -P 5 $TC -b",
+            "./tdc_multibatch.py -x par_ -a 500001 -m 5 $DEV2 $BATCH_DIR 100000 5 replace",
+            "./tdc_multibatch.py -x par_ $DEV2 $BATCH_DIR 100000 5 del"
+        ],
+        "cmdUnderTest": "find $BATCH_DIR/par_* -print | xargs -n 1 -P 10 $TC -b",
+        "expExitCode": "0",
+        "verifyCmd": "$TC -s filter show dev $DEV2 ingress",
+        "matchPattern": "filter protocol ip pref 1 flower chain 0 handle",
+        "matchCount": "500000",
+        "teardown": [
+            "$TC qdisc del dev $DEV2 ingress",
+            "/bin/rm -rf $BATCH_DIR"
+        ]
     }
 ]
-- 
2.13.6


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH net-next 0/8] Add tests for unlocked flower classifier implementation
  2019-02-22 14:00 [PATCH net-next 0/8] Add tests for unlocked flower classifier implementation Vlad Buslov
                   ` (7 preceding siblings ...)
  2019-02-22 14:00 ` [PATCH net-next 8/8] selftests: concurrency: add test to verify parallel replace/delete Vlad Buslov
@ 2019-02-22 17:35 ` Cong Wang
  2019-02-24 20:50 ` David Miller
  9 siblings, 0 replies; 11+ messages in thread
From: Cong Wang @ 2019-02-22 17:35 UTC (permalink / raw)
  To: Vlad Buslov
  Cc: Linux Kernel Network Developers, Jamal Hadi Salim, David Miller,
	shuah, batuhanosmantaskaya, Lucas Bates, Davide Caratti,
	Marcelo Ricardo Leitner, Chris Mi

On Fri, Feb 22, 2019 at 6:00 AM Vlad Buslov <vladbu@mellanox.com> wrote:
>
> Implement tests for tdc testsuite to verify concurrent rules update with
> rtnl-unlocked flower classifier implementation. The goal of these tests
> is to verify general flower classifier correctness by updating filters
> on same classifier instance in parallel and to verify its atomicity by
> concurrently updating filters in same handle range. All three filter
> update operations (add, replace, delete) are tested.
>
> Existing script tdc_batch.py is re-used for batch file generation. It is
> extended with several optional CLI arguments that are needed for
> concurrency tests. Thin wrapper tdc_multibatch.py is implemented on top
> of tdc_batch.py to simplify its usage when generating multiple batch
> files for several test configurations.
>
> Parallelism in tests is implemented by running multiple instances of tc
> in batch mode with xargs tool. Xargs is chosen for its ease of use and
> because it is available by default on most modern Linux distributions.

I don't look into the details, but I love to see we have tests for parallel
filter updates! So for the whole patchset:

Acked-by: Cong Wang <xiyou.wangcong@gmail.com>

Thanks!

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH net-next 0/8] Add tests for unlocked flower classifier implementation
  2019-02-22 14:00 [PATCH net-next 0/8] Add tests for unlocked flower classifier implementation Vlad Buslov
                   ` (8 preceding siblings ...)
  2019-02-22 17:35 ` [PATCH net-next 0/8] Add tests for unlocked flower classifier implementation Cong Wang
@ 2019-02-24 20:50 ` David Miller
  9 siblings, 0 replies; 11+ messages in thread
From: David Miller @ 2019-02-24 20:50 UTC (permalink / raw)
  To: vladbu
  Cc: netdev, jhs, xiyou.wangcong, shuah, batuhanosmantaskaya, lucasb,
	dcaratti, marcelo.leitner, chrism

From: Vlad Buslov <vladbu@mellanox.com>
Date: Fri, 22 Feb 2019 16:00:39 +0200

> Implement tests for tdc testsuite to verify concurrent rules update with
> rtnl-unlocked flower classifier implementation. The goal of these tests
> is to verify general flower classifier correctness by updating filters
> on same classifier instance in parallel and to verify its atomicity by
> concurrently updating filters in same handle range. All three filter
> update operations (add, replace, delete) are tested.
> 
> Existing script tdc_batch.py is re-used for batch file generation. It is
> extended with several optional CLI arguments that are needed for
> concurrency tests. Thin wrapper tdc_multibatch.py is implemented on top
> of tdc_batch.py to simplify its usage when generating multiple batch
> files for several test configurations.
> 
> Parallelism in tests is implemented by running multiple instances of tc
> in batch mode with xargs tool. Xargs is chosen for its ease of use and
> because it is available by default on most modern Linux distributions.

Series applied, thanks Vlad.

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2019-02-24 20:50 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-22 14:00 [PATCH net-next 0/8] Add tests for unlocked flower classifier implementation Vlad Buslov
2019-02-22 14:00 ` [PATCH net-next 1/8] selftests: tdc_batch.py: add options needed for concurrency tests Vlad Buslov
2019-02-22 14:00 ` [PATCH net-next 2/8] selftests: concurrency: add test to verify parallel rules insertion Vlad Buslov
2019-02-22 14:00 ` [PATCH net-next 3/8] selftests: concurrency: add test to verify parallel rules deletion Vlad Buslov
2019-02-22 14:00 ` [PATCH net-next 4/8] selftests: concurrency: add test to verify parallel rules replace Vlad Buslov
2019-02-22 14:00 ` [PATCH net-next 5/8] selftests: concurrency: add test to verify concurrent replace Vlad Buslov
2019-02-22 14:00 ` [PATCH net-next 6/8] selftests: concurrency: add test to verify concurrent delete Vlad Buslov
2019-02-22 14:00 ` [PATCH net-next 7/8] selftests: concurrency: add test to verify parallel add/delete Vlad Buslov
2019-02-22 14:00 ` [PATCH net-next 8/8] selftests: concurrency: add test to verify parallel replace/delete Vlad Buslov
2019-02-22 17:35 ` [PATCH net-next 0/8] Add tests for unlocked flower classifier implementation Cong Wang
2019-02-24 20:50 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).