From patchwork Mon Nov 20 08:42:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 13460931 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 A3AC5C5AD4C for ; Mon, 20 Nov 2023 08:43:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 32F0F6B0409; Mon, 20 Nov 2023 03:43:17 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 307906B0408; Mon, 20 Nov 2023 03:43:17 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 159916B0409; Mon, 20 Nov 2023 03:43:17 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 037056B0406 for ; Mon, 20 Nov 2023 03:43:17 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id A2F7AB5863 for ; Mon, 20 Nov 2023 08:43:16 +0000 (UTC) X-FDA: 81477693192.21.47ECDCC Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf19.hostedemail.com (Postfix) with ESMTP id 911791A0003 for ; Mon, 20 Nov 2023 08:43:14 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=18reAZ2y; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=b4bGvsyU; dmarc=pass (policy=none) header.from=suse.de; spf=pass (imf19.hostedemail.com: domain of osalvador@suse.de designates 195.135.220.29 as permitted sender) smtp.mailfrom=osalvador@suse.de ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1700469794; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=9KwZyfV7MQI2yuPA0zEe5ABuumoWkd6UHOrlY+2DXtc=; b=Y0cGXhwHcBz7OrYb5Yd8DunSC4ANSM0bmjY75T4wRxffKmLEsqMgjsGc6qU7ITPasqS/YZ SCsyamP5I2gAD5dSR3b4lsW4FwMh/tzPvelZgJrnAUrZjzdz3D7OPX7lQ2tPRSmS6hPpSr laa606WKS8FM1V9Bf+VTXCZ1+M5g8LA= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=18reAZ2y; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=b4bGvsyU; dmarc=pass (policy=none) header.from=suse.de; spf=pass (imf19.hostedemail.com: domain of osalvador@suse.de designates 195.135.220.29 as permitted sender) smtp.mailfrom=osalvador@suse.de ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1700469794; a=rsa-sha256; cv=none; b=OjuhHCTvy5jh6n2NLhbo0YC6o9vFY5obFGsxNIuDLfEP/OYgeDyCCpLCXaR9ELLUepe1FA F6FZtEiqEhV4a6CndhxwAroTvgzfg/X92uq7xkVBaaharhvqbfhD/rJ5AOdd702BEZnZNI c3GMrpGcDJu1114mdxLgBo8ldXOmUJU= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 445531F750; Mon, 20 Nov 2023 08:43:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1700469793; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9KwZyfV7MQI2yuPA0zEe5ABuumoWkd6UHOrlY+2DXtc=; b=18reAZ2yAcdBFEdQaz+5irPkXXOsJxea/MYnsQ2USIGUzIzALXtdh1iC3nRFOl3Fa83l0D OHUw1+MIjrSfQuR9T8l4yChyFrGeIZjwyqpLPP6qgjQHsoEGBnlbt5vPwMxGsOeXi6z/D3 wABxJWx6Ce7ztWJih95VFqr3pWmgcIY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1700469793; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9KwZyfV7MQI2yuPA0zEe5ABuumoWkd6UHOrlY+2DXtc=; b=b4bGvsyUeKGgJYWUfFX4xb35t3MGvceX54PAP448j1O6i8ZNYOXZEHgJ7q0xT4BPOq49pN NJmqUYfaGjEVT4AQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 8CA3413912; Mon, 20 Nov 2023 08:43:12 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id IEt/HyAcW2U3VgAAMHmgww (envelope-from ); Mon, 20 Nov 2023 08:43:12 +0000 From: Oscar Salvador To: Andrew Morton Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Michal Hocko , Vlastimil Babka , Waiman Long , Suren Baghdasaryan , Marco Elver , Andrey Konovalov , Eric Dumazet , Alexander Potapenko , Oscar Salvador Subject: [PATCH v6 2/4] lib/stackdepot: Move stack_record struct definition into the header Date: Mon, 20 Nov 2023 09:42:58 +0100 Message-Id: <20231120084300.4368-3-osalvador@suse.de> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20231120084300.4368-1-osalvador@suse.de> References: <20231120084300.4368-1-osalvador@suse.de> MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 911791A0003 X-Stat-Signature: o6sesuw5z78g7bwek8zcysp1ftsfm83a X-Rspam-User: X-HE-Tag: 1700469794-932269 X-HE-Meta: U2FsdGVkX18nqyi38sWG1ZI5V/iyAZNBsylhcLEkYbGPEopdhLNuCDCJMVzyQ3CRcUnM13OFGKvrrKzLJdPSSOWNr+YA/q7FGt0FmJKHPir1xgisEPzw5RBkmr2lg4prh305NcfPMOYYzKf8EdJVII4UoR0YxbKDgZgmz4B0GlqGXGBRvZjhULbJBIxVQNFSiR4sk85BHSsJL6/1OLocwWNHqwGf+yhjPbo0IkENcF+uQZv3oyHg4ydCWEZ+kbIY3hqONxzdpvACfRDfAH74TxVquqCgrhHAwAnl0RbR/uGgiJaOGXORs9WkNB7+X63NkZwzVSiL7jDstdrDuvR7r67C+uA5jKKuUY7rHsXblO/UrHtBWFByrytWq/LFj2SEIn03yzyYy4bqIEVpgSC/XnTZ1zojQ9SlZFxQkaDHFFUaJ9lUxZME4U+O2+BtfzZSCiIGOWbIqRTyJLATl3EN263rwQjQ6wMnwY8YCBUY7dHTXKoL3E4JItRFD/eZ0NnGt8UcQEkAHy9/dacYNgwY+fVsDeVHA8bYHY7TpuMv4eJynwdSPTbqaw2CjcjgQ69v3AXFLr0SxvQXEmZFLaVljuUFIe3Axk+IdJmngWfmIpJgE/jxk4w7Wm5vRJrjHkdyd6gJvI38jmWT/VN1Bh+/bWT4abTE20tfYbl8FgSlCRCbduW4pi0vl+a1wy3qUBMKLA5NA4bdm0Wbsm4lcVMZkZE3yRJr2IUtr/SBLW26H+udj074y5ZPnUm/TGagvdbpMbzEtGfMY55yT4/utB/pfVM+pTwouRvPKA1z5L7O1SKbrhbgoignjRTKIMY2i9LtqN6z5BcHLpSsIHbrFciRJuCmTEaZmA/AReFZk6pojNRtNFrJxhQzwXo6l74UNr4kb17jrHcZG1eiKGJBE6fvoj4880qiXa8GYgHH144MmUvzwd6xonn/tj1dx2mvnb8AzoHF0T/3vJRd3nszGwo sMtK6EKy k/cG+ni3WXV96KgAmqjKUcof2b8wrs2eQUMYnJALQHmXM05PaAJ62r5qwP0wWDBnZMO71KOmvZIe/cAI4ix2AZ5nlbOfnbVV5Fby6bhCBshNcJULnygwxWlFQrn2kLIPx0hEckjHT9zCk0r5doQGnfISSUGpT52SWdMHkKnwAjtOoS2JQ2f7DAd6caz2kg6KPD4NnqKXfmv/7AnCxfwK+CG7mGNAeTnSN+4ke83eHcTd26kgypYdnn2jHbw9/XfxCS7BP 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: In order to move the heavy lifting into page_owner code, this one needs to have access to stack_record structure, which right now sits in lib/stackdepot.c. Move it to the stackdepot.h header so page_owner can access stack_record's struct fields. Signed-off-by: Oscar Salvador --- include/linux/stackdepot.h | 34 ++++++++++++++++++++++++++++++++++ lib/stackdepot.c | 34 ---------------------------------- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/include/linux/stackdepot.h b/include/linux/stackdepot.h index 6ba4fcdb0c5f..269a828a5e94 100644 --- a/include/linux/stackdepot.h +++ b/include/linux/stackdepot.h @@ -32,6 +32,40 @@ typedef u32 depot_stack_handle_t; */ #define STACK_DEPOT_EXTRA_BITS 5 +#define DEPOT_HANDLE_BITS (sizeof(depot_stack_handle_t) * 8) + +#define DEPOT_VALID_BITS 1 +#define DEPOT_POOL_ORDER 2 /* Pool size order, 4 pages */ +#define DEPOT_POOL_SIZE (1LL << (PAGE_SHIFT + DEPOT_POOL_ORDER)) +#define DEPOT_STACK_ALIGN 4 +#define DEPOT_OFFSET_BITS (DEPOT_POOL_ORDER + PAGE_SHIFT - DEPOT_STACK_ALIGN) +#define DEPOT_POOL_INDEX_BITS (DEPOT_HANDLE_BITS - DEPOT_VALID_BITS - \ + DEPOT_OFFSET_BITS - STACK_DEPOT_EXTRA_BITS) +#define DEPOT_POOLS_CAP 8192 +#define DEPOT_MAX_POOLS \ + (((1LL << (DEPOT_POOL_INDEX_BITS)) < DEPOT_POOLS_CAP) ? \ + (1LL << (DEPOT_POOL_INDEX_BITS)) : DEPOT_POOLS_CAP) + +/* Compact structure that stores a reference to a stack. */ +union handle_parts { + depot_stack_handle_t handle; + struct { + u32 pool_index : DEPOT_POOL_INDEX_BITS; + u32 offset : DEPOT_OFFSET_BITS; + u32 valid : DEPOT_VALID_BITS; + u32 extra : STACK_DEPOT_EXTRA_BITS; + }; +}; + +struct stack_record { + struct stack_record *next; /* Link in the hash table */ + u32 hash; /* Hash in the hash table */ + u32 size; /* Number of stored frames */ + union handle_parts handle; + refcount_t count; /* Number of the same repeated stacks */ + unsigned long entries[]; /* Variable-sized array of frames */ +}; + /* * Using stack depot requires its initialization, which can be done in 3 ways: * diff --git a/lib/stackdepot.c b/lib/stackdepot.c index d35edac430c4..1343d3095bc1 100644 --- a/lib/stackdepot.c +++ b/lib/stackdepot.c @@ -30,40 +30,6 @@ #include #include -#define DEPOT_HANDLE_BITS (sizeof(depot_stack_handle_t) * 8) - -#define DEPOT_VALID_BITS 1 -#define DEPOT_POOL_ORDER 2 /* Pool size order, 4 pages */ -#define DEPOT_POOL_SIZE (1LL << (PAGE_SHIFT + DEPOT_POOL_ORDER)) -#define DEPOT_STACK_ALIGN 4 -#define DEPOT_OFFSET_BITS (DEPOT_POOL_ORDER + PAGE_SHIFT - DEPOT_STACK_ALIGN) -#define DEPOT_POOL_INDEX_BITS (DEPOT_HANDLE_BITS - DEPOT_VALID_BITS - \ - DEPOT_OFFSET_BITS - STACK_DEPOT_EXTRA_BITS) -#define DEPOT_POOLS_CAP 8192 -#define DEPOT_MAX_POOLS \ - (((1LL << (DEPOT_POOL_INDEX_BITS)) < DEPOT_POOLS_CAP) ? \ - (1LL << (DEPOT_POOL_INDEX_BITS)) : DEPOT_POOLS_CAP) - -/* Compact structure that stores a reference to a stack. */ -union handle_parts { - depot_stack_handle_t handle; - struct { - u32 pool_index : DEPOT_POOL_INDEX_BITS; - u32 offset : DEPOT_OFFSET_BITS; - u32 valid : DEPOT_VALID_BITS; - u32 extra : STACK_DEPOT_EXTRA_BITS; - }; -}; - -struct stack_record { - struct stack_record *next; /* Link in the hash table */ - u32 hash; /* Hash in the hash table */ - u32 size; /* Number of stored frames */ - union handle_parts handle; - refcount_t count; /* Number of the same repeated stacks */ - unsigned long entries[]; /* Variable-sized array of frames */ -}; - static bool stack_depot_disabled; static bool __stack_depot_early_init_requested __initdata = IS_ENABLED(CONFIG_STACKDEPOT_ALWAYS_INIT); static bool __stack_depot_early_init_passed __initdata;