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 6D081C5475B for ; Fri, 8 Mar 2024 20:59:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C3FE96B03EE; Fri, 8 Mar 2024 15:59:09 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BF03A6B03EF; Fri, 8 Mar 2024 15:59:09 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ADF606B03F0; Fri, 8 Mar 2024 15:59:09 -0500 (EST) 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 9FBBB6B03EE for ; Fri, 8 Mar 2024 15:59:09 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 3540E412A2 for ; Fri, 8 Mar 2024 20:59:09 +0000 (UTC) X-FDA: 81875086818.08.1224078 Received: from out-170.mta1.migadu.com (out-170.mta1.migadu.com [95.215.58.170]) by imf03.hostedemail.com (Postfix) with ESMTP id 0FC5920014 for ; Fri, 8 Mar 2024 20:59:06 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=YchRsTnI; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf03.hostedemail.com: domain of kent.overstreet@linux.dev designates 95.215.58.170 as permitted sender) smtp.mailfrom=kent.overstreet@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709931547; 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=16tltxVeMMEw9pz0FgVo7SBn8wQw+mbWn8zd0k+HEg4=; b=Zh8nYPpUqo/unU/nlpNy/x4ZRy1KASM/Keltm03qp931O1AaJXtMyizKx9zPmGb+RJUu6S yhbCeV/1NyxYWyDeSTj3euuBLcMEYEHIhvksgMksKvfXpy+ETcKf71ZSX5/4NkSUSyBqYM etI3EwFbcQY6OEjZS9L4qXgfaeXV92o= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=YchRsTnI; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf03.hostedemail.com: domain of kent.overstreet@linux.dev designates 95.215.58.170 as permitted sender) smtp.mailfrom=kent.overstreet@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709931547; a=rsa-sha256; cv=none; b=gBCKQOa0UTAaxSEDIjiDafgVfZ4w1Mc3guxItFaIuS/EZHy9j4JYwhTmqdGjLJj1nbNy8F V4i77s7WtAJ/6s/U0uC6Xy007S5TdPoK+AhZFCh7pEt9wZbarTF9+8UxVmJDgu+OiR8ddE AKd4lk35WiisAycIubV4JMCLR3GfLeo= Date: Fri, 8 Mar 2024 15:58:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1709931544; 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=16tltxVeMMEw9pz0FgVo7SBn8wQw+mbWn8zd0k+HEg4=; b=YchRsTnIUKCyE218om24MGZqG7uNt1OY8Y42Fw87BWNmdbKNMXwHtUlHYfS+h7ySACFA7L cleRRhE8hjpxTk716zFNbZOS27KBbyZVVwlDufTC+1h7SDEig2ed5xWn/oOroo6zf3sxFW Ldqn0WgiMqgvnDVBr0sf4V7CRvWAQqQ= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Kent Overstreet To: Matthew Wilcox Cc: "Christoph Lameter (Ampere)" , linux-mm@kvack.org, Vlastimil Babka , Andrew Morton , Pekka Enberg , David Rientjes , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com> Subject: Re: [PATCH] mm/slub: Make __ksize() faster Message-ID: References: <20240308031325.218676-1-kent.overstreet@linux.dev> <6iv6cmclbkx4vrhpohjlg6r3pf7cf3nsgiydycmsmlhsrjo4bd@bohvkgia6wyx> <9b609df3-b4af-e0fa-dcbe-1358cd317194@gentwo.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 0FC5920014 X-Stat-Signature: 73nntezx5k7e7s6zx8gkh3kun4hc6s79 X-HE-Tag: 1709931546-144366 X-HE-Meta: U2FsdGVkX180UCzYn5UZBlUCQYvdtONmGvtbK3+S/Lmw/SiZn6STSSdpT0dNdN6LJMg4PWkhBWi/wChPo4MNshZMH6AJKppMCdMrmEGng02hdZZ8Q26zKEcjLIhBYrPvMIY4eaUmJnnFJReVaTJl+QnaSwKKePV1WpHFLOcSTyrnQtgwLi8EmnT6VDgIGkDXmbkLzRRCQyWL6YdbN745jFNrCtjJGcZQYs4Zk+yl+TzQzYJPZe3EIxT97umTOeZ2XG81xbqLuHLkEI53TB5PsDHHl8/EbQVLIfBg3NCBZnU+Q1Tc+EgKbR6zb8ax7Ozlgs+CEoAnamFhbVPMYX+og0rCZwbiiME234n5pSsOgrluN+lVfkHBBIElzqKF9QrUfD39ezvhwxjcBpJ3P8NYEUqeYXPly0oB1/atWxc8XT/+qXaPVfyQBE+FuzBtEahdMNUfexfKb/XSiff/+0eTXP+DnD49QzKiZwKildGY819tcMyVTbNXh2vtuVHtrhRB4bNB6s5TE8TR+8qeDqBZsP2VghETgF8rMid/skTeqvTEV01e5EKz84rhv9HxDwjwiwa7R1FG1NTsjjC/h1cRpra0a235Do5YtGYDF2P/IaHLNK8Ih2SDxdsNScrjVSgB3h0md7BuHH3HBF2OviZIlURYO3koTxmLWZ1XCpqQbbITm+c5JosZFP13aHMJW7JbfMj4mPeL3aQhCzCmpq2iLv4LkZX/5L4Pl0ISrE/KI6yrJt8bxdAto9a/4a6nXTWoMCANF4h60A61tZwSwchQrE8022dXfyr/soZF5fbQcgCSVS6bkHJspRviIUwjz/Q4RwBpnYqfjoi5kFmdy/p9PGa1TwPmZ0TiXZYtYugXWbjR7YUB62Tx6jMNSB5NYwhWWPrXDlP60b+SYbltoSwobx+h73VbfJ69UHe5rpuQe/0vSLrIfz9Hzz6i5EqcK8DhIUwAluLYKQ77wwsOnC9 ruHjIebR tb+S8tALV2EAhGutuCuf+ddlIfnJYwFpTRzBfCzUuX/Qim5mqb4fP7rOQoWdqnp2qImkwRrsNLNrtUQXGHHZfev8wSsHfJjSMZOHlyJLgj2rKU80gbfne7jg41RFx/IEiKP4dbsTe68XONyaoqe7ZeHSOcdHTHjtNy6mT08GHmQpg7sT5fH4ZfVTdRN55as3ysROl 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: List-Subscribe: List-Unsubscribe: On Fri, Mar 08, 2024 at 06:26:11PM +0000, Matthew Wilcox wrote: > On Fri, Mar 08, 2024 at 09:12:06AM -0800, Christoph Lameter (Ampere) wrote: > > > > > On Fri, Mar 08, 2024 at 11:27:32AM -0500, Kent Overstreet wrote: > > > > On Fri, Mar 08, 2024 at 02:58:48PM +0000, Matthew Wilcox wrote: > > > > > There are potentiually better uses for those bits. We could turn > > > > > folio_test_slab() into a PageType test, freeing up a page flag. > > > > > > > > They overlap _mapcount, did you figure out how to use that for a > > > > PageType enum? > > > > > > In 2018 ... 6e292b9be7f4358985ce33ae1f59ab30a8c09e08 > > > > > > > This seems to be 32 bit field. We could segment that into two unsigned > > shorts. In fact any operation on a slab larger than 2xPAGE_SIZE is directly > > turned into a page allocator call bypassing slub. So you only need 0 ... 2 * > > PAGE_SIZE for the range of the int. > > Are there any CPUs with PAGE_SIZE > 65535? ;-) > > It could, just about, be done. Although not on Hexagon with its crazy > 256kB page. Right now, I reserve 0xf000007f to catch over/underflow, > although this is perhaps excessive and I could get away with just > 0x8000007f. That leaves 24 bits. We've currently got 4 in use, and I > want to add two more (Slab and HugeTLB), so there's 18 bits remaining. > > So is it really worth burning all the remaining bits on implementing > ksize with one fewer pointer dereference, given that struct kmem_cache > is read-mostly and should live in the CPU cache quite well? Ok, this is the first I'd seen of these PageType shenanigans :) That definitely takes priority over shaving cycles here; but could we clean that up and expand it? Does it really need to be a bitmask? And really, enums should be enums (that we can give a proper type name to) not #defines and raw ints. If we did that, and killed PG_slab and made it part of the PageType enum, that frees up a few bits.