From patchwork Fri Feb 10 21:16:00 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: 13136461 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 81CE0C05027 for ; Fri, 10 Feb 2023 21:18:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1C9CD6B0195; Fri, 10 Feb 2023 16:18:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 184296B0198; Fri, 10 Feb 2023 16:18:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 068A26B0199; Fri, 10 Feb 2023 16:18:21 -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 EAC1D6B0195 for ; Fri, 10 Feb 2023 16:18:20 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id C0BB9A0601 for ; Fri, 10 Feb 2023 21:18:20 +0000 (UTC) X-FDA: 80452645560.23.DFEA27E Received: from out-40.mta1.migadu.com (out-40.mta1.migadu.com [95.215.58.40]) by imf28.hostedemail.com (Postfix) with ESMTP id D13DBC0016 for ; Fri, 10 Feb 2023 21:18:18 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=b9EI77+L; spf=pass (imf28.hostedemail.com: domain of andrey.konovalov@linux.dev designates 95.215.58.40 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=1676063899; 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=QNTpFR8imhU+1RyFIUQnZTnn23HrW1qgGxbRYaqWOq4=; b=u3EK6mjGDr9Q4r5K/KzGgYWEMmckiBXMXzPG+V1uz6Z9lZdDsbq4zrQKvy/gpIl5vxp26F DKOUbo5877OqGUTRMNcqtVKCx4tf6F+xOfMa/4Do8O8N7ZzNASeSNFd18/Dh1drvJG5JLq 1VKlLj+lgP8ix87Xwo07LGfNiPNw5m0= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=b9EI77+L; spf=pass (imf28.hostedemail.com: domain of andrey.konovalov@linux.dev designates 95.215.58.40 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=1676063899; a=rsa-sha256; cv=none; b=tdkID6RRAawJ3nWJVGk9IrkIzs+jjnisUoa1pY1DlejuLmvOz73zH7OY7E4mXbOUeBaG40 dxsfVEbkN22Lbx1h2mHEVHWMlfh00syRfTKVA28f4dmC8UEEZnrszrKhD7sbDV66qrGf8H zJQEx/lS9Xr+pfER9A+0tsvcrfL6NbY= 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=1676063897; 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=QNTpFR8imhU+1RyFIUQnZTnn23HrW1qgGxbRYaqWOq4=; b=b9EI77+Lu2ejg1Id6cPrNsMBDYr8WIpJ2zMEg4RXlgJI+QYF6OL/oaxKk1OH2WIRdUewQW zBxE8rT/+Ts7luOzOazTc5KLDee/mIDM5G27VvuS9X7RoT9lIJeLwV8TTioXm6vGFwrCjU VRzh0cOmh0kJxe7ubs0kkTWdypYXNt4= 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 v2 12/18] lib/stacktrace: drop impossible WARN_ON for depot_init_pool Date: Fri, 10 Feb 2023 22:16:00 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Stat-Signature: cxptuusigy4bwq4kyqof6181nxsyhhp5 X-Rspam-User: X-Rspamd-Queue-Id: D13DBC0016 X-Rspamd-Server: rspam06 X-HE-Tag: 1676063898-616571 X-HE-Meta: U2FsdGVkX19mEJ9QN1+slWkNdyofrQjgyhw8VFfvW2Lg6+jz0sVTcQdWXYMBNe8LTNhc+mpqPVBwqkMZeZSbTa40/1Q40XXgaAZ/2kA9vmzAOPExwxNZ9n3Xe2+v3M91qh/Ght+um7SdoE0AdIf/hU1Jr+7lMmAdhQ+pAooz/hi25Zut3HYRrxFB2/eJl18n5wFSu1PeEOpFw/xHVpPmBMbeXpG7PQthXVBAh3/XAyVlAd9Y4h2ZBsflA4e4XULdtlFi7Q192L7iwZlTexUgpabttJM4QDMdqoUu9s+AHCrKc+aYlBCXNszRplwef9+rBnH4QyzNFkop+5Z2NaAtziip8Df12Av9q1MaQqWXbIZXoUUjZN/VjN94rVxUN5loePQGaboCIU11L9/iLubmmNYTAXzWzIDpeCQNuGxXxHmjAsqfVCQeGfJO2mqygD2CHZMmTmyBAehLhede+xXhD1+qFMEIgJDvuNwsmR90ItRlVCUEJrbHi7RvpN9Wnh9RXawMFK8Rf83hVqQNQBR9pro/t0eLRMEuNLAdeArFc2PtwmJ7jL69/y+tRATlVWpsLsoPETu7dXIBVaZDgx7zY17c3cvQSbpOw2YOYk894DGgP8s9HIQ3rjO/3TCdvO1XK6YQRUaCYn4Nb1jyXujt2E9U5HaOiHtpCRIqc6pVZIF3yimTZk8xQmiutFwxtH9Id3RudseE5RGm438lhNA9ttwMZRNhUiYOaSSdxgcv1Sgwnxj6J7RSzvVMCkdwUxDL+MD2olpU5pt4n1T4RQA59t+xClqJOZ0hAkHZcxSL2KF+uMOqIChs+FenvB88JwOy+KwRlyvhsxolM93oqFFirWbM5jp5c2FvyurMC2wTsxui+S4Wx++qt3UloFK/9QRmtlCExEguaNAs20spPG1Dt/u2ZxB5rR2VVfZ2PkFyRyxo6FcsYCLKb5fMHeqaoh3RNljBVcK3FttoK63j8xt QISnp6MV M7y4dGcmz6pda7uefs0/5/t6GB6Lk0g6EVZkTFfA7e9XsCvG6bI5R3VHxXK1PIlzIcTOolmMwrK+Y+UCnwgkUFZpXjEk+aYVamDHY0+rriELKd+6Y3OSVXKQGBzaqbcwRWVtgJ8p4NWR+GJ39aym2f1Xcbw== 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_pool 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_pool 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_pool to its first call site. Also change the return type of depot_init_pool to void as it now always returns true. Signed-off-by: Andrey Konovalov Reviewed-by: Alexander Potapenko --- lib/stackdepot.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/stackdepot.c b/lib/stackdepot.c index 7f5f08bb6c3a..d4d988276b91 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_pool(void **prealloc) +static void depot_init_pool(void **prealloc) { - if (!*prealloc) - return false; /* * This smp_load_acquire() pairs with smp_store_release() to * |next_pool_inited| below and in depot_alloc_stack(). */ if (smp_load_acquire(&next_pool_inited)) - return true; + return; if (stack_pools[pool_index] == NULL) { stack_pools[pool_index] = *prealloc; *prealloc = NULL; @@ -243,7 +241,6 @@ static bool depot_init_pool(void **prealloc) */ smp_store_release(&next_pool_inited, 1); } - return true; } /* Allocation of a new stack in raw storage */ @@ -270,7 +267,8 @@ depot_alloc_stack(unsigned long *entries, int size, u32 hash, void **prealloc) if (pool_index + 1 < DEPOT_MAX_POOLS) smp_store_release(&next_pool_inited, 0); } - depot_init_pool(prealloc); + if (*prealloc) + depot_init_pool(prealloc); if (stack_pools[pool_index] == NULL) return NULL; @@ -435,7 +433,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_pool(&prealloc)); + depot_init_pool(&prealloc); } raw_spin_unlock_irqrestore(&pool_lock, flags);