Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp6032723pxb; Mon, 14 Feb 2022 13:36:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJySGO6otZnWPrY7du27redfLNNWH0WgBnrqWj46RAosESzHsD52Ep7bdO5sZq60CxU/pmQa X-Received: by 2002:a63:6886:: with SMTP id d128mr846022pgc.522.1644874568205; Mon, 14 Feb 2022 13:36:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644874568; cv=none; d=google.com; s=arc-20160816; b=ANNxaactleL8pG3wa0FDfjzxzmHzzB3Kbdj+YJXwhZ/HxBcR6zEQDH+42jRTBbF46N Zm9TrPutn9v5lPu1NJGzT9s1sNM+ITjtTslIqr3P5neSnYjtOjo/CgjrM55l38z23q83 2ZNREJvc6ypHDTGOX2kNwQ9lt4r2kAkrUwG0Df8Ik53plgn06zolcowFp+Ngw3V/vRMK eijlNzwKt/vtQYWUc0gp9YWEbcEIEf07smSoAQXQB/2BOd3jW/lcrUtFvPg4jQLfEzl9 gaJe8t3z8OSz1sSXA6MKBI8lPqDCgSD67HSh0VXAamjLqsN4+CByDHP8yzg+HiJHZVvc dDIA== 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=c/bS6El9B0zRCiRKsjycXs0hnJXDV/WUGWitZwC9Ic4=; b=MoMInaC2oOZwdDxaxmR6zPKvyQxENDMuUOkgLkei4KuRLivKw9jpbYYQWtkczVNB3v raDUCUwLw2Bcqc8coMY4D888CN2CUm2rY7CdxLlKu7Jv3rKxcCBCKuLB0BJMLhFQc1Ox yf49VthJ+ifAOvq6e/gIse7CaOWpmSBcSJTVVGNHAnjmAHoO0QupIIOdakLJhETLRUpH h3swcfnsevYBdWXUZypQkBfrOUIKt4it9HrEG9DH5mlTEWpxvt7rJXora3E0K19xzlgz 5jVcnH6u1mbLpHXuY7qPFEeemtfFB/Zayayd8UtQ/eqx/2SJh/z0xcrcvnL01ejmfZW9 0EFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=jILBRWKt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id a1si2923196pju.52.2022.02.14.13.36.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Feb 2022 13:36:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=jILBRWKt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 39EA716E7F7; Mon, 14 Feb 2022 12:59:24 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229655AbiBNU7Z (ORCPT + 99 others); Mon, 14 Feb 2022 15:59:25 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:57182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229616AbiBNU7Y (ORCPT ); Mon, 14 Feb 2022 15:59:24 -0500 Received: from mail-oi1-x230.google.com (mail-oi1-x230.google.com [IPv6:2607:f8b0:4864:20::230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6EC8145E1C; Mon, 14 Feb 2022 12:59:10 -0800 (PST) Received: by mail-oi1-x230.google.com with SMTP id x4so8500904oic.9; Mon, 14 Feb 2022 12:59:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=c/bS6El9B0zRCiRKsjycXs0hnJXDV/WUGWitZwC9Ic4=; b=jILBRWKtzkWUzvcgS2TtBHr2FiKhc/8ebPSF7R/0nQgYxsyunQT0ay6z5V5NW6UJ9u lzzu6Rf5X0IX5cyZ8gwJ9qZ56Z7CAN3XeIkcULOv5Lonwc1t4Rvlk0AbXIsAcUXzpWYk L3cHi2ADLPm/hcYwXf997I+ZtmwbIpg2mfjXsrnj8ciiP9t+x69GDWT2QkBd4OR5f2PJ OIy3ISfH3csPXkqjTnYBNU8KOxtkTddTHMCmAtlYooeKJnSJQInOB5i5uUzdlCyI2Rsl 1iKmxz4rQUQUBV/M8OWE/AcfS5hQA6baq5iuWI+V0YYk7A3sPYU7OdV2CSCfLE/XfxuH TQbw== 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=c/bS6El9B0zRCiRKsjycXs0hnJXDV/WUGWitZwC9Ic4=; b=KM22bbmih8XMMzW9p9NCNaRsYmMe49yM1IeSF/OVtXimjUW7kWVOVz5mEifa9KR60P g9SK3yTHLdMVXPwo/wdj0KIGceg4/OlRzt5vZ3v7XXCGHl/DaQB2HhM8qjTQT4XkUPdE nENlyqmAd0cAw5gWULX5RwQi8nZiE+hwjwcQc9fo604EPh5+frXFcqu8DKPx/22zMiGG mbRa4w8htsYoUJgQVTaFlQQJ9ZWvvvUassJgAd7rUl0n4DspznTOviSdzAZ8l8u3MFLI NRhgfwfV3xf8jJ1nxqb8STOTCf+i57J2SwwOvCbW1Aa1qLhCj9XizKsmOu/fU4qyqlc0 yl5g== X-Gm-Message-State: AOAM530n59oR9Ej8au5G+bwKoYT+B3NCRokXoac3Y5MJ549kSG+ULfWV 1ovx1YESb0LY/BkUs0xl4zCz1fJrtS0Cah6FjNlt9ZGaiUw= X-Received: by 2002:a17:90b:1d84:b0:1b4:dc8e:2cc2 with SMTP id pf4-20020a17090b1d8400b001b4dc8e2cc2mr458721pjb.122.1644870485755; Mon, 14 Feb 2022 12:28:05 -0800 (PST) MIME-Version: 1.0 References: <20220201205534.1962784-1-haoluo@google.com> <20220201205534.1962784-6-haoluo@google.com> <20220203180414.blk6ou3ccmod2qck@ast-mbp.dhcp.thefacebook.com> In-Reply-To: From: Alexei Starovoitov Date: Mon, 14 Feb 2022 12:27:54 -0800 Message-ID: Subject: Re: [PATCH RFC bpf-next v2 5/5] selftests/bpf: test for pinning for cgroup_view link To: Hao Luo Cc: Alexei Starovoitov , Andrii Nakryiko , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , KP Singh , Shakeel Butt , Joe Burton , Stanislav Fomichev , bpf , LKML Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE 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: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 14, 2022 at 12:23 PM Hao Luo wrote: > > On Mon, Feb 14, 2022 at 11:25 AM Alexei Starovoitov > wrote: > > > > On Mon, Feb 14, 2022 at 10:29 AM Hao Luo wrote: > > > Hi Alexei, > > > > > > Actually, I found this almost worked, except that the tracepoints > > > cgroup_mkdir and cgroup_rmdir are not sleepable. They are inside a > > > spinlock's critical section with irq off. I guess one solution is to > > > offload the sleepable part of the bpf prog into a thread context. We > > > may create a dedicated kernel thread or use workqueue for this. Do you > > > have any advice? > > > > Are you referring to spin_lock in TRACE_CGROUP_PATH > > that protects global trace_cgroup_path[] buffer? > > Yes, that's the spin_lock I am talking about. > > > That is fixable. > > Do you actually need the string path returned by cgroup_path() in bpf prog? > > Maybe prog can call cgroup_path() by itself when necessary. > > Parsing strings isn't great anyway. The bpf prog probably needs the last > > part of the dir only. So cgrp->kn->name would do it? > > The TRACE_CGROUP_PATH wasn't designed to be turned on 24/7. > > That global spin_lock is not great for production use. > > No need to delegate sleepable bpf to thread context. > > Let's refactor that tracepoint a bit. > > No, we don't need cgroup_path(). We are going to name the directories > by cgrp->kn->id. I can add a fast version for cgroup_xxx tracepoints, > which don't require the full path and can be turned on 24/7. Sounds good. We need a flag for tracepoints anyway to indicate which ones are sleepable. Probably similar to what we did for DEFINE_EVENT_WRITABLE.