Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp197599rwb; Thu, 27 Jul 2023 11:17:20 -0700 (PDT) X-Google-Smtp-Source: APBJJlEtqs+7W3OB4IcdM4w1KyKpoCia3aiVIm3USi6hU/PYD/7cvLrncKcX+LL/lNVSXraDhrag X-Received: by 2002:a05:6a20:96c2:b0:13b:cc09:a547 with SMTP id hq2-20020a056a2096c200b0013bcc09a547mr4908617pzc.36.1690481839671; Thu, 27 Jul 2023 11:17:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690481839; cv=none; d=google.com; s=arc-20160816; b=KQSPuGnKEvG7BDOdn4YjEi4cG2pKfdt+kXd7roJOGOm5FRnvcC58M9L4v5Zt+Bma92 517x7CzZce0E3AQw0JbZYke75OnIkKqspIdp5ZupEXTfgWtiSGXzCC894VOsCYoTmiZT Z51/p3H/hv3uvz1WIHC7feeM3rD+vbZFbWDtQ5fM9GGdcBh/hcLYHH7w4FtR9TgI3Nd1 eMSyA9LjWqbGDUG2DQ1xjdW9pL+tPGIDvZAbxxfjIPrAvvRA4iih3putYGmF/soup5fM bBahKJzX70AmA247MXEtJtIczcZ7pzcPNB9LAOdUv/NPzSm+AZzMO/dm1RtfaKd69/3X Frkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=niENjOE1icbcpi7kZRifQxcvaZR6brVmI8ZmmVizlZU=; fh=DzfAQmaQtpfYN4rLxEqAWsPNGV4ySy2VjBBGlDHD2L4=; b=GoQXrIzi0txTtOyrR8CRfWQDnH8HxAn+rU7KXFq4Hr433ZL7+nlpGH448/O+cX31R6 oTcOz2y90hwaI/IyX55gYOrOGV9fv8snJpqIGlInCcxG6FYtbm7oGuGtx0Mn/XzTbAZc jZRMOdoEBgZ6HaEyYEFXJK8GEGe7pd5vwRxO1RFtPVAPnHSoU6BDeM0FE7gQtHYllOgQ aoMcDwSwZF6PTvAyrItJ69+X35u+2IQCpQ3qhu681ufCWvzilDiDeuoB9qMIZK5SPQeu B/S+V49gr+3pP6NZsJeO8GRFQAe2BE/owsHaB9sPQNIPeJdfLzPtaFRpYQJXEUuktkGF o8yA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=QV4PKhlv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id be3-20020a656e43000000b00563fbbe378asi1627900pgb.59.2023.07.27.11.17.07; Thu, 27 Jul 2023 11:17:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=QV4PKhlv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231938AbjG0RRu (ORCPT + 99 others); Thu, 27 Jul 2023 13:17:50 -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: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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