Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp335269lqt; Mon, 18 Mar 2024 09:07:26 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXLOdC0Yj1S7ZwV0OyGP9JAkMS6w5YiOf96pK/+5M0EdAPgloNBwDRRz7+MA7Hfa/gEnMRcHxlRQoE6hdWMPlg3cCjhlNRCzysXwuQDGA== X-Google-Smtp-Source: AGHT+IEAjb+9DulL0ibGMi6mEefV0Up3SkF2qqq4g7IMa4yjE8T0MHtGQsp1+GYNBtHobZp6qAAZ X-Received: by 2002:a05:6a00:4b41:b0:6e6:270a:9303 with SMTP id kr1-20020a056a004b4100b006e6270a9303mr12984409pfb.32.1710778046023; Mon, 18 Mar 2024 09:07:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710778046; cv=pass; d=google.com; s=arc-20160816; b=SEEDdn4+2CsZosLfce8TMXTFU1E+XbU2FI0yIkASYrL67o6kRn/sTuXLRVDDmX71rH JUA34r13WbfQZfUc8Rzc/B7mtDcwBBV3wyGNwwgnnvjmyAJN8ItcFVtQI0ysO0DqvgtY UgvJYrLAUjuq+Db2oW6etbIvGfyQtyT/N5K6Y3ve47Z1n2TZnlb17xnmv9CvW/sE9IEq ZP8xRfMtmBjfBm8lqlTa7PQyBVF4+UIOgllZANiMcd6WVXvJiGXKOrcZHVx2izZzBIxr qNMkfu8OIIKO4dFQ//8BOla3NViZTG4Yw5vjjoF7LeruXvRwVBs1ghJ8ZcQ5xEnfYK10 Fmng== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=BRMBKkFLpx5UEPxApBmIvNsw7kmzwH3SFmSAn82Rk90=; fh=usBNs6HZpp+SXiXJ/zAr5UJhmKqQjhjCDgFCZmL0PCQ=; b=i1MODVqXcJJMc6VUBxUDAF0Nctm0m3j6wPy12L6U4nSRBDM8mhOnyD8z3rmzMet0or zkOpzdjcvtD/UbxyIkpcbRh3fvpXiWPAqHvCDYJEFQXwMiwlvCbi6kJQ0jxqVm0E5wI2 /koTpjZqTdBtqxsJROFrnzeaBqZLUaEC135quefPML5OI55XqCKGqQhBEdFKKLD1pqux nDyQJS4qNsr8GSaLsxFIRBvtUjn8hQg2r5Pr9/oL1Pli5iH+zirNayf3v4JFKHSFThhG rfBhOg88AO+LMVA8qbzZS3RnXlz3R7xXEVoAa4Th/qESd/a8oy94TMjN/uXBXKv54CTq mPGA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=OPMBfRAf; arc=pass (i=1 spf=pass spfdomain=flex--sdf.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-106356-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106356-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id x52-20020a056a000bf400b006e535a40f7dsi9044378pfu.91.2024.03.18.09.07.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 09:07:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-106356-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=OPMBfRAf; arc=pass (i=1 spf=pass spfdomain=flex--sdf.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-106356-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106356-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id AE867281509 for ; Mon, 18 Mar 2024 16:07:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1995F53378; Mon, 18 Mar 2024 16:07:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="OPMBfRAf" Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9A2144F5FE for ; Mon, 18 Mar 2024 16:07:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710778038; cv=none; b=cnL+RLo+udHN4rGUZe+PV70EWl3pbGVXsiXAR71kENTSz6fHx+iK0PsjwbuRB5oeX1F4A5+1BVTnbv8uinwZHqOjxUZWsZuMoiZbkX60/SYsbrOEjhU8FO6I0ADgkpbxLD9zMrmRo4vfZ9avKQ0PVH/4kNGYCjLdSUbUk0u4sAs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710778038; c=relaxed/simple; bh=5PXmXrICF6GrxaIO5e63Q2oLbzQ0JOSVAmmok0aNVlk=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Th5IzgsDPg8K+spkawmQX8IRqJ3pYl492nuAmlLv5+vZxR7cr8kGpDP3YMmdtxK5Dtn2tuWjYIgsWSWXDmoNFkyEjbP9ZE9ll/jSZGUtEDO/sJLCOVX7lGxIRyd1b8clK+H1zW9fTV7a8Gf9uIzIR7TzmVQnc+/OElZ2gxn2yFI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--sdf.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=OPMBfRAf; arc=none smtp.client-ip=209.85.219.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--sdf.bounces.google.com Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dc6ceade361so7390818276.0 for ; Mon, 18 Mar 2024 09:07:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1710778035; x=1711382835; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=BRMBKkFLpx5UEPxApBmIvNsw7kmzwH3SFmSAn82Rk90=; b=OPMBfRAfTDzTP/74uNhVXmO+gTEpKu7gbzJ5Sb5V+BQlqjvDmHP75aMYXGYpfxUqRg 7Vo0pnr73pB1E3PJ4b/KwoUeZlkGFYoimtt/WgavjE4oxTi3IuK2ttCq5F2Z2tz2Px8Y EGwMfHmlv9JFlPX4xFLXQzk8IX3RjsP/ZNgs19mRCyItI50rxvv2cIri3oN9dIkSjQZm dQjTtnVfPEGz4B0RnmJGP4UzOqPsIIhzidHZN/8m+LJbATYyelLuB9XeLlpd248TOFo7 t3m5bF96seueMF+2AF1+abFHD2UJoJny23BDwfE6GxWPknAyfR0nkyYsHSxQSd3JVlxc 0GZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710778035; x=1711382835; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=BRMBKkFLpx5UEPxApBmIvNsw7kmzwH3SFmSAn82Rk90=; b=IljSt1dDqYo8YoJ3k3qFQC9rrLWDpao/QRQus60jxiwBLalUqo/u9GuV1rMCVUbiby V6d2dtC49aji9psaVkoyU5K6ZjWtzSKml5d7EPWGFOvSNadlxaePABhYSEFkJXvtiW3c IStagWPCSEoAqHQAJiKXfRL9GJqTxqmpIkVAs0Ixs+Ijr7/wsEndSHQV5lbyD5IvLUUS Zn5yitpgwn+ZBSuK+cONug8esWDLoO6Xm+0bLwMz1W8bFe8NamHUZA7h/rLzcIqhEDn4 aXWlpticVQU7yc/YsRS/V1nS/Si3chpgrCmhLBZhGnVStGfmB8A7HaMxcsX8Vd1Xkrbx D6ag== X-Forwarded-Encrypted: i=1; AJvYcCXPE3sRSrI3r77AjPBsuo698Q5EEjbGxc8CJjqnAWcwlBg858v5GhIfQkS0YZmB5u1YMUJrvzFhh8xzvQoiPV7/85eoWJSA6W4pkQvk X-Gm-Message-State: AOJu0Ywcc8672UvkTNIyLbzMcQH00gICkpvgFWMg4uZ6ed+gE+BYIP/7 vpPi55IstRTPdfA8hSLBEZXbUZKCWmbQ/y+xWC48HSTkEnrk5SbQR6m/t2hQmGtCqQ== X-Received: from sdf.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5935]) (user=sdf job=sendgmr) by 2002:a05:6902:1004:b0:dc7:5aad:8965 with SMTP id w4-20020a056902100400b00dc75aad8965mr3240384ybt.0.1710778034738; Mon, 18 Mar 2024 09:07:14 -0700 (PDT) Date: Mon, 18 Mar 2024 09:07:13 -0700 In-Reply-To: <20240316162241.628855-1-josef@netflix.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240316162241.628855-1-josef@netflix.com> Message-ID: Subject: Re: [PATCH V2 bpf-next 1/2] bpf: add bpf_task_get_cgroup kfunc From: Stanislav Fomichev To: Jose Fernandez Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Hao Luo , Jiri Olsa , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Tycho Andersen Content-Type: text/plain; charset="utf-8" On 03/16, Jose Fernandez wrote: > This patch enhances the BPF helpers by adding a kfunc to retrieve the > cgroup v2 of a task, addressing a previous limitation where only > bpf_task_get_cgroup1 was available for cgroup v1. The new kfunc is > particularly useful for scenarios where obtaining the cgroup ID of a > task other than the "current" one is necessary, which the existing > bpf_get_current_cgroup_id helper cannot accommodate. A specific use > case at Netflix involved the sched_switch tracepoint, where we had to > get the cgroup IDs of both the prev and next tasks. > > The bpf_task_get_cgroup kfunc acquires and returns a reference to a > task's default cgroup, ensuring thread-safe access by correctly > implementing RCU read locking and unlocking. It leverages the existing > cgroup.h helper, and cgroup_tryget to safely acquire a reference to it. > > Signed-off-by: Jose Fernandez > Reviewed-by: Tycho Andersen Acked-by: Stanislav Fomichev