Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp871688rwo; Sat, 22 Jul 2023 01:44:10 -0700 (PDT) X-Google-Smtp-Source: APBJJlEtDf2j43+1Srqx5douiAL89RmMh+ZcorY26Cy2w+d8P5M6zIoXAOnK9ew44OyG7WokjLzJ X-Received: by 2002:a17:902:e9cb:b0:1bb:3e35:6416 with SMTP id 11-20020a170902e9cb00b001bb3e356416mr4487836plk.56.1690015450247; Sat, 22 Jul 2023 01:44:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690015450; cv=none; d=google.com; s=arc-20160816; b=DXSavoWU7jCcMVsg/Lo9MF4BmLfBqhEm2ZfP+dywXjTmOKqyghCSfb1qxFKQFKxXoe P5Tu05z4dnYY0za7yghHn+SnwVFOvQuzF3CpWjlSStJ2Q9S2fMhAGxdV5SukVeb3BgCC XEvajNeqX71Y+7GUUREOIykGw8+xa4Pp9Zj+ivEfE0HYduXOEj/SX4PVosN6DH5rWjaj 1mV0S5IRy7/cWwzMH5Rm1RRo5OXPN3w1L4n4/95oKbGcsQz8S2tLu03c6nF5lUoSjpbN zwqiE2TXDQyXGWtGtBsJRHxynAJ1X3IkNO7A2KDJR5PHdXbWG1yFs9k4aWlExAOHoSwH Ip7Q== 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:dkim-signature; bh=OdAax6y1uOCyCmGv7I0BcTzo2TNpDSMP38eL9Kd2TKg=; fh=kw9j8wzGMzsBY2Au+7RzP5doXADIRuoiRE2fCu2Zxr8=; b=FzrOGcXAxnZHIOeIBoiKLqMUsp0Z6JRV4tmeWxioKUoQgixMJAYMmRgp2QylDIxTGx 4XHDGEPktugQ54iUzxlRVkWQhnVw3ZcDZW7gjejpd0Xd0lZKxyLQIJgday8KANc61omS kbIqmT5o1pxxvF+d8Cbf63w/i4STS+I8XgsWvhgoWz20xXP/DeJfqqiFlAFSWmUu+PTt BI/MIuDmHP3oaK3F19Q9jCwe8/MmC+HUYPvyU5e9QKbRWvAim7aebA3D/z9uWgC6swWa /9dJkikqKV5ktSy0kpuh8jDYhVFdvADondMZULdJGnrU8mlbdd762JPfPnD2ueoRcIBl +X4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Kj9zb2QV; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kk4-20020a170903070400b001b3d27c4f48si4522404plb.57.2023.07.22.01.43.58; Sat, 22 Jul 2023 01:44:10 -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=@kernel.org header.s=k20201202 header.b=Kj9zb2QV; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231324AbjGVHtQ (ORCPT + 99 others); Sat, 22 Jul 2023 03:49:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231318AbjGVHtP (ORCPT ); Sat, 22 Jul 2023 03:49:15 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87BBA3C3D for ; Sat, 22 Jul 2023 00:48:39 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 941496010F for ; Sat, 22 Jul 2023 07:48:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9A43DC433C8; Sat, 22 Jul 2023 07:47:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690012082; bh=6MQ29HDi9RobghOfq9ww6P1ehrV7jdzcjLwHNnWU8TY=; h=From:To:Cc:Subject:Date:From; b=Kj9zb2QV2XUlO6ArJk7Um1dVjnJix123wkWielmwHI1G12aNiMOftnyppaawHQ2Ev 9QihLXgFdtBBVHkdUPcfxtp1WVr9oya/sDbZZHbv5Kb0KTENPsRQoJpiK84Nf9JszY aSsTkzZicl1F5DjvqaDwI9SkAjwEaPqXUptOLRt+EbkNT4pzyFXhdl5Cyn8e/gkXum e76D0qNn7Zm3o1CUc/bhEHQtKDqPC4tV5gIUdbrXCZmma6fqI8R8SpEqaQeIK8ZVYJ HoNqbHSk/r12c+HB/7bmVVjDFGFtClCwxaOpVGUlPJlPNz0x5ot1ozRxr9xlTQOSuh fZztE9O4HIqIg== From: Arnd Bergmann To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Hou Tao Cc: Arnd Bergmann , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Kumar Kartikeya Dwivedi , bpf@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] bpf: force inc_active()/dec_active() to be inline functions Date: Sat, 22 Jul 2023 09:47:44 +0200 Message-Id: <20230722074753.568696-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 From: Arnd Bergmann Splitting these out into separate helper functions means that we actually pass an uninitialized variable into another function call if dec_active() happens to not be inlined, and CONFIG_PREEMPT_RT is disabled: kernel/bpf/memalloc.c: In function 'add_obj_to_free_list': kernel/bpf/memalloc.c:200:9: error: 'flags' is used uninitialized [-Werror=uninitialized] 200 | dec_active(c, flags); Mark the two functions as __always_inline so gcc can see through this regardless of optimizations and other options that may prevent it otherwise. Fixes: 18e027b1c7c6d ("bpf: Factor out inc/dec of active flag into helpers.") Signed-off-by: Arnd Bergmann --- kernel/bpf/memalloc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/bpf/memalloc.c b/kernel/bpf/memalloc.c index 51d6389e5152e..23906325298da 100644 --- a/kernel/bpf/memalloc.c +++ b/kernel/bpf/memalloc.c @@ -165,7 +165,7 @@ static struct mem_cgroup *get_memcg(const struct bpf_mem_cache *c) #endif } -static void inc_active(struct bpf_mem_cache *c, unsigned long *flags) +static __always_inline void inc_active(struct bpf_mem_cache *c, unsigned long *flags) { if (IS_ENABLED(CONFIG_PREEMPT_RT)) /* In RT irq_work runs in per-cpu kthread, so disable @@ -183,7 +183,7 @@ static void inc_active(struct bpf_mem_cache *c, unsigned long *flags) WARN_ON_ONCE(local_inc_return(&c->active) != 1); } -static void dec_active(struct bpf_mem_cache *c, unsigned long flags) +static __always_inline void dec_active(struct bpf_mem_cache *c, unsigned long flags) { local_dec(&c->active); if (IS_ENABLED(CONFIG_PREEMPT_RT)) -- 2.39.2