Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2953589rwd; Fri, 16 Jun 2023 10:13:06 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7/ko94+myiJT7QCYLLOCtj3zqDiln2STwuFm3KeydeSAhPGimgsxNi1VU85A/qLoOQlxsV X-Received: by 2002:a05:6830:4807:b0:6b0:cccc:3279 with SMTP id dg7-20020a056830480700b006b0cccc3279mr2655036otb.12.1686935586297; Fri, 16 Jun 2023 10:13:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686935586; cv=none; d=google.com; s=arc-20160816; b=nT6666i/2DXBcw1H4xFhH+BK3xLbWYy2vUhPXXhneA6jl5YLnpStIlz280hXqbkuwS Wv1etLZwuFZuA6njUsjH8LCSkFgA54yHUNF5kmDLjYHS5eoKjTH2tVq+zMughHsPS9+x /zrxOWx7i2odYoQhJBCQybzlaWOFssN6nDdnny4TLGz414k0QEzb7i5jugblHjDsLL4c gDsz6/oGMPJrOX6a858tEp0unfiAMRub+CF+KOahu8jSEug9hrqGvLzdnFrDZoTN2FhV n8W7AqPeKdzlnNL5Xv+VJFXnSpZsh0/NKIustXT2JAE+bzZ5WE/iU/94rN3bmUXTwmjh /z+g== 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:dkim-signature:date; bh=IfKIglpY59qnffneasZzBrgWBI/BVVKcO3nvK+88q6Q=; b=0oixq4330WFXWLH/oDpxUqQZ79Us74z/yNFJ7wHz0eYYjVYyAnrqAm5j837pF+1e7i xz2KIi78+Pxvh+NV0XaAYq35jQQYF0REW50LZmj5xwN66oH/iWrudQpp6IShioXPIhr2 7SsYqS4aKHIrSJ5doYwRKpzpzjUEhm3AJzRqCD0/ong6//o82anpCTtv8uyJl4SmEeCZ w1jXxZloAElUA+sirQnQmeXu1JsiehEPyjoFl9gdwlg5psxaYQ+jYPVJ6uC0074prAn3 2/qmXlN7N1uZdJKAFLxQO5tXDOjH5MTuBME5u1h5CNJz9CL/FWVqgS2xfdd/J9sqhvwo rYnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=f7uDVOP+; 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=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gf23-20020a17090ac7d700b0025e8f2c9a62si751796pjb.63.2023.06.16.10.12.31; Fri, 16 Jun 2023 10:13:06 -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=@linux.dev header.s=key1 header.b=f7uDVOP+; 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=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345626AbjFPQsR (ORCPT + 99 others); Fri, 16 Jun 2023 12:48:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345382AbjFPQsM (ORCPT ); Fri, 16 Jun 2023 12:48:12 -0400 Received: from out-16.mta0.migadu.com (out-16.mta0.migadu.com [IPv6:2001:41d0:1004:224b::10]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E037E30F7 for ; Fri, 16 Jun 2023 09:48:10 -0700 (PDT) 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-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable 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 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