Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp576588ioo; Sat, 21 May 2022 07:32:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyGR+PQTQay3ynZVcZFGIUqbrOvMZXUxWmECLkjTp22hvc32x6ncXcD80/3R2dQjSQsp0Ds X-Received: by 2002:a17:907:720f:b0:6f8:5c31:4027 with SMTP id dr15-20020a170907720f00b006f85c314027mr12823982ejc.284.1653143574829; Sat, 21 May 2022 07:32:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653143574; cv=none; d=google.com; s=arc-20160816; b=nDknLQXr9/EtaZ3/i24fZsMBR2ct3yaSdibKW1jO5ryAh9Duv3MkcuxLzwsBM0F06N l5gnh+tH04Yhc7mpHkuO32tzRoUoGPYSk5OjtodZNcTeWE8oFVaMUEtziSM7eOej/3id ahdz9ipfTtAsCDo/YlT59RU+cPxTpuNxL1MHm8NDwTG5PsVHcriSjDJRxQoS502EXF5y wuqXpeCfTuhgb+UH9U3qGgmeLVC4/R1B+jZgA7b1PFKAi2D3rx92GCNxTDOautGFeGFC N2V7r32VarIdEdHJNlTZJZDOeZLli0GR/elMscC1JGp8DvsC5fld7cxIFjIlq4lIIf40 c0Zw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=69cx6mPg1rWURoZo4NX3ijOmJtwQkSNn64F/hEHNYSU=; b=SlzpC4fNKM44llrMJYsmwjNXkmq66SIl3jC4/C0qOZdfJyZ4UCnJgqCX+6AYRh151J VDCUIcuNmkNtDMXVO9KAMb9J7ciocZB3LyXzbJOJRSmkW5UNO4UBl6F7JnkYsU3e3qfF 1YCJpFDLmlxtm/4Cm4evjmwXgImXn5we2+96PfVa6J0klUbhBPwrWmN6wksDy65s4vIA r2BklBs97bGPw9h/Z7+fWTXdlCgyZEi5XnG6YCtOIH4h/nyoZuQ85vW7rzvaetm7wNj1 xjQYK8g6Q8GLqIfEsZ+6mLw2L3qIpr9Y8W/4+eXWFKPrg/VBgAs2Q3GXTyvyZMSZI/xk AcNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=BCreR+XU; 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 d24-20020aa7ce18000000b0042abf683338si9569083edv.212.2022.05.21.07.32.29; Sat, 21 May 2022 07:32:54 -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=BCreR+XU; 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 S1344422AbiETBVr (ORCPT + 99 others); Thu, 19 May 2022 21:21:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344389AbiETBVl (ORCPT ); Thu, 19 May 2022 21:21:41 -0400 Received: from mail-pf1-x44a.google.com (mail-pf1-x44a.google.com [IPv6:2607:f8b0:4864:20::44a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 410FE29817 for ; Thu, 19 May 2022 18:21:40 -0700 (PDT) Received: by mail-pf1-x44a.google.com with SMTP id t29-20020a056a00139d00b005107ebaefeaso3446932pfg.20 for ; Thu, 19 May 2022 18:21:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=69cx6mPg1rWURoZo4NX3ijOmJtwQkSNn64F/hEHNYSU=; b=BCreR+XUKTegtpZpREe5xPvg68UCcKsrUAIVbGh5bI2zogHrCn+YHLq0FMySF7Z8+U 3nTv8stgycmvTmhhg+YPkCLz4UYr3ZJz7474U4xhyJE3TKlT4rYlAp0vn5NBMmGoe2ov dgweabl3iJGlpFuwJTqJRwak1koJWau8g/NP85L4CjmiJUzSKn4LzPc2hkHvubatyBQP /96s5b/5xzfSh2L2JFvPZ2hVNpAhSiLyYoCG5VatpXZ/1CZSaKHDY0Xa+XvkgrFotW3c B1tX82bRy1h3iblza4rY3Q+jRM97bMVY3aW48bY0dTk7oUfdIoNGjySPHVcDY3xSepq3 Yujw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=69cx6mPg1rWURoZo4NX3ijOmJtwQkSNn64F/hEHNYSU=; b=sTAwLil3uHl2BEMTTKC7YpJo71kNTz2rpZ93IhOB8YQqsKL0iNFsbzZT7j1ThFyBKa jcAuAo1qIJL8LOniWXDTBGjuwsStJFH/BCZMJ4FTBd7SngPZ7sB33qVkbnBi2gPJg3ag iYWStfT7qLhxUn5n5Zrp3c4YKD94m/E+Kr6CTHw+7xlzRyhDzWE2qiKSijkHZGemq6oc Yl56bL37Vh1hJUTBCrNTEASmzkt+oDp3vby4e8kKe/o3ppGMylVEK3mj8g3YBqC5XvVD P/cgwpu7YO3y8IZE7IvQtOgivq5b/rXZXaRBpI/4VAUuyru4gyaxIX8hLngM3y8n5u58 zkpQ== X-Gm-Message-State: AOAM531A5ZqO8E16kBd1R80eNjquuc0FN5TJLWKVzaMZrWkf0xbLGPUw WZ2V35vMKcOzUViwMqM8Fti6u0qpc07wl4Mv X-Received: from yosry.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:2327]) (user=yosryahmed job=sendgmr) by 2002:a05:6a00:724:b0:4fa:a35f:8e0f with SMTP id 4-20020a056a00072400b004faa35f8e0fmr7557670pfm.25.1653009699699; Thu, 19 May 2022 18:21:39 -0700 (PDT) Date: Fri, 20 May 2022 01:21:29 +0000 In-Reply-To: <20220520012133.1217211-1-yosryahmed@google.com> Message-Id: <20220520012133.1217211-2-yosryahmed@google.com> Mime-Version: 1.0 References: <20220520012133.1217211-1-yosryahmed@google.com> X-Mailer: git-send-email 2.36.1.124.g0e6072fb45-goog Subject: [PATCH bpf-next v1 1/5] cgroup: bpf: add a hook for bpf progs to attach to rstat flushing From: Yosry Ahmed To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Hao Luo , Tejun Heo , Zefan Li , Johannes Weiner , Shuah Khan , Roman Gushchin , Michal Hocko Cc: Stanislav Fomichev , David Rientjes , Greg Thelen , Shakeel Butt , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, cgroups@vger.kernel.org, Yosry Ahmed Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL 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 Add an empty bpf_rstat_flush() hook that is called during rstat flushing. bpf programs that make use of rstat and want to flush their stats can attach to bpf_rstat_flush(). Signed-off-by: Yosry Ahmed --- kernel/cgroup/rstat.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/kernel/cgroup/rstat.c b/kernel/cgroup/rstat.c index 24b5c2ab5598..e7a88d2600bd 100644 --- a/kernel/cgroup/rstat.c +++ b/kernel/cgroup/rstat.c @@ -141,6 +141,12 @@ static struct cgroup *cgroup_rstat_cpu_pop_updated(struct cgroup *pos, return pos; } +/* A hook for bpf stat collectors to attach to and flush their stats */ +__weak noinline void bpf_rstat_flush(struct cgroup *cgrp, + struct cgroup *parent, int cpu) +{ +} + /* see cgroup_rstat_flush() */ static void cgroup_rstat_flush_locked(struct cgroup *cgrp, bool may_sleep) __releases(&cgroup_rstat_lock) __acquires(&cgroup_rstat_lock) @@ -168,6 +174,7 @@ static void cgroup_rstat_flush_locked(struct cgroup *cgrp, bool may_sleep) struct cgroup_subsys_state *css; cgroup_base_stat_flush(pos, cpu); + bpf_rstat_flush(pos, cgroup_parent(pos), cpu); rcu_read_lock(); list_for_each_entry_rcu(css, &pos->rstat_css_list, -- 2.36.1.124.g0e6072fb45-goog