Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp675914lqh; Thu, 28 Mar 2024 12:46:29 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU+H+Un63Vtm+yhhFhmRfXOJ0lFsYQBN/G0dDN4AqqdMxetM8CqtaAupGSA9PH/r1kPIyHL60jIQx4EWx3UbqGMq2EJxBWCpfuj6qU60A== X-Google-Smtp-Source: AGHT+IGri1N2e7QbMjGokHz1L36Lhpq3kFKcAL5FiRJnJwd88At22VpyY2VkuDGfoZg4YyBmj1Zd X-Received: by 2002:a17:906:6981:b0:a4d:fda1:e242 with SMTP id i1-20020a170906698100b00a4dfda1e242mr199965ejr.44.1711655189213; Thu, 28 Mar 2024 12:46:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711655189; cv=pass; d=google.com; s=arc-20160816; b=fiCHxDza5dGNrjUDQOzeyT5t6ml/4EH9mFvJjl5GNeEvQs1c9fLr7bSnELp9vCUw7i lsf9lP7G+3l+x9xXb/FDxdjJNnpPXI10TNWQh/X/OGt6vQk3rlSmKl+hPMKxyHTFU1gZ ONAw0qosHNWib6jO5xyiCbXoMMJCqN9TXTGSAXwj1+jqDDmKlvW71zX3mX3K+hsaa/+/ jh+XZO9ts8jNm76OaodOeg0izzEVFNi9za92O7pcNnT1CLNI61zb2vgP16RrlhUm1hUL n0/cBrRnWYwyJGdOjB0VMcLvFy9v0BZjMiOSrNTVKzbYiW7rkDBd9LZ1budh8SmQXczh ZkRg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=spgJqmt4sgwaRYWhJ7flL2ZvsHlYCW0N6JgDCKojbDc=; fh=Wrzlmj2URSTRyNvtf3H0GgJGasKIOLa60Qt6f8aj6jw=; b=VwNNVpNk2D2CwJesMzVvc2GhT7gIJIOs5u4XRi6aead0Pm+3XnP5cpFqQRzGzYNqnj dLElzGmjtaVXcbN+O4qemjTosDlXW5g2k5zgeOX8nzyasiPqjVRD9HDLERGulC+1fl3m xqAkLM/7igbgVE2JOIpO4BjBBEw6+Sqm2FVuxpcZ5MV62J79/p/RUUHw6Pr03+eI3qc1 6OzGVq9YJ74R9cxM/M7KtPqcyeyKJ4XPkev9e9gc9XN9o6lo0yenNrYbVYigTmyeHUiF V0jxCObjf9s5iHtcXVuVsBP68VvIipY5h/Rcb7P2v+9DZ2pVX9ctXdBp75N69cxsqzLw WcEQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=KUerO6QI; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-123499-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-123499-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id o21-20020a1709062e9500b00a4df0659d48si1014893eji.868.2024.03.28.12.46.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 12:46:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-123499-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=KUerO6QI; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-123499-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-123499-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 am.mirrors.kernel.org (Postfix) with ESMTPS id EB3001F21602 for ; Thu, 28 Mar 2024 19:46:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C44A21386DD; Thu, 28 Mar 2024 19:46:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KUerO6QI" Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (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 6E1B21849; Thu, 28 Mar 2024 19:46:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711655178; cv=none; b=LOtlFXufwnuEClYWoTg4ex/XkoPP9iobuIH0cGcV+Q2gZ6JpZfkt5jAiQMDfyWExXEsj0VVpXMtdWz6O8Q+Ei/AgAyfd2djbrIklkJzKwLBsZzO4KNNXcnuSUvKyyS3I7A4QCS7tFKE8T5trLdRM+B82ea354ah1tWo9yXlprFg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711655178; c=relaxed/simple; bh=spgJqmt4sgwaRYWhJ7flL2ZvsHlYCW0N6JgDCKojbDc=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=BTBgBQXZH6tC5+nWZ+58cqKF6KpLSgiBl5ocQlnP8+cFILHiOnVKPyX7ETgKrk8QeOMdBeLJmxe1xdRWWxv0f7DTqsrENEQEc0QHG7P4PQyWmZhZzS5MoG2Wh917D58kcl5Se1ryTjo95poKbVu3cukjFOLdibmxl9v5d0iL6KQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=KUerO6QI; arc=none smtp.client-ip=209.85.221.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-341b9f6fb2eso864898f8f.2; Thu, 28 Mar 2024 12:46:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711655175; x=1712259975; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=spgJqmt4sgwaRYWhJ7flL2ZvsHlYCW0N6JgDCKojbDc=; b=KUerO6QI5JQ/YwBujcu/N1ElqfV1Y2/PcBI8LWNh9Fa6l8ijI3QLr8qJdyViTUUiPM +px9K9TO6dB4AYxUMt1wJs0SRW6m81gG7YZ6SmMDKtlYNuZafuadriIH5nx6hT5cEHwi yL8bh90xea5HssZdWnVYdg4rMCDrrdRU4MTt/gqJqvjoByO9cNF+olYepzDomrCOYL48 k7odhOKf+q+yEYZWB2we4vmKNKkFaXTFlDliF7GXqflWBDcqXCkIllBBNgCJvzpMJqCw w5cxtzO0MT+gpgyDXcm6cJ+O1P0Q/YgUPFBZau52yJCnA3umiZeqkLbHP+MNMmdE5BdC He4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711655175; x=1712259975; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=spgJqmt4sgwaRYWhJ7flL2ZvsHlYCW0N6JgDCKojbDc=; b=wxRhp7FJJIYFXOzdkpxi4Ww4+S6sFV2FvI401AAB0DtPbJ/aMmVq3elJin3iEXl7pr 0vmQS3O+gZFNg9JSIE9XAUo2XLFmjG/eWA3bJF5mEDS0yB3vE5C0UvXS3czozFUFMbXC ZRdGW+Hq8eL+BILnorEsKjEyzr3Te3AG8n/UHsgMk1gwal1PTEDnO4AwiZNs2Xhywm2X 66egB2wI/2hjXantqUty6aQNTZAZRmzcZF49SnLxXeLI5onXeklWBU98nYMyK9Prjdvk CDzHTrqllPssygOeUVzJQip/5Kd7j4ot5mvwy6S7gnpRbhSYiprMes2AC1bnevc5y+N0 YCEg== X-Forwarded-Encrypted: i=1; AJvYcCVx1HhP/nhXQAOaPeZRUMSKnTQoB133dgUlTHs6kdDVrVVmkjDCXuSAx7k9/bm91tJussp0S4yjRQFdrvHbHGNBeF85Ho+9N1EbFHFPF85Iu+BDR7xvEl4dwlWQPLIjaFhRFy61JnA/t3HRQBnZyDvrc1NFew/i9bxneSVIa1G292wjYzTCdj9KgIogxDpmd0o3rNkLxv2bpVt2Ag== X-Gm-Message-State: AOJu0YwC47D81a/brX+fwjRQoofLbXvy4XqaNUAXpXC9SY0HOvo1qB2W hpbJDj4kmgaQS5gR9ZEIEIHnIAVaHYRw1FC/dq2TXfhXJIvcLgaZkZkEzmTxVG9JElV/NIJepD2 0mFCnzBimdByA1q/EYTm5InsxVeQ= X-Received: by 2002:a5d:66d0:0:b0:33e:d547:4318 with SMTP id k16-20020a5d66d0000000b0033ed5474318mr29659wrw.47.1711655174605; Thu, 28 Mar 2024 12:46:14 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240327-ccb56fc7a6e80136db80876c@djalal> <20240327225334.58474-1-tixxdz@gmail.com> In-Reply-To: From: Alexei Starovoitov Date: Thu, 28 Mar 2024 12:46:03 -0700 Message-ID: Subject: Re: [RFC PATCH bpf-next 0/3] bpf: freeze a task cgroup from bpf To: Tejun Heo Cc: Djalal Harouni , Zefan Li , Johannes Weiner , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Mykola Lysenko , Shuah Khan , LKML , "open list:CONTROL GROUP (CGROUP)" , bpf , "open list:KERNEL SELFTEST FRAMEWORK" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Mar 28, 2024 at 10:58=E2=80=AFAM Tejun Heo wrote: > > Hello, Alexei. > > On Thu, Mar 28, 2024 at 10:32:24AM -0700, Alexei Starovoitov wrote: > > > It bothers me a bit that it's adding a dedicated interface for someth= ing > > > which already has a defined userspace interface. Would it be better t= o have > > > kfunc wrappers for kernel_read() and kernel_write()? > > > > How would that look ? > > prog cannot and shouldn't open a file. > > Oh, I didn't know. Why is that? > > > The seq_file would be passed/pinned by user space? > > Would it work if it's just "open this file, write this and then close it"= ? Continuing discussion... To use kernel_file_open() it would need path, inode, cred. None of that is available now. Allocating all these structures just to wrap a cgroup pointer feels like overkill. Of course, it would solve the need to introduce other cgroup apis that are already available via text based cgroupfs read/write. So there are pros and cons in both approaches. Maybe the 3rd option would be to expose: cgroup_lock() as a special blend of acquire plus lock. Then there will be no need for bpf_task_freeze_cgroup() with task argument. Instead cgroup_freeze() will be such kfunc that takes cgroup argument and the verifier will check that cgroup was acquired/locked. Sort-of what we check to access bpf_rb_root.