Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp6272285rwd; Mon, 19 Jun 2023 05:08:03 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6SboeDS2xBkj65z2Q2Bi+NkjY0/OguBqcltKGtZ6bfROaFgiPT3XovjCecdagRQoD+7qfu X-Received: by 2002:a17:902:d509:b0:1b5:cd6:8246 with SMTP id b9-20020a170902d50900b001b50cd68246mr13082410plg.2.1687176483197; Mon, 19 Jun 2023 05:08:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687176483; cv=none; d=google.com; s=arc-20160816; b=rlG+YbTPaxVaEnlJrzJTX+CG9CWA+bG7A3c+DyadeHG0X2iM58CTgAPpvJ4SIvMgLd 4N1bGU0+NulsxHVIiq6KX28eDfMgQW2tBj+MsTuPPGPUX3wLv4Y1BLNE7KdoYdaF7EWr i6OTRJFZjrdL97BqJWqU6fEfeJYjdwfmp3OR7YOxiYKwg/cSJ0A8ThwgbpuFvHuFBS3z ykO6rhWzEXTDylqB5jrbSGE+dXJkgzsfnPZ9NtV49uw2PVYBqU4tIEdLZ/iaFUOlrRlm bUgce8beatUgsmgJNKnJeYkNCoGv+8A2Qr/hz4zFagxyINKHGXORGTQ/CXro0gTvvWKG jnIQ== 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=Tt3RWh8BEKoqLhK86LDh7llJ14l6KCTXk/okAyPXAzA=; b=E2T5LIJKjjnjcaM7V1qEWYaPysPZuxRdHwqFWQKusCw7y4ZD84PsGunfH3yAe8hQfm 6X1fGWmR+mFybV7QpNnPPbFsO/Duf88ikVGvpGeE71Gja/ZjLt5bOa40hX9H1QajpBPn YrZfbZ+oVDv97C+gZCPI6cmnUIifgNlPiN6rmHrYKQcGJ7cknoOUnV1wcDkWnTOHR1oY aBxZ+3RTXxpBO6qhl0FHgm58wVc7taqyRZBA3xh6x47jNtVH+PYWjQTIbK+56IMXJggm R06DTWHIj9VyPwtPwN5HVGtuL7Wth9oMyHRGrDHmA6ibOFmaym0v1dDk7df7GW0uUtWA efBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=i+cENnWb; 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 l15-20020a170903244f00b001a95babe3c0si1487899pls.371.2023.06.19.05.07.48; Mon, 19 Jun 2023 05:08:03 -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=i+cENnWb; 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 S230397AbjFSLei (ORCPT + 99 others); Mon, 19 Jun 2023 07:34:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229519AbjFSLeg (ORCPT ); Mon, 19 Jun 2023 07:34:36 -0400 Received: from out-34.mta0.migadu.com (out-34.mta0.migadu.com [91.218.175.34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1483FEE for ; Mon, 19 Jun 2023 04:34:34 -0700 (PDT) Date: Mon, 19 Jun 2023 07:34:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1687174472; 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=Tt3RWh8BEKoqLhK86LDh7llJ14l6KCTXk/okAyPXAzA=; b=i+cENnWbA17Y+F/fishc8UmKkX2d11aFrfbkEA/RSeJGs8DaK+pP54Vf1C7aoZ8NsEj74R cXaE50KWXHIuXWZXVuGC783hgIjWLesjrEEDAYhwTaqLKdCoI85w4n4+GuOUgBvzA2QigP oa1A17/zsm0VN2UgH6YNfjC3Cc/g4gI= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Kent Overstreet To: Andy Lutomirski Cc: Mike Rapoport , Linux Kernel Mailing List , 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 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: <20230619113426.c37bpwvdagbzyevn@moria.home.lan> 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-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 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: > > https://lore.kernel.org/linux-fsdevel/cb6533c6-cea0-4f04-95cf-b8240c6ab405@app.fastmail.com/T/#u We're still in need of an arch independent text_poke() api.