Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp4897118rwd; Sun, 18 Jun 2023 01:09:28 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ78D3d2clR9hi6hcoNluR18JQNq5dwRshP8Ks+i0zjz+gYBuo9UIk/W8Z5trFwMQJN92uc1 X-Received: by 2002:a05:6a00:1886:b0:64d:f5a:3fd2 with SMTP id x6-20020a056a00188600b0064d0f5a3fd2mr10102678pfh.28.1687075768092; Sun, 18 Jun 2023 01:09:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687075768; cv=none; d=google.com; s=arc-20160816; b=SA4RY6pJdrFmdWaQvOXNgB+HVA1ue0RC0xjNaPh1aDGpTlViM+kubozsg34qs7KuUt M8QLyrZWxmSA00gnGGozZzlVpsJ4IkCkrI8aOh0c942P8VOES9z6cSBu/vtrEYQ08e5t DRdSTpNpMww2tRFxAh3NwT/aQmcHa6E99yx+ka2WYEom8Jij9p9T5bCU/pc+v8isL0H0 C8m1v902l1jaM20d5NgtVTIiY0IrGEFV8j2lnDe9/cALyiun1iWidNiQ4dKVrQ3xp8ee tSoNJOkEWqK/p7REW3RYK4JczwBs+wTxgKwQWmHJoWanw9qDs0D2mjdc4xokgWc9aiTH 8RDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=KVnHRZvbtYsZRHFOmwAX/PwESPT50BQhipa0iGaLtWg=; b=LFeVFZMNLxdS061bN+K0FjDchFFo3c+nuf7tCImUk2CO/minhzXa1xPjn+ZgOoH1NR t1avoQapSa75BoVpYGlCanVl91o0lkzdJThQaQNiDkmwyQq5CufB7/jtLnr5aqkt0VZ/ ni9WTLyMI8bFtfCH3SFX/cCEXM1DGa8E6+PXPoj+6uSQ8X5aEprJDc+yehuU7pha5xlZ u5V4Ee7QnSqGWSwqfARE2fSWy+AO7CvYVNlDBPaGB79qhAGY+J23REF8bNF/ztzk+OPt I6MlLOxo+hVXyBhdMAk7P8zdvHgDtx2e3ZPqlCTBG4lWMkFYRz5XWfZ3U6c8FfhloZPF WIiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sRSVsUz+; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k28-20020aa79d1c000000b00625c6092a12si3707664pfp.215.2023.06.18.01.09.16; Sun, 18 Jun 2023 01:09:28 -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=@kernel.org header.s=k20201202 header.b=sRSVsUz+; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229562AbjFRIBS (ORCPT + 99 others); Sun, 18 Jun 2023 04:01:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229470AbjFRIBR (ORCPT ); Sun, 18 Jun 2023 04:01:17 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1FA0D10D7; Sun, 18 Jun 2023 01:01:16 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B17EC60F61; Sun, 18 Jun 2023 08:01:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7DA1EC433C0; Sun, 18 Jun 2023 08:01:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1687075275; bh=JOdF7gdXvqBjASqKs6SWBkQKDgB3N69nrNaZPukvaeM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=sRSVsUz+8qwPDTD+DbQ8ZGj3oxWbs6Q2yclpQ5oA01FgfO3x99AMq57vy9vTmKGCz zxsNFAk2tsVXc2/ZMKN5WrqHKwwq7cFYa5f3HPOYIxlAVh8JcIK7E8a/4ukOQRZ4nx MkY7brx+YmsqJJOWjKI+esA6758vzynczNeZM28mb8D2036W2Ac3dVaBq4RYIRm2lO UwBKETxVcKwPW5jcSjXTb+3J9p7JSrJABXAw2lEoobsEXKewtbcSu8Iyl/ROefguVb JB6NowqZPjsvgPvrW3+OErG+qxYX7mjk/nhQmoo1FPg/indEYGUiochf7rWuDn85yN s8jpvUG70jw+A== Date: Sun, 18 Jun 2023 11:00:27 +0300 From: Mike Rapoport To: Andy Lutomirski Cc: Linux Kernel Mailing List , Andrew Morton , Catalin Marinas , Christophe Leroy , "David S. Miller" , Dinh Nguyen , Heiko Carstens , Helge Deller , Huacai Chen , Kent Overstreet , Luis Chamberlain , Mark Rutland , Michael Ellerman , Nadav Amit , "Naveen N. Rao" , Palmer Dabbelt , Puranjay Mohan , Rick P Edgecombe , "Russell King (Oracle)" , 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, the arch/x86 maintainers Subject: Re: [PATCH v2 02/12] mm: introduce execmem_text_alloc() and jit_text_alloc() Message-ID: <20230618080027.GA52412@kernel.org> 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: X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 On Sat, Jun 17, 2023 at 01:38:29PM -0700, Andy Lutomirski wrote: > On Fri, Jun 16, 2023, at 1:50 AM, 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(). > > > > Is there anything in this series to help users do the appropriate > synchronization when the actually populate the allocated memory with > code? See here, for example: This series only factors out the executable allocations from modules and puts them in a central place. Anything else would go on top after this lands. > https://lore.kernel.org/linux-fsdevel/cb6533c6-cea0-4f04-95cf-b8240c6ab405@app.fastmail.com/T/#u -- Sincerely yours, Mike.