-
Yonghong Song authored
additional fix for issue #1850 for the below case in test_clang.py; int test(struct pt_regs *ctx, struct mm_struct *mm) { return mm->rss_stat.count[MM_ANONPAGES].counter; } the current rewriter generates: int test(struct pt_regs *ctx) { struct mm_struct *mm = ctx->di; return ({ typeof(atomic_long_t) _val; __builtin_memset(&_val, 0, sizeof(_val)); bpf_probe_read(&_val, sizeof(_val), (u64)(&mm->rss_stat.count) + (MM_ANONPAGES)); _val; }).counter; } The third argument of bpf_probe_read() is incorrect. The correct third argument should be (u64)((&mm->rss_stat.count) + (MM_ANONPAGES)) This patch fixed the issue by adding extra parenthesis for the outer u64 type casting. int test(struct pt_regs *ctx) { struct mm_struct *mm = ctx->di; return ({ typeof(atomic_long_t) _val; __builtin_memset(&_val, 0, sizeof(_val)); bpf_probe_read(&_val, sizeof(_val), (u64)((&mm->rss_stat.count) + (MM_ANONPAGES))); _val; }).counter; } Signed-off-by: Yonghong Song <yhs@fb.com>
eb7b586d