From patchwork Mon Jan 30 20:49:37 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: 13121825 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 0EB3FC636D3 for ; Mon, 30 Jan 2023 20:52:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AFA876B007B; Mon, 30 Jan 2023 15:51:59 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A907D6B0087; Mon, 30 Jan 2023 15:51:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7F49B6B0085; Mon, 30 Jan 2023 15:51:59 -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 64A686B007B for ; Mon, 30 Jan 2023 15:51:59 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 35F1BAB0AE for ; Mon, 30 Jan 2023 20:51:59 +0000 (UTC) X-FDA: 80412662358.10.BAC58E7 Received: from out-3.mta0.migadu.com (out-3.mta0.migadu.com [91.218.175.3]) by imf03.hostedemail.com (Postfix) with ESMTP id 8496320018 for ; Mon, 30 Jan 2023 20:51:56 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=eYNx9UpT; spf=pass (imf03.hostedemail.com: domain of andrey.konovalov@linux.dev designates 91.218.175.3 as permitted sender) smtp.mailfrom=andrey.konovalov@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1675111916; a=rsa-sha256; cv=none; b=K89u/yTdK30ldGepZIZDHar83Ef4sQA4l8w5D2PkgfAy8Go2A0xbxW85i3GejwSyAV8A/j BD8+rswT7g0wuyMfTsOZeFQVcjD9pXXHwxwNPPFLgqccBc+lZ3me2LIivozyUNO1LHfz99 4D4lCDtTZs3Kbf4vUI0bShGxEcckphE= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=eYNx9UpT; spf=pass (imf03.hostedemail.com: domain of andrey.konovalov@linux.dev designates 91.218.175.3 as permitted sender) smtp.mailfrom=andrey.konovalov@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=1675111916; 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=RlJNrgwkJjY9MAGqUmKKlmI8AUnL0lcVfhP1HY83LkM=; b=f46J91CfIhynKJA3PTSPogGZCAbdaKgm64zHnTmbwQz0v+0s9a3qjxTS9eUWJRurkB7Vdn 0p6m+GUbsyYD8bOfg+1kPElLI0tFSeo9ZMAyHBcDeogpWDuE/aaAoKTj7vCpjLV0UtVemK ye1vv9ObzDs0V9yAsPQfWNAMGw5xy80= 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=1675111915; 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=RlJNrgwkJjY9MAGqUmKKlmI8AUnL0lcVfhP1HY83LkM=; b=eYNx9UpTD8qASdAvQ2avXbDAzDV2XZyf2RCfcvrg11Z3tf9mCrYiiV6w1yAx9dx3/GBwYW pyvA7lWPKBOd+CbhHKC8yhjQP8SgvWhgeotaVOX7oF+PqX3R0B7OR1AjbnJRaZIq6CK/KL 3u69jMJaEnaHOynRgJBlAMbH9ZxnhRg= From: andrey.konovalov@linux.dev To: Marco Elver , Alexander Potapenko Cc: Andrey Konovalov , Vlastimil Babka , kasan-dev@googlegroups.com, Evgenii Stepanov , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov Subject: [PATCH 13/18] lib/stacktrace: drop impossible WARN_ON for depot_init_slab Date: Mon, 30 Jan 2023 21:49:37 +0100 Message-Id: <7e7434a0d4e8a71138aec2c8a3c69a4eebf49935.1675111415.git.andreyknvl@google.com> In-Reply-To: References: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspam-User: X-Rspamd-Queue-Id: 8496320018 X-Rspamd-Server: rspam01 X-Stat-Signature: 5tkaeqhgtgb8xshj5355fop5a5cenx5a X-HE-Tag: 1675111916-76719 X-HE-Meta: U2FsdGVkX1/6e+wEqwm3i0XL92s0mT+fbL7fpd4Lc1J+ngGVx8NbhzR+hUb+yHb9E6c8zISugbg8bG4KQUBc6itYNZ5dSSSM6PfBk5a/RY+YUS8V4Qxap3CkyuxWpw4M92P8m3JOXE9X1FyKrrepI4x35jVwJ3+3jaCjErmcKn6l1uglKa6W+68zERZnD4fbrPgMfKY5piMphuy72BQWxVWc0I61svHBKvw7pRyFdvNdsr7GQGux9Wxt0u2AgbVnBbAWzl+ctAoA99vGf7pb5qSJCB5h8EjAkXGpTFzkPgu41hmuQ/xvHuzFOqQ7ixdjV3pl6XgAWjqVhG57NGMvSX6s0C/zRLyt47ukC/tLTjtPVxuLJ0RQ3b0fw7231BdO35gJCf9g0C2yIXlnujcX6MUaewPqoNsl7twtEBwGvwe1D6rFBOjDFmuQOLWjU6Jrd1gxAeOIZ8yMmvjL880MX0XwgdhlUzdiyIEvO1gFMBWnZMX3ta3hLC8yuWr8oNGM7k2AMDYXkncmljgAy1KoGCisFVkmR6EoqdovkH7XgkxKgVFUs4J1kGnHT03LkcTc8e909PCoRbSJlM94L+jk/qDKcosfhuWkvcV6ophxc3tuqDY/Vs7dNF751ypbLkmMu7kHeGdrxBsh0Bl9U8GQqbFj3nJ6Hfd4obJ2LFUml7fwgG5OcAeMub531fe1Aa66zZY468yxNE3YqkI2APa3Gyt42AJRf836Xux3s9iBUX+SsOpZzIC/SJqovAV2SDPVTPI/D9Gb434oblsNhlnDxBIoZno0fOAZmTwO+pbkdAVxNW18g5gWr64Rkd90KFdQPsjfog3QQlgmpNAorL9G5Wv0ZBZQKQQyJFa1MWWx3Nz1cKiGiMHYz4B25JmK8Fz3bf5y+KbCcxvvVp+Q+FoPLcMnyg8YVBcpxMp/7nrQNoL5zbwCmf/twP+Cmmyk78kdXFpsCyp2dRCZe4hlxcg jVt2KaOI rgAUvVpUGVy8NHlT6soJ8xro94U3aaSpS35OVSJV7aXrGOB1hN5PF2I0a4oe1KZbwQnxIbsXrEQxZxz9mfr/gJ0e2vmHyQPNssK3xjP23RWH9UII+0dE1d9L1i/EiIVV78v4vaQTSKeOr8i/XjhIYeuk4Dw== 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: From: Andrey Konovalov depot_init_slab has two call sites: 1. In depot_alloc_stack with a potentially NULL prealloc. 2. In __stack_depot_save with a non-NULL prealloc. At the same time depot_init_slab can only return false when prealloc is NULL. As the second call site makes sure that prealloc is not NULL, the WARN_ON there can never trigger. Thus, drop the WARN_ON and also move the prealloc check from depot_init_slab to its first call site. Also change the return type of depot_init_slab to void as it now always returns true. Signed-off-by: Andrey Konovalov --- lib/stackdepot.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/stackdepot.c b/lib/stackdepot.c index b946ba74fea0..d6be82a5c223 100644 --- a/lib/stackdepot.c +++ b/lib/stackdepot.c @@ -218,16 +218,14 @@ int stack_depot_init(void) } EXPORT_SYMBOL_GPL(stack_depot_init); -static bool depot_init_slab(void **prealloc) +static void depot_init_slab(void **prealloc) { - if (!*prealloc) - return false; /* * This smp_load_acquire() pairs with smp_store_release() to * |next_slab_inited| below and in depot_alloc_stack(). */ if (smp_load_acquire(&next_slab_inited)) - return true; + return; if (stack_slabs[slab_index] == NULL) { stack_slabs[slab_index] = *prealloc; *prealloc = NULL; @@ -244,7 +242,6 @@ static bool depot_init_slab(void **prealloc) smp_store_release(&next_slab_inited, 1); } } - return true; } /* Allocation of a new stack in raw storage */ @@ -271,7 +268,8 @@ depot_alloc_stack(unsigned long *entries, int size, u32 hash, void **prealloc) if (slab_index + 1 < DEPOT_MAX_SLABS) smp_store_release(&next_slab_inited, 0); } - depot_init_slab(prealloc); + if (*prealloc) + depot_init_slab(prealloc); if (stack_slabs[slab_index] == NULL) return NULL; @@ -436,7 +434,7 @@ depot_stack_handle_t __stack_depot_save(unsigned long *entries, * We didn't need to store this stack trace, but let's keep * the preallocated memory for the future. */ - WARN_ON(!depot_init_slab(&prealloc)); + depot_init_slab(&prealloc); } raw_spin_unlock_irqrestore(&slab_lock, flags);