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 309C3EB64DB for ; Fri, 16 Jun 2023 16:48:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 559706B0074; Fri, 16 Jun 2023 12:48:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4E2786B0075; Fri, 16 Jun 2023 12:48:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 383388E0001; Fri, 16 Jun 2023 12:48:13 -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 2505D6B0074 for ; Fri, 16 Jun 2023 12:48:13 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id D9EC140C73 for ; Fri, 16 Jun 2023 16:48:12 +0000 (UTC) X-FDA: 80909193624.10.3F7D0EC Received: from out-35.mta0.migadu.com (out-35.mta0.migadu.com [91.218.175.35]) by imf29.hostedemail.com (Postfix) with ESMTP id 02F64120014 for ; Fri, 16 Jun 2023 16:48:10 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=f7uDVOP+; spf=pass (imf29.hostedemail.com: domain of kent.overstreet@linux.dev designates 91.218.175.35 as permitted sender) smtp.mailfrom=kent.overstreet@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686934091; 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=IfKIglpY59qnffneasZzBrgWBI/BVVKcO3nvK+88q6Q=; b=t3DRZUFf3VWdCdAn5d8b3R3v7NHiSggBgTG7FjdETU5e61ow/q7rRGZsXkG1zYUnoJ7Xtx NE39RcM00rq4tsdNrs5s3uvk9RzXNdyNohFiNCP8R0CjByGDD41xYJw7EyuIXpPoOtJUer Xb4lHLSypmPG/pPlny3XR4Po4/R+jWQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686934091; a=rsa-sha256; cv=none; b=2Aa4+pYFmbBiQ3CgW3cH0JcmN1TKBz6Ue0gMBF8Q50gPJ10btB0zjrWiQPZoUoRmj96FbU fkNmjkzLpSf98UBNt5NUaE3rRD8Fy2gQSDsKtNm1qYahjj9yCaQjRYFsGTKPlW6UeWOh4P Jczfj9azi170lqwia8SJV6vVsSweXXM= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=f7uDVOP+; spf=pass (imf29.hostedemail.com: domain of kent.overstreet@linux.dev designates 91.218.175.35 as permitted sender) smtp.mailfrom=kent.overstreet@linux.dev; dmarc=pass (policy=none) header.from=linux.dev Date: Fri, 16 Jun 2023 12:48:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1686934088; 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: in-reply-to:in-reply-to:references:references; bh=IfKIglpY59qnffneasZzBrgWBI/BVVKcO3nvK+88q6Q=; b=f7uDVOP+LriTx1GPKpO/iGQAeI7fAgmRpvVnoi5jo3ti6yVsQ9wInwSxipV6MgfOy574mI FDCFPj1N9Nd5bgTFZS6HIo1mpnuNsg8Mx89vQT9KdcpGA0IcSmQVrnh8mL+CQCqd9x3abe jZmmh6fZtZim0+prcqCTRKU0uIKCYhg= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Kent Overstreet To: Mike Rapoport Cc: linux-kernel@vger.kernel.org, Andrew Morton , Catalin Marinas , Christophe Leroy , "David S. Miller" , Dinh Nguyen , Heiko Carstens , Helge Deller , Huacai Chen , Luis Chamberlain , Mark Rutland , Michael Ellerman , Nadav Amit , "Naveen N. Rao" , Palmer Dabbelt , Puranjay Mohan , Rick Edgecombe , Russell King , Song Liu , Steven Rostedt , Thomas Bogendoerfer , Thomas Gleixner , Will Deacon , bpf@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, linux-modules@vger.kernel.org, linux-parisc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, loongarch@lists.linux.dev, netdev@vger.kernel.org, sparclinux@vger.kernel.org, x86@kernel.org Subject: Re: [PATCH v2 02/12] mm: introduce execmem_text_alloc() and jit_text_alloc() Message-ID: References: <20230616085038.4121892-1-rppt@kernel.org> <20230616085038.4121892-3-rppt@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230616085038.4121892-3-rppt@kernel.org> X-Migadu-Flow: FLOW_OUT X-Stat-Signature: 8ry7n1syyut6ktn36wfhf4s93rprsctp X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 02F64120014 X-Rspam-User: X-HE-Tag: 1686934090-620527 X-HE-Meta: U2FsdGVkX1/lLfG2pd+yeXrS8fhfscY8t/UWUnuhUbr/HZ8EJujflRD3ApeK652KaWalQdu4RNwmq17WSQie4+TrGAcHWto9Gormh01+0uAHDyFzjnw7IDyn9PNAIcoPTbbyO15rRG+wDHmiJgUTWCI6pUlM5PsD1EfbnXJGel/COPOxpOnbqDR7HrN8F+SAIiaCEJ3da1ksOgXpuwbG05xvFIIRG+K6C+qkK6TjZTL2WJQGAqFa9gQKwp8/KpBrN3GV6z05mqHXEOGCQnRifRV7dZ3SQlTN7xSFToGUIXYC0CNZir7qxthxpIyOUSa8/ObHCZwZQME1SUUEV2tFe/VDg2cXVobURE1y6WWiJdj4YqnoxpjlT/p9fodbHDDOwb97qfwXlN1D5kSt/mURv9CmKfns03tzPtRjWIZHZcidsEPhcFd8RLF76Sv8est9PG7TpCh/YWVDYRwK3jbZ8+uHYIDR/y4uTS9xpw/66A6+k+tDtoNB6RMK08b3sglbqstzDb6IyyJMmxjcTP8jFDQnYm9qcjqME48NvH40kZyQ6fXKx+xQXoCi9RmqVqRHm7ePwR7XIWTy6Uhe7yjEO1kgGUBArl+8Tyl5nowzDW92sAYOUROX2IVDu3HoyXpCm3W8gYFi7pfTaFrtqKtedIil0SBriasn28yqh+FajA+E8tgELfFu6ZpBmoZGd41QFyS7JXTmpqetq9k/AIbAsqWm4b2+MIWpqEGFpmD3HN6wmhuKfJwuHEBHf59wDPhZq1pNM/wDeGAnXK9cn7Y/kPZzVquz0OM+trhYcIlXlhUiHkCawZJYjmedpLy8duFSZX+OnUM2orU1Ev4IznuO1j4OftuDjVw++wh8su8z7QCR5gqx2O0eGNhBpB3ou+3NumE+odDVIAMGVkbwiBGK9tUMB0kBLvmxgnm70aJ3rqIn07f7urgpQt4+m5RNYonbGahF0WM7e+PBDT6t68M fd4V/gP8 Xgb5J/8S6zvINHlxQpUhhPUhoTyJPr7j5YbWyCg3dfQ0Pk+OxtH1jM19rgQRa4cPLDDbRw3SPnlHPmqa8OhElwJlygop93G0+yjjonDAzCACbF3aRcEr4GRIEMgbmymGq/mgO4Ga4+7TiH4ALMQzzqpcbQ9fWPYRqAVscXNXHnXvMJZvm9C1c1LbzMsBZj5NhBaZ8UfK7+h3cl29aAlXqrdaubfDLFFn37R6h 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 Fri, Jun 16, 2023 at 11:50:28AM +0300, Mike Rapoport wrote: > From: "Mike Rapoport (IBM)" > > module_alloc() is used everywhere as a mean to allocate memory for code. > > Beside being semantically wrong, this unnecessarily ties all subsystems > that need to allocate code, such as ftrace, kprobes and BPF to modules > and puts the burden of code allocation to the modules code. > > Several architectures override module_alloc() because of various > constraints where the executable memory can be located and this causes > additional obstacles for improvements of code allocation. > > Start splitting code allocation from modules by introducing > execmem_text_alloc(), execmem_free(), jit_text_alloc(), jit_free() APIs. > > Initially, execmem_text_alloc() and jit_text_alloc() are wrappers for > module_alloc() and execmem_free() and jit_free() are replacements of > module_memfree() to allow updating all call sites to use the new APIs. > > The intention semantics for new allocation APIs: > > * execmem_text_alloc() should be used to allocate memory that must reside > close to the kernel image, like loadable kernel modules and generated > code that is restricted by relative addressing. > > * jit_text_alloc() should be used to allocate memory for generated code > when there are no restrictions for the code placement. For > architectures that require that any code is within certain distance > from the kernel image, jit_text_alloc() will be essentially aliased to > execmem_text_alloc(). > > The names execmem_text_alloc() and jit_text_alloc() emphasize that the > allocated memory is for executable code, the allocations of the > associated data, like data sections of a module will use > execmem_data_alloc() interface that will be added later. I like the API split - at the risk of further bikeshedding, perhaps near_text_alloc() and far_text_alloc()? Would be more explicit. Reviewed-by: Kent Overstreet