Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp46396lqz; Fri, 29 Mar 2024 08:07:57 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWn1otE/KEgGEh1a4i3lV+nBzFLu6p4X4aG6798NyyL0DVDHwau0DlDr69hapjsU6sbg3oLFR7BQc2ryREZAALP/uY1+WZvNSLKtRrWPA== X-Google-Smtp-Source: AGHT+IE8P1n+/565B3fXjurG7e/mqMtxmyVsMOCjcD9X1zoTwSV/g+wR6Sv2J9Qjquu6BHrnPoNX X-Received: by 2002:a05:6a00:3a22:b0:6ea:df69:aa80 with SMTP id fj34-20020a056a003a2200b006eadf69aa80mr2539255pfb.24.1711724876789; Fri, 29 Mar 2024 08:07:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711724876; cv=pass; d=google.com; s=arc-20160816; b=Od27BFU9Y7Vf592J2Rg3bmHBumfc8RUvWPt6y+eP8jsxJ+tcOpmlvA3XNpOHt5timr GTCSoim0oogOKIePAdFe28fFaRTA2iAkQ9ELXiKokXEArcwVTFz3MuMyas1oeMoqEqQJ 0SSjs+cPdS3+xkCKdkriPjEaZiDXuqtpGV8I7sBajghGxj5/Ooaa4bSyGSj8aOd69ER6 ErmzcFqroef5l07YlzKDui86DdsgJTg8LekGvdi/z2XrISLYukTt27Ji0WcEKleobMxh CS//456OOYNkphSWySDg9N/PRl4bIAtBAs33PeL4dM4iJ2ixPtXT71gWpzGdP6p3Dfi3 OZeQ== 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:content-language :references:cc:to:subject:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=T7xEQIH74hDY+Lda40i905LEC8Iht3ogaURW2kap73s=; fh=dGs5DrjCKdSb3RRYJhRw5/5YhaIfRGE12V2VSqEmUxg=; b=gFf9e5zzcyjny8bOo6mHZpbaVqGu7twkx2X9Z3XCuZJboJXN68Xzo5AEOt+hA98YBp DIVfPH0e7OnmiHuiAnyMuk4RH3uVYmFdJ3qC5kxynWTbLS5oFZgktuN7mp2ya+oQRzM6 DtDK3JyX3w2ag1ycyKkEmeEmz6rTOuclE98kZDwJPKTkSBxQWRSIMhXa3XtvB8lTpzqe VV1/xIdfurI27LvmAACQtUdwVCbWfp8D2de6i9aFx/zGAbVne+D2tObvbfyTuvWAdweI 0Zhm34bAmn8RiOpcvh9JDzQHX/tVgjB0GtFtd0s0/M29FdFpTGJBc/oKEoaF/eoK3GN4 0rxQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Je4jNSGa; 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-125059-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-125059-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 o20-20020a63f154000000b005d8b48044d3si3731611pgk.723.2024.03.29.08.07.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 08:07:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-125059-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=Je4jNSGa; 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-125059-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-125059-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 6ACD628987D for ; Fri, 29 Mar 2024 15:04:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7A4BD13B596; Fri, 29 Mar 2024 13:22:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Je4jNSGa" Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.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 E8B9D1422D9; Fri, 29 Mar 2024 13:22:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711718556; cv=none; b=sKqaHgW14G2b4KNi1KWfYsUX/dFHCUp+b0UUxm/rviwzZ18/rtW3B8T8lswKbwIu39URy6ulE4DchDcCBS1XEQuZDU2EIkE/qFAK2ri50YT4WPAo6QkiZ93bjWj7Lgo3vmVNU6oEWKAlBZh/8C0fUCTJzes/dTGoRVu3lbmQCDM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711718556; c=relaxed/simple; bh=AnvJ5kofMrFFJqZi34ryz5OBe6mw7RXfXxGMEtAbKAs=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Tg7Jji0Hz8e5mk/1KIDs+52CWUlV010jRKPhA9HC9sfo1eH1VYgOyXmyR6bRMpGkXExBFFFQLfwDcSY3kxQZx6EPf5qf7HWkblmq84PRUj450YlNucdWsTlrdR9vyZBrNqu1aYDVYsLzIUxwpIpyL9DGMASqS21RVL+MQ+WS9EY= 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=Je4jNSGa; arc=none smtp.client-ip=209.85.128.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-wm1-f45.google.com with SMTP id 5b1f17b1804b1-415446af364so9121465e9.0; Fri, 29 Mar 2024 06:22:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711718553; x=1712323353; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:mime-version:date:message-id:from:to:cc :subject:date:message-id:reply-to; bh=T7xEQIH74hDY+Lda40i905LEC8Iht3ogaURW2kap73s=; b=Je4jNSGaJtYIX22uI04dL/yhpsXkEPu/CP6RrpVIfw5ru1l6gvPoxvyiDTMUG7Aj/a lP9S10cCk8TkTAtvd2TQxOjX9R95T7YsnRcbnRrbZvKBwrvnLetP2MA6dvlvpvMGH7Pv +XbioBaYnIO0LYhKz4s76/23mXpbTDU1hef+cegeXC8S2NDWNdRmj/viJ1gcmNQPa86w zs+1OARs3T/MV9sTSeaYVPrm5DFZw/RgRvN7iR3EYhFBzGD5iYqOgNQo7SXNtbZwFe3R rpGB04gBDJaG8RAJ+SEnoGYuWGPZARimWB5NctgnCTDv7GOy2u/AjSdiMXy+MAlkl7ih j0DA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711718553; x=1712323353; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=T7xEQIH74hDY+Lda40i905LEC8Iht3ogaURW2kap73s=; b=R3Lze86XldhwJl9PgYeh98NuhSsNaQH7PtlASkbQWWlL+I5RGYuPddmp0cvF+a2CaN g1CR+fvvERh2Mv7aeZOsJisRLhUZQqGt7mwiwzKh1uVS1K7P92ph/gM4uG9tgJRfIxE6 c5+KGBvRi/v4xEQLM/wu5qKeAxpxnJTnxdl6qRw65uBdu3F3IMeZx99RrK21jJYjnf+d 9sDwaegZG94O1G8XN8Z9WvgoAt/fMmINmQEFmntgKfgtMg+DNFwmZp0RwMWbVqKB8f5A WDBKYC7jbuoR55+zooXpqv7kDu8Je7AcD8mS/wElRYbWdAq5WQTut4P8T05115fGvP4g 9RxA== X-Forwarded-Encrypted: i=1; AJvYcCVHMoHOyjXWLv8LFyite9Ptqvjj9i5T3sJBK4S/c2l+tsk/iALVsLrBN6BK/xcoifBNEueynO69WQDEWRLV4EeQLmzsx9VPLF41w/qnDw7sQFfo203HmUc/v5KsRLsIirViFijANjUORNt9L0iWqXULY1Vc3KziqRLvLettV8aC6IhE+qkdsvAS72KVSkHT9VjdPcxC7ln+z9GVFw== X-Gm-Message-State: AOJu0YyP5EpejNdmWNLnK9aEPdNwTIIy7oltT0NwiriZON6y1G6NY0+R dd+5GniO0j3FYmW+sCaxQt34hh/zGTJUNFQ+mb2OP1qnxrFMU65c X-Received: by 2002:a05:600c:3c99:b0:414:90ea:34ad with SMTP id bg25-20020a05600c3c9900b0041490ea34admr4775141wmb.6.1711718552890; Fri, 29 Mar 2024 06:22:32 -0700 (PDT) Received: from [192.168.1.113] ([105.107.228.62]) by smtp.gmail.com with ESMTPSA id n17-20020a05600c501100b0041550a2ac10sm1499996wmr.6.2024.03.29.06.22.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 29 Mar 2024 06:22:32 -0700 (PDT) Message-ID: Date: Fri, 29 Mar 2024 14:22:28 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [RFC PATCH bpf-next 0/3] bpf: freeze a task cgroup from bpf To: Tejun Heo , Alexei Starovoitov Cc: 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" References: <20240327-ccb56fc7a6e80136db80876c@djalal> <20240327225334.58474-1-tixxdz@gmail.com> Content-Language: en-US From: Djalal Harouni In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hello Tejun, Alexei, On 3/28/24 22:01, Tejun Heo wrote: > Hello, > > On Thu, Mar 28, 2024 at 01:45:56PM -0700, Alexei Starovoitov wrote: >> On Thu, Mar 28, 2024 at 1:02 PM Tejun Heo wrote: >>> >>> There's also cgroup.kill which would be useful for similar use cases. We can >>> add interface for both but idk. Let's say we have something like the >>> following (pardon the bad naming): >>> Yes having the cgroup.kill from bpf would be useful! >>> bpf_cgroup_knob_write(struct cgroup *cgrp, char *filename, char *buf) >>> >>> Would that work? I'm not necessarily in love with the idea or against adding >>> separate helpers but the duplication still bothers me a bit. >> >> I liked it. >> So filename will be one of cgroup_base_files[].name ? >> We probably don't want psi or cgroup1_base_files in there. > > Would it matter? If the user has root perm, they can do whatever with the > files anyway, so I'm not sure why we'd restrict any specific knob. Maybe we > wanna make sure @filename doesn't include '/'? Or is it that you don't want > to go through the usual file name look up? 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. Thanks!