Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp634687pxk; Thu, 1 Oct 2020 10:13:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwMh+cMnKkEW4qMLSdGV/x66u5nr5VwSEjcDqpkQ3H2xaWg2iVIGYSQHJ0/zifsED1guR9+ X-Received: by 2002:aa7:cd5a:: with SMTP id v26mr8981523edw.38.1601572396474; Thu, 01 Oct 2020 10:13:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601572396; cv=none; d=google.com; s=arc-20160816; b=SMj7HOj1z4vadIV+FtDnN+vRdGhNpWxjodLKjQW707v9yJL0ihX4CvR7ib+A6RffKB Tt+3LSQu41E8A6hYOF/wMlIJOxoIQU+wlvHXcq/pA1CMYO6fSPE0bPen9zrjQBsw/FeU QH96vLX169XRJlmrhbZtTD5kZtGgm8sz3l/np+xgsOGx7RAI5Nd4HxtiUkB4Wu13zCDI CA895PeDIS3FBZUUTjzIBsCY9rraAfNBJsZm4SILkZxupkJKXYb/QYaWZZwmKJHy51/s 5fmg5Wqwra1lh2ZVyYyWdbAkg92enra5v0CKBgdnxHFrtdylkwPnBqSyMB09qNsopzW7 5aXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=OQfLRcAOWIw59NGfi9I7ckeREQIiyms4IQUXnhx6Cus=; b=ivODgC54ccCza4xM7b2VkrpvXO/xxIb7uw0KtQOr4SivMQAIm+ekxstp+n9qm/Th3l Q/6Aax3nMuvYR0vcRZXi5RNMiaJj5KJA0WTrArEXvAEO2uMEuChQLB+hhpo/4nwSRkK/ JlayxTOhT5W2ToA1R9LYNCkKt4WU1FUXKmlZxkaU7v5azth2q7GEBmOs1okwtd7VMmgV uswbAOefX0u6lpG8xqn2ETeaKmLzkvskw8dTSory3NeO6qQjGhiz516m8JlOlXb76SzJ B4wQBQ9p/R8DQDlGkTss84AnKgFXnai0Cc7D1YwMRmGpQEBBf+REzjybFsK6onRhH5um eZrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rlOFvsv5; 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 dr5si3605961ejc.370.2020.10.01.10.12.51; Thu, 01 Oct 2020 10:13:16 -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=rlOFvsv5; 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 S1732784AbgJARLi (ORCPT + 99 others); Thu, 1 Oct 2020 13:11:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732213AbgJARLh (ORCPT ); Thu, 1 Oct 2020 13:11:37 -0400 Received: from mail-lj1-x242.google.com (mail-lj1-x242.google.com [IPv6:2a00:1450:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CC4AC0613D0; Thu, 1 Oct 2020 10:11:37 -0700 (PDT) Received: by mail-lj1-x242.google.com with SMTP id u4so5288619ljd.10; Thu, 01 Oct 2020 10:11:37 -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:content-transfer-encoding; bh=OQfLRcAOWIw59NGfi9I7ckeREQIiyms4IQUXnhx6Cus=; b=rlOFvsv5FwPcqIxobQWQ1xGP+0tJz/39SJOrkdvVSsV2wDiuwU5KtbGGXd8gIbfp7G Fz6lUfVfTVmWLBGLtXoNYw5eQVGBSPylBSM3LLMgoQm4rNGuGouXPYPxnh5b13Tm6Xi/ 9jPJPlx3TXKfi033zJMImDtn2B5KDHOfFKLm8ZfRLsh+Y0sx58PzJsqcJJEKBqrvyZL9 Jr47hoX3ChaN1NL8tf5GQ3cxM6fo30suy5NHN4V+pORPKwttTDAZCMYDKrnEEXCAZcNd UveDzaVg6YnTHEkgTsI9lAszviyJ9DZloRmnuFfD3pgbdjAZWcP20KqEgSuwfQYx84YY 1N2Q== 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:content-transfer-encoding; bh=OQfLRcAOWIw59NGfi9I7ckeREQIiyms4IQUXnhx6Cus=; b=DEQUbGVKQeVaeRSUrEcGh6QNbfNb0vvgf1VrenOMNb2cvlchPFXne3X8ZZRgz25MfK 9rcEXbUi2+3wvvXeOKzgpfFqjIwiljbl4NjbJy3/BDoEXlTWo8EtiscfTgew8hVAfvbo B73cXXyC5ZP7+2PavLnPjmebJ52hOj1F/eMHh/+LBiquIA93e+/n8i1k6W6tuZmEUutQ 396CB3ZCwddo1Mx1Ydkw34WJxBaJYaDP9eE++O11kS5bebdx/R9aWfUmvimtYdpdlk1L boul2CWqAqoByr4lTMATJZOTgquPbzOseNdLUxmJ8ZRamV8pirLrLYC5lvf9pWOehKv+ R7xA== X-Gm-Message-State: AOAM531biNBTMijuF9DOIiSr7byuXBq+trL9Ce7FZhhwBjVbLFDlwZhs 7E02hF43mVKkQvuSpRCxdI92idifpt/PLBzMGKA= X-Received: by 2002:a2e:7014:: with SMTP id l20mr2810578ljc.91.1601572295556; Thu, 01 Oct 2020 10:11:35 -0700 (PDT) MIME-Version: 1.0 References: <20200928090805.23343-1-lmb@cloudflare.com> <20200928090805.23343-3-lmb@cloudflare.com> <20200929055851.n7fa3os7iu7grni3@kafai-mbp> <20201001072348.hxhpuoqmeln6twxw@ast-mbp.dhcp.thefacebook.com> In-Reply-To: From: Alexei Starovoitov Date: Thu, 1 Oct 2020 10:11:23 -0700 Message-ID: Subject: Re: [PATCH bpf-next v2 2/4] selftests: bpf: Add helper to compare socket cookies To: Andrii Nakryiko Cc: Lorenz Bauer , Martin KaFai Lau , Shuah Khan , Alexei Starovoitov , Daniel Borkmann , kernel-team , "open list:KERNEL SELFTEST FRAMEWORK" , Network Development , bpf , LKML Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 1, 2020 at 10:09 AM Andrii Nakryiko wrote: > > On Thu, Oct 1, 2020 at 12:25 AM Alexei Starovoitov > wrote: > > > > On Wed, Sep 30, 2020 at 10:28:33AM +0100, Lorenz Bauer wrote: > > > On Tue, 29 Sep 2020 at 16:48, Alexei Starovoitov > > > wrote: > > > > > > ... > > > > > > > There was a warning. I noticed it while applying and fixed it up. > > > > Lorenz, please upgrade your compiler. This is not the first time su= ch > > > > warning has been missed. > > > > > > I tried reproducing this on latest bpf-next (b0efc216f577997) with gc= c > > > 9.3.0 by removing the initialization of duration: > > > > > > make: Entering directory '/home/lorenz/dev/bpf-next/tools/testing/sel= ftests/bpf' > > > TEST-OBJ [test_progs] sockmap_basic.test.o > > > TEST-HDR [test_progs] tests.h > > > EXT-OBJ [test_progs] test_progs.o > > > EXT-OBJ [test_progs] cgroup_helpers.o > > > EXT-OBJ [test_progs] trace_helpers.o > > > EXT-OBJ [test_progs] network_helpers.o > > > EXT-OBJ [test_progs] testing_helpers.o > > > BINARY test_progs > > > make: Leaving directory '/home/lorenz/dev/bpf-next/tools/testing/self= tests/bpf' > > > > > > So, gcc doesn't issue a warning. Jakub did the following little exper= iment: > > > > > > jkbs@toad ~/tmp $ cat warning.c > > > #include > > > > > > int main(void) > > > { > > > int duration; > > > > > > fprintf(stdout, "%d", duration); > > > > > > return 0; > > > } > > > jkbs@toad ~/tmp $ gcc -Wall -o /dev/null warning.c > > > warning.c: In function =E2=80=98main=E2=80=99: > > > warning.c:7:2: warning: =E2=80=98duration=E2=80=99 is used uninitiali= zed in this > > > function [-Wuninitialized] > > > 7 | fprintf(stdout, "%d", duration); > > > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > > > > > > > > The simple case seems to work. However, adding the macro breaks thing= s: > > > > > > jkbs@toad ~/tmp $ cat warning.c > > > #include > > > > > > #define _CHECK(duration) \ > > > ({ \ > > > fprintf(stdout, "%d", duration); \ > > > }) > > > #define CHECK() _CHECK(duration) > > > > > > int main(void) > > > { > > > int duration; > > > > > > CHECK(); > > > > > > return 0; > > > } > > > jkbs@toad ~/tmp $ gcc -Wall -o /dev/null warning.c > > > jkbs@toad ~/tmp $ > > > > That's very interesting. Thanks for the pointers. > > I'm using gcc version 9.1.1 20190605 (Red Hat 9.1.1-2) > > and I saw this warning while compiling selftests, > > but I don't see it with above warning.c example. > > clang warns correctly in both cases. > > I think this might be the same problem I fixed for libbpf with [0]. > Turns out, GCC explicitly calls out (somewhere in their docs) that > uninitialized variable warnings work only when compiled in optimized > mode, because some internal data structures used to detect this are > only maintained in optimized mode build. > > Laurenz, can you try compiling your example with -O2? All of my experiments I did with -O2. > [0] https://patchwork.ozlabs.org/project/netdev/patch/20200929220604.83= 3631-2-andriin@fb.com/ > > > > > > Maybe this is https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D18501 ? = The > > > problem is still there on gcc 10. Compiling test_progs with clang doe= s > > > issue a warning FWIW, but it seems like other things break when doing > > > that. > > > > That gcc bug has been opened since transition to ssa. That was a huge > > transition for gcc. But I think the bug number is not correct. It point= s to a > > different issue. I've checked -fdump-tree-uninit-all dump with and with= out > > macro. They're identical. The tree-ssa-uninit pass suppose to warn, but= it > > doesn't. I wish I had more time to dig into it. A bit of debugging in > > gcc/tree-ssa-uninit.c can probably uncover the root cause.