Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5700994rwd; Sun, 18 Jun 2023 17:47:45 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6b6H/YEfjZpepDGtw4GvWX1UHQKm5saziPvqN1xH5PtxjnQeQsHpm3eJPte6ELu1a26/F5 X-Received: by 2002:a05:622a:40b:b0:3f6:4892:c773 with SMTP id n11-20020a05622a040b00b003f64892c773mr11851811qtx.30.1687135665668; Sun, 18 Jun 2023 17:47:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687135665; cv=none; d=google.com; s=arc-20160816; b=T/wae1udxoklvFoZs+vmTvfMWldtlHiPi9ERGSSfDwoiX1iPy8/rBxa0ePARmnIYLV pkaR68lv132YO4373yDcTUA/DHsPJBeYGsbhngSjskF71tXo44eg9vPLAQSbCThSgEYs qIaZRtzO76BbxrQqfTzEYw5d86dwpeuV/YcD7Mta9tIjZB8v8Khx9NYgCHLnjXvn5sEN InRBia6Hbg94viM2LoT9MqOmWF0lkQr68WOTX7aPM7J+73tO4jQQ/17PewEI6FeId/FT xVa9vP+9iZjxpKVIayeAI5n3txikPY6TTqaaLbzlNwvcM0BhZ6/7MuKtZRqqUDQMgbKl AKxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=vsMXbrKh0JGoYY4QV9GoJzzJG7ynUwMTeuBBW75Cixw=; b=NB/Kp5SWXutMglsizvRLRMPnywSwpsK/xJ7FkNb3ZP6f3fdfVLO1NUTC8Wev7WrA9v rUzRboEFTA3EFO4aG2q+9mPpR2OoWTkk6glqXXo+JYExJvgqSpvamUepnyjZbxNBfPUT UAHlW5jZyzvzo8IG0YbFUGr2NHP44/UIzQf4PqnZQzl38qC6Iy5ELzpVPHnuV3aZD+gr pmSCa/P7bqYDcrS6wHOHnQOWXEU8jlEH3U8vK+lfyG/or+GrbB8n5D7VocPcWsfNjtsc Nos0KB2ynKw4EW06dk3H/elgUNgWbiBK5fGtHHsAawblELHfKsFxRK1bXtZ3clwnujov zqwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=rUN14PJn; dkim=neutral (no key) header.i=@linutronix.de header.b=lLIbNU3p; 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=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x25-20020aa78f19000000b00666ec58d91bsi4826986pfr.99.2023.06.18.17.47.06; Sun, 18 Jun 2023 17:47:45 -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=@linutronix.de header.s=2020 header.b=rUN14PJn; dkim=neutral (no key) header.i=@linutronix.de header.b=lLIbNU3p; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229553AbjFSAoF (ORCPT + 99 others); Sun, 18 Jun 2023 20:44:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229472AbjFSAoD (ORCPT ); Sun, 18 Jun 2023 20:44:03 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A3AD188; Sun, 18 Jun 2023 17:44:01 -0700 (PDT) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1687135439; 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=vsMXbrKh0JGoYY4QV9GoJzzJG7ynUwMTeuBBW75Cixw=; b=rUN14PJnvCNMHwi3GTEOlfidoeu9X715ZKU0SYtls/E3LdchOubCrv6G6mpg1kS5Tfe1/9 s4JZa7jZI7/5XwWNgt1s7Bm2c/bSSDDBur1GSNft3GZ9udoq7EXJISSUO38jFXsNGvEbM0 tkM74ZwC4qjXGWb7oec1XP9g1Yz2kDYVXq2zWp3OYogUAp3NdYJ+EU/2VWfMYxaoBPM/f0 h8mrju1Sc9ps1cTeu3nCYiDGzqD/IRl0erFde+EUGB5wGGP14zw+GKvCyObIUHvlYiaxv4 ceZRK3Uxj0lWHTCBTGtW1lP8JYu8YM/FvQhC52QcdmikiK6sh8q/uSftK+9f4w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1687135439; 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=vsMXbrKh0JGoYY4QV9GoJzzJG7ynUwMTeuBBW75Cixw=; b=lLIbNU3pTbmQ6EcHS74pAHUeumYKJH5D0qb0hsj7fDkEeEfUM8kX51p2S8npikVP/atNyj ZNKqUDCt/8atTiDw== To: Kent Overstreet Cc: Mike Rapoport , 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 , 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 06/12] mm/execmem: introduce execmem_data_alloc() In-Reply-To: <20230618231431.4aj3k5ujye22sqai@moria.home.lan> References: <20230616085038.4121892-1-rppt@kernel.org> <20230616085038.4121892-7-rppt@kernel.org> <87jzw0qu3s.ffs@tglx> <20230618231431.4aj3k5ujye22sqai@moria.home.lan> Date: Mon, 19 Jun 2023 02:43:58 +0200 Message-ID: <87h6r4qo1d.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain 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_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 Kent! On Sun, Jun 18 2023 at 19:14, Kent Overstreet wrote: > On Mon, Jun 19, 2023 at 12:32:55AM +0200, Thomas Gleixner wrote: > > Thomas, you're confusing an internal interface with external No. I am not. Whether that's an internal function or not does not make any difference at all. Having a function growing _eight_ parameters where _six_ of them are derived from a well defined data structure is a clear sign of design fail. It's not rocket science to do: struct generic_allocation_info { .... }; struct execmem_info { .... struct generic_allocation_info alloc_info; ; struct execmem_param { ... struct execmem_info[NTYPES]; }; and having a function which can either operate on execmem_param and type or on generic_allocation_info itself. It does not matter as long as the data structure which is handed into this internal function is describing it completely or needs a supplementary argument, i.e. flags. Having tons of wrappers which do: a = generic_info.a; b = generic_info.b; .... n = generic_info.n; internal_func(a, b, ....,, n); is just hillarious and to repeat myself tasteless and therefore disgusting. That's CS course first semester hackery, but TBH, I can only tell from imagination because I did not take CS courses - maybe that's the problem... Data structure driven design works not from the usage site down to the internals. It's the other way round: 1) Define a data structure which describes what the internal function needs to know 2) Implement use case specific variants which describe that 3) Hand the use case specific variant to the internal function eventually with some minimal supplementary information. Object oriented basics, right? There is absolutely nothing wrong with having internal_func(generic_info *, modifier); but having internal_func(a, b, ... n) is fundamentally wrong in the context of an extensible and future proof internal function. Guess what. Today it's sufficient to have _eight_ arguments and we are happy to have 10 nonsensical wrappers around this internal function. Tomorrow there happens to be a use case which needs another argument so you end up: Changing 10 wrappers plus the function declaration and definition in one go instead of adding One new naturally 0 initialized member to generic_info and be done with it. Look at the evolution of execmem_alloc() in this very pathset which I pointed out. That very patchset covers _two_ of at least _six_ cases Song and myself identified. It already had _three_ steps of evolution from _one_ to _five_ to _eight_ parameters. C is not like e.g. python where you can "solve" that problem by simply doing: - internal_func(a, b, c): + internal_func(a, b, c, d=None, ..., n=None): But that's not a solution either. That's a horrible workaround even in python once your parameter space gets sufficiently large. The way out in python is to have **kwargs. But that's not an option in C, and not necessarily the best option for python either. Even in python or any other object oriented language you get to the point where you have to rethink your approach, go back to the drawing board and think about data representation. But creating a new interface based on "let's see what we need over time and add parameters as we see fit" is simply wrong to begin with independent of the programming language. Even if the _eight_ parameters are the end of the range, then they are beyond justifyable because that's way beyond the natural register argument space of any architecture and you are offloading your lazyness to wrappers and the compiler to emit pointlessly horrible code. There is a reason why new syscalls which need more than a few parameters are based on 'struct DATA_WHICH_I_NEED_TO_KNOW' and 'flags'. We've got burned on the non-extensibilty often enough. Why would a new internal function have any different requirements especially as it is neither implemented to the full extent nor a hotpath function? Now you might argue that it _is_ a "hotpath" due to the BPF usage, but then even more so as any intermediate wrapper which converts from one data representation to another data representation is not going to increase performance, right? > ... I made the same mistake reviewing Song's patchset... Songs series had rough edges, but was way more data structure driven and palatable than this hackery. The fact that you made a mistake while reviewing Songs series has absolutely nothing to do with the above or my previous reply to Mike. Thanks, tglx