From patchwork Mon Nov 20 17:47:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: andrey.konovalov@linux.dev X-Patchwork-Id: 13461836 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 58172C2BB3F for ; Mon, 20 Nov 2023 17:50:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D78B76B038C; Mon, 20 Nov 2023 12:50:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D02D56B0391; Mon, 20 Nov 2023 12:50:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B2D8A6B0390; Mon, 20 Nov 2023 12:50:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 7EA5F6B038D for ; Mon, 20 Nov 2023 12:50:48 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 6176B16093A for ; Mon, 20 Nov 2023 17:50:48 +0000 (UTC) X-FDA: 81479072976.20.338D882 Received: from out-174.mta1.migadu.com (out-174.mta1.migadu.com [95.215.58.174]) by imf03.hostedemail.com (Postfix) with ESMTP id B282120016 for ; Mon, 20 Nov 2023 17:50:46 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=WmK6Qhek; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf03.hostedemail.com: domain of andrey.konovalov@linux.dev designates 95.215.58.174 as permitted sender) smtp.mailfrom=andrey.konovalov@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1700502646; 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=mWJyEm6VyaOWhREL8AAhhvtbKxcDTX0iHOdq2I7biaE=; b=RBSTdDKgI8MfRIb5+1881pMdSdSIrxTJ1TWXD5Y87kODowI3jPMajRtj+gkqg3i4zXENNc aJ3jFA8Rm0MB8UkS5kgK2N/q6S8YaIeLBmSi2ANKcEUhEJ8Tk6L12o84GcSQK+tTrqcWvz tHEFBxgK5ufMuNIARSn2W3MIE+Ihiew= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=WmK6Qhek; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf03.hostedemail.com: domain of andrey.konovalov@linux.dev designates 95.215.58.174 as permitted sender) smtp.mailfrom=andrey.konovalov@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1700502646; a=rsa-sha256; cv=none; b=8Vwn6Lyp5SRLMmKaFUqR3NwsaCiXusVwO/hurluiWG2qvL6MLibVqIJOcrL4spQHIhr4SV v0rot5RaVeyufGauHG6gcr5KGfw4mRKApcUGPZi1IEoJuvkT6X6N4OLi2+fRWBE5EU56MK u7VreEwjMv3XikGyVBWTIijtFmeh5w4= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1700502645; h=from:from:reply-to:subject:subject: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=mWJyEm6VyaOWhREL8AAhhvtbKxcDTX0iHOdq2I7biaE=; b=WmK6QhekX7FInJyHV2uIR20pRmvpYax2GIBAaZMlPJyA0fa28yyqkU2wHc9EZkcNKhaGVw rpPS5IdkJL5crjQMbxbFNxa8MnpB9QR4IgbAId2GDpPOic2y+TwrC0P2SZxzr/nb1ApKtj eY3o0dSnWGXhfqV2/RcUKsx+woR/BOo= From: andrey.konovalov@linux.dev To: Andrew Morton Cc: Andrey Konovalov , Marco Elver , Alexander Potapenko , Dmitry Vyukov , Vlastimil Babka , kasan-dev@googlegroups.com, Evgenii Stepanov , Oscar Salvador , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov Subject: [PATCH v4 22/22] lib/stackdepot: adjust DEPOT_POOLS_CAP for KMSAN Date: Mon, 20 Nov 2023 18:47:20 +0100 Message-Id: <301a115cf7ce8ddb42ef6de9151c2bb76ba728fc.1700502145.git.andreyknvl@google.com> In-Reply-To: References: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspamd-Queue-Id: B282120016 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: 9bt6yhsormzcfea9hztejso4yp3916it X-HE-Tag: 1700502646-962587 X-HE-Meta: U2FsdGVkX19L9dM3YHXWugfm4pcuAacDEKi7uYqw/qaSRYPHWiR1W9r5nL1gd27kPEYB+KfLKNPj8IV1UnK62l7eVx0vCPYaPeBqZF4pMPw1x4LlaJKVogSKXxNoHBOX11faDitT+VBLd2RT3RqKNXcRLDWo4qecWXy1bIQWLmQoyJ2B+dbVD5cT1Fv81ztGG3odBX0htzkFU3ZwoVOCEO60j6fvFq+GQ03UysTRAc5ryjOdIdwfvv+Emb3ZboXEy1JoN1HzBznJ+T9090WNZoO5WCFMVU2ZwRQFisnLDprpY9YCp7129U/RkZXcbKvRs+kSr05lhty3+15+pKIwTzRDqEYLRB2T7Bew/G4hHwP8G9ADl+8lPR85T5uvr/7/uNvweppttx/i4uxNeGgXiDlrjkb5+6Jj5CKpT8EV6/nGebnRUaZOiqWc7ZGTjNpEcTjFHwsuisyWMHeTsIBGoWxaY2cwqyT8igFx0F/GAH++Lm89K6M74jP5eg9qgrGXwBM+0YMKT4E4q7cG+cQrMKtwsiE2AT87Ik+rmf4KvWfFltxIjFit+m+d9FYfT4QnH1BACyuoqco6HCLTUqkqkl0S6Zn58jKSoAPgYrEYb4BX/Z4HzuPddHHun3vwdZS1P5v3WXTimrGTRANMfrCta8wlqKIQiF+eGH5wrF49pCNoXPa4JIJ0YVx4Jep1jvgmnym5jIqNu9qkUMgXV9SVfrtnf/PgaP54ltFTv3DF/dwnIUmFZUJdgz6Xc59pQ4+PT46ohoutdfk6rkXmbhu+o2CTrxrW8pS6exJNuxj4dIaXsOPfVOshuWHZxeMxnS7fKRcSW7ksQv5aGA3mHRZBY75sgadqVanXiOB0iFwHBNasiZb/vFVOti3qZs2vArhU0YbSvOHL/+VjwZrxAEx7PQlha/t6A1ehPVZPM+ukCL2JurT2Xu5CTq1f2AkfZmA56akRBQoqVfN0+aNWEyv kdI351JH q9nuwUbj58BX4R/XtGKep70cTnGhzjwFODk0Dz/w+wUezlelCdSHDePQk+Q3u5HS8H+HIwEIrdmgER6Fu+kD2L+3IyS00ICE86hrds2leoT0Img4= 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: From: Andrey Konovalov KMSAN is frequently used in fuzzing scenarios and thus saves a lot of stack traces. As KMSAN does not support evicting stack traces from the stack depot, the stack depot capacity might be reached quickly with large stack records. Adjust the maximum number of stack depot pools for this case. The average size of a stack trace saved into the stack depot is ~16 frames. Thus, adjust the maximum pools number accordingly to keep the maximum number of stack traces that can be saved into the stack depot similar to the one that was allowed before the stack trace eviction changes. Signed-off-by: Andrey Konovalov --- lib/stackdepot.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/stackdepot.c b/lib/stackdepot.c index c1b31160f4b4..870cce2f4cbd 100644 --- a/lib/stackdepot.c +++ b/lib/stackdepot.c @@ -41,7 +41,17 @@ #define DEPOT_OFFSET_BITS (DEPOT_POOL_ORDER + PAGE_SHIFT - DEPOT_STACK_ALIGN) #define DEPOT_POOL_INDEX_BITS (DEPOT_HANDLE_BITS - DEPOT_OFFSET_BITS - \ STACK_DEPOT_EXTRA_BITS) +#if IS_ENABLED(CONFIG_KMSAN) && CONFIG_STACKDEPOT_MAX_FRAMES >= 32 +/* + * KMSAN is frequently used in fuzzing scenarios and thus saves a lot of stack + * traces. As KMSAN does not support evicting stack traces from the stack + * depot, the stack depot capacity might be reached quickly with large stack + * records. Adjust the maximum number of stack depot pools for this case. + */ +#define DEPOT_POOLS_CAP (8192 * (CONFIG_STACKDEPOT_MAX_FRAMES / 16)) +#else #define DEPOT_POOLS_CAP 8192 +#endif #define DEPOT_MAX_POOLS \ (((1LL << (DEPOT_POOL_INDEX_BITS)) < DEPOT_POOLS_CAP) ? \ (1LL << (DEPOT_POOL_INDEX_BITS)) : DEPOT_POOLS_CAP)