From mboxrd@z Thu Jan 1 00:00:00 1970 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KUerO6QI" 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-Google-Smtp-Source: AGHT+IFWusnGRofxUqkdce214ptGaKSLBbD5ujAd410w8xh3y92TbU6CAQLelLuqig0w7Y4NkcB6iXOU8DyX1KjSe4Q= 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.