From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 68DA6CA1007 for ; Wed, 3 Sep 2025 00:29:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 834AF8E0003; Tue, 2 Sep 2025 20:29:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7E4E48E0001; Tue, 2 Sep 2025 20:29:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6FA8E8E0003; Tue, 2 Sep 2025 20:29:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 5CBCA8E0001 for ; Tue, 2 Sep 2025 20:29:05 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id E2FCB13AD28 for ; Wed, 3 Sep 2025 00:29:04 +0000 (UTC) X-FDA: 83846054208.03.0A34994 Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by imf07.hostedemail.com (Postfix) with ESMTP id 5659740002 for ; Wed, 3 Sep 2025 00:29:03 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=UHxl1z2M; spf=pass (imf07.hostedemail.com: domain of tj@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=tj@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1756859343; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=/ERR3eAUcklFTTBqjF7jv7I1yKckhOM4LnlQPamACus=; b=LeeJnrLwLnIPRXPRp3uPny3rRatxoqF/LEYrTTS6bVNRkG8M7jEjKXmfSftVbdr7Mz8GSE JroSMuHGSLDqW7uEJR4wESOVtbQFWTWdtge7D+0r3FiRie4i0/PsJjHI1UGIsvMnRRsUhu VGGn8xBcySUjXzdMvFSq0zDyG5XevwU= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=UHxl1z2M; spf=pass (imf07.hostedemail.com: domain of tj@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=tj@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1756859343; a=rsa-sha256; cv=none; b=Q9hrJT/BtWIprZq3yO+B0kkoM8+ZNnTWqZRAk6YWkqLruEJuoDaFRL4X3EMcYsCxrRRwJG giQvA7/pYtWZIdnaYGs/2I2/QlKRjTWW3ogqzdvlI1lFx6s3bYBCYJG6BWW7+9QIyj9lEB 3Lsjx2u0hPpZEv+4Z8ozltqiD8m7vAY= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id B24AA6022A; Wed, 3 Sep 2025 00:29:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3E84BC4CEED; Wed, 3 Sep 2025 00:29:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1756859342; bh=U6crchSx22A1Dkt0nN8K+hqbGunsTXrVtw8pYSSnspQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=UHxl1z2MauCod22FbWqCkY6B5xkLKi5v1sCfCih9PmgDeWl6ShYcQ4PqJQC2fCBDD ejCgibNuovMVGUJl/ISP88p2mUL1tipGRboeaDkwOSPjYKxdz+i9BLka2e5meyuAl/ iLaiOyimIXhQ7f29wZx7a8laO0//URfaUDDKqgjSF/wm+mmFDuyqD8TbWlmqO/3Tpu PGvi2PYP7h9YI6Vqlf64fLXbkhHKbL/HxBZk5aAmFE3BCpMZR7geaUzPGagj7gSUQT vAYVUEOO8JtZV4uLblMB3kmx6TDPHaYTR4hYT4Tq00dk1eVrdYNIU113DI9qGSfx8j yLyDyRnl1PwIw== Date: Tue, 2 Sep 2025 14:29:01 -1000 From: Tejun Heo To: Roman Gushchin Cc: Alexei Starovoitov , Martin KaFai Lau , Kumar Kartikeya Dwivedi , linux-mm , bpf , Suren Baghdasaryan , Johannes Weiner , Michal Hocko , David Rientjes , Matt Bobrowski , Song Liu , Alexei Starovoitov , Andrew Morton , LKML Subject: Re: [PATCH v1 01/14] mm: introduce bpf struct ops for OOM handling Message-ID: References: <20250818170136.209169-1-roman.gushchin@linux.dev> <20250818170136.209169-2-roman.gushchin@linux.dev> <87ms7tldwo.fsf@linux.dev> <1f2711b1-d809-4063-804b-7b2a3c8d933e@linux.dev> <87wm6rwd4d.fsf@linux.dev> <87iki0n4lm.fsf@linux.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87iki0n4lm.fsf@linux.dev> X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 5659740002 X-Stat-Signature: rtm5jex9kz16estih63suwtyyyr47bsg X-Rspam-User: X-HE-Tag: 1756859343-790322 X-HE-Meta: U2FsdGVkX1+DoOXnZxAaDC1AbFEu+AG8DgM6vcNDoZp7YHFJu4hwrcEMdePbAJipbQSiS5U3BL28mCnVFnbLtf6Sv7rpQIGoN0mHmiXgsAFOh9TT4aMOy82iIq/7MkUZWCbZ9lPFNHDTToKbBO5X5LZEkd0Rd+3xRZbpwQmFxWvLgooXsIfbuLLadyLPX5+MerNUcK2nYFs6+2i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f0BMpUWkNwKQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Hello, Roman. How are you? On Tue, Sep 02, 2025 at 10:31:33AM -0700, Roman Gushchin wrote: ... > Btw, what's the right way to attach struct ops to a cgroup, if there is > one? Add a cgroup_id field to the struct and use it in the .reg() > callback? Or there is something better? So, I'm trying to do something similar with sched_ext. Right now, I only have a very rough prototype (I can attach multiple schedulers with warnings and they even can schedule for several seconds before melting down). However, the basic pieces should may still be useful. The branch is: git://git.kernel.org/pub/scm/linux/kernel/git/tj/sched_ext.git scx-hier-prototype There are several pieces: - cgroup recently grew lifetime notifiers that you can hook in there to receive on/offline events. This is useful for initializing per-cgroup fields and cleaning up when cgroup dies: https://git.kernel.org/pub/scm/linux/kernel/git/tj/sched_ext.git/tree/kernel/sched/ext.c?h=scx-hier-prototype#n5469 - I'm passing in cgroup_id as an optional field in struct_ops and then in enable path, look up the matching cgroup, verify it can attach there and insert and update data structures accordingly: https://git.kernel.org/pub/scm/linux/kernel/git/tj/sched_ext.git/tree/kernel/sched/ext.c?h=scx-hier-prototype#n5280 - I wanted to be able to group BPF programs together so that the related BPF timers, tracing progs and so on can call sched_ext kfuncs to operate on the associated scheduler instance. This currently isn't possible, so I'm using a really silly hack. I'm hoping we'd be able to get something better in the future: https://git.kernel.org/pub/scm/linux/kernel/git/tj/sched_ext.git/commit/?h=scx-hier-prototype&id=b459b1f967fe1767783360761042cd36a1a5f2d6 Thanks. -- tejun