Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp256725lqz; Fri, 29 Mar 2024 16:05:28 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUABSjivv4kO6zESJNya1EN6qvl8AhcUKcI4fFWnqgSwvTaoRCkth26K9umAOmbXWyo1QxJehBBZxnaG9vVt+pTuM1tRVol4Vwik7+HFw== X-Google-Smtp-Source: AGHT+IH+Yn3MHsrq/AkCC8ICixeUCHyAgbGLHTraOWVL+P/7FmHhfcdkxoE28qkiK4O1qNzImpOB X-Received: by 2002:a05:6a20:12ce:b0:1a3:c8ab:5a7c with SMTP id v14-20020a056a2012ce00b001a3c8ab5a7cmr4908441pzg.22.1711753528402; Fri, 29 Mar 2024 16:05:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711753528; cv=pass; d=google.com; s=arc-20160816; b=npuOy26EPKg5fnCUHwZgfO9sPh2JJHYrOhVrGDAq7sUW3tr0eyqtnG2xvgx0Rhj/tA O1M4EB/f9zfDV1XKgKv3YHQEyuq/6RK04OY4H34W17VztDILsFimJjUQa5uAIASPLdrG O56VJ+7UqdXEXHi3a+FDeyXusPyc6byd/5GxpaSL7aS4CSvuVdrGoC6RiGuPVmpn4FwI l88lEQ2w8t1IBcx0xv/aH9fOgrT83mkadofbHt41+V62FFdz8mzPpR6T18tGr0tou86J 5o+iB9yfpo3fJb2HVa5MQbMtShyyC+dMna+KeYeQRMQNAlkKVC1Hmbn063EB9EM+kpCm OWew== 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=s5EA1dNOkzmqCgmVjiD2GJtPLu9i/Imtz0kuQLrem3Q=; fh=yijQXk53bVELcSxlHJuaEwKfnDCnCV2LyWKOI4nZUic=; b=hIwnq6+rPxNHIS1qzlfxL/RhdGri3z/AMKXqcclJDifRJcucdQZ0cUPgMls7dVNoo/ Lkxoyx+fGXXy1Qh03tR7HVpho50l1Qoi4rvkjY+1/g2Sy6vNTG9XiBUZZracflgJ84Zf L97Jgdje5XQIs0Dl1FncH/9MbrBXQnwr3pWgGYEMMqRZpbC82uQQDe+fDf2b0IQox1zk j7YrDg2dxRCrZAJpTvNbKLf/9063jebBDu961TqVoVKLb8jXN4CGs2qPv4y7Wehkz/SZ 3dPTpiwhk5EZCqDQk3lf0LTWZHh3MZhT+7rHg9C4sut4iIdBYaq98CiZYYUEGTMd0/sO zacg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=U6BheGdN; 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-125506-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-125506-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 c12-20020a62f84c000000b006e69b40d4adsi4297438pfm.100.2024.03.29.16.05.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 16:05:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-125506-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=@gmail.com header.s=20230601 header.b=U6BheGdN; 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-125506-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-125506-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 8533D282057 for ; Fri, 29 Mar 2024 23:05:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5636F13F012; Fri, 29 Mar 2024 23:05:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="U6BheGdN" Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (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 B5C9913E895; Fri, 29 Mar 2024 23:05:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711753508; cv=none; b=FLeM8DL77EJQk6d3SoFqLdC7M9KInCrb73EaxABSIo6M20qhRi8lEN3eVO9pY77/N7l6TnWH2cSI20IexzpQI34U709g9VIp29JeVqTWnX76yniTt+/10d7iY8jWp+91WIOH3ijzvfB6Ea7PPBXZLP9SjUiLT5N7hcNrPeQ40gM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711753508; c=relaxed/simple; bh=bbuOaKvrjP/9RP0DxEgIjZZL+rizhBaVvYfdFek3Ayw=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=lnKhXE0aLOBD7K1hY7M6uqlFa/aZRGqyfFx+VEjK8k6kal30SuIwFkrDs3hk5qFwJW2fZkesMP+UOA/OHPfsfVDDQRBZh66kxclEpsMd7l69fKS9U356kjE/Ick3Y6RmiwyscvuDpiu792NkL3zqiWcz1vHtzdsMJOqwuW2zPac= 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=U6BheGdN; arc=none smtp.client-ip=209.85.221.47 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-f47.google.com with SMTP id ffacd0b85a97d-341cf28e055so1634072f8f.0; Fri, 29 Mar 2024 16:05:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711753505; x=1712358305; 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=s5EA1dNOkzmqCgmVjiD2GJtPLu9i/Imtz0kuQLrem3Q=; b=U6BheGdNeUMgaKm6mNXGRnCp1esqQW4gDO+RDLN6EV/KrDD7i6+on8+lbzNlgefLbm vokX82qEqTfkZmbM5iPf420jv5rOA9f2TScYT/l+ReBghoC2Dxeop7Qn+BW49Pz/pqGV 5LwcLd/RxQuwWvNjQFbdokj04/tmUVvt98WDZqneNDeLrVSee5LJo4ySP+5XemFaRc/J tMwvhImcXJKZj7SpxQhVw5es2SbaltiPVSJi6nuvxgEVKbo466rwWWJijCjefxNoqrbc gLY2+M0cV3lepFWrNj5FCM/Hl6jZUskfjYzN4k57oIOLVzOg95D26J4/pRzX7ujDMJiE N0Sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711753505; x=1712358305; 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=s5EA1dNOkzmqCgmVjiD2GJtPLu9i/Imtz0kuQLrem3Q=; b=C09g1n69spfR6CUS/oEhb9r2Y0OyMbpQc2V0849IsD9Xam4Pf4kKeCbV08O1EoClPK a8sC0xD/pVaIKxrm/xsr+vu5QKmO/7sLBmoLryWpDpIHa5oPUOIOCv8M48e2npr3gv6t cpyPT/UyTXQc5kns9OK8w8TfeaLpaTv9Z1ykSNrB1RJ7eAkY5nM1LVikGrKpxJ1kOZyX Io3pBpIojitRFyBy/96N4PliO/nJYxVjJqco64vj7aY0hLCIebgh3e1xP3rMO/XySBZm DHnEEN15/m/x4IOJ9jwGVv9vL3gSyuE5ImQxjCNXbYH7BWjApFrAICyWI4UcBweMC5ue 3s9g== X-Forwarded-Encrypted: i=1; AJvYcCWhoUbV68p4KJcbPDCXQ9D7P4zTusuthY+FGCAXM9+zaLQom1hP/iSNSC7g8PauKphynB4HtWVb6rcfu5iC7WSJqy3lvxyLqVa9XedwE7vd/+20qs20XDTiC30CTP/C60sVSBvIENbBoBzgLz83cJqBcRzya3aF0QGQqX2MeqLUPPFa+EqJp6wtXJvXHWPNsJblWfYDnvUhbSrPmg== X-Gm-Message-State: AOJu0YyzlVXeqSG5DsAWannGBgZ73MxCu2I7krdyOqHH/vHWT8e0xMKS KIco58NPvq7ziTRt2lbKKhsopNd1wO02rnTPY72KEzzhleIxDiAzzWuy+H0n2IZzsmASEmW5Yov 0FqHs3PXu+o49whdrOCbX453xatRjEMcGNFs= X-Received: by 2002:a5d:4452:0:b0:33e:b78b:5831 with SMTP id x18-20020a5d4452000000b0033eb78b5831mr2444474wrr.52.1711753504850; Fri, 29 Mar 2024 16:05:04 -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: Fri, 29 Mar 2024 16:04:53 -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 Fri, Mar 29, 2024 at 2:39=E2=80=AFPM Tejun Heo wrote: > > Hello, > > On Fri, Mar 29, 2024 at 02:22:28PM +0100, Djalal Harouni wrote: > > It would be easy at least for me if I just start with cgroupv2 and > > ensure that it has same available filenames as if we go through kernfs. > > Not a root cgroup node and maybe only freeze and kill for now that are > > part of cgroup_base_files. > > > > So if I get it right, somehow like what I did but we endup with: > > > > In bpf, cgroup was already acquired. > > > > bpf_cgroup_knob_write(cgroup, "freeze", buf) > > |_ parse params -> lock cgroup_mutex -> cgroup_freeze() -> unlock > > > > > > cgroup_freeze_write(struct kernfs_open_file *of, char *buf,...) > > |_ parse params -> cgroup_ref++ -> krnfs_active_ref-- -> > > -> lock cgroup_mutex -> cgroup_freeze() -> unlock + krnfs++ ... > > > > Please let me know if I missed something. > > I've thought about it a bit and I wonder whether a better way to do this = is > implementing this at the kernfs layer. Something like (hopefully with a > better name): > > s32 bpf_kernfs_knob_write(struct kernfs_node *dir, const char *knob, cha= r *buf); > > So, about the same, but takes kernfs_node directory instead of cgroup. Th= is > would make the interface useful for accessing sysfs knobs too which use > similar conventions. For cgroup, @dir is just cgrp->kn and for sysfs it'd= be > kobj->sd. This way we can avoid the internal object -> path -> internal > object ping-poinging while keeping the interface a lot more generic. What= do > you think? And helpers like cgroup_freeze_write() will be refactored to take kernfs_node directly instead of kernfs_open_file? Makes sense to me. Sounds like a minimal amount of changes and flexible enough.