Message ID | 20221123135253.637525-1-void@manifault.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b599:b0:88:f841:fdc9 with SMTP id df25csp2150261dyb; Wed, 23 Nov 2022 06:04:36 -0800 (PST) X-Google-Smtp-Source: AA0mqf7vzdlJtipNoCFRB63tQHs1onY6KcV6RvqVjjHRiX8PEsh231tyoC6z+nrQOJv7r6uJhUXf X-Received: by 2002:a17:90a:ab84:b0:213:343:9873 with SMTP id n4-20020a17090aab8400b0021303439873mr36630658pjq.102.1669212276558; Wed, 23 Nov 2022 06:04:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669212276; cv=none; d=google.com; s=arc-20160816; b=EZ7JHX8qe+ga1SyNCoKL9vjnyDViE7qxEt0cKZvq73eUu0cEqnoSVKqQjVOnrb7tLk cJsw3uvt3bUyXqUambVR4kdS+CeAgd1hznt1QZ+od4n/JUE187uWUoJHF5D2+4bUpl/e QiCYLyN16ZwO6uOMT8o0lmt9TRHeXyetkVqsO+Pwjsg247Gdpt70VVVp0BZEfIs97qFM dx7SNNCmYim78DrOcr4pRYZ/CSoq5REHtKYWTpRdAt4EyEd1u/8+j7dWu7ROUO0swSya q3HEqhCfMFJd8oLcUMYWBwhlCXTo2dcnEeE9l2QsiMU74vCu+YsZSDYfLwQ6PJlWZ5hN i2Tg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=Ru2/Qo/Fi2mBuBD/tnfTwcQucjWsxv7vBNnif4KKxRg=; b=g7My9uQ4uPjsKEjuGtIzu0OPoAaMsu/HmaIQzdrzMDHE//d+g2Q79qBdmB73dXC54E jVsi4DwEDSYjGoD8UoJqAdwW6hnVGqJLqdwh4H/Bk1d+MlTAm67DLtDX5+rsAbNMoW2m UytAHNawLek2TLCwXC9PkGNAqnjHAWRT2qSghFBhX7ldhcFZBpCwfnSCDky80j9yO2ny lZy1qMp6Yp7S+IvQharUIN0MvcOYTdfo65Y9Sa/N+IbqegTJGjkZoYNfXSzcUTVdKc5T heOiszinBLUTamnDljmnVJ2FRAkeg3RFxud9rfZDhmW2MlcdJAx8k4nhkD5T7BA60GTC 5ZoA== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b10-20020a17090ae38a00b0021824fcc6b9si1807431pjz.63.2022.11.23.06.04.17; Wed, 23 Nov 2022 06:04:36 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236189AbiKWN7G (ORCPT <rfc822;fengqi706@gmail.com> + 99 others); Wed, 23 Nov 2022 08:59:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238082AbiKWN6o (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 23 Nov 2022 08:58:44 -0500 Received: from mail-qk1-f173.google.com (mail-qk1-f173.google.com [209.85.222.173]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E855943AEB; Wed, 23 Nov 2022 05:52:54 -0800 (PST) Received: by mail-qk1-f173.google.com with SMTP id i9so2889252qkl.5; Wed, 23 Nov 2022 05:52:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Ru2/Qo/Fi2mBuBD/tnfTwcQucjWsxv7vBNnif4KKxRg=; b=Irq8G/TbUp1OPHCe0S0cViZvzY0QkvV12l6XN9jOCRUDRKIcpR+VzomCErm49MN08v h5gRzTg1qp9GJrvlWBggvMxQ9uUozo+ER9Ef7HQqYZYCBbaABj4xBYCQ1OTIB3Vmj350 11bVR24Mza84+vJfSS6TmpVUgCmUwPTCnxJfB+aSC0xGQ5WUq+cZfZr/fTxnvYkH+5YH sW0wkHK1XxnLrL34CNkEwlgiqrot3A4Ri5ZLAfYlg9GRrqSCNJoX2MHpFkcLbkNAB6Az itu9j/m0S4r99E0nY4d9qsRYSXfKsuD66h2X6WHNaZ1xN6W92KMu7Fdr742elPFC3IIa rFjg== X-Gm-Message-State: ANoB5pmoLjq4/E8ByoNxc+PWTPZgBOyIumdZD1w32D6lxANnqMH8KrKH m0QHplv7ThAdaVlCTLZANYgi7Vhzn4j0MXl4 X-Received: by 2002:a05:620a:561:b0:6fa:4b0b:d08f with SMTP id p1-20020a05620a056100b006fa4b0bd08fmr25515242qkp.488.1669211573582; Wed, 23 Nov 2022 05:52:53 -0800 (PST) Received: from localhost (c-24-15-214-156.hsd1.il.comcast.net. [24.15.214.156]) by smtp.gmail.com with ESMTPSA id d7-20020a05620a240700b006e702033b15sm12525280qkn.66.2022.11.23.05.52.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Nov 2022 05:52:53 -0800 (PST) From: David Vernet <void@manifault.com> To: bpf@vger.kernel.org Cc: ast@kernel.org, andrii@kernel.org, daniel@iogearbox.net, martin.lau@linux.dev, yhs@fb.com, song@kernel.org, sdf@google.com, john.fastabend@gmail.com, kpsingh@kernel.org, jolsa@kernel.org, haoluo@google.com, tj@kernel.org, kernel-team@fb.com, linux-kernel@vger.kernel.org, kernel test robot <lkp@intel.com> Subject: [PATCH bpf-next] bpf: Don't use idx variable when registering kfunc dtors Date: Wed, 23 Nov 2022 07:52:53 -0600 Message-Id: <20221123135253.637525-1-void@manifault.com> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750295932194255721?= X-GMAIL-MSGID: =?utf-8?q?1750295932194255721?= |
Series |
[bpf-next] bpf: Don't use idx variable when registering kfunc dtors
|
|
Commit Message
David Vernet
Nov. 23, 2022, 1:52 p.m. UTC
In commit fda01efc6160 ("bpf: Enable cgroups to be used as kptrs"), I added an 'int idx' variable to kfunc_init() which was meant to dynamically set the index of the btf id entries of the 'generic_dtor_ids' array. This was done to make the code slightly less brittle as the struct cgroup * kptr kfuncs such as bpf_cgroup_aquire() are compiled out if CONFIG_CGROUPS is not defined. This, however, causes an lkp build warning: >> kernel/bpf/helpers.c:2005:40: warning: multiple unsequenced modifications to 'idx' [-Wunsequenced] .btf_id = generic_dtor_ids[idx++], Fix the warning by just hard-coding the indices. Fixes: fda01efc6160 ("bpf: Enable cgroups to be used as kptrs") Reported-by: kernel test robot <lkp@intel.com> Signed-off-by: David Vernet <void@manifault.com> --- kernel/bpf/helpers.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
Comments
On 11/23/22 5:52 AM, David Vernet wrote: > In commit fda01efc6160 ("bpf: Enable cgroups to be used as kptrs"), I > added an 'int idx' variable to kfunc_init() which was meant to > dynamically set the index of the btf id entries of the > 'generic_dtor_ids' array. This was done to make the code slightly less > brittle as the struct cgroup * kptr kfuncs such as bpf_cgroup_aquire() > are compiled out if CONFIG_CGROUPS is not defined. This, however, causes > an lkp build warning: > >>> kernel/bpf/helpers.c:2005:40: warning: multiple unsequenced > modifications to 'idx' [-Wunsequenced] > .btf_id = generic_dtor_ids[idx++], > > Fix the warning by just hard-coding the indices. > > Fixes: fda01efc6160 ("bpf: Enable cgroups to be used as kptrs") > Reported-by: kernel test robot <lkp@intel.com> > Signed-off-by: David Vernet <void@manifault.com> I hit the same issue with clang build and used the same workaround below. Acked-by: Yonghong Song <yhs@fb.com> > --- > kernel/bpf/helpers.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c > index e4e9db301db5..da2681ebb7c3 100644 > --- a/kernel/bpf/helpers.c > +++ b/kernel/bpf/helpers.c > @@ -2019,16 +2019,16 @@ static const struct btf_kfunc_id_set common_kfunc_set = { > > static int __init kfunc_init(void) > { > - int ret, idx = 0; > + int ret; > const struct btf_id_dtor_kfunc generic_dtors[] = { > { > - .btf_id = generic_dtor_ids[idx++], > - .kfunc_btf_id = generic_dtor_ids[idx++] > + .btf_id = generic_dtor_ids[0], > + .kfunc_btf_id = generic_dtor_ids[1] > }, > #ifdef CONFIG_CGROUPS > { > - .btf_id = generic_dtor_ids[idx++], > - .kfunc_btf_id = generic_dtor_ids[idx++] > + .btf_id = generic_dtor_ids[2], > + .kfunc_btf_id = generic_dtor_ids[3] > }, > #endif > };
Hello: This patch was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <ast@kernel.org>: On Wed, 23 Nov 2022 07:52:53 -0600 you wrote: > In commit fda01efc6160 ("bpf: Enable cgroups to be used as kptrs"), I > added an 'int idx' variable to kfunc_init() which was meant to > dynamically set the index of the btf id entries of the > 'generic_dtor_ids' array. This was done to make the code slightly less > brittle as the struct cgroup * kptr kfuncs such as bpf_cgroup_aquire() > are compiled out if CONFIG_CGROUPS is not defined. This, however, causes > an lkp build warning: > > [...] Here is the summary with links: - [bpf-next] bpf: Don't use idx variable when registering kfunc dtors https://git.kernel.org/bpf/bpf-next/c/2fcc6081a7bf You are awesome, thank you!
diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c index e4e9db301db5..da2681ebb7c3 100644 --- a/kernel/bpf/helpers.c +++ b/kernel/bpf/helpers.c @@ -2019,16 +2019,16 @@ static const struct btf_kfunc_id_set common_kfunc_set = { static int __init kfunc_init(void) { - int ret, idx = 0; + int ret; const struct btf_id_dtor_kfunc generic_dtors[] = { { - .btf_id = generic_dtor_ids[idx++], - .kfunc_btf_id = generic_dtor_ids[idx++] + .btf_id = generic_dtor_ids[0], + .kfunc_btf_id = generic_dtor_ids[1] }, #ifdef CONFIG_CGROUPS { - .btf_id = generic_dtor_ids[idx++], - .kfunc_btf_id = generic_dtor_ids[idx++] + .btf_id = generic_dtor_ids[2], + .kfunc_btf_id = generic_dtor_ids[3] }, #endif };