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]) by smtp.lore.kernel.org (Postfix) with ESMTP id AAEA6C369DC for ; Tue, 29 Apr 2025 21:31:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 95FCC6B0082; Tue, 29 Apr 2025 17:31:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 90E5B6B0083; Tue, 29 Apr 2025 17:31:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7D8726B0085; Tue, 29 Apr 2025 17:31:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 46A566B0082 for ; Tue, 29 Apr 2025 17:31:44 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 3FC2EC860B for ; Tue, 29 Apr 2025 21:31:45 +0000 (UTC) X-FDA: 83388378570.07.7B8CE62 Received: from out-178.mta0.migadu.com (out-178.mta0.migadu.com [91.218.175.178]) by imf22.hostedemail.com (Postfix) with ESMTP id 5C83DC0009 for ; Tue, 29 Apr 2025 21:31:43 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=RpoLWHj9; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf22.hostedemail.com: domain of roman.gushchin@linux.dev designates 91.218.175.178 as permitted sender) smtp.mailfrom=roman.gushchin@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1745962303; a=rsa-sha256; cv=none; b=M1LLEigLAAiW3XeV6DkPO2CsFF47pT7oNmc8mj6ChpaZVkidNyTIK1MS6d7fndnuK53d47 DzOSKUyR3/funvsZYo79ed/6o5gaBm8BxRh0T8eeotP2niFioU/aaOZBnj3DEsHwiGQQtV aZuHUo+kWnToJZz3EANcdAmx2+vPN50= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=RpoLWHj9; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf22.hostedemail.com: domain of roman.gushchin@linux.dev designates 91.218.175.178 as permitted sender) smtp.mailfrom=roman.gushchin@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1745962303; 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=EhK44/8Ys5iZS1I95Gpf9TqiXTQ03StabhU2aIbnGz0=; b=OE2DvIGsWjSveMnrkbRcX+61V1qhwplnRMD274Ayauh2yhQOiukGr4WvmAqhiY4SNv+uGJ pFx/dhOZihRNhaBMOY/mGqfXF2fQNX9LAa+Jq0P6BtVcgRzAlws6+HgPvUNFIayuEBtT6W 2iOwxloF0ba5fZK0cCYRIcUkq1Iuxi0= Date: Tue, 29 Apr 2025 21:31:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1745962301; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=EhK44/8Ys5iZS1I95Gpf9TqiXTQ03StabhU2aIbnGz0=; b=RpoLWHj9v72jkc+SsJKuznsirnepqqaYc4rnWbmg6qDrd5FNw/0Sv63lIssnA/dSZrIuF6 4Vh2ibWZ0VBPVCkglXEto1ilSA2wLvA1cTnU1hVqEeOJ3kuCmRavlPYIqyFm5wN4ZMURRr nRjYlZqWCQ2NLIySrECZzILAU3jkntI= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Roman Gushchin To: Michal Hocko Cc: linux-kernel@vger.kernel.org, Andrew Morton , Alexei Starovoitov , Johannes Weiner , Shakeel Butt , Suren Baghdasaryan , David Rientjes , Josh Don , Chuyi Zhou , cgroups@vger.kernel.org, linux-mm@kvack.org, bpf@vger.kernel.org Subject: Re: [PATCH rfc 10/12] mm: introduce bpf_out_of_memory() bpf kfunc Message-ID: References: <20250428033617.3797686-1-roman.gushchin@linux.dev> <20250428033617.3797686-11-roman.gushchin@linux.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 5C83DC0009 X-Stat-Signature: n35xm7bz1m5z8zsn4aptyb43rufiz8pe X-Rspam-User: X-HE-Tag: 1745962303-880162 X-HE-Meta: U2FsdGVkX1+usKzOI9Uqb3qRNbxMx0f1xjee/N69Cm3hfIh5Mj/fcwEA5dPiQK7tb4Xb97E1edeB5GL7DrAxrVLpftdAty7NFxa72W3uy02/apC4CHHV1bbp8sOl7xvIbOA9fyGinzCl+pT7Fyt/2DEOGRKgefMfudZLe+wsUxV6KDVohINnIhsIfRixubrjH4i3Qi6ZyQrJ7SG562jP1Y/rQWhljh/joiMWONn0VybEKD5QgakKG4upeJ3aZo8cXpMAL01UTvwoQ3wzV+MEfe1Si3irw2PwIWBdAucEnTxbfo1JlWnuUCoZ8DNXeZB/Gc7jBnVhbXRwZhQZVVEbhXOnKwr0W7qPwcSY+HQXgnv+ByJU5QPON7LlCKo/9O+T+nvUfMsbgzjehI4ZPexHQBOothEIp/Nncz9RChU5vVQ5GedZ5LGEs4knvQk2T7Piut2IDWZKrhbtMyx4alYJz9TmHZ3L9yU0wgqFZiLK+E+7ENIsNG/FZA5IY8vgXNk3veUBB4vjLslF06rS/BZlZLq1mf+6zNC/nOYNtcLTv3HvqvKPHlqyLU9Ung3/ehjJ6eTKNAf0eJCGNq60BwGlxYYoFlHWAmZu8E6YeY2XWGyWEKVrTSJ+PhA2HN4B2zP6oRIxzgU+f8K5EGMr0BUhwc9KvGpVOP7aK9+jpeP7APd80zEQ5d2xiIGMSdPk4khlDTEUTxmLEgKnn4grYq8+O26IfIeKbwLh07kjhq3rQr9qwiiM86yMBbwCCHCe05jAI7NedMPYEhxHal6yk8yEh5BPBWQk3D6UdDCogyYimHDZF7HHWP9gtjXaMN8rp07ZYE75CBmY3OjYhxqz1cwZUk47da2rwdQq8ncwGjiR1llnKB215fZpHsh4LBazJjntO4dPFA9hOzK7kLPDRC8ddV5Iz0MwLMWX6ZP9bpJ+azINXTbP6pCNwdMf1vDZEmje7yLSuUERpmU++OgN/EX P2hdKzMl lm7rhERrzZOTN2v7Xd01u2UC6c1hLU5am1YVGzejLREcq/fi2CMLfBGKTr1nyqOcsuyEOU8xPVLTv0x79tZI/H8JO7Tdr40O0Cb3wBbvg1UT+XoajmXicSfiaNwEQEn9yOJjfq4xLywxk9lHoleXz0YpGPKi9Hh3qZKPp1BG/blZTPRIC3CELaFN/BPJCBRsKnDg53m5MApOhGzbfHdKGpcPquHzMnDCILROSHxgzGv+QjRr00qUl9UYJrvWx7ZhqJzw16SP7TD6mM0w= 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: On Tue, Apr 29, 2025 at 01:46:07PM +0200, Michal Hocko wrote: > On Mon 28-04-25 03:36:15, Roman Gushchin wrote: > > Introduce bpf_out_of_memory() bpf kfunc, which allows to declare > > an out of memory events and trigger the corresponding kernel OOM > > handling mechanism. > > > > It takes a trusted memcg pointer (or NULL for system-wide OOMs) > > as an argument, as well as the page order. > > > > Only one OOM can be declared and handled in the system at once, > > so if the function is called in parallel to another OOM handling, > > it bails out with -EBUSY. > > This makes sense for the global OOM handler because concurrent handlers > are cooperative. But is this really correct for memcg ooms which could > happen for different hierarchies? Currently we do block on oom_lock in > that case to make sure one oom doesn't starve others. Do we want the > same behavior for custom OOM handlers? It's a good point and I had similar thoughts when I was working on it. But I think it's orthogonal to the customization of the oom handling. Even for the existing oom killer it makes no sense to serialize memcg ooms in independent memcg subtrees. But I'm worried about the dmesg reporting, it can become really messy for 2+ concurrent OOMs. Also, some memory can be shared, so one OOM can eliminate a need for another OOM, even if they look independent. So my conclusion here is to leave things as they are until we'll get signs of real world problems with the (lack of) concurrency between ooms. Thanks