Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2962248pxb; Tue, 13 Apr 2021 14:55:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyWhxA5frFfb2vLUYvSI7dpA06CVjAPLGw/8unRIql8SVR0s1duuxUAhENRpnMMWKJeie/I X-Received: by 2002:a17:906:2808:: with SMTP id r8mr25901470ejc.140.1618350936521; Tue, 13 Apr 2021 14:55:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618350936; cv=none; d=google.com; s=arc-20160816; b=I+8azLDYkrBRYlQJQpoHAt0tFOTRUHrmm3ZIF1izZba2lCzp230hVHO8KgNKf0Qpju jFtNDg70xSsIv55VA/V8GQZK8OIjgsUsiJZuC85ipRdo+7fhQvmF6/H2ep+W57Vn3Big cCRtGq2liLSW4kIxCXxK5xfOOQt9WXA8NLUuBLvvQqthc7LZoYLEhKhchqwhhvlKSP/G Ra+BHMtU+/ZqqIHYnWp5u6i+iLZx+efX03x6mRxYG1qnlYkYsV5g+zucmSxczXfdo/Eb hyTMaBTyJ1RMXQMCdH4eux0bTJvD/obcsFXCxKR2MNL73GyVjgAl8fbwIqnHYkDCLyYn 8wag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=v4TjHCXfhg5d3LryO0dAvVeknac0k2NZ/3RM2aA8938=; b=Aen6X7vLsAPDLZ6pwGSUlUbvBroE6hAyWcBOXW/KXj9sOm7TEMyWkFGdzbHrJpTRFU GnMJ1c99J6klt2PZV9Wc6p7f18kB5q51QDiGjogEXwz4IWkQq0IwtjemNGseD0lJUiNg f03TQmDa1yP6aPb9Kb3mmwnSD7IG6hEi515hQoEci7u3Lbp68hhJxTv4EILuVnqPj8VN IJE7tSu/vqJq0glv+MIclxQYQXX7X/3Ftw7dIdE2PzbAodGFgl8PbfcJbI9mxwLOGgK/ xlDgDeBAS13Mmbm+Ok/0D0iaIjj/Y3WzM2PGrrPiUECdKw6ldXgju3gmSKvlgV1qDRUO FkHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=f3UEPkvU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h17si4321034ejx.114.2021.04.13.14.55.12; Tue, 13 Apr 2021 14:55:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=f3UEPkvU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346965AbhDMQ6b (ORCPT + 99 others); Tue, 13 Apr 2021 12:58:31 -0400 Received: from mail-lf1-f45.google.com ([209.85.167.45]:43700 "EHLO mail-lf1-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345673AbhDMQ6a (ORCPT ); Tue, 13 Apr 2021 12:58:30 -0400 Received: by mail-lf1-f45.google.com with SMTP id r8so28335362lfp.10; Tue, 13 Apr 2021 09:58:09 -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=v4TjHCXfhg5d3LryO0dAvVeknac0k2NZ/3RM2aA8938=; b=f3UEPkvUinbjyZ+3ysqA1LgBZJfqb7CMeN8m/FHDsqK4+L/XHEHaZ9lLz2oK+ONlCS HihjonPwPXsmjPs9sF1B7GXmgLb7H9+ZgiKLVKpDA4Jq0aZUu0BG24wBn0k0r9FggK65 13U7tx8DvcEQ9THUnUSo4RYy61bQiiVcpVlvL6SRIm+RRvlgQWacL9BfITPamvnGUTM3 KKMyncRsIzgx+LjrKGLZxecHzLxolt/Xovfj4Ky29b0AhKRYZc4Oqm6Yq1ze3CXorMS8 DoE6zWiCdVznpYeQQj+wWdwDbk4GlyEjThpGgIOWTXhbLYSvHAhVEI4pnUl6Ro0EbIAw s9Kw== 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=v4TjHCXfhg5d3LryO0dAvVeknac0k2NZ/3RM2aA8938=; b=W3mqWip97jAffsfMkMgBGOJ4WfcgvqQTWSu/eRVLAM6JYkOU10aaKxVlrhyK8eyLE3 VqNjyFLegZC1mfu7e799II92zUib1qGuobTPhtGZbPVc8HP18o48t2RuC+x3NzlVHLPA bXXFBSdq2SqW1SyPE//PE7jNafqCGBVDh761qMNgNsBFpNB+LV61S0lfwzs4yEzZQ8jP 4atWZ53cR60xFj4sstvrebJF+sgXzy1Va+gaAmG0F8v1Qh3MPQZB7R31p/DUQZ4/8Sgf k1atsqs0ktKTgl5z0r4e3R7dax3gJy83xK1PmAVW4i+0P1tA/v3ub38wdHQdJfmvYBKa tSLA== X-Gm-Message-State: AOAM530PapGckSdxd16NJeq84Z8Um2CQ+RqMQw5w4U2Xkf8AjJc88iW9 GG9XTnfztizi8k5MICvza3e5BG0R3s1HgikTigk= X-Received: by 2002:a19:c1d4:: with SMTP id r203mr23420280lff.182.1618333028915; Tue, 13 Apr 2021 09:57:08 -0700 (PDT) MIME-Version: 1.0 References: <1618307549-78149-1-git-send-email-yang.lee@linux.alibaba.com> In-Reply-To: From: Alexei Starovoitov Date: Tue, 13 Apr 2021 09:56:57 -0700 Message-ID: Subject: Re: [PATCH] selftests/bpf: use !E instead of comparing with NULL To: "Bird, Tim" Cc: Yang Li , Shuah Khan , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , "open list:KERNEL SELFTEST FRAMEWORK" , Network Development , bpf , LKML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 13, 2021 at 9:32 AM wrote: > > > -----Original Message----- > > From: Alexei Starovoitov > > > > On Tue, Apr 13, 2021 at 9:19 AM wrote: > > > > > > > -----Original Message----- > > > > From: Alexei Starovoitov > > > > > > > > On Tue, Apr 13, 2021 at 9:10 AM wrote: > > > > > > > > > > > > > > > > > > > > > -----Original Message----- > > > > > > From: Alexei Starovoitov > > > > > > > > > > > > On Tue, Apr 13, 2021 at 2:52 AM Yang Li wrote: > > > > > > > > > > > > > > Fix the following coccicheck warnings: > > > > > > > ./tools/testing/selftests/bpf/progs/profiler.inc.h:189:7-11: WARNING > > > > > > > comparing pointer to 0, suggest !E > > > > > > > ./tools/testing/selftests/bpf/progs/profiler.inc.h:361:7-11: WARNING > > > > > > > comparing pointer to 0, suggest !E > > > > > > > ./tools/testing/selftests/bpf/progs/profiler.inc.h:386:14-18: WARNING > > > > > > > comparing pointer to 0, suggest !E > > > > > > > ./tools/testing/selftests/bpf/progs/profiler.inc.h:402:14-18: WARNING > > > > > > > comparing pointer to 0, suggest !E > > > > > > > ./tools/testing/selftests/bpf/progs/profiler.inc.h:433:7-11: WARNING > > > > > > > comparing pointer to 0, suggest !E > > > > > > > ./tools/testing/selftests/bpf/progs/profiler.inc.h:534:14-18: WARNING > > > > > > > comparing pointer to 0, suggest !E > > > > > > > ./tools/testing/selftests/bpf/progs/profiler.inc.h:625:7-11: WARNING > > > > > > > comparing pointer to 0, suggest !E > > > > > > > ./tools/testing/selftests/bpf/progs/profiler.inc.h:767:7-11: WARNING > > > > > > > comparing pointer to 0, suggest !E > > > > > > > > > > > > > > Reported-by: Abaci Robot > > > > > > > Signed-off-by: Yang Li > > > > > > > --- > > > > > > > tools/testing/selftests/bpf/progs/profiler.inc.h | 22 +++++++++++----------- > > > > > > > 1 file changed, 11 insertions(+), 11 deletions(-) > > > > > > > > > > > > > > diff --git a/tools/testing/selftests/bpf/progs/profiler.inc.h b/tools/testing/selftests/bpf/progs/profiler.inc.h > > > > > > > index 4896fdf8..a33066c 100644 > > > > > > > --- a/tools/testing/selftests/bpf/progs/profiler.inc.h > > > > > > > +++ b/tools/testing/selftests/bpf/progs/profiler.inc.h > > > > > > > @@ -189,7 +189,7 @@ static INLINE void populate_ancestors(struct task_struct* task, > > > > > > > #endif > > > > > > > for (num_ancestors = 0; num_ancestors < MAX_ANCESTORS; num_ancestors++) { > > > > > > > parent = BPF_CORE_READ(parent, real_parent); > > > > > > > - if (parent == NULL) > > > > > > > + if (!parent) > > > > > > > > > > > > Sorry, but I'd like the progs to stay as close as possible to the way > > > > > > they were written. > > > > > Why? > > > > > > > > > > > They might not adhere to kernel coding style in some cases. > > > > > > The code could be grossly inefficient and even buggy. > > > > > There would have to be a really good reason to accept > > > > > grossly inefficient and even buggy code into the kernel. > > > > > > > > > > Can you please explain what that reason is? > > > > > > > > It's not the kernel. It's a test of bpf program. > > > That doesn't answer the question of why you don't want any changes. > > > > > > Why would we not use kernel coding style guidelines and quality thresholds for > > > testing code? This *is* going into the kernel source tree, where it will be > > > maintained and used by other developers. > > > > because the way the C code is written makes llvm generate a particular > > code pattern that may not be seen otherwise. > > Like removing 'if' because it's useless to humans, but not to the compiler > > will change generated code which may or may not trigger the behavior > > the prog intends to cover. > > In particular this profiler.inc.h test is compiled three different ways to > > maximize code generation differences. > > It may not be checking error paths in some cases which can be considered > > a bug, but that's the intended behavior of the C code as it was written. > > So it has nothing to do with "quality of kernel code". > > and it should not be used by developers. It's neither sample nor example. > > Ok - in this case it looks like a program, but it is essentially test data (for testing > the compiler). Thanks for the explanation. yes. That's a good way of saying it. Of course not all tests are like this. Majority of bpf progs in selftests/bpf/progs/ are carefully written, short and designed as a unit test. While few are "test data" for llvm.