Re: [iovisor-dev] Automatic Loop Unrolling not working with #pragma unroll

2016-12-08 Thread Fulvio Risso via iovisor-dev

Dear Thomas,
definitely a good reason for not unrolling the loop.
Thanks,

fulvio

On 08/12/2016 15:12, Thomas Graf via iovisor-dev wrote:

On 7 December 2016 at 22:06, Mauricio Vasquez via iovisor-dev
 wrote:

BPF_TABLE("array", u32, struct rt_entry, routing_table, ROUTING_TABLE_DIM);

static int handle_rx(void *skb, struct metadata *md) {
  u8 *cursor = 0;
  struct ip_t *ip = cursor_advance(cursor, sizeof(*ip));

  int i = 0;
  struct rt_entry *rt_entry_p = 0;
  u32 ip_dst_masked = 0;

  //#pragma unroll
  #pragma clang loop unroll(full)
  for (i = 0; i < ROUTING_TABLE_DIM; i++) {
rt_entry_p = routing_table.lookup();


Might be because you pass a pointer here?


if (rt_entry_p) {
  ip_dst_masked = ip->dst & rt_entry_p->netmask;
  if (ip_dst_masked == rt_entry_p->network) {
goto FORWARD;
  }
}
  }

DROP:
  return RX_DROP;

FORWARD:
  pkt_redirect(skb,md, rt_entry_p->port);
  return RX_REDIRECT;
}

Do you have any idea why clang is not unrolling that loop?


It is working fine for us here and we're just using the standard unroll pragma:
https://github.com/cilium/cilium/blob/master/bpf/lib/l3.h#L131
___
iovisor-dev mailing list
iovisor-dev@lists.iovisor.org
https://lists.iovisor.org/mailman/listinfo/iovisor-dev


___
iovisor-dev mailing list
iovisor-dev@lists.iovisor.org
https://lists.iovisor.org/mailman/listinfo/iovisor-dev


Re: [iovisor-dev] arm64: LLVM ERROR: Inline asm not supported

2016-12-08 Thread Ming Lei via iovisor-dev
Hi Alexei,

Thank you for so quick response!

On Fri, Dec 9, 2016 at 12:37 AM, Alexei Starovoitov
 wrote:
> On Thu, Dec 8, 2016 at 8:20 AM, Ming Lei via iovisor-dev
>  wrote:
>> Hi,
>>
>> Bcc can be installed on ubuntu 16.04/arm64 successfully, but when
>> I try to trace, the folllowing failure[1] is triggered.
>>
>> So is bcc not ready for arm64? Or something is wrong?
>>
>> BTW, clang/llvm is 3.8, and I am happy to try any patches/tests
>> if you have ideas about the issue.
>>
>> Thanks,
>> Ming
>>  %w0
>> 13 warnings generated.
>> LLVM ERROR: Inline asm not supported by this streamer because we don't
>> have an asm parser for this target
>
> I suspect this is due to bcc not passing -D__ASM_SYSREG_H into clang
> like we do in samples/bpf/Makefile to workaround this issue.

Yeah, that is one problem, once I apply the following change,
vfscount.py starts working, but a new issue[1] is triggered when
'trace vfs_open' is run:

diff --git a/src/cc/frontends/clang/kbuild_helper.cc
b/src/cc/frontends/clang/kbuild_helper.cc
index 8fbefd2..77cfc39 100644
--- a/src/cc/frontends/clang/kbuild_helper.cc
+++ b/src/cc/frontends/clang/kbuild_helper.cc
@@ -84,6 +84,7 @@ int KBuildHelper::get_flags(const char
*uname_machine, vector *cflags) {
   cflags->push_back("-include");
   cflags->push_back("./include/linux/kconfig.h");
   cflags->push_back("-D__KERNEL__");
+  cflags->push_back("-D__ASM_SYSREG_H");
   cflags->push_back("-D__HAVE_BUILTIN_BSWAP16__");
   cflags->push_back("-D__HAVE_BUILTIN_BSWAP32__");
   cflags->push_back("-D__HAVE_BUILTIN_BSWAP64__");


Do you have any idea about this issue?

[1] waring log
ubuntu@ubuntu:~/git/bcc/tools$ sudo ./trace.py vfs_open
In file included from /virtual/main.c:2:
In file included from include/linux/ptrace.h:5:
In file included from include/linux/sched.h:19:
In file included from include/linux/timex.h:56:
In file included from include/uapi/linux/timex.h:56:
In file included from include/linux/time.h:5:
In file included from include/linux/seqlock.h:35:
In file included from include/linux/spinlock.h:87:
In file included from ./arch/arm64/include/asm/spinlock.h:21:
In file included from ./arch/arm64/include/asm/processor.h:32:
In file included from ./arch/arm64/include/asm/alternative.h:4:
./arch/arm64/include/asm/cpufeature.h:180:53: error: use of undeclared
identifier
  'ID_AA64MMFR0_BIGENDEL_SHIFT'
return cpuid_feature_extract_unsigned_field(mmfr0,
ID_AA64MMFR0_BIGENDEL_...
   ^
./arch/arm64/include/asm/cpufeature.h:181:47: error: use of undeclared
identifier
  'ID_AA64MMFR0_BIGENDEL0_SHIFT'
cpuid_feature_extract_unsigned_field(mmfr0,
ID_AA64MMFR0_BIGENDEL...
^
./arch/arm64/include/asm/cpufeature.h:186:55: error: use of undeclared
identifier
  'ID_AA64PFR0_EL0_SHIFT'
u32 val = cpuid_feature_extract_unsigned_field(pfr0,
ID_AA64PFR0_EL0_SHIFT);
 ^
./arch/arm64/include/asm/cpufeature.h:188:16: error: use of undeclared
identifier
  'ID_AA64PFR0_EL0_32BIT_64BIT'
return val == ID_AA64PFR0_EL0_32BIT_64BIT;
  ^
./arch/arm64/include/asm/cpufeature.h:216:55: error: use of undeclared
identifier
  'SYS_ID_AA64MMFR0_EL1'
return 
id_aa64mmfr0_mixed_endian_el0(read_system_reg(SYS_ID_AA64MMFR0_EL1));
 ^
In file included from /virtual/main.c:2:
In file included from include/linux/ptrace.h:5:
In file included from include/linux/sched.h:19:
In file included from include/linux/timex.h:56:
In file included from include/uapi/linux/timex.h:56:
In file included from include/linux/time.h:5:
In file included from include/linux/seqlock.h:35:
In file included from include/linux/spinlock.h:87:
In file included from ./arch/arm64/include/asm/spinlock.h:21:
In file included from ./arch/arm64/include/asm/processor.h:34:
./arch/arm64/include/asm/hw_breakpoint.h:149:29: error: use of
undeclared identifier
  'SYS_ID_AA64DFR0_EL1'
u64 dfr0 = read_system_reg(SYS_ID_AA64DFR0_EL1);
   ^
./arch/arm64/include/asm/hw_breakpoint.h:152:7: error: use of
undeclared identifier
  'ID_AA64DFR0_BRPS_SHIFT'
ID_AA64DFR0_BRPS_SHIFT);
^
./arch/arm64/include/asm/hw_breakpoint.h:158:29: error: use of
undeclared identifier
  'SYS_ID_AA64DFR0_EL1'
u64 dfr0 = read_system_reg(SYS_ID_AA64DFR0_EL1);
   ^
./arch/arm64/include/asm/hw_breakpoint.h:161:7: error: use of
undeclared identifier
  'ID_AA64DFR0_WRPS_SHIFT'
ID_AA64DFR0_WRPS_SHIFT);
  

Re: [iovisor-dev] arm64: LLVM ERROR: Inline asm not supported

2016-12-08 Thread Alexei Starovoitov via iovisor-dev
On Thu, Dec 8, 2016 at 8:20 AM, Ming Lei via iovisor-dev
 wrote:
> Hi,
>
> Bcc can be installed on ubuntu 16.04/arm64 successfully, but when
> I try to trace, the folllowing failure[1] is triggered.
>
> So is bcc not ready for arm64? Or something is wrong?
>
> BTW, clang/llvm is 3.8, and I am happy to try any patches/tests
> if you have ideas about the issue.
>
> Thanks,
> Ming
>  %w0
> 13 warnings generated.
> LLVM ERROR: Inline asm not supported by this streamer because we don't
> have an asm parser for this target

I suspect this is due to bcc not passing -D__ASM_SYSREG_H into clang
like we do in samples/bpf/Makefile to workaround this issue.
___
iovisor-dev mailing list
iovisor-dev@lists.iovisor.org
https://lists.iovisor.org/mailman/listinfo/iovisor-dev


Re: [iovisor-dev] Automatic Loop Unrolling not working with #pragma unroll

2016-12-08 Thread Thomas Graf via iovisor-dev
On 7 December 2016 at 22:06, Mauricio Vasquez via iovisor-dev
 wrote:
> BPF_TABLE("array", u32, struct rt_entry, routing_table, ROUTING_TABLE_DIM);
>
> static int handle_rx(void *skb, struct metadata *md) {
>   u8 *cursor = 0;
>   struct ip_t *ip = cursor_advance(cursor, sizeof(*ip));
>
>   int i = 0;
>   struct rt_entry *rt_entry_p = 0;
>   u32 ip_dst_masked = 0;
>
>   //#pragma unroll
>   #pragma clang loop unroll(full)
>   for (i = 0; i < ROUTING_TABLE_DIM; i++) {
> rt_entry_p = routing_table.lookup();

Might be because you pass a pointer here?

> if (rt_entry_p) {
>   ip_dst_masked = ip->dst & rt_entry_p->netmask;
>   if (ip_dst_masked == rt_entry_p->network) {
> goto FORWARD;
>   }
> }
>   }
>
> DROP:
>   return RX_DROP;
>
> FORWARD:
>   pkt_redirect(skb,md, rt_entry_p->port);
>   return RX_REDIRECT;
> }
>
> Do you have any idea why clang is not unrolling that loop?

It is working fine for us here and we're just using the standard unroll pragma:
https://github.com/cilium/cilium/blob/master/bpf/lib/l3.h#L131
___
iovisor-dev mailing list
iovisor-dev@lists.iovisor.org
https://lists.iovisor.org/mailman/listinfo/iovisor-dev