Git Product home page Git Product logo

Comments (4)

yonghong-song avatar yonghong-song commented on May 14, 2024

The following diff fixed the problem:

plumgrid@yhs-plumgrid:~/iovisor/bcc/tests/jit$ git diff

diff --git a/tests/jit/bpfdev1.b b/tests/jit/bpfdev1.b
index c2ecddd..bc04002 100644
--- a/tests/jit/bpfdev1.b
+++ b/tests/jit/bpfdev1.b
@@ -110,49 +110,53 @@ u32 main(struct proto::skbuff *skb) {
       u32 old_ip:32;
       u64 src_mac:48;
       u64 dst_mac:48;
+      u32 bpfdev_ip:32;
+      u32 slave_ip:32;

       struct ConfigKey cfg_key = {.index = 0};
       struct ConfigLeaf *cfg_leaf;
       config_map.lookup(cfg_key, cfg_leaf) {};
       on_valid(cfg_leaf) {
-        struct MacaddrKey mac_key = {.ip = cfg_leaf->bpfdev_ip};
-        struct MacaddrLeaf *mac_leaf;
-
-        mac_key.ip = cfg_leaf->bpfdev_ip;
-        macaddr_map.lookup(mac_key, mac_leaf) {};
-        on_valid (mac_leaf) {
-          src_mac = mac_leaf->mac;
-        } else {
-         goto EOP;
-        }
-
-        mac_key.ip = cfg_leaf->slave_ip;
-        macaddr_map.lookup(mac_key, mac_leaf) {};
-        on_valid (mac_leaf) {
-          dst_mac = mac_leaf->mac;
-        } else {
-         goto EOP;
-        }
-
-        // rewrite ethernet header
-        pkt.rewrite_field($ethernet.dst, dst_mac);
-        pkt.rewrite_field($ethernet.src, src_mac);
-
-        // ip & udp checksum
-        incr_cksum(@ip.hchecksum, $ip.src, cfg_leaf->bpfdev_ip);
-        incr_cksum(@ip.hchecksum, $ip.dst, cfg_leaf->slave_ip);
-        incr_cksum(@udp.crc, $ip.src, cfg_leaf->bpfdev_ip, 1);
-        incr_cksum(@udp.crc, $ip.dst, cfg_leaf->slave_ip, 1);
-
-        // rewrite ip src/dst fields
-        pkt.rewrite_field($ip.src, cfg_leaf->bpfdev_ip);
-        pkt.rewrite_field($ip.dst, cfg_leaf->slave_ip);
+        bpfdev_ip = cfg_leaf->bpfdev_ip;
+        slave_ip = cfg_leaf->slave_ip;
+      } else {
+        goto EOP;
+      }

+      struct MacaddrKey mac_key = {.ip = bpfdev_ip};
+      struct MacaddrLeaf *mac_leaf;
+
+      mac_key.ip = bpfdev_ip;
+      macaddr_map.lookup(mac_key, mac_leaf) {};
+      on_valid (mac_leaf) {
+        src_mac = mac_leaf->mac;
+      } else {
         goto EOP;
+      }

+      mac_key.ip = slave_ip;
+      macaddr_map.lookup(mac_key, mac_leaf) {};
+      on_valid (mac_leaf) {
+        dst_mac = mac_leaf->mac;
       } else {
         goto EOP;
       }
+
+      // rewrite ethernet header
+      pkt.rewrite_field($ethernet.dst, dst_mac);
+      pkt.rewrite_field($ethernet.src, src_mac);
+
+      // ip & udp checksum
+      incr_cksum(@ip.hchecksum, $ip.src, bpfdev_ip);
+      incr_cksum(@ip.hchecksum, $ip.dst, slave_ip);
+      incr_cksum(@udp.crc, $ip.src, bpfdev_ip, 1);
+      incr_cksum(@udp.crc, $ip.dst, slave_ip, 1);
+
+      // rewrite ip src/dst fields
+      pkt.rewrite_field($ip.src, bpfdev_ip);
+      pkt.rewrite_field($ip.dst, slave_ip);
+
+      goto EOP;
     }
   }

plumgrid@yhs-plumgrid:~/iovisor/bcc/tests/jit$

Basically, the map result should have a short live range by copying to local variable.

from bcc.

4ast avatar 4ast commented on May 14, 2024

the diff is mangled it seems. It seems it's a workaround by using inside knowledge of front-end gen ?
I think we should try to fix it in the backend. Clearly r2=r1 assignments are redundant.
I also don't 'remat' pass to be run. It's important. Otherwise constant values will be copied between registers instead of using 'mov Rx, imm' which is faster, less register pressure and easier on verifier.

from bcc.

drzaeus77 avatar drzaeus77 commented on May 14, 2024

I've updated the diff with proper github markdown syntax. Alexei, do you have any advice on how to fix it in the backend, or are you considering that your own AI?

from bcc.

4ast avatar 4ast commented on May 14, 2024

I don't have a concrete plan. I suspect there is still something we missing
about pass_manager. Probably need to enable several more passes.

On Mon, May 11, 2015 at 6:34 AM, Brenden [email protected] wrote:

I've updated the diff with proper github markdown syntax. Alexei, do you
have any advice on how to fix it in the backend, or are you considering
that your own AI?


Reply to this email directly or view it on GitHub
#10 (comment).

from bcc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.