Received: by 2002:ac0:cd04:0:0:0:0:0 with SMTP id w4csp336418imn; Fri, 1 Jul 2022 16:38:01 -0700 (PDT) X-Google-Smtp-Source: AGRyM1toYA0AuOL3sbmtmvEXTxH6BKfxPexEZzi3TbW8ZHYtZ78pipFdQjNnbHEJi90K1spAzWjv X-Received: by 2002:a17:902:cec4:b0:16a:1fc3:b6e6 with SMTP id d4-20020a170902cec400b0016a1fc3b6e6mr22772105plg.129.1656718681092; Fri, 01 Jul 2022 16:38:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656718681; cv=none; d=google.com; s=arc-20160816; b=kSBk08bN//stp/Ci2+ceRAiOLet/Ylfx7cRbNvIWMDR58EDEXSqYKLHkyb386Wt2vA kP9P3VluIddXZ+WYSAPqs5oPuS9XtED7d2r6aSSJ1naPcma8ovL4EaU46xIZpWhQRNOF dJBugEqdaA3qkzCGbTYdIejkDcleWJUeZwpfaapPWKjNBaS8dF/ip72Zxu2YN2zw5D4K 5aDw3B4NY1sEgrH86SWSivSWYWLXmIs+uaEjCHjyBSTiWCWOuSQYCHPaNta7ZI4KHU3p MA1XmTXpzuwj35+kveTyF/H7bLEKCWq/xgw1GiRbeNLRxg0kJtc1ZhA1JSCcEZjMgklL wpbw== 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=vB+wIPmejTn5guDzm5cOLEtXJ3nVXhdD7b4J4pd+cFY=; b=Osk0cM6G2fx+xxmG85brPwQKxGmooenqHWepRXihmxHeSnit1Z+p7TgKQLAUOn4kkk VrafQ/Cre5ezSQ5SwPrap+iHMMcTSUevIwUuEfTRkXQaLT0Jbrt27IEZNLB6zJ1wo6rt rq96xNsJVHUtGL3N5tSP7ZnjK2qi3dMRH8y4kAnb9OJvJP6CGsSmSR83pKg0sHlCKq+2 d4EGNBk/pMGMlHhlan81jQnBxwcWlBFN9aZjmVX6T/Gg3jpfS80t62bxldtWC8PCc7Tl n/4rkQbWdsCMtO+Pnb4xr1gNVewPP2d0114saVig2bYngDsokJykdOOd0mXjr7Yh6lpj ly/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=g6OkOcxX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b11-20020a056a000ccb00b0052545059695si4022858pfv.307.2022.07.01.16.37.46; Fri, 01 Jul 2022 16:38:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=g6OkOcxX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230414AbiGAX20 (ORCPT + 99 others); Fri, 1 Jul 2022 19:28:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230172AbiGAX2Z (ORCPT ); Fri, 1 Jul 2022 19:28:25 -0400 Received: from mail-qt1-x82a.google.com (mail-qt1-x82a.google.com [IPv6:2607:f8b0:4864:20::82a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7AAE27B32 for ; Fri, 1 Jul 2022 16:28:23 -0700 (PDT) Received: by mail-qt1-x82a.google.com with SMTP id z13so1758554qts.12 for ; Fri, 01 Jul 2022 16:28:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=vB+wIPmejTn5guDzm5cOLEtXJ3nVXhdD7b4J4pd+cFY=; b=g6OkOcxXIvG59akpnlImlIcETkdMs26zUNWZQ7dS0paRnswQFjyUzljmU0lm45Ib0h 0G/oxnjfVsmFsfH9s8GG0BWyLSiR43LrciR6mGgnaBm1jZmpQxOM+VER18y0zlcr2kfM 2/TQ/BiTV0uXVtJBx3k/DlrG4G5htuJ4I0T2sN4KYYSSQAGYRhaG3AuEkPZbLt3h5pXf 5WALSJGk8C8SFulTVbniylYxiH6EBhxnRVlM/VcL3kHGVTyle1R047fofkkf62Bxghqo pqw/irKAUFGsBAXs+wUObzD/Q0FAxX1Hk8lrghs+vElBBVNb7lf7JhOHrcR9IpYWq4kn z9Mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=vB+wIPmejTn5guDzm5cOLEtXJ3nVXhdD7b4J4pd+cFY=; b=YbQT1zDaRLq81eW0tQxVCkHkh4z/Gni170EueCNcFG+7z/RxM6GHHc5EI5uyNQCLGS iSmoIzIbLL4NHb+GKNR0zLRNvx2K2rvfgwCMeSpQAYfxdCO20F1yC8Fft4l21ekLv1zg wg2ec4upaw5NlnQNXYQ+BjeBeW03CRZBGIbQsSM0IY5vcMKZ2KTIzdxPIkrPm5n28jOc 8aYOjKdCNEM/j8tMWTLmttpK3ne2UlP03nRpfdY+iK3IKyk7X3grKHfyjDQBO4RpL+vt xnsriOcUoMFAwi4YIO2y9A9FL710J15VdKdhWTtSAhWl5JanIC15GDDcMPJ3kmcRoscl u7kg== X-Gm-Message-State: AJIora8VRbHTlyMhGH84Xj6jgTuGG0BaECaJ1xHOQBrPNW7DQnEJAVz9 X7TMZMEIsMP/qMrXJduSIrYBsiG9Gwi4y4b6n0Vrcg== X-Received: by 2002:a05:6214:202f:b0:432:4810:1b34 with SMTP id 15-20020a056214202f00b0043248101b34mr18957932qvf.35.1656718102554; Fri, 01 Jul 2022 16:28:22 -0700 (PDT) MIME-Version: 1.0 References: <20220610194435.2268290-1-yosryahmed@google.com> <20220610194435.2268290-9-yosryahmed@google.com> <00df1932-38fe-c6f8-49d0-3a44affb1268@fb.com> <59376285-21bc-ff12-3d64-3ea7257becb2@fb.com> In-Reply-To: <59376285-21bc-ff12-3d64-3ea7257becb2@fb.com> From: Hao Luo Date: Fri, 1 Jul 2022 16:28:11 -0700 Message-ID: Subject: Re: [PATCH bpf-next v2 8/8] bpf: add a selftest for cgroup hierarchical stats collection To: Yonghong Song Cc: Yosry Ahmed , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , John Fastabend , KP Singh , Tejun Heo , Zefan Li , Johannes Weiner , Shuah Khan , Michal Hocko , Roman Gushchin , David Rientjes , Stanislav Fomichev , Greg Thelen , Shakeel Butt , Linux Kernel Mailing List , Networking , bpf , Cgroups Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 28, 2022 at 11:27 PM Yonghong Song wrote: > > > > On 6/28/22 12:43 AM, Yosry Ahmed wrote: > > On Mon, Jun 27, 2022 at 11:47 PM Yosry Ahmed wrote: > >> > >> On Mon, Jun 27, 2022 at 11:14 PM Yonghong Song wrote: [...] > >>> btf_dump_data:FAIL:ensure expected/actual match unexpected ensure > >>> expected/actual match: actual '(union bpf_iter_link_info){.map = > >>> (struct){.map_fd = (__u32)1,},.cgroup ' > >>> test_btf_dump_struct_data:PASS:find struct sk_buff 0 nsec > >>> > >> > >> Yeah I see what happened there. bpf_iter_link_info was changed by the > >> patch that introduced cgroup_iter, and this specific union is used by > >> the test to test the "union with nested struct" btf dumping. I will > >> add a patch in the next version that updates the btf_dump_data test > >> accordingly. Thanks. > >> > > > > So I actually tried the attached diff to updated the expected dump of > > bpf_iter_link_info in this test, but the test still failed: > > > > btf_dump_data:FAIL:ensure expected/actual match unexpected ensure > > expected/actual match: actual '(union bpf_iter_link_info){.map = > > (struct){.map_fd = (__u32)1,},.cgroup = (struct){.cgroup_fd = > > (__u32)1,},}' != expected '(union bpf_iter_link_info){.map = > > (struct){.map_fd = (__u32)1,},.cgroup = (struct){.cgroup_fd = > > (__u32)1,.traversal_order = (__u32)1},}' > > > > It seems to me that the actual output in this case is not right, it is > > missing traversal_order. Did we accidentally find a bug in btf dumping > > of unions with nested structs, or am I missing something here? > > Probably there is an issue in btf_dump_data() function in > tools/lib/bpf/btf_dump.c. Could you take a look at it? > Regarding this failure of btf_dump_data, the cause seems that: I added a new struct in 'union bpf_iter_link_info' in this patch series, which expanded bpf_iter_link_info's size from 32bit to 64bit. However, the test still used the old struct to initialize, which makes a temporary stack variable (of type bpf_iter_link_info) partially initialized. If I initialize the type by the larger new struct only, btf_dump_data will output the correct content and the said test will pass. Yosry, we need to fold the said solution in the patch which introduced changes to bpf_iter_link_info, so that it won't break the test. I haven't dug into btf_dump_data() on why partially initialized union fails. I need to look at the get_cgroup_vmscan_delay selftest in this patch now. Hao