Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp1722597rdh; Tue, 26 Sep 2023 01:10:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH8ZTbR+JJvgShpXfYDG+bPikPYLf6DKbTp7iGU62Ku5Z2oOrr10L8R2TB3rd4NXHtoyOlT X-Received: by 2002:a05:6870:3109:b0:1dc:9714:e2b3 with SMTP id v9-20020a056870310900b001dc9714e2b3mr11421824oaa.7.1695715850197; Tue, 26 Sep 2023 01:10:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695715850; cv=none; d=google.com; s=arc-20160816; b=jAQ1rxgI4+jI+x7d1hS5IDDriGX+FPcmP+WDZ1Dgh0vMW9KaHPRi18fPVHXW8M/Qfm 2oNmuaMd5QGUL0g5Men6I+ab2vq04jEbL/2CnTXCJCxzdx3+tWxbiJgM7HziNbkrZg5g sHQVVp2g32DrLCOCv6HgjGhENM8IrCXHfLifM/MYrhvB2OljyegubZxoN3gmYw5O6zVC m8Lagq/1CzT+zYQAOjcRbu1j2vQ9LkjWY07MtGYzXYa6iqvkCCqRYoAMNg9ViO/08XWe iPqzv3xYk0Au5fbRUHMMt7cDNTg6M4U9pH7Zj2EiV7qDHWDxpOWh/O/n4HI1w/0npq35 k+ig== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=yhlj6GB/jPpZLBIF7GTkheYVDphmios4NWkTZl2cmUk=; fh=LLxVw4x/YA0p2nrisYkbRBF7OIGhT8MrMihKmdCsSWw=; b=Na11OsXUHK+tFGMDzBiMOxzO0KzOWIEm8K/52i0mJg9N/xK02ClBnyY2cXxcWvwe12 2e5PTqXHsmNpBwUyEvGuobXaFREpxyHQI5XJstPmCZ3M/a196mH6iFu5N12hGx1DzH6m yDKdjvKR3R72Zm3nCgenUc5Mnyeub8Dqo5FEvKm8JkivUSYeFC8CqACY79zRifeHikWk X5VAaztImQMH1/H83PYmwcTYElXE39LqvWQlLkfXNTK2hxdKOmcA7ehxgoBLH8cWT018 LxaalHTIknLmeepOQ4lvkWoajthCfev0chBCq3yZqr4k3ot+UWxJEXQpNkbMRgOJLrv+ PXMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RLx2TLWK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id bt9-20020a632909000000b00578e29ae274si950410pgb.521.2023.09.26.01.10.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 01:10:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RLx2TLWK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 153628080D6A; Tue, 26 Sep 2023 01:05:36 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229556AbjIZIFe (ORCPT + 99 others); Tue, 26 Sep 2023 04:05:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233807AbjIZIFb (ORCPT ); Tue, 26 Sep 2023 04:05:31 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B933D116; Tue, 26 Sep 2023 01:05:24 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DEB07C433C7; Tue, 26 Sep 2023 08:05:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695715524; bh=+Amk36a0CBOiKu5+FtjGQvFX395/lzfG991XVrUkCKk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=RLx2TLWKtN7VAMAOy6Z+yt+5L2H3WvCxgk6fo3xEAFTVDZv0mPqQm9oryMdet+1qZ obrB5TY2nE/qbUSfaI1uId3y2yRK2qnxEYYQpqf8IMXRqLpaWcyp6r1h8W5YGqDDxg /Ipk9rb4CjRrT7bowSHMduOUAEuaFMTD7nXxu83iUI+O1xmmOj2PJsMoiGARKNDMsM m8lXDTJPRNGVXjXTr34wm+BzlG4p+UzrUM7cd5TVxTprWIBaR+mK3IXevwTFE0yWC2 SIHL7mRKLFjL2iR5rLVY4OdrYFjdV9kMecllhx3OCPX+UXN+tAGab3AHw/soEZdxZb tvxNd43ZGN+BA== Date: Tue, 26 Sep 2023 11:04:22 +0300 From: Mike Rapoport To: Song Liu Cc: linux-kernel@vger.kernel.org, Andrew Morton , =?iso-8859-1?Q?Bj=F6rn_T=F6pel?= , 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 Edgecombe , Russell King , 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 v3 02/13] mm: introduce execmem_text_alloc() and execmem_free() Message-ID: <20230926080422.GP3303@kernel.org> References: <20230918072955.2507221-1-rppt@kernel.org> <20230918072955.2507221-3-rppt@kernel.org> <20230923153808.GI3303@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 26 Sep 2023 01:05:36 -0700 (PDT) On Sat, Sep 23, 2023 at 03:36:01PM -0700, Song Liu wrote: > On Sat, Sep 23, 2023 at 8:39 AM Mike Rapoport wrote: > > > > On Thu, Sep 21, 2023 at 03:34:18PM -0700, Song Liu wrote: > > > On Mon, Sep 18, 2023 at 12:30 AM Mike Rapoport wrote: > > > > > > > > > > [...] > > > > > > > diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c > > > > index 42215f9404af..db5561d0c233 100644 > > > > --- a/arch/s390/kernel/module.c > > > > +++ b/arch/s390/kernel/module.c > > > > @@ -21,6 +21,7 @@ > > > > #include > > > > #include > > > > #include > > > > +#include > > > > #include > > > > #include > > > > #include > > > > @@ -76,7 +77,7 @@ void *module_alloc(unsigned long size) > > > > #ifdef CONFIG_FUNCTION_TRACER > > > > void module_arch_cleanup(struct module *mod) > > > > { > > > > - module_memfree(mod->arch.trampolines_start); > > > > + execmem_free(mod->arch.trampolines_start); > > > > } > > > > #endif > > > > > > > > @@ -510,7 +511,7 @@ static int module_alloc_ftrace_hotpatch_trampolines(struct module *me, > > > > > > > > size = FTRACE_HOTPATCH_TRAMPOLINES_SIZE(s->sh_size); > > > > numpages = DIV_ROUND_UP(size, PAGE_SIZE); > > > > - start = module_alloc(numpages * PAGE_SIZE); > > > > + start = execmem_text_alloc(EXECMEM_FTRACE, numpages * PAGE_SIZE); > > > > > > This should be EXECMEM_MODULE_TEXT? > > > > This is an ftrace trampoline, so I think it should be FTRACE type of > > allocation. > > Yeah, I was aware of the ftrace trampoline. My point was, ftrace trampoline > doesn't seem to have any special requirements. Therefore, it is probably not > necessary to have a separate type just for it. Since ftrace trampolines are currently used only on s390 and x86 which enforce the same range for all executable allocations there are no special requirements indeed. But I think that explicitly marking these allocations as FTRACE makes it clearer what are they used for and I don't see downsides to having a type for FTRACE. > AFAICT, kprobe, ftrace, and BPF (JIT and trampoline) can share the same > execmem_type. We may need some work for some archs, but nothing is > fundamentally different among these. Using the same type for all generated code implies that all types of the generated code must live in the same range and I don't think we want to impose this limitation on architectures. For example, RISC-V deliberately added a range for BPF code to allow relative addressing, see commit 7f3631e88ee6 ("riscv, bpf: Provide RISC-V specific JIT image alloc/free"). > Thanks, > Song -- Sincerely yours, Mike.