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 8E903C7EE23 for ; Thu, 18 May 2023 19:02:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0B743900004; Thu, 18 May 2023 15:02:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 067E8900003; Thu, 18 May 2023 15:02:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E7232900004; Thu, 18 May 2023 15:02:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id D5563900003 for ; Thu, 18 May 2023 15:02:05 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id AC25E120980 for ; Thu, 18 May 2023 19:02:05 +0000 (UTC) X-FDA: 80804295810.26.6C79928 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf23.hostedemail.com (Postfix) with ESMTP id 867AC140018 for ; Thu, 18 May 2023 19:01:42 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=WHGVaGT8; spf=pass (imf23.hostedemail.com: domain of song@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=song@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684436502; a=rsa-sha256; cv=none; b=DrVJEcASBpGxzRCs36DGPY106eJ7uYTEZhKnM21TQnMJ4bmyhbRU6qDZT68MUN+O4xeSjF QBFrr6X2TFi45xoZXaYsvYjLUpPBcRBFPzybiuu9UpUjzIOpmkwf9wAWZ6Rpko6GGEfkLr cGRL5Ffcc68FIXro18gMAWR0yr1cmqA= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=WHGVaGT8; spf=pass (imf23.hostedemail.com: domain of song@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=song@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684436502; 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=o3yvPkE5yjhBzx5bhnFwj3XxVjNNT1oZLcD6MttWUWE=; b=vlCm9/IUfYpHuFka6os+igtdUexA0O3HAJolPjOKoWTmv4NiBvf/A5Tr1jxRfbh+NE47vA WsZe/7sp/Kg378aLRvn7LVp3P/y6YOb+O+/qkf3pOYTSrHfUTJq/3MfTuULbBsRXdGkl+l DX1tIZnF/Tecs84KtLQX0F5LWOyTvrQ= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 33BF4651C7 for ; Thu, 18 May 2023 19:01:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 16421C433A1 for ; Thu, 18 May 2023 19:01:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684436500; bh=3L8pliCTcYUFN6WVwRXOTT1aMopsshjE7du+I5x8OKw=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=WHGVaGT8oxG3wdGdjq3yn6h/fsfp7MDD9K73/F0qNr9Mq+dI33dNnQkopLjyRY2Mz SPocIESAQofhxJRhJt3Cw9WIRZM6i+r1Qt2cgMM0h49RIpW3n1G2on4A72DQEY9qa/ /pJsEkH5HaIPTQf5sU2y7JofD7s7K6ApwWyGxXehLq76i23OgJWBtqx/o0VYHhw3Hy MNEfwtKR827qCIlE2WhLodkk2XgzZhQsySquNW5SVf8PnnBdMPFpyw6JGmgAiew6LW 3gkNDrrz8civpViRf++fnK5JCpy9M9bb9n3qvM1DuSxW7dfuLHDgRZyozoPdb31o01 N2FQyOgj3BYwA== Received: by mail-lf1-f53.google.com with SMTP id 2adb3069b0e04-4f1411e8111so2730247e87.1 for ; Thu, 18 May 2023 12:01:39 -0700 (PDT) X-Gm-Message-State: AC+VfDzDaCY2pDr7TgArjyQycGA5PXmzrmRVWn0E2iohZ26jxQE5yYYt Q5sp7mCK/G3yDjXOL/aKa11La4x3/Vx69+Dh8O4= X-Google-Smtp-Source: ACHHUZ5UXg1eeNGVLZjwNMxRFsYhtB74PojLRAdmrB5ozRnZzqbdO3B1Ji+4jthPGpZmNv80z+cnzCKVNY6FTQuBjDQ= X-Received: by 2002:ac2:4198:0:b0:4ec:8245:3986 with SMTP id z24-20020ac24198000000b004ec82453986mr68503lfh.14.1684436498062; Thu, 18 May 2023 12:01:38 -0700 (PDT) MIME-Version: 1.0 References: <20230308094106.227365-1-rppt@kernel.org> <20230308094106.227365-2-rppt@kernel.org> <20230518152354.GD4967@kernel.org> In-Reply-To: From: Song Liu Date: Thu, 18 May 2023 12:01:26 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH 1/5] mm: intorduce __GFP_UNMAPPED and unmapped_alloc() To: Kent Overstreet Cc: Mike Rapoport , linux-mm@kvack.org, Andrew Morton , Dave Hansen , Peter Zijlstra , Rick Edgecombe , Thomas Gleixner , Vlastimil Babka , linux-kernel@vger.kernel.org, x86@kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 867AC140018 X-Stat-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j+J/4nAXqHiydm6N+1uJJVrKZaTMbexjUMuLscSlSSP+/ER7X1gZvbkbZH/O7uy9RnLHDevFv/WXvwK7CeEAUFE6xas8A3Ym8sHqMWQ7KK85ItZiCS6gzX93MT1+MeCYc+weqf/nx08w1Y4Ehc5dfJbQM4dv6WG0aNV1HQaMMBQ61+I/uSczymliA1Of0XqRM3YD+koTqP78pHlLCSMpO/sElj2fW13R3UzbJ7I/cchhJg3yR7R1fSKB54QQECGEupT95Rsb5JvFl4qpwQh3r+6rgAYb5MB3+AmZF6hGOT73RX1ZTWuFrrCUxbt6bRloTySOKua0Npg0ZbErI90= 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 Thu, May 18, 2023 at 9:58=E2=80=AFAM Kent Overstreet wrote: > > On Thu, May 18, 2023 at 09:33:20AM -0700, Song Liu wrote: > > I am working on patches based on the discussion in [1]. I am planning t= o > > send v1 for review in a week or so. > > For reference, here's my own (early, but functioning :) slab allocator: > > Look forward to comparing! > -->-- > From 6eeb6b8ef4271ea1a8d9cac7fbaeeb7704951976 Mon Sep 17 00:00:00 2001 > From: Kent Overstreet > Date: Wed, 17 May 2023 01:22:06 -0400 > Subject: [PATCH] mm: jit/text allocator > > This provides a new, very simple slab allocator for jit/text, i.e. bpf, > ftrace trampolines, or bcachefs unpack functions. > > With this API we can avoid ever mapping pages both writeable and > executable (not implemented in this patch: need to tweak > module_alloc()), and it also supports sub-page sized allocations. > > Signed-off-by: Kent Overstreet [...] > +static void *jit_cache_alloc(void *buf, size_t len, struct jit_cache *ca= che) > +{ > + struct jit_slab *s =3D > + list_first_entry_or_null(&cache->partial, struct jit_slab= , list) ?: > + jit_slab_alloc(cache); > + unsigned obj_idx, nr_allocated; > + > + if (!s) > + return NULL; > + > + obj_idx =3D find_first_zero_bit(s->objs_allocated, cache->objs_pe= r_slab); > + > + BUG_ON(obj_idx >=3D cache->objs_per_slab); > + __set_bit(obj_idx, s->objs_allocated); > + > + nr_allocated =3D bitmap_weight(s->objs_allocated, s->cache->objs_= per_slab); > + > + if (nr_allocated =3D=3D s->cache->objs_per_slab) { > + list_del_init(&s->list); > + } else if (nr_allocated =3D=3D 1) { > + list_del(&s->list); > + list_add(&s->list, &s->cache->partial); > + } > + > + return s->executably_mapped + (obj_idx << cache->obj_size_bits); > +} IIUC, "len" is ignored in jit_cache_alloc(), so it can only handle <=3D16 byte allocations? Thanks, Song