From patchwork Mon Nov 20 17:47:08 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: 13461824 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 9078EC5AE5B for ; Mon, 20 Nov 2023 17:48:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B7B2E6B0351; Mon, 20 Nov 2023 12:48:38 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B05406B0355; Mon, 20 Nov 2023 12:48:38 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 92F856B0357; Mon, 20 Nov 2023 12:48:38 -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 757426B0351 for ; Mon, 20 Nov 2023 12:48:38 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 4A7CC1201BE for ; Mon, 20 Nov 2023 17:48:38 +0000 (UTC) X-FDA: 81479067516.06.7767EFA Received: from out-181.mta0.migadu.com (out-181.mta0.migadu.com [91.218.175.181]) by imf12.hostedemail.com (Postfix) with ESMTP id 75D8E40024 for ; Mon, 20 Nov 2023 17:48:36 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=mVlXzudg; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf12.hostedemail.com: domain of andrey.konovalov@linux.dev designates 91.218.175.181 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=1700502516; 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=Wo0lOk4QF0V4/CSryrBtBcTGMr2NPIzDQs2c2iiME6Q=; b=edhz44Ja+Qju4gJD0ILhFfujkGhMTv7H1bQXPLOj4xk1W8CVns7OMleM1r1hHbXtxr3g89 BAVGmsXE+b++9MEJDlC3yzkyvN23J6opXoY0ujqyXzI2KeTs91MLp8N+pC89/AaGcOmjIm kSfRDmJl+Vps+NHooYXGYneNtPHj1BE= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=mVlXzudg; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf12.hostedemail.com: domain of andrey.konovalov@linux.dev designates 91.218.175.181 as permitted sender) smtp.mailfrom=andrey.konovalov@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1700502516; a=rsa-sha256; cv=none; b=QO3tgZeoqtlEGHZNbkSsVA1MneiujxwoNmPrJV5P6xIMOZyisfbpd76+P+PrqwIrXAGrPU c+SXZkI+qLCIuTHk8r8uwcSIx20x+QdfAHXc+4+Su2kfMA/9uE/s9cEnVVuAEOKxfWUsrK qxbiFE4+zGBVp5/wReU6LJI0e1owcU4= 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=1700502515; 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=Wo0lOk4QF0V4/CSryrBtBcTGMr2NPIzDQs2c2iiME6Q=; b=mVlXzudgWPREwFPbPjEzWKl0pkuPrGrBfXgV/o3hu2wbrexzrKyl7c+k+ldkpF3cqIoiwI u8DO0T3MhAJP+5xhUN4eko0SgcoGz172qfdNSCMVSIN1yVWwfrjX7hnhKKWOfY2ZNwgi4e RtBwt9lIOYU3HUK95YFtEZQHsBHOLqY= 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 10/22] lib/stackdepot: store next pool pointer in new_pool Date: Mon, 20 Nov 2023 18:47:08 +0100 Message-Id: <448bc18296c16bef95cb3167697be6583dcc8ce3.1700502145.git.andreyknvl@google.com> In-Reply-To: References: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspamd-Queue-Id: 75D8E40024 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: j1znxzugyd8gqry1e5h95isqjk7rbwfk X-HE-Tag: 1700502516-867121 X-HE-Meta: U2FsdGVkX1/RSoNXode3MkOpIAPl2ufJxZI+gKk5MrEO40jRHcQTJ1qC3RcTwng+epfi+vnFMcpIcrllFNmal1XcLJ88rQkObqRgjHebo6Ha3aip+dnIqYRX4E9wiPV1haKuwx7lflSUlv/woU+mTT9MN6l1X2TUnWePV4QoPJvWSwp+vr34XbASOf10dVZR2H0FpCuAYQIn0490X1zem/TRszZ6+d9GAV7TIghsXBHa4O+0J4A5JzcLZW2OlOkQpzUSf530zt46OWRl+1vicDHhW3/s4pBdGiDZtvgSDaHwtNI+C+VQ+agzU5YdHey6UNYHTQ4rz0/DGfR2hoH6bkgTwXnLO68U46NSRUcHufzM0BEMPUSz8fFC140naD5FmZa4PKWZf+9nbjJ1nCVqI6uGukLfh3pA8xS6YWTvo9ro4ZmsDJl9mtNFx7KvYiKkxr2G4J0VIcsib5bB5CawuOir0ctyuj1Ry8rfIB3DzYegybilPPzSgQ/0EoR4sjLFp3EELYgPm6dekehCL72DW2LnVBaZv8rOQ+vzEVaAzH8y0wf798FKDIOMwM0Dg5Ah/+3npXpyYd6F7OBL9krI7A9Y0oAePyTaUrMqKHkssvAEr4AK7UqdczaGXz8A6nHwE3WOjrSVP+r6J9qD2eSsbyVumDjCfIu55o2h5cQs8Jc1HQfxOmrHXmf8AGwhYuzunxAYgPz8eWWbzKLeAVeml9HLIzVfxRZw3wWG9uXI9dpdOHheAQqzhMhRgdn+w//06Vlg6EahZCMCMsxpl9ZYFuMPdBil6tpCQEINNujN99hseBQCFKNoQ5wHv3AbhF5feAM3Ad5n1fcQOuz0hTStWmkO4vSZHpfMkDccTJsXTlbT3PSbDgmZJZkP486ooN8p36n0u9Ehdwt5IFnkNStwjVKVz5RnS+uYn32Onx2v7gmQ3n+cduEba9cXXjuLeqKqbn+pemuUnrs5jqSTtqA 4QJqVTyx Z1lBlT/t/rdTx0J6fDYyW7qBRUNfR4Zew/4NY92vf/8GoNCcoPc0tTigML68+Khf+OMO5W9hBQZBuNQAeLTbbet635Xa9raAw/ajm6kwIQUv520I= 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 Reviewed-by: Oscar Salvador --- lib/stackdepot.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/stackdepot.c b/lib/stackdepot.c index a38661beab97..68c1ac9aa916 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. */ @@ -241,7 +243,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; } @@ -272,6 +274,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; /*