From: Chris Mi <chrism@mellanox.com>
To: netdev@vger.kernel.org
Cc: gerlitz.or@gmail.com, stephen@networkplumber.org,
dsahern@gmail.com, marcelo.leitner@gmail.com
Subject: [patch iproute2 v5 0/3] tc: Add -bs option to batch mode
Date: Wed, 3 Jan 2018 11:55:14 +0900 [thread overview]
Message-ID: <20180103025517.3767-1-chrism@mellanox.com> (raw)
Currently in tc batch mode, only one command is read from the batch
file and sent to kernel to process. With this patchset, we can accumulate
several commands before sending to kernel. The batch size is specified
using option -bs or -batchsize.
To accumulate the commands in tc, client should allocate an array of
struct iovec. If batchsize is bigger than 1, only after the client
has accumulated enough commands, can the client call rtnl_talk_msg
to send the message that includes the iov array. One exception is
that there is no more command in the batch file.
But please note that kernel still processes the requests one by one.
To process the requests in parallel in kernel is another effort.
The time we're saving in this patchset is the user mode and kernel mode
context switch. So this patchset works on top of the current kernel.
Using the following script in kernel, we can generate 1,000,000 rules.
tools/testing/selftests/tc-testing/tdc_batch.py
Without this patchset, 'tc -b $file' exection time is:
real 0m15.125s
user 0m6.982s
sys 0m8.080s
With this patchset, 'tc -b $file -bs 10' exection time is:
real 0m12.772s
user 0m5.984s
sys 0m6.723s
The insertion rate is improved more than 10%.
In this patchset, we still ack for every rule. If we don't ack at all,
'tc -b $file' exection time is:
real 0m14.484s
user 0m6.919s
sys 0m7.498s
'tc -b $file -bs 10' exection time is:
real 0m11.664s
user 0m6.017s
sys 0m5.578s
We can see that the performance win is to send multiple messages instead
of no acking. I think that's because in tc, we don't spend too much time
processing the ack message.
v3
==
1. Instead of hacking function rtnl_talk directly, add a new function
rtnl_talk_msg.
2. remove most of global variables to use parameter passing
3. divide the previous patch into 4 patches.
v4
==
1. Remove function setcmdlinetotal. Now in function batch, we read one
more line to determine if we are reaching the end of file.
2. Remove function __rtnl_check_ack. Now __rtnl_talk calls __rtnl_talk_msg
directly.
3. if (batch_size < 1)
batch_size = 1;
v5
==
1. Fix a bug that can't deal with batch file with blank line.
2. Describe the limitation in man page.
Chris Mi (3):
lib/libnetlink: Add a function rtnl_talk_msg
tc: Add -bs option to batch mode
man: Add -bs option to tc manpage
include/libnetlink.h | 3 ++
lib/libnetlink.c | 59 ++++++++++++++++++-------
man/man8/tc.8 | 9 ++++
tc/m_action.c | 90 +++++++++++++++++++++++++++++---------
tc/tc.c | 70 +++++++++++++++++++++++------
tc/tc_common.h | 8 +++-
tc/tc_filter.c | 121 +++++++++++++++++++++++++++++++++++++--------------
7 files changed, 276 insertions(+), 84 deletions(-)
--
2.14.3
next reply other threads:[~2018-01-03 2:55 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-03 2:55 Chris Mi [this message]
2018-01-03 2:55 ` [patch iproute2 v5 1/3] lib/libnetlink: Add a function rtnl_talk_msg Chris Mi
2018-01-03 4:08 ` David Ahern
2018-01-04 7:27 ` Chris Mi
2018-01-03 2:55 ` [patch iproute2 v5 2/3] tc: Add -bs option to batch mode Chris Mi
2018-01-03 4:25 ` David Ahern
2018-01-04 7:32 ` Chris Mi
2018-01-03 2:55 ` [patch iproute2 v5 3/3] man: Add -bs option to tc manpage Chris Mi
2018-01-03 2:57 ` [patch iproute2 v5 0/3] tc: Add -bs option to batch mode David Ahern
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180103025517.3767-1-chrism@mellanox.com \
--to=chrism@mellanox.com \
--cc=dsahern@gmail.com \
--cc=gerlitz.or@gmail.com \
--cc=marcelo.leitner@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox