From patchwork Mon Oct 23 16:22:40 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: 13433189 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 46486C004C0 for ; Mon, 23 Oct 2023 16:24:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D431C6B0101; Mon, 23 Oct 2023 12:24:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BE7A26B0104; Mon, 23 Oct 2023 12:24:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9C2A16B0105; Mon, 23 Oct 2023 12:24:08 -0400 (EDT) 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 6B68B6B0102 for ; Mon, 23 Oct 2023 12:24:08 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 4FA38C012E for ; Mon, 23 Oct 2023 16:24:08 +0000 (UTC) X-FDA: 81377248176.23.B6DA5E0 Received: from out-202.mta1.migadu.com (out-202.mta1.migadu.com [95.215.58.202]) by imf09.hostedemail.com (Postfix) with ESMTP id 7A0B114003D for ; Mon, 23 Oct 2023 16:24:06 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=NfBcevWE; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf09.hostedemail.com: domain of andrey.konovalov@linux.dev designates 95.215.58.202 as permitted sender) smtp.mailfrom=andrey.konovalov@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1698078246; a=rsa-sha256; cv=none; b=g7LCTymF67/uGO4ttr9NNlIXsavnRoq2dH7qr9HAnoVVttoLYw+cLlEyoo/lAbxU6OYsyw +VXeUIUxUjagQH/fGbgZLrD/AyCy+7WFf5/midexa6sZpgAXlYLIrK8eXKboINcjwi8NDr ffArikJSGNgWXAL2bU9H2Zce8i2Ir7o= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=NfBcevWE; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf09.hostedemail.com: domain of andrey.konovalov@linux.dev designates 95.215.58.202 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=1698078246; 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=ApzhSzVlCGqOU4aCEVUKgk2/C6zStSgrVwNwdDBjs8U=; b=pmNRvaBAQ06AkZ/wCOJemNIjm+sdsUKkUjlAMsB1npDozfpZMReqT7mYhgwdT9NKRT958V PVa+P/eQ9mGlB1tnj2ttI0pdJpm6MA+iKUn4F+EEfZcFr9B98t5B2cipm+xddtMV2euKat CGyZouvf3DtJfstjKDzc3St+LiIogk0= 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=1698078245; 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=ApzhSzVlCGqOU4aCEVUKgk2/C6zStSgrVwNwdDBjs8U=; b=NfBcevWE9BlTOxp5WKU+AFsbwgvY+znjPFhBjCe3OZapZ0zGGWutAZrUfoCCoyqQvxbvaI R7EdE6nsCaw0PPJ/YMOZJqf2yEfy6oqmcAkClvCx2QV09MJBtPRaCYiYEtW9gHNizb9Lbe 030j3vL55nL81zukRlM4oSMetrRtY+M= From: andrey.konovalov@linux.dev To: Marco Elver , Alexander Potapenko Cc: Andrey Konovalov , Dmitry Vyukov , Vlastimil Babka , kasan-dev@googlegroups.com, Evgenii Stepanov , Oscar Salvador , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov Subject: [PATCH v3 09/19] lib/stackdepot: store next pool pointer in new_pool Date: Mon, 23 Oct 2023 18:22:40 +0200 Message-Id: <852c5fed993f6b1e21beca9faa85e0fc2d9b84e6.1698077459.git.andreyknvl@google.com> In-Reply-To: References: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 7A0B114003D X-Stat-Signature: iibf5c66671x8mf83rqyd68ks9o5tz6q X-HE-Tag: 1698078246-152713 X-HE-Meta: U2FsdGVkX19ggVqqXRTi87Z+EOi/XMWYg1LWdAF18uVJEKYOqSo0sAw5y4VnB8HijjQuX7rkP0YQ1TlT/EwDHmUucxb2dzxODCO5BRlpwa6i5ZVxpZSdfA8sdZamLuwrMsnd4YEoWwnbCtlXTO1tL/QhkfvVy6PO9HRs/HbHP2pxdCfA86R2NFVpGonLyHVKTDKj2fgypcvi3rNPs3WBgtUi78qfmKxm5SOQr7/JKKjPoDElyRlM1ltxFtLHrIbtQxuR/kY+T0BVCASywb2dgkVQCWTh+ljaN1Ih6Co3l+v+GMgiH+N7fgtr8YfLZSVQsWBqU60Ez89wV6GT6q4dgWUpJG0IT1/scowJnjR1vAHEF5EsNYskRcvnDz0FI1EkUKjAM5wTJ6fVZvy/ylU95XwqDx+dbkGf31KtRAGV/Gle0w+mwHLj+xsMUtHzi3Hr0rQt6ogJE5cTi3ZP2L72ktRdZKGEwM44wptJs++FLlq0hrgkY93/Da3/HDg1d0aNyu+cy3ceEMbSVAjdcp29jMIgnA4uvvzz03dHoba0NXhL8G5IgCQEw/fjSP+i8vhhjfrQ4PJ3hdaZ250gm2EEe5aF9PRONR/cuPJjv7yF2Lg4VwuL8i3RQmL8u//vVetDiUfV8bskWh253p5wApPWcw/x2a5t929c89UEm4vmDnaXPPG2aajS9TGrGGeleKtntx/27HOsX2bgIxgFS4+gNAIfekuH24FifswsQ7ik14zj2wXviqVFusykbBsPZG3FuJ2hgYIADV3gIzA0eaXelGmrU5BGJu/ys7DQubc5xWFPJm+vGGHlNV4J6Ygw9qets+2lmewoXOdlUMCKUxJHUN93lMXgI2+f1Flwd5HVh+008F2dEwWkH9EbrAZOosKGooOoQwCsId/t9tp7ndDJN7c81qlOBAptgdpE34095knXYNT0eEIuxSn8gi8HFceH3oZzevZ7cK9Aan1M4jF 6f2GniC2 weAVx7dsn/9GaSO7/2qfIWQiferq9enpRztdmG49Sf+PYhkOs/bbtIA+xyfFB1jC8iC0yz2y+kww3Aeb0wliH8TV3e9tW6h47c7Zj2wJ+WmktT9EoS3Q+84BjI93iGEH5/bVMiaml3l1Yc1W6mpIdOLogtw== 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 Instead of using the last pointer in stack_pools for storing the pointer to a new pool (which does not yet store any stack records), use a new new_pool variable. This a purely code readability change: it seems more logical to store the pointer to a pool with a special meaning in a dedicated variable. Reviewed-by: Alexander Potapenko Signed-off-by: Andrey Konovalov --- lib/stackdepot.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/stackdepot.c b/lib/stackdepot.c index 7579e20114b1..5315952f26ec 100644 --- a/lib/stackdepot.c +++ b/lib/stackdepot.c @@ -85,6 +85,8 @@ static unsigned int stack_hash_mask; /* Array of memory regions that store stack traces. */ static void *stack_pools[DEPOT_MAX_POOLS]; +/* Newly allocated pool that is not yet added to stack_pools. */ +static void *new_pool; /* Currently used pool in stack_pools. */ static int pool_index; /* Offset to the unused space in the currently used pool. */ @@ -235,7 +237,7 @@ static void depot_keep_new_pool(void **prealloc) * as long as we do not exceed the maximum number of pools. */ if (pool_index + 1 < DEPOT_MAX_POOLS) { - stack_pools[pool_index + 1] = *prealloc; + new_pool = *prealloc; *prealloc = NULL; } @@ -266,6 +268,8 @@ static bool depot_update_pools(size_t required_size, void **prealloc) * stack_depot_fetch(). */ WRITE_ONCE(pool_index, pool_index + 1); + stack_pools[pool_index] = new_pool; + new_pool = NULL; pool_offset = 0; /*