Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp412436imw; Thu, 14 Jul 2022 03:58:09 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tUFf2ksxnAEAQpG3qjhTKAnmzBsuAbbZ0ijv1TKzSzBrSmkG9OKJPZpEt6HTkBUofuvQ1g X-Received: by 2002:a05:6402:1d53:b0:43a:9ba7:315b with SMTP id dz19-20020a0564021d5300b0043a9ba7315bmr11500720edb.350.1657796288833; Thu, 14 Jul 2022 03:58:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657796288; cv=none; d=google.com; s=arc-20160816; b=QWtRxK1nPnnZ0qv8TZXvlsznyNP16pzZYgaduOVnmdaNrpUXBoIqE3jULJOSgJtCJ1 U6N2l5dduhaPk8hBRMLesLdtSXbR7Gxxu/Ld8FnIhFdUtzhVLv31rcUajHsonhBkKB4o Cv8snhmeVajAXMyVpDCDxJ4RDJF3N6lraHHsmk7a42fT88vnNztSpk6L0Kb7riFrnl9M QfisuBfgDiG7ly2v1FxhrMo5lhFscOHklw3DTo1b45fkPAeuYumAuldOsHBdzwoNZZk0 dIfd7H3u97NwpE4cdNyUPJCtZ8XbUo9VB3YpoV5+iobyy7QMaa7TxF6OfLAMmeZrIW+F 2sMA== 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=0Gkk0NC34K+apqrYO+RTe0+nfUNqT3lfjLteCbnILho=; b=Ype2Wku8qOp/N8cbaBDNLDdzxjYS2hZQHmx5VdksJrrVzLk7NtrJ/3SWDaR2hrAOTl JCv4eOP1feCCjnukTRbnEELmHSmzxBvHc6TYLWBdYAyQgiiLhscLIEZsV3VSoquJyN92 ApW1NEm4slZwRKnw0886L3ig+ohW61ri3b2IY8a85X10HgLUyNfuknctJZYk+sKTUtYN 4z4ElVzfDb8chLLT5+qWCyxTGeHp4Nv+WsqMQRv7HxtA4MuMRyir5YJvOUFJwmNPSZ8z 0Vz2Fu9xYQS0Nf7VKVNvb9/HjxpLuVXezxTlBTIBzhEMYkAD6zKCMxPgNfy7KDyJhPjR 1W6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=UFnSe+fh; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gn23-20020a1709070d1700b0072b2e31d066si2321054ejc.642.2022.07.14.03.57.43; Thu, 14 Jul 2022 03:58:08 -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=@infradead.org header.s=casper.20170209 header.b=UFnSe+fh; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230073AbiGNKQl (ORCPT + 99 others); Thu, 14 Jul 2022 06:16:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237801AbiGNKQj (ORCPT ); Thu, 14 Jul 2022 06:16:39 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 586DB120A5; Thu, 14 Jul 2022 03:16:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=0Gkk0NC34K+apqrYO+RTe0+nfUNqT3lfjLteCbnILho=; b=UFnSe+fhAVY6yhXjV2wPJ61iZ8 2Zw0OYv0osZnIIxvRy4gbl9Ye5kgg+qtQKMQkvhFyAK32I4SIz8biMp+cQChL4nwYrIOG6C9ex0Ef f8U+9j9tY1bXIkJVNz+BPOChOnGQrY3uTbXPb+H8mB29/YqRxwsKepdNGgjXhQGGRQAiaiCXQXaCR fpHfR8jE+VDhlrnJsDgRZjQMdGT1qeIdRxvz6Re/H0sOAKr8FKrB+YaDbMcUjAbbDYwWHaeq77Jdg /X5bj3osOCoUykMSaOAx17CzfJkkDvSFWE1X4eNNlbC4Qk3E0NHW17ULmCJInK+jjxGJdV7o3rS7d pVljFdig==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=worktop.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1oBvsy-009HkF-C2; Thu, 14 Jul 2022 10:15:56 +0000 Received: by worktop.programming.kicks-ass.net (Postfix, from userid 1000) id E144A980120; Thu, 14 Jul 2022 12:10:36 +0200 (CEST) Date: Thu, 14 Jul 2022 12:10:36 +0200 From: Peter Zijlstra To: Song Liu Cc: Song Liu , bpf , lkml , Linux-MM , "linux-modules@vger.kernel.org" , Luis Chamberlain , Steven Rostedt , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Masami Hiramatsu , "naveen.n.rao@linux.ibm.com" , "davem@davemloft.net" , "anil.s.keshavamurthy@intel.com" , "keescook@chromium.org" , "hch@infradead.org" , "dave@stgolabs.net" , "daniel@iogearbox.net" , Kernel Team , "x86@kernel.org" , "dave.hansen@linux.intel.com" , "rick.p.edgecombe@intel.com" , "akpm@linux-foundation.org" Subject: Re: [PATCH bpf-next 1/3] mm/vmalloc: introduce vmalloc_exec which allocates RO+X memory Message-ID: References: <20220713071846.3286727-1-song@kernel.org> <20220713071846.3286727-2-song@kernel.org> <7C927986-3665-4BD6-A339-D3FE4A71E3D4@fb.com> <78A18945-0841-4CCE-8A33-6C09ECBFF7E1@fb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <78A18945-0841-4CCE-8A33-6C09ECBFF7E1@fb.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,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 Wed, Jul 13, 2022 at 09:20:55PM +0000, Song Liu wrote: > > > > On Jul 13, 2022, at 1:26 PM, Peter Zijlstra wrote: > > > > On Wed, Jul 13, 2022 at 03:48:35PM +0000, Song Liu wrote: > > > >>> So how about instead we separate them? Then much of the problem goes > >>> away, you don't need to track these 2M chunks at all. > >> > >> If we manage the memory in < 2MiB granularity, either 4kB or smaller, > >> we still need some way to track which parts are being used, no? I mean > >> the bitmap. > > > > I was thinking the vmalloc vmap_area tree could help out there. > > Interesting. vmap_area tree indeed keeps a lot of useful information. > > Currently, powerpc supports CONFIG_ARCH_WANTS_MODULES_DATA_IN_VMALLOC, Only PPC32; and it's due to a constraint in their MMU vs page protections. > which leaves module_alloc just for module text. If this works, we get > separation between RO+X and RW memory. What would it take to enable > CONFIG_ARCH_WANTS_MODULES_DATA_IN_VMALLOC for x86_64? The VM_TOPDOWN_VMAP flag and ensuring the data and code regions never overlap. Once you have that you can enable it. Specifically the problem is that data needs to be in the s32 immediate range just like code, so we're constrained to the module range. Given that constraint, the easiest solution is to use the different ends of that range.