Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp326559lqt; Mon, 18 Mar 2024 08:55:03 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWbW4jYpdt8My9/ynCU1OoODjnEOjmaQMSd7F9PT5ryIzAvjKP3ZloCKzF/Q6fCibYhkREJ+llyQMfuvpGio+fIXLmzbMsOa73/AR5Jbg== X-Google-Smtp-Source: AGHT+IHeW/Qolmvltaa7gn9ZNc4x/gXG+szrV2j5qmfavVEfKr7hFHBIxFlFT+jYaBilAZyg6cVC X-Received: by 2002:a2e:7017:0:b0:2d2:3041:574e with SMTP id l23-20020a2e7017000000b002d23041574emr7549266ljc.4.1710777303790; Mon, 18 Mar 2024 08:55:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710777303; cv=pass; d=google.com; s=arc-20160816; b=AAhrVFWZd+Z/8RjTXH091NYJROUJKbtG8NPd0ENwHnkCGuj2fsJH2Hh+9+LxxkBxBF P0cqxVRRYQXc1yPkT6iZ6KzptWNiWcyQEI9ZYuJobpfS9V9uDHzajI9PawNsQ8Zi0uGr SpzHeKxzKWtAk26gYtH6Mi9KP06YM1LnGIgKJdkIg4KfNSmb71v1XI9L0AOHeHNViMLp JrZKatO12lmCCyyaYqBPdikj93p/3qZDG3ksPvPlCdtPQ78lpQYiL395geWC0kPNFFSP lIwW4kRTt9fhM4Y3Fg+uEN7Dl9k3nwefzY4cVZVGp1u6F8eq6y9d49Ob2/3XT9JTFJYO JpoQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:dkim-signature:message-id; bh=vcYOMEAYiLvp5GB4txzZlGS/nl9zQLTuqwsD6e0HZqo=; fh=YtO40hgfjC4pAS6BAK+eKg2sC0GQHPqzLP9KwCEoz7Y=; b=bJI0TN3ZOhxFxvMcIqJfsJXRRofuGwd+Oaq5ENpjAHNJ8jzX2FYwPY/hrwsiLkkBwg +HsgN9sdWIHUAAf7f5SXPjYeAck5o7UmqmIfWO4srZrjYwbbQQtK5Ax+15nNi59i/xdE f/HotibCItm9ydXhm6VK5mWCf+aRwEM0LHGxK6Y3X227/3KXVUYTiElbdNeAyNmHCqqW IApRoHvPqYPx1lj7vqTUNj7vWfdQWRLRGO7JU9Ci8Ly11U1eH/l2QZImWwedzDA5XOnO JFjN4lo7um/wq/nOfrbZOMCabfFv8L59zbqNblWIesnsYOD0VUAFxoLutlHmeLW51U1s +88w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=Nf56PJI7; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-106342-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106342-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id f4-20020a056402194400b00568b41d7b0bsi3328036edz.630.2024.03.18.08.55.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 08:55:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-106342-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=Nf56PJI7; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-106342-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106342-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 7B4121F21189 for ; Mon, 18 Mar 2024 15:55:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BA85A52F8F; Mon, 18 Mar 2024 15:54:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="Nf56PJI7" Received: from out-171.mta0.migadu.com (out-171.mta0.migadu.com [91.218.175.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 25F3D537E1 for ; Mon, 18 Mar 2024 15:54:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710777289; cv=none; b=Q7VNXG6xBm/MQ7ZX0ieiWRCkbsWuRrA9Hjpbr2QVN3sq8fNXW+HHpqTR0DjlXx0zPXiHWzZm3wVs4bQxo5/R+5VZIAJ3iF3LwLe6OB5SH2RK1Oe+HDkHwrQeDqj5fRgCiGY4g3pbZRWkXE5v8VS8oI7ZNKooLgGML6C9xG773Lo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710777289; c=relaxed/simple; bh=vcYOMEAYiLvp5GB4txzZlGS/nl9zQLTuqwsD6e0HZqo=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=IeQnWsPUDwcEonlG3PgSacr1tKqjXzp+vAS/U3QwShKoeT0ymlbxTwdmrPRPWXzbYCRHCSs5GtEoZL7ufSro6cgWol1z/SHZ2jZGmBQGKuzoNs0IM4dIs/NH8X/xP7sWHySk8y0s3zWz9lBRpjSQyMn5YND6oOkfShTREFjb2Es= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=Nf56PJI7; arc=none smtp.client-ip=91.218.175.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Message-ID: <34832c57-644d-45d6-b4bc-bd801e8bc5f5@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1710777285; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vcYOMEAYiLvp5GB4txzZlGS/nl9zQLTuqwsD6e0HZqo=; b=Nf56PJI7xVOJrkS0f+71pB57ZHPJZk+tAQmCboLUR++39APQGUvTjN+hGBk58eCXf257pk zJNFU/kKTrR+8M4wSDsbOCGFRJCKYUQPjw6tZyk9oz1ad6MS8FiRhOwwnUnvW+SEKnEjO/ UQcVPeBWNq2Qe9cLrSQ33qnzMnzJ28A= Date: Mon, 18 Mar 2024 08:54:39 -0700 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH V2 bpf-next 1/2] bpf: add bpf_task_get_cgroup kfunc Content-Language: en-GB To: Jose Fernandez , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Tycho Andersen References: <20240316162241.628855-1-josef@netflix.com> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Yonghong Song In-Reply-To: <20240316162241.628855-1-josef@netflix.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT On 3/16/24 9:22 AM, 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: Yonghong Song