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 9EB8DC433EF for ; Wed, 6 Jul 2022 18:51:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 182A86B0073; Wed, 6 Jul 2022 14:51:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 10E2F8E0002; Wed, 6 Jul 2022 14:51:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EC8FC8E0001; Wed, 6 Jul 2022 14:51:08 -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 DB3316B0073 for ; Wed, 6 Jul 2022 14:51:08 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 9D67920617 for ; Wed, 6 Jul 2022 18:51:08 +0000 (UTC) X-FDA: 79657567416.12.2B1A3C9 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) by imf01.hostedemail.com (Postfix) with ESMTP id 387CF40015 for ; Wed, 6 Jul 2022 18:51:08 +0000 (UTC) Received: by mail-pl1-f172.google.com with SMTP id c13so10622942pla.6 for ; Wed, 06 Jul 2022 11:51:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=qOVYbAeMuUTqqBL9cN7VNIllKUdudIxLEASAJ8q4pSo=; b=kiYMusPRoyf2MXU7Z6Oz6kTe1rl1jQNhCf3sPKcG05Un85jHHFyqHXAI07NeI+Pbo9 Td3Kg5Aqf9GCry0uh4Ot6yFRZP6OzBCZ/UFtfc9oF/76q10jquN6ObefAsGn0qeoe+KT kbU50KqYB22AkAghu1TbGnCFVpJI/lZqVYKyoX6Vud0vogmfw9jrZ38u3D4yyJpgvDeH dzkikEE+QhkYSmCLb09G3xfpJ/qbQOOnNAGHso6Fh3a+f0PwuZ0AWwtVBdA3taqAsu/R DgzSP1lI69TSvEWjcaEMoPVpbcds3c2IcO2kA+OS1AXFC378Xjk5TqqM5ZbJvfxtg1ZL LeTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=qOVYbAeMuUTqqBL9cN7VNIllKUdudIxLEASAJ8q4pSo=; b=xv0kRixFJrDe9lKKay3jt1agMteQw0xIN2ughtWJBdOb90RMDhIrIAQ0bTYT8P7HZX 1GlWNSZs6YqXnJdHTrzWjM0JBtQtGwGKtdk1XYgBfUXLOr7EshyDuhzv+x/g2574Al4/ c08txLm7vKuU9QEo3qjsPINi+gxXyEFD46j13N2/cRVi5hOuuYBKE7JJJIAVYdvmvYDO Jq3UXuc7hMDgCwp0sDgVeF9geBijSuEdtgBbZK8DZfwKvQhO2YgpqiE2ONhF/EVZLBMl rsy29lr21Td3vlaj2DogsbBj2BE1POkjEb/LZgWccP3HZadZ3kC/JJoNfDru4sv7r136 HHGg== X-Gm-Message-State: AJIora+e2pbnaWsG3H33laiWssiQfMqkinQxDuVAl68LaWCiDybdzBV5 FtJrB0W04mLN+lp1V0VP4k8= X-Google-Smtp-Source: AGRyM1uFB0iL8cEYKSKELNOUTDYbEHc7nn7WNdRd8QL5L5frD1AGt8s2utJ8xxPHqgESUjcvOAfhng== X-Received: by 2002:a17:902:cccf:b0:168:e13c:5cd9 with SMTP id z15-20020a170902cccf00b00168e13c5cd9mr48567088ple.53.1657133467180; Wed, 06 Jul 2022 11:51:07 -0700 (PDT) Received: from MacBook-Pro-3.local ([2620:10d:c090:500::2:8597]) by smtp.gmail.com with ESMTPSA id ij7-20020a170902ab4700b0016bd8a76f67sm8603745plb.67.2022.07.06.11.51.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jul 2022 11:51:06 -0700 (PDT) Date: Wed, 6 Jul 2022 11:51:03 -0700 From: Alexei Starovoitov To: Matthew Wilcox Cc: Christoph Hellwig , davem@davemloft.net, daniel@iogearbox.net, andrii@kernel.org, tj@kernel.org, kafai@fb.com, bpf@vger.kernel.org, kernel-team@fb.com, linux-mm@kvack.org, Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Vlastimil Babka Subject: Re: [PATCH bpf-next 0/5] bpf: BPF specific memory allocator. Message-ID: <20220706185103.jdybh757u5esokt3@MacBook-Pro-3.local> References: <20220706175034.y4hw5gfbswxya36z@MacBook-Pro-3.local> <20220706180525.ozkxnbifgd4vzxym@MacBook-Pro-3.local.dhcp.thefacebook.com> <20220706182635.ccgt6zcr6bkd3rjc@MacBook-Pro-3.local> <20220706183619.3mmtsyi72c6ss5tu@MacBook-Pro-3.local> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1657133468; a=rsa-sha256; cv=none; b=6zjE+UqT/UPu9LfKGszPBUZDWwR5uj6wo5bFZQO2Djo0EUG9VaG5kD3Kn6nXsfVqqdLSx0 2lZH0/xDjNWHeMBjfrao8F2jMTlcNRgmI8UpVmx7FWs8cJUke5/BDCsOEwfnC7rjcudS9T M3wq7c/NQhGk/lpLWGWRUhtp9dNiHyI= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=kiYMusPR; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf01.hostedemail.com: domain of alexei.starovoitov@gmail.com designates 209.85.214.172 as permitted sender) smtp.mailfrom=alexei.starovoitov@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1657133468; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=qOVYbAeMuUTqqBL9cN7VNIllKUdudIxLEASAJ8q4pSo=; b=bqTiq5XGCkVhPZaUz7UGE9xfhUO7/7oP38co5bC1rD9DHA8WOFtT+HJftLeULcDPEu5gaY MPn6Fa8B0hoRfUPCzusO/2ILmsXGdUgQa3hoHjr1ZGhRszu1FeIxQw6xRYEqoh6hrWbtHZ RBRjRl0kaztAsVWxEAx0LbG2srn93zU= X-Stat-Signature: 79zi6ucpqknjbgqxeniw9b8uafma15i7 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 387CF40015 Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=kiYMusPR; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf01.hostedemail.com: domain of alexei.starovoitov@gmail.com designates 209.85.214.172 as permitted sender) smtp.mailfrom=alexei.starovoitov@gmail.com X-HE-Tag: 1657133468-519716 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: On Wed, Jul 06, 2022 at 07:40:44PM +0100, Matthew Wilcox wrote: > On Wed, Jul 06, 2022 at 11:36:19AM -0700, Alexei Starovoitov wrote: > > On Wed, Jul 06, 2022 at 07:31:34PM +0100, Matthew Wilcox wrote: > > > On Wed, Jul 06, 2022 at 11:26:35AM -0700, Alexei Starovoitov wrote: > > > > On Wed, Jul 06, 2022 at 07:21:29PM +0100, Matthew Wilcox wrote: > > > > > On Wed, Jul 06, 2022 at 11:05:25AM -0700, Alexei Starovoitov wrote: > > > > > > On Wed, Jul 06, 2022 at 06:55:36PM +0100, Matthew Wilcox wrote: > > > > > > > For example, I assume that a BPF program > > > > > > > has a fairly tight limit on how much memory it can cause to be allocated. > > > > > > > Right? > > > > > > > > > > > > No. It's constrained by memcg limits only. It can allocate gigabytes. > > > > > > > > > > I'm confused. A BPF program is limited to executing 4096 insns and > > > > > using a maximum of 512 bytes of stack space, but it can allocate an > > > > > unlimited amount of heap? That seems wrong. > > > > > > > > 4k insn limit was lifted years ago. > > > > > > You might want to update the documentation. > > > https://www.kernel.org/doc/html/latest/bpf/bpf_design_QA.html > > > still says 4096. > > > > No. Please read what you're quoting first. > > I did read it. It says > > : The only limit known to the user space is BPF_MAXINSNS (4096). It’s the > : maximum number of instructions that the unprivileged bpf program can have. > > It really seems pretty clear to me. You're saying my understanding > is wrong. So it must be badly written. Even now, I don't understand > how I've misunderstood it. huh? Still missing 'unprivileged' in the above ? and completely ignoring the rest of the paragraph in the link above? > > > > bpf progs are pretty close to be at parity with kernel modules. > > > > Except that they are safe, portable, and users have full visibility into them. > > > > It's not a blob of bytes unlike .ko. > > > > > > It doesn't seem unreasonable to expect them to behave like kernel > > > modules, then. If they want to allocate memory in NMI context, then > > > they should get to preallocate it before they go into NMI context. > > > > You're still missing 'any context' part from the previous email. > > Really, this is not a productive way to respond. I want to help > and you're just snarling at me. To help you need to understand what bpf is while you're failing to read the doc.