Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add command-line argument for debugging purposes (-dm) and only print the last_size info when debug is enabled #324

Merged
merged 2 commits into from
Nov 24, 2014

Conversation

clopez
Copy link
Contributor

@clopez clopez commented Nov 19, 2014

The first commit on this PR adds a new command line to snabswitch:

-dm = Enable developer mode. Enables debug prints and asserts.
  • This sets to true a global variable _G.developer_debug that can be
    used on the rest of snabswitch to enable prints, asserts or other
    things that are not intended for production.
  • Make all other parts of snabswitch where a debug variable was used
    (or should be used) to depend on this one.

The second commit makes the last_size print check to happen only when debug is enabled (previously debug was just an alias to print). Check PR #323 for info about this issue

  * -dm = Enable developer mode. Enables debug prints and asserts.

  * This sets to true a global variable _G.developer_debug that can be
    used on the rest of snabswitch to enable prints, asserts or other
    things that are not intended for production.

  * Make all other parts of snabswitch where a debug variable was used
    (or should be used) to depend on this one.
 * This code starts triggering on a kernel >= 3.14 (Ubuntu 14.04 uses
   3.13, so this went unnoticed). It causes a lot of flood because it
   triggers constantly.

 * Example of the output from snabswitch when running same_vlan.ports
   with both VMs running Kernel 3.14.23 and running an iperf test
   (MTU 1500) between both VMs:

      size=  2036
      size=  1524
      size=  2036
      size=  1524
      size=  2036
      size=  1524
      [ .... repeated ad-infinitum ]

 * I have bisected the Linux kernel, the commit that causes this print to
   trigger is fb51879dbceab9c40a39018d5322451691909e15 (merged on 3.14)
   https://git.kernel.org/linus/fb51879
@clopez clopez mentioned this pull request Nov 19, 2014
@@ -259,7 +259,7 @@ function VirtioNetDevice:vm_buffer (iovec)
iovec.offset = 0
end
end
if last_size ~= b.size then print("size=", b.size) last_size=b.size end
if last_size ~= b.size then debug("size=", b.size) last_size=b.size end
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we somehow disable this whole line when debug is not enabled.
I know how to do it in C with macros, what is the right approach in Lua?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can do something like:

   if _G.developer_debug then
      if last_size ~= b.size then debug("size=", b.size) last_size=b.size end
   end

?

lukego added a commit that referenced this pull request Nov 24, 2014
Add command-line argument for debugging purposes (-dm) and only print the last_size info when debug is enabled
@lukego lukego merged commit db1bdef into snabbco:master Nov 24, 2014
@lukego
Copy link
Member

lukego commented Nov 24, 2014

Good idea, thanks for the patch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants