From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-178.mta0.migadu.com (out-178.mta0.migadu.com [91.218.175.178]) (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 7768735BDCD for ; Wed, 29 Oct 2025 20:27:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761769632; cv=none; b=c58LAwRo+Ju/gkC5rLjonGH9M371nWfQUZQI8f/R43g33QyS89kVRGys37ZffuA4ezReEp+wd3U70Sh2hXhvSpO/Qk25SOvjDrUrOxaK3OUSjYQiJbdI2C8csvT8tCCrze6mLLN7tWCcf/i01qB/7hNkjkkqoUZFIvW7G0DPaSE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761769632; c=relaxed/simple; bh=+Pc7w3IAtNlTyP1zbbSyl8Dgv7qPtTj68AwRg9Qnoeo=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=Z93fCbbtRlJoJDU7o94muqXwXmNSSjjwh2WmaHbOJ8CnfbJ4yVPcueT+51RIPGa+c6GNkYhqNM3YgO5AkgYa5NmTdE1QcZQu8qOEHEVginp9ELLwY6NDPB7x2ta4wofDsoDL1Qoglm/UsHM3FZjPIraX06uFGPmyXdDRpFl9MwI= 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=uDvBTjFN; arc=none smtp.client-ip=91.218.175.178 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="uDvBTjFN" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1761769626; 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=L5vmLW+oATPFNaWdtHY1yVME8el6pZeETE8QCtK8TCA=; b=uDvBTjFNloStyK5QFb/yoXxdR2x9MXtvvx+VlwjlfcjJkJJCF/u4jP8Z1O8uvzIJVQei7i DLMoZGz0HxN1qz2OYh0rxnJZijSp4ZzRT5ISRcNxuFsImqMhMXzbscUzEIQ+vEupnezkGS jrYIMHJUDg0Es/IWmxMEqmpTQ0M5jVI= From: Roman Gushchin To: Song Liu Cc: Andrew Morton , linux-kernel@vger.kernel.org, Alexei Starovoitov , Suren Baghdasaryan , Michal Hocko , Shakeel Butt , Johannes Weiner , Andrii Nakryiko , JP Kobryn , linux-mm@kvack.org, cgroups@vger.kernel.org, bpf@vger.kernel.org, Martin KaFai Lau , Kumar Kartikeya Dwivedi , Tejun Heo Subject: Re: [PATCH v2 02/23] bpf: initial support for attaching struct ops to cgroups In-Reply-To: (Song Liu's message of "Wed, 29 Oct 2025 11:01:00 -0700") References: <20251027231727.472628-1-roman.gushchin@linux.dev> <20251027231727.472628-3-roman.gushchin@linux.dev> Date: Wed, 29 Oct 2025 13:26:59 -0700 Message-ID: <87cy65e9nw.fsf@linux.dev> Precedence: bulk X-Mailing-List: cgroups@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Song Liu writes: > On Mon, Oct 27, 2025 at 4:17=E2=80=AFPM Roman Gushchin wrote: > [...] >> struct bpf_struct_ops_value { >> struct bpf_struct_ops_common_value common; >> @@ -1359,6 +1360,18 @@ int bpf_struct_ops_link_create(union bpf_attr *at= tr) >> } >> bpf_link_init(&link->link, BPF_LINK_TYPE_STRUCT_OPS, &bpf_struct= _ops_map_lops, NULL, >> attr->link_create.attach_type); >> +#ifdef CONFIG_CGROUPS >> + if (attr->link_create.cgroup.relative_fd) { >> + struct cgroup *cgrp; >> + >> + cgrp =3D cgroup_get_from_fd(attr->link_create.cgroup.rel= ative_fd); > > We should use "target_fd" here, not relative_fd. Ok, thanks! > > Also, 0 is a valid fd, so we cannot use target_fd =3D=3D 0 to attach to > global memcg. Yep, switching to using root_memcg's fd instead. Thanks!