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 0FD4BC433EF for ; Wed, 6 Jul 2022 17:55:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8BDE46B0072; Wed, 6 Jul 2022 13:55:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 86D3A6B0073; Wed, 6 Jul 2022 13:55:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 75E4A6B0074; Wed, 6 Jul 2022 13:55:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 642D16B0072 for ; Wed, 6 Jul 2022 13:55:53 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 3489B343B3 for ; Wed, 6 Jul 2022 17:55:53 +0000 (UTC) X-FDA: 79657428186.07.7F7C779 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf23.hostedemail.com (Postfix) with ESMTP id C9F2714002A for ; Wed, 6 Jul 2022 17:55:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=pElM16asE/8kobagivFhEnyEoB+5zrvT4JPDEdv7s7k=; b=Ig2PKkFZYKESdYdGxhdJVLffQn JObi3ixHlQul2s2k6EwDWRSOSr08OhSgh1WLF2MtGB4SSRcefqWtnpbUIgBznyT8tWX9EGiPWfN1j Ny8EaWctSNYRJr33PDbUPblThM0BDHvECM2IRids8bSM31n2Csy7oU8z2qyDfw68gagq+WQaSGvk9 lYAjf6CvCt5FCDrzGCB40NgF+KGQhIgfoaRUDTVvDfQNGuVJT9rozPWa6tlFdjuGKfalj20Lq5/Ow zEMrj0yKvMP/i41iakboGt+cq/mX0N2JRyaSvbZRdJnTbVq0t/L5m2M8cytYJQ4zhrQftkArG7vVR j5COvtjw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1o99FQ-001qgB-ET; Wed, 06 Jul 2022 17:55:36 +0000 Date: Wed, 6 Jul 2022 18:55:36 +0100 From: Matthew Wilcox To: Alexei Starovoitov 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: References: <20220623003230.37497-1-alexei.starovoitov@gmail.com> <20220706175034.y4hw5gfbswxya36z@MacBook-Pro-3.local> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220706175034.y4hw5gfbswxya36z@MacBook-Pro-3.local> ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1657130152; a=rsa-sha256; cv=none; b=PmtEeZ7Ij3/7V67xZTv5QhW36GBlianv1FRMebq435YMh/f6LULiXjn6hejsIozAM7uo1F PkyiQ8pxohMLZznHO96e1aOf84u+90ecC9YyxCX3PEDAvesdW4Ly3BDXMeSOo1vNRkRXjx E6f0GgdFjC4gXbLnw2fernfkEUQT0B8= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=Ig2PKkFZ; dmarc=none; spf=none (imf23.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1657130152; 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=pElM16asE/8kobagivFhEnyEoB+5zrvT4JPDEdv7s7k=; b=J76tV5CDmR93IKpA4Th3KnNoE0GdfaTGDWgfnoHRu2CbiQZUv/TimRkQenXVWgnBb55vr/ aAQO6pfMixQcFR9bmiOZBnIqjXBSgyBGGvl06sW6JVXsg94Hh8wo4a41R1ZIbH/SArfgay 1MOWge4bP0Yr+a5xFH0263uUhWBue/E= X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: C9F2714002A X-Rspam-User: Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=Ig2PKkFZ; dmarc=none; spf=none (imf23.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-Stat-Signature: abm5jcmda7goog1g869n1tt1179suctu X-HE-Tag: 1657130151-315568 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 10:50:34AM -0700, Alexei Starovoitov wrote: > On Mon, Jul 04, 2022 at 09:34:23PM +0100, Matthew Wilcox wrote: > > On Mon, Jun 27, 2022 at 12:03:08AM -0700, Christoph Hellwig wrote: > > > I'd suggest you discuss you needs with the slab mainainers and the mm > > > community firs. > > > > > > On Wed, Jun 22, 2022 at 05:32:25PM -0700, Alexei Starovoitov wrote: > > > > From: Alexei Starovoitov > > > > > > > > Introduce any context BPF specific memory allocator. > > > > > > > > Tracing BPF programs can attach to kprobe and fentry. Hence they > > > > run in unknown context where calling plain kmalloc() might not be safe. > > > > Front-end kmalloc() with per-cpu per-bucket cache of free elements. > > > > Refill this cache asynchronously from irq_work. > > > > I can't tell from your description whether a bump allocator would work > > for you. That is, can you tell which allocations need to persist past > > program execution (and use kmalloc for them) and which can be freed as > > soon as the program has finished (and can use the bump allocator)? > > > > If so, we already have one for you, the page_frag allocator > > (Documentation/vm/page_frags.rst). It might need to be extended to meet > > your needs, but it's certainly faster than the kmalloc allocator. > > Already looked at it, and into mempool, and everything we could find. > All 'normal' allocators sooner or later synchornously call into page_alloc, Today it does, yes. But it might be adaptable to your needs if only I knew what those needs were. For example, I assume that a BPF program has a fairly tight limit on how much memory it can cause to be allocated. Right?