From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 684B6EB64D7 for ; Sun, 18 Jun 2023 23:14:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A2DD08D0002; Sun, 18 Jun 2023 19:14:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9B76B8D0001; Sun, 18 Jun 2023 19:14:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 87EC18D0002; Sun, 18 Jun 2023 19:14:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 742458D0001 for ; Sun, 18 Jun 2023 19:14:45 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 42584160320 for ; Sun, 18 Jun 2023 23:14:45 +0000 (UTC) X-FDA: 80917425330.23.9F56FC5 Received: from out-31.mta0.migadu.com (out-31.mta0.migadu.com [91.218.175.31]) by imf28.hostedemail.com (Postfix) with ESMTP id 462C0C0017 for ; Sun, 18 Jun 2023 23:14:43 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=n8muyYIF; spf=pass (imf28.hostedemail.com: domain of kent.overstreet@linux.dev designates 91.218.175.31 as permitted sender) smtp.mailfrom=kent.overstreet@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687130083; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=KNV5zwl+hLzM43CrYb9nr/b3a6OyCWH6RWURaog0Xso=; b=1KcxComZhC6t1h2Wp2QquvVLIlUPNE4a+ZOxWOjBZWpGmN/D0KGuil5fyf1H3cKRsIZj2S oENDEhIAPLU7zSKbOA1eDqNJ8shzdd9WBxqms43NCanHe0Vfax0SM9FMwf7IKrDzxHG7ig 9NqMUG3DsUe2zU5zvpY8DuJWqlThfKA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687130083; a=rsa-sha256; cv=none; b=Ovpce1FyTwBmdOXsiVy4ipLB+iMhjrFVePvI3At41djAKFpamADFjw3ZmrDx5VpjIoefJ2 sB2gcm78SbTx5QS4mM8agd+7CuahEBoG+io/hT6f2EEqGJwP8Fy81xn5UZA3oFlSKrg8cM Ydn+xP6zR2W4R4tKsPvf88yf3+q0DT0= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=n8muyYIF; spf=pass (imf28.hostedemail.com: domain of kent.overstreet@linux.dev designates 91.218.175.31 as permitted sender) smtp.mailfrom=kent.overstreet@linux.dev; dmarc=pass (policy=none) header.from=linux.dev Date: Sun, 18 Jun 2023 19:14:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1687130080; 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=KNV5zwl+hLzM43CrYb9nr/b3a6OyCWH6RWURaog0Xso=; b=n8muyYIFu4NWn2jUrxuhNWtbUM5+mIauth+1Pc71A47mzFzPENac7CXSnCthrLOM9Mp8Vp ZC85r5mgKM1Z6DbUVT6Cjqrw0askzvY2hRQW+Cy+BiYrMDlad4Bi9in+atwC+gux88leWU Lsl3kE3f4XQNXRl/yeFL9WdFeIa4tAE= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Kent Overstreet To: Thomas Gleixner 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() Message-ID: <20230618231431.4aj3k5ujye22sqai@moria.home.lan> References: <20230616085038.4121892-1-rppt@kernel.org> <20230616085038.4121892-7-rppt@kernel.org> <87jzw0qu3s.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87jzw0qu3s.ffs@tglx> X-Migadu-Flow: FLOW_OUT X-Stat-Signature: mdi7ieeoj6h6b9qgisubz7gcqbc8o515 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 462C0C0017 X-Rspam-User: X-HE-Tag: 1687130083-383734 X-HE-Meta: U2FsdGVkX18ZUNGef9Cuhe1dqj3gf4dzqMqH4Ac6Z7lCD/9SVFx0qaLxQuUCXR6b/wOaiCwYR3eA4HP1c89c/TGHsYVCM7gylxRFBE+NCdQyFhJ/728Q/xQSPHghXc9wy4aM8ilfJvWQRXb+vsioUgGYZgblgrWxU/0BDzuJnsOevKuQWCbmQwGzbPo+EPcEtZUC/0NoLyY3rDpuB0YCXvqV/YHWABTB5zL/avigecSZLAdu21SfMfFtU6swrSfhvBIvipFPnXvuU690pjY68ZRYx0oPRPg5HJYA2/Te5j6eyrjWSE9fgCWYyW4uJEqZw1/jD5holCek0/PgqfU4WHrQhvnEiqK2Y+FuHVQk1QjH60hYZYhRRqNRKzv4CflqOnw5hHpcI/kxPCI65ssbJMKR5dUQAKwMy6BSnwN3efx8WB0pn0YS33TL7B89Yg+inlpKZ3ZwE0gdAaGySxSHfaOjh9xe6s9wgcKkHDBwBm0LV8ZJ3Hb3LoMVaX9OLGhTvBjYqgGYbjYrsI9OnyeeH7rXb5r/kUBSoPRQ5cL6apSIeTEQDsBBRgLnATVYw14Gxb3HZJ8pFtQely0LiBowXFu6Lov/uMZwqe0DH6BMlAFXdd1SF4HXqvNzO2fKE6Wj0eYfu+BN/H5mjBvxX8NGtHqtXhi0xp3O6Tm3QNrQ2oiEfEcdfl3kRVwFQmrv1y8wr7pRXF9U2W7Sl/s1ZaTgRacrVvuC1ByGA+WTfL5RLvhVDgfu+ct8oAv3MFh71vi+AKVYEV3SIWetR0XntgQ07C2HbMuBNlolvCQE3aBFUj3h7Pga7TuG6uFtafRyRWO3TcEEj0j+8gSlW4QSCcErYKY9M3pK8d8jTExCt30dJcRV6v43UZAUs58UGH43fOghrEKnG6F8mSmk2KOtPpogCnQlEHKVJeSnrMRX1ikWggvA/urNTlpm8QDo3sFUFsjAo6qC7kiiEFxf4yzj0WW HEJne+PV oHI5hkorMsHOiPvtEprTXQ2wSdzUHTrY7//MX7mJUamJ88g9KDa0MPP76QU51Bg9oaTtaxO4ncGXqfbOja94LOct1jgkpxMvYxgL5+GFR7o2/FU9ebG46yDJAnjd/xhIK9qx4IK1a8T/BSWsD05ZyBtP0U1PGRQZfQ3Tf8tEgyOSheF8= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon, Jun 19, 2023 at 12:32:55AM +0200, Thomas Gleixner wrote: > Mike! > > Sorry for being late on this ... > > On Fri, Jun 16 2023 at 11:50, Mike Rapoport wrote: > > > > +void *execmem_data_alloc(size_t size) > > +{ > > + unsigned long start = execmem_params.modules.data.start; > > + unsigned long end = execmem_params.modules.data.end; > > + pgprot_t pgprot = execmem_params.modules.data.pgprot; > > + unsigned int align = execmem_params.modules.data.alignment; > > + unsigned long fallback_start = execmem_params.modules.data.fallback_start; > > + unsigned long fallback_end = execmem_params.modules.data.fallback_end; > > + bool kasan = execmem_params.modules.flags & EXECMEM_KASAN_SHADOW; > > While I know for sure that you read up on the discussion I had with Song > about data structures, it seems you completely failed to understand it. > > > + return execmem_alloc(size, start, end, align, pgprot, > > + fallback_start, fallback_end, kasan); > > Having _seven_ intermediate variables to fill _eight_ arguments of a > function instead of handing in @size and a proper struct pointer is > tasteless and disgusting at best. > > Six out of those seven parameters are from: > > execmem_params.module.data > > while the KASAN shadow part is retrieved from > > execmem_params.module.flags > > So what prevents you from having a uniform data structure, which is > extensible and decribes _all_ types of allocations? > > Absolutely nothing. The flags part can either be in the type dependend > part or you make the type configs an array as I had suggested originally > and then execmem_alloc() becomes: > > void *execmem_alloc(type, size) > > and > > static inline void *execmem_data_alloc(size_t size) > { > return execmem_alloc(EXECMEM_TYPE_DATA, size); > } > > which gets the type independent parts from @execmem_param. > > Just read through your own series and watch the evolution of > execmem_alloc(): > > static void *execmem_alloc(size_t size) > > static void *execmem_alloc(size_t size, unsigned long start, > unsigned long end, unsigned int align, > pgprot_t pgprot) > > static void *execmem_alloc(size_t len, unsigned long start, > unsigned long end, unsigned int align, > pgprot_t pgprot, > unsigned long fallback_start, > unsigned long fallback_end, > bool kasan) > > In a month from now this function will have _ten_ parameters and tons of > horrible wrappers which convert an already existing data structure into > individual function arguments. > > Seriously? > > If you want this function to be [ab]used outside of the exec_param > configuration space for whatever non-sensical reasons then this still > can be either: > > void *execmem_alloc(params, type, size) > > static inline void *execmem_data_alloc(size_t size) > { > return execmem_alloc(&exec_param, EXECMEM_TYPE_DATA, size); > } > > or > > void *execmem_alloc(type_params, size); > > static inline void *execmem_data_alloc(size_t size) > { > return execmem_alloc(&exec_param.data, size); > } > > which both allows you to provide alternative params, right? > > Coming back to my conversation with Song: > > "Bad programmers worry about the code. Good programmers worry about > data structures and their relationships." Thomas, you're confusing an internal interface with external, I made the same mistake reviewing Song's patchset...