From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C07C2C433E1 for ; Tue, 30 Jun 2020 21:26:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9AFEB2065D for ; Tue, 30 Jun 2020 21:26:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CqI5q8x8" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730716AbgF3V0g (ORCPT ); Tue, 30 Jun 2020 17:26:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730694AbgF3V0e (ORCPT ); Tue, 30 Jun 2020 17:26:34 -0400 Received: from mail-qk1-x742.google.com (mail-qk1-x742.google.com [IPv6:2607:f8b0:4864:20::742]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 138CBC061755; Tue, 30 Jun 2020 14:26:34 -0700 (PDT) Received: by mail-qk1-x742.google.com with SMTP id 80so20159881qko.7; Tue, 30 Jun 2020 14:26:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=u6QrfK0w5ybbH9fi34xXU8b52YrlyrA/11EhFWPjHcY=; b=CqI5q8x8tEfzpcgQJRXsrlzwKqVx+wSi8n79eup4ry7b6IboG8x3Mo5ta+oAtr6eao 1am7Wn0i/Uv0SJ6VTpa5eBmBnp+9xy/x+bEisQE5ZlhxVjJWCyOa4cDwY+hue3zb2+j5 j+h6l6giCeAFx5TefdU1ML9TNV4SFpFD91ZvzwAxHPj2Gm2frJI+s+JacWMiAKVnNHVp OhoZhO5O6ui0V4njxE3Pg+SFDtt9Rpo5cKZZQ3UNYJRgXEdJW08Sx82AIQrZI7uouNUw sM1Vt2FerL4pXP5AQu6BVts9FOnYKboA+BPb8w2Ed3J7+aD5NlhNJRkvTxi9d/tLDKnk 51Bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=u6QrfK0w5ybbH9fi34xXU8b52YrlyrA/11EhFWPjHcY=; b=UI5tSun2jrcj88D91B5J+fXwmpgUmN4QPlAoVvU1yfoh6qojEXvIPeReH2VtywhZVA Y5zurzQBlj/4d6A3iJDMtefGhSrRF3hdwYcu8LqeA15Kt8R2pO2FAVVO5bxI0uaCnVN+ +pBsgNmcV32++UiZRDLrHSK02IOA8RDvPz/00o5VNAXZz/yV6KdKhsoCV6A7GJXh/VX+ c4o3xmTs66YJS9Bo3Wm8PsDPmsNk8D3QgqhnIhXQ4tTG/qBV/rcRlacXiCFfSkXS3hyr qIgbzoNymK0g3LJSrcwOBV7s7oPeROGJLqA7sOqvb1HP7fGBySDGh6QHAAaQUpIyZnft 5Cdg== X-Gm-Message-State: AOAM533fNLeFO3C1E+TGEqnfKYaajboPX3feKrQ0PuZYCnQq3EFdqrxU o8Me8C+ga3RtBMkSudhkKUNbgtrHu4mZJur83Zk= X-Google-Smtp-Source: ABdhPJzNTMwPYp9iv+oRxOsQCp2yESwoibyek38j7BPYdMXfXDzKD6C5b60bb9+VFoBgf+eNaEiI78MjsxtvU5aRFpY= X-Received: by 2002:a37:270e:: with SMTP id n14mr20807794qkn.92.1593552393299; Tue, 30 Jun 2020 14:26:33 -0700 (PDT) MIME-Version: 1.0 References: <20200630184922.455439-1-haoluo@google.com> In-Reply-To: <20200630184922.455439-1-haoluo@google.com> From: Andrii Nakryiko Date: Tue, 30 Jun 2020 14:26:21 -0700 Message-ID: Subject: Re: [PATCH bpf-next] selftests/bpf: Switch test_vmlinux to use hrtimer_range_start_ns. To: Hao Luo Cc: Networking , bpf , open list , clang-built-linux , "open list:KERNEL SELFTEST FRAMEWORK" , Stanislav Fomichev , Shuah Khan , Alexei Starovoitov , Andrii Nakryiko , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 30, 2020 at 1:47 PM Hao Luo wrote: > > The test_vmlinux test uses hrtimer_nanosleep as hook to test tracing > programs. But it seems Clang may have done an aggressive optimization, > causing fentry and kprobe to not hook on this function properly on a > Clang build kernel. > > A possible fix is switching to use a more reliable function, e.g. the > ones exported to kernel modules such as hrtimer_range_start_ns. After > we switch to using hrtimer_range_start_ns, the test passes again even > on a clang build kernel. > > Tested: > In a clang build kernel, the test fail even when the flags > {fentry, kprobe}_called are set unconditionally in handle__kprobe() > and handle__fentry(), which implies the programs do not hook on > hrtimer_nanosleep() properly. This could be because clang's code > transformation is too aggressive. > > test_vmlinux:PASS:skel_open 0 nsec > test_vmlinux:PASS:skel_attach 0 nsec > test_vmlinux:PASS:tp 0 nsec > test_vmlinux:PASS:raw_tp 0 nsec > test_vmlinux:PASS:tp_btf 0 nsec > test_vmlinux:FAIL:kprobe not called > test_vmlinux:FAIL:fentry not called > > After we switch to hrtimer_range_start_ns, the test passes. > > test_vmlinux:PASS:skel_open 0 nsec > test_vmlinux:PASS:skel_attach 0 nsec > test_vmlinux:PASS:tp 0 nsec > test_vmlinux:PASS:raw_tp 0 nsec > test_vmlinux:PASS:tp_btf 0 nsec > test_vmlinux:PASS:kprobe 0 nsec > test_vmlinux:PASS:fentry 0 nsec > > Signed-off-by: Hao Luo > --- Took me a bit of jumping around to find how it is related to nanosleep call :) But seems like it's unconditionally called, so should be fine. Acked-by: Andrii Nakryiko > tools/testing/selftests/bpf/progs/test_vmlinux.c | 16 ++++++++-------- > 1 file changed, 8 insertions(+), 8 deletions(-) > [...]