Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp3647585rwd; Fri, 16 Jun 2023 23:04:49 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ67b1obDQJtI/RKtCexpL4Y2WoJ/kqB3BoVuOeYazkHuEIXQ40c047/1mVUNZgxSQtqznkZ X-Received: by 2002:a05:6830:32a8:b0:6b0:e010:4b44 with SMTP id m40-20020a05683032a800b006b0e0104b44mr1301592ott.33.1686981888934; Fri, 16 Jun 2023 23:04:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686981888; cv=none; d=google.com; s=arc-20160816; b=LJV9XiWpBmkR4WpmV7FIZiaF33l9+eonSwqkylSGs4lBr1yRADRO8UKvaH7z5QFJ24 6gAdjxftw/Pkmc+6JsgF6w8Gz+jYL5gem1qBEnCO4Y+YbQ0ernhFbHChN0cQPPNoceGk kWe6Yhln163sw6VmwxxlAMYaWoJnR19f2cXgcKnp94K0Hm6DBLOTQOO2xRpx41At4duF XuiEQw8J4A6G9ajn4CIWwR0byIsikpstpw72qe40a0/MMgK+0OsQdYw6Ktz1H/SxFVt4 CL0kgt/ckHwbzWGsNob5BceTklM9MTYTVtPmVmssN5piJKhXOP/jSFC57pKMhc06K2P1 nnWw== 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=+kGWBLyDfhTCDtZcBuR10p+fn54/Laq+yoObILqNGYg=; b=j8zlv181XpcyRgFXCXpHmmVGtje4qm3PMvmNyCmccC5t95jf5KXx3ITpPjXbT1Fzit WJq10dflwvqT8+hUUACaAF22bSoaeN7xlI4RQSMxgsaJ4ZN1Ab3N9duJOj0bsb8qKRXq 2s6HNSHl5OnEzdQ/cN0OWLLB9ouWFEEL54z05TQJp8uq4neZngrlMMu7z/zuYWYj2A5M N9Z/8KEtstRtGm9dAFLBMvgnXu5dYFHFXj6AbV6JEN1Z+pxJezRwmSLIJxvIU0b57XyK SEvJBiYKLxvIPsUwaqFIGGx4JQfVes1H12HS1z9LUv8Qy1YU/5MyRQWBRgZugNgMZwVe E3zA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="B9hc07/U"; 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 b5-20020a63eb45000000b0053b8c98d14bsi13105776pgk.859.2023.06.16.23.04.30; Fri, 16 Jun 2023 23:04:48 -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="B9hc07/U"; 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 S231912AbjFQF60 (ORCPT + 99 others); Sat, 17 Jun 2023 01:58:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229493AbjFQF6X (ORCPT ); Sat, 17 Jun 2023 01:58:23 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CEDA110DD; Fri, 16 Jun 2023 22:58:22 -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 6B04960BC3; Sat, 17 Jun 2023 05:58:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DA841C433C8; Sat, 17 Jun 2023 05:58:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686981501; bh=9SqjLlF2xzEFMDzeUI2FvZ8TQ/VYLeU5U3+d2ag6lCs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=B9hc07/UYnnRas23n9bJwWr+pH130gxwd28u02GqPOK/3pfJBCaemAnqVGrkDZJvc c1CAOIsikGJgqoHvH/7lYMCMhV6ZKfKOSUTWgFsy65h+ShXGvPeLAwohq+3h4qZEdI 4hdYWdRJ1+jHavy8l0eCEiP9dZuoxTKyc1UOJ6v+W6Yd8E12mVMWzVMrv38nPKgPzX moqJqCymmH/VJkuy+GUQ7PHhVA13ypUE+mj0CzOEMjMShVb3ccT9eDbLaWG8SQqxxA PHzQL4oLwI3nEQGSA+tdAQmm6prwylQLhbSagwZslqD3uTtetH44zVkHm5GQY4CCKg LaEhwb1fWA+nA== Date: Sat, 17 Jun 2023 08:57:35 +0300 From: Mike Rapoport To: Kent Overstreet 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: <20230617055735.GN52412@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 Fri, Jun 16, 2023 at 12:48:02PM -0400, Kent Overstreet wrote: > 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. With near and far it should mention from where and that's getting too long. I don't mind changing the names, but I couldn't think about something better than Song's execmem and your jit. > Reviewed-by: Kent Overstreet Thanks! -- Sincerely yours, Mike.