Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp73449ioo; Fri, 20 May 2022 14:21:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxxLdOoGuPSph9x4SZGzEY46KvC8QUoRxr99GivcN1cJl/CCpT2ZkWCgaxAFgs5TxGQXrj6 X-Received: by 2002:aa7:cd87:0:b0:427:f800:220d with SMTP id x7-20020aa7cd87000000b00427f800220dmr13262608edv.112.1653081704380; Fri, 20 May 2022 14:21:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653081704; cv=none; d=google.com; s=arc-20160816; b=SNnQphIpf2hRHmJJ1ynpZKwHI3W4+aW6fFqmiH/wxaMpU1AEZeNFAPUK+L9RD6C/2a QQt3KedKH3HSnw7XNopf235P/ORUqllyYlmBQrdHMHI5EmiITxMziBdI5cdegxUINwKg bhi3Fto1XxPAr1NNVfBhVzGbQ1Rhv06769ln4HUjpQlw1p/gTLOYTJqQdhgdKMylQt1M Gp1qdymj6A/BdFAIhDpS0Z9I0RgISGURXbANB5Dyi+aDVn6i5S0YjP7dbHGb1WjEblIp lEL2YnZ6BQpp6mZaasmfuacln2d3GO3p1FZ6WmzGDF/QCWJUtRRFPhVgViHiXS3sEedk tPJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=0c6tWWHaqv9YocEluVJeMxSaQ4ffT6xCHDnlxrPLBcE=; b=0FAVjzV/DVKiQQGkJytDdIa/rUSsArIG/ZQ6/7t5vUGAr8wW8GgRoDE389IJpd66po Z8ZmGHCZF6/hpKwwzAvlLSKAgmDLGGuyjyA/MyRICy0b/sBeyGz3XMgZ/FfC04+03VZW TEOhyBY5fglf71+RXPrXbSB0REaE7hc6V7qOUhpANyhaXA9aAZsGurYOnonhq8d8wRIW 7PmUpVuBYLzu1NNyBZyhcNYfdvQc0OmdP+iGSXJIJkS/68tBkcS2g+QCbekY0PxOSi6o dwCS5mKsZycBx5G6wwUw5SgCLiGIxCIPwACqQkloeUUIj+mACueo3ZDqElbwOPExEwz1 xCAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=IvQ0zqSK; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kq20-20020a170906abd400b006f3e35a64d1si8532621ejb.561.2022.05.20.14.21.17; Fri, 20 May 2022 14:21:44 -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=@gmail.com header.s=20210112 header.b=IvQ0zqSK; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347747AbiETJf2 (ORCPT + 99 others); Fri, 20 May 2022 05:35:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347727AbiETJfU (ORCPT ); Fri, 20 May 2022 05:35:20 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C49DE13F40C; Fri, 20 May 2022 02:35:18 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id f10so7561331pjs.3; Fri, 20 May 2022 02:35:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=0c6tWWHaqv9YocEluVJeMxSaQ4ffT6xCHDnlxrPLBcE=; b=IvQ0zqSKhM4OPBa9NW2eBe3mL6oMzRwfVSXxibRyEnDg7sQiJOrnFMuGIUjkpXv1iG Fomrt61emOrTmIb11bduSCbpEE+y/l0zKOvlJ2p1EgpEY2tiFAiCjgBiDKYCl9pbsgI8 D17DhLJjB1MxjhxyBT9Gm1EhgLhYiTK4srsjlRyVHfWcNrZcd5cG5arh7GSCqSV/X6z3 9jReKVrkwiMg+7ubudidg5VZOUH5WVMpWkJ/5yfxEcwZOP64zVkVGkkDkFYtOyH/whj1 jPS4I2G4sRp02+3P5Hq+1rGL+lKjRcS0BuYvw/IOIKcLpY0YoP/lDWfb/VJTTKPQsPiR 9g8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=0c6tWWHaqv9YocEluVJeMxSaQ4ffT6xCHDnlxrPLBcE=; b=Kl+gsTyow5Bpv+dm6815urwkdVPM1HwAm7jxoYELji/QDpCxcvopo+nhabS6FaaZvQ VowfBCTvt81UE6wwjRnV8HjsfcIEFXVY3hvGhaUmKv+8Lru/2XCn99pRcVVBzipJ00b8 +1y3KRLEmAx9tqo+k3LaPPlivN4kVYkj95isoVf46BUMyLtqG0gPCZnD/pWXK1rnKMW/ uaDqvqHr8/5htQIi0sDqGWSPUmbo7RPNXhE+l5SrXf6T1df20MXHWtu+9lD6CVPw++Ey vrvo/XR2HV+8yJ5gDuk0HNq+ts+h+nMrJJ8nwsz0yuks7fE1g2okIh8va6YcY2BuW1/4 vGvw== X-Gm-Message-State: AOAM530qx4kFoBnsKoP18uTIwYWtrgnpLguaUdCLRS8JrhnQfC8wleyi ayF2SJt6QuC6gsdaDSmWO9E= X-Received: by 2002:a17:90b:3ece:b0:1df:95b:18a8 with SMTP id rm14-20020a17090b3ece00b001df095b18a8mr10788682pjb.67.1653039317938; Fri, 20 May 2022 02:35:17 -0700 (PDT) Received: from localhost ([103.4.221.252]) by smtp.gmail.com with ESMTPSA id 187-20020a6215c4000000b0050dc7628146sm1351337pfv.32.2022.05.20.02.35.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 May 2022 02:35:17 -0700 (PDT) Date: Fri, 20 May 2022 15:06:07 +0530 From: Kumar Kartikeya Dwivedi To: Yosry Ahmed Cc: Tejun Heo , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Hao Luo , Zefan Li , Johannes Weiner , Shuah Khan , Roman Gushchin , Michal Hocko , Stanislav Fomichev , David Rientjes , Greg Thelen , Shakeel Butt , Linux Kernel Mailing List , Networking , bpf , Cgroups Subject: Re: [PATCH bpf-next v1 2/5] cgroup: bpf: add cgroup_rstat_updated() and cgroup_rstat_flush() kfuncs Message-ID: <20220520093607.sadvim2igfde6x22@apollo.legion> References: <20220520012133.1217211-1-yosryahmed@google.com> <20220520012133.1217211-3-yosryahmed@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 On Fri, May 20, 2022 at 02:43:03PM IST, Yosry Ahmed wrote: > On Fri, May 20, 2022 at 12:24 AM Tejun Heo wrote: > > > > On Fri, May 20, 2022 at 01:21:30AM +0000, Yosry Ahmed wrote: > > > Add cgroup_rstat_updated() and cgroup_rstat_flush() kfuncs to bpf > > > tracing programs. bpf programs that make use of rstat can use these > > > functions to inform rstat when they update stats for a cgroup, and when > > > they need to flush the stats. > > > > > > Signed-off-by: Yosry Ahmed > > > > Do patch 1 and 2 need to be separate? Also, can you explain and comment why > > it's __weak? > > I will squash them in the next version. > > As for the declaration, I took the __weak annotation from Alexei's > reply to the previous version. I thought it had something to do with > how fentry progs attach to functions with BTF and all. > When I try the same code with a static noinline declaration instead, > fentry attachment fails to find the BTF type ID of bpf_rstat_flush. > When I try it with just noinline (without __weak), the fentry program > attaches, but is never invoked. I tried looking at the attach code but > I couldn't figure out why this happens. > With static noinline, the compiler will optimize away the function. With global noinline, it can still optimize away the call site, but will keep the function definition, so attach works. Therefore __weak is needed to ensure call is still emitted. With GCC __attribute__((noipa)) might have been more appropritate, but LLVM doesn't support it, so __weak is the next best thing supported by both with the same side effect. > In retrospect, I should have given this more thought. It would be > great if Alexei could shed some light on this. > > > > > Thanks. > > > > > > -- > > tejun -- Kartikeya