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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4A8FC001E0 for ; Thu, 27 Jul 2023 17:18:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232331AbjG0RRv (ORCPT ); Thu, 27 Jul 2023 13:17:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229541AbjG0RRs (ORCPT ); Thu, 27 Jul 2023 13:17:48 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38CE997; Thu, 27 Jul 2023 10:17:47 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id CCF5621A8F; Thu, 27 Jul 2023 17:17:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1690478265; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=niENjOE1icbcpi7kZRifQxcvaZR6brVmI8ZmmVizlZU=; b=QV4PKhlv07RzPWFz4H11F+xa1G/rYCNmHsZTYzVwzbPVhlPTIGea2Akt5jl/3I0+tMCvQU rwg6AFeUJWdFauIz4nAA/sY9Js5OsX/Ezb5NefJxxH2f3Nk7uT5RrV5/1+AeyHQn1BgILs D7C+SDb4nHyr9AAKr4bTFDPyxIKvRtg= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id A5B2F13902; Thu, 27 Jul 2023 17:17:45 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id nDPOJbmmwmS5YwAAMHmgww (envelope-from ); Thu, 27 Jul 2023 17:17:45 +0000 Date: Thu, 27 Jul 2023 19:17:44 +0200 From: Michal Hocko To: Alexei Starovoitov Cc: Alan Maguire , Chuyi Zhou , Johannes Weiner , Roman Gushchin , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , bpf , LKML , wuyun.abel@bytedance.com, robin.lu@bytedance.com Subject: Re: [RFC PATCH 0/5] mm: Select victim memcg using BPF_OOM_POLICY Message-ID: References: <20230727073632.44983-1-zhouchuyi@bytedance.com> <7dbaabf9-c7c6-478b-0d07-b4ce0d7c116c@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 27-07-23 08:57:03, Alexei Starovoitov wrote: > On Thu, Jul 27, 2023 at 4:45 AM Alan Maguire wrote: > > > > On 27/07/2023 08:36, Chuyi Zhou wrote: > > > This patchset tries to add a new bpf prog type and use it to select > > > a victim memcg when global OOM is invoked. The mainly motivation is > > > the need to customizable OOM victim selection functionality so that > > > we can protect more important app from OOM killer. > > > > > > > It's a nice use case, but at a high level, the approach pursued here > > is, as I understand it, discouraged for new BPF program development. > > Specifically, adding a new BPF program type with semantics like this > > is not preferred. Instead, can you look at using something like > > > > - using "fmod_ret" instead of a new program type > > - use BPF kfuncs instead of helpers. > > - add selftests in tools/testing/selftests/bpf not samples. > > +1 to what Alan said above and below. > > Also as Michal said there needs to be a design doc with pros and cons. > We see far too often that people attempt to use BPF in places where it > shouldn't be. > If programmability is not strictly necessary then BPF is not a good fit. To be completely honest I am not sure whether BPF is the right fit myself. It is definitely a path to be explored but maybe we will learn not the proper one in the end. The primary reason for considering it though is that there is endless (+1) different policies how to select a victim to kill on OOM. So having an interface to hook into and make that decision sounds very promissing. This might be something very static like EXPORT_SYMBOL that a kernel module can hook into or a more broader BPF callback that could be more generic and therefore allow for easier to define policy AFAIU. -- Michal Hocko SUSE Labs