Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp613636rdg; Thu, 10 Aug 2023 13:27:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGyW/ea6dUlpO2TlXRjB/qaLXmi7JbLXRJDCFcN8V194TzbVyYBKSX7Y/wW+JJoLbvaLClS X-Received: by 2002:a17:906:53c8:b0:99c:bcbe:c9e4 with SMTP id p8-20020a17090653c800b0099cbcbec9e4mr2989324ejo.32.1691699273529; Thu, 10 Aug 2023 13:27:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691699273; cv=none; d=google.com; s=arc-20160816; b=rN13NH5eb3nkmpwy9xUt0cPzRSC1N22E9eh0WvyMWYSGFnKzQabg+E2npHUkq3cMOs giINUG5Uy0z57iS78pLS0IcZ/LL5bCwuZzQ+o80HWY4gbhPr0BnFMQiQ43d5ifMyt+ZU yx7YRW9elIuu1YQcqzhbRm4AAZzJlxB7Ag1WO+7sBjny2AfgoeegDM+gx30kqnBnWjjS rZSV501pwByvhHo0aQZQKT0eQokLGdbvU4dZ8jIxS9fepC1FlbBad8zzeemufvqyAUKH lsC465S4Ih5Xjl99/DxnxW+/2kK0+Vua42xMvNrNDy83C4EdCjxYbnJl7kIhbHLVkr2p yz+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:mime-version:date :dkim-signature:message-id; bh=OuDx6q87jGoCwsecy09MqUn126nk87pBh26c1SpaUZI=; fh=wB4QP6IzmgoGNYLxJk4J9gUWUWC8dalb472N3+BotfA=; b=TxdO546DtSVx6Wr9h7jwxil7szQV/SpEp1IZHvNQzcQzxF1a9lybrtB+AAJuAw4glc aTW4+GCgm4xjVyGeGCzuWhl1H0eJGBMWgVk92ADBJIIlxmn6E4X7GrV/R0fITm0OFMVA T/aUu+oEAHLcgwvCMk87i/h86Cg8z9C53S3l/6ScElRDDtR/CmGJMmhKp+ENeH3OKBnF KH3Faw0h3wpYqnXyyyHhD1QPy8t+wqgmgQhP837/2k1DXR2FB+abw/FUyykQVSCARr5y ruvOu5efR1/sf2yHHn20BS7BZ1o7+pRRJa1yvneQHcrQxSsTkRQNSvaEchxqr84hnomC QIvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=EyIqYMe+; 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=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lu21-20020a170906fad500b0099bd622e4bbsi2086872ejb.861.2023.08.10.13.27.27; Thu, 10 Aug 2023 13:27:53 -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=@linux.dev header.s=key1 header.b=EyIqYMe+; 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=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235064AbjHJTlN (ORCPT + 99 others); Thu, 10 Aug 2023 15:41:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233486AbjHJTlM (ORCPT ); Thu, 10 Aug 2023 15:41:12 -0400 Received: from out-110.mta1.migadu.com (out-110.mta1.migadu.com [95.215.58.110]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5C4D26B5 for ; Thu, 10 Aug 2023 12:41:10 -0700 (PDT) Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1691696468; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OuDx6q87jGoCwsecy09MqUn126nk87pBh26c1SpaUZI=; b=EyIqYMe+6RnnpEVKI1DDmD/DL9g9mqschLBHCfLPeH6sJI8V8oI6p18NmddlVUh3zGrgdw poEHB80/OafLc+5Z6Lp9U0lr8Q2o7wCEKcA1LyrzheoJx3KQJ3/Sg87iEIFDJiR0dvde6F Iq5XbQuMFFQkt0xZcte/W+q0kmgGJSs= Date: Thu, 10 Aug 2023 12:41:01 -0700 MIME-Version: 1.0 Subject: Re: [RFC PATCH 1/2] mm, oom: Introduce bpf_select_task Content-Language: en-US To: Michal Hocko , Roman Gushchin Cc: Chuyi Zhou , hannes@cmpxchg.org, ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, muchun.song@linux.dev, bpf@vger.kernel.org, linux-kernel@vger.kernel.org, wuyun.abel@bytedance.com, robin.lu@bytedance.com References: <20230804093804.47039-1-zhouchuyi@bytedance.com> <20230804093804.47039-2-zhouchuyi@bytedance.com> <866462cf-6045-6239-6e27-45a733aa7daa@bytedance.com> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Martin KaFai Lau In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS 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 >>>> First, I'm a bit concerned about implicit restrictions we apply to bpf programs >>>> which will be executed potentially thousands times under a very heavy memory >>>> pressure. We will need to make sure that they don't allocate (much) memory, don't >>>> take any locks which might deadlock with other memory allocations etc. >>>> It will potentially require hard restrictions on what these programs can and can't >>>> do and this is something that the bpf community will have to maintain long-term. >>> >>> Right, BPF callbacks operating under OOM situations will be really >>> constrained but this is more or less by definition. Isn't it? >> >> What do you mean? > > Callbacks cannot depend on any direct or indirect memory allocations. > Dependencies on any sleeping locks (again directly or indirectly) is not > allowed just to name the most important ones. > >> In general, the bpf community is trying to make it as generic as possible and >> adding new and new features. Bpf programs are not as constrained as they were >> when it's all started. bpf supports different running context. For example, only non-sleepable bpf prog is allowed to run at the NIC driver. A sleepable bpf prog is only allowed to run at some bpf_lsm hooks that is known to be safe to call blocking bpf-helper/kfunc. From the bpf side, it ensures a non-sleepable bpf prog cannot do things that may block. fwiw, Dave has recently proposed something for iterating the task vma (https://lore.kernel.org/bpf/20230810183513.684836-4-davemarchevsky@fb.com/). Potentially, a similar iterator can be created for a bpf program to iterate cgroups and tasks.