Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1557763rwd; Sun, 14 May 2023 22:50:28 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ78f5vSQAiv/4QkB6sS1EQd0tnArqwWjri2zuToX1JtWY3BrmrAT9/QAEAd13IK8NyY3mLo X-Received: by 2002:a05:6a20:7d81:b0:104:3f3a:c973 with SMTP id v1-20020a056a207d8100b001043f3ac973mr13260770pzj.7.1684129828118; Sun, 14 May 2023 22:50:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684129828; cv=none; d=google.com; s=arc-20160816; b=hC6xk4B9pmbhlUyI3HmOs8DkScrCuieQwikweIXwggaOH0jHAqZilY0y7k7kBp5wMV IWZqOg8GZyKcBU+MFkdCg67x4iKiHkr1KE92ATFwyc0p93PSWtskRlyuEzGtZ9mvZoLW YD3CDcGpCFQES9x+Fc+vuq4WIVJ3utHUa31CWE0VAkEs4y5Trc2sF1MvuJ6VrAHCSLMw 3BhdiX8mwvfsG+NJSq/rB4mvRgmvuoLBw3mS8qCh+ipr2XqzQoy0eNwSXRdFjCimtb4k Jfi2MC408BMICyG/HJQikdc02JFGPD1V7LQUFSVUlWwxX9ZXovF2NyyctOV5GCwOsYMX 9AIA== 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:dkim-signature:date; bh=q2mGEUvyHwZiGTrF0TDmaBKI7TfcH+VD1Blkzm5ytFk=; b=KiEMK3oiCPEc599wl5H5jAYOlQjtczSdwHcHQm/nxkDh2J2yM8rkJu+GqFwhaWC9b9 RxUNAA2DeYDkkt9MGVGiNDqP0doRXs3AneXFnYuiiwM0UgRX1cvLY0sHEX3rn4vmi9tv rB5aZsUGwfdBp3liMktOMO2FTTAR5tWhpAbVuICYnfC912KDZcVfLUC6D3za2GE4a9lC zRlTPrWJNaaWrSZXkiet47CQlzL6oJtHTHsc0XZLgbBBA3s1j6XUjIW3rnc5XB9Mtnx8 B7d8aQE4WMKGv07JwI7l/l5nMQD7vqAU+gQ4pvDEMjB8qpOK5YT0HFL9K+Rz+brQ7wr0 QxVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=QJAzPvdo; 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 z23-20020a63b917000000b005098590f1edsi15585133pge.757.2023.05.14.22.50.14; Sun, 14 May 2023 22:50:28 -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=QJAzPvdo; 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 S229929AbjEOFC4 (ORCPT + 99 others); Mon, 15 May 2023 01:02:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229950AbjEOFCy (ORCPT ); Mon, 15 May 2023 01:02:54 -0400 Received: from out-2.mta0.migadu.com (out-2.mta0.migadu.com [91.218.175.2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DB77E73 for ; Sun, 14 May 2023 22:02:51 -0700 (PDT) Date: Mon, 15 May 2023 01:02:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1684126969; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=q2mGEUvyHwZiGTrF0TDmaBKI7TfcH+VD1Blkzm5ytFk=; b=QJAzPvdoQUkeyTUk6S2C+QWy4jL4zcmYveWG3SSgImiqUUCC42tKyxxcO2zjN7BKZll567 0ccXmBJd5mbCp9XkvCh9Jw/aMSC5/HQXIWaA8wvZfGp6/o4zsDQVFiMoWCF2m/8nSah/lp /VcUxVy7M0z3GWs4tmlJsv/ywE8JtAA= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Kent Overstreet To: Christophe Leroy Cc: Lorenzo Stoakes , Christoph Hellwig , "linux-kernel@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "linux-bcachefs@vger.kernel.org" , Kent Overstreet , Andrew Morton , Uladzislau Rezki , "linux-mm@kvack.org" Subject: Re: [PATCH 07/32] mm: Bring back vmalloc_exec Message-ID: References: <20230509165657.1735798-1-kent.overstreet@linux.dev> <20230509165657.1735798-8-kent.overstreet@linux.dev> <8f76b8c2-f59d-43fc-9613-bb094e53fb16@lucifer.local> <6f049870-1684-1875-3cdc-73e1323ffdb0@csgroup.eu> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <6f049870-1684-1875-3cdc-73e1323ffdb0@csgroup.eu> 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=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 Mon, May 15, 2023 at 04:45:42AM +0000, Christophe Leroy wrote: > > > Le 15/05/2023 à 01:43, Kent Overstreet a écrit : > > On Sun, May 14, 2023 at 06:39:00PM +0000, Christophe Leroy wrote: > >> I addition to that, I still don't understand why you bring back > >> vmalloc_exec() instead of using module_alloc(). > >> > >> As reminded in a previous response, some architectures like powerpc/32s > >> cannot allocate exec memory in vmalloc space. On powerpc this is because > >> exec protection is performed on 256Mbytes segments and vmalloc space is > >> flagged non-exec. Some other architectures have a constraint on distance > >> between kernel core text and other text. > >> > >> Today you have for instance kprobes in the kernel that need dynamic exec > >> memory. It uses module_alloc() to get it. On some architectures you also > >> have ftrace that gets some exec memory with module_alloc(). > >> > >> So, I still don't understand why you cannot use module_alloc() and need > >> vmalloc_exec() instead. > > > > Because I didn't know about it :) > > > > Looks like that is indeed the appropriate interface (if a bit poorly > > named), I'll switch to using that, thanks. > > > > It'll still need to be exported, but it looks like the W|X attribute > > discussion is not really germane here since it's what other in kernel > > users are using, and there's nothing particularly special about how > > bcachefs is using it compared to them. > > The W|X subject is applicable. > > If you look into powerpc's module_alloc(), you'll see that when > CONFIG_STRICT_MODULE_RWX is selected, module_alloc() allocate > PAGE_KERNEL memory. It is then up to the consumer to change it to RO-X. > > See for instance in arch/powerpc/kernel/kprobes.c: > > void *alloc_insn_page(void) > { > void *page; > > page = module_alloc(PAGE_SIZE); > if (!page) > return NULL; > > if (strict_module_rwx_enabled()) > set_memory_rox((unsigned long)page, 1); > > return page; > } Yeah. I'm looking at the bpf code now. Can I just say, for the record - god damn this situation is starting to piss me off? This really nicely encapsulates everything I hate about kernel development processes and culture and the fscking messes that get foisted upon people as a result. All I'm trying to do is write a fucking filesystem here people, I've got enough on my plate. Dealing with the fallout of a kernel interface going away without a proper replacement was NOT WHAT I FUCKING HAD IN MIND? 5% performance regression without this. That's just not acceptable, I can't produce a filesystem that people will in the end want to use by leaving performance on the table, it's death of a thousand cuts if I take that attitude. Every 1% needs to be accounted for, a 5% performance regression is flat out not going to happen. And the real icing on this motherfucking turd sandwich of a cake, is that I'm not the first person to have to solve this particular technical problem. BPF has the code I need. But, in true kernel fashion, did they recognize that this was a subproblem they could write as a library, both making their code more modular and easier to understand, as well as, oh I don't know, not leaving a giant steaming turd for the next person to come along? Nope. I'd be embarassed if I was responsible for this.