From patchwork Wed Sep 13 17:14:34 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: 13383622 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 01523EE01F7 for ; Wed, 13 Sep 2023 17:16:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EB27D6B0261; Wed, 13 Sep 2023 13:15:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E61B26B0266; Wed, 13 Sep 2023 13:15:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D02F06B0269; Wed, 13 Sep 2023 13:15:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id AC9D56B0261 for ; Wed, 13 Sep 2023 13:15:59 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 7A600A02D4 for ; Wed, 13 Sep 2023 17:15:59 +0000 (UTC) X-FDA: 81232226838.05.19D8859 Received: from out-219.mta1.migadu.com (out-219.mta1.migadu.com [95.215.58.219]) by imf16.hostedemail.com (Postfix) with ESMTP id A4B8D180030 for ; Wed, 13 Sep 2023 17:15:57 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=wHA2oEp9; spf=pass (imf16.hostedemail.com: domain of andrey.konovalov@linux.dev designates 95.215.58.219 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=1694625357; 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=iF8d5PIu0hiypd5p1X1vzHkKz0HhegtzJ4nwY5HqH4s=; b=i7SB8dO7MSjqrAapTUW2mSAiHOqGMyQ9baey5fsTvBwjz/vqZhSMTPmoRHD4wqCnewIBq4 1LU13qsXwrmw8mA6aBmhq5mmpixO7kNEEc7Nb2UC98E8e/pHZ+nkvNozh5nP+i+XFGzp1Q XrmtlIqMhe+fQUsRfoPwnVMgPbAPVD0= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=wHA2oEp9; spf=pass (imf16.hostedemail.com: domain of andrey.konovalov@linux.dev designates 95.215.58.219 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=1694625357; a=rsa-sha256; cv=none; b=OVivM9R2bkjvmMy+Q8eKg/79AggNFFUpzAhauEW8SRVW84av7Bv5b+WYhGcBf7VEfKyXib QoJptSUm2rjqGUCYMmE2LC4jZ0cTmXuH/lXbXMEt7RammouxX7UuWSD1Z3FD1KELPN9HZl TxwwV01JAwH38Sn2XwM00GZIuwctZQ4= 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=1694625356; 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=iF8d5PIu0hiypd5p1X1vzHkKz0HhegtzJ4nwY5HqH4s=; b=wHA2oEp9M2Png7tDBErdFmtaGLdMmLLdtrI6Au1BGNIa11sMWCsUSSkjE5ssXZQMsf89kF /ktIdpIwNBEW+HewSCwtqwLFJguCHnjOmSkrdVpWer6wxYm1qnbAq12KYjmRjrBs1FoPap FFJ3/1H7E9nEL5HyfuXogMs6GDWTN4w= 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 v2 09/19] lib/stackdepot: store next pool pointer in new_pool Date: Wed, 13 Sep 2023 19:14:34 +0200 Message-Id: <3a7056408e391ff0c66b5f50c460a7b9f796228f.1694625260.git.andreyknvl@google.com> In-Reply-To: References: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspamd-Queue-Id: A4B8D180030 X-Rspam-User: X-Stat-Signature: gf9n9astw78taxemnnf91kht8iq1yx54 X-Rspamd-Server: rspam01 X-HE-Tag: 1694625357-607500 X-HE-Meta: U2FsdGVkX1+ywWXGbcC5HAfvquvR1tclhkEC3sjLVTmQLsERdWwbIeie8UZ6n+h05IWa9j4fgUsniCRbJz5VP2f93tklO4IIrDPSZnXVyUf9R3hkcWeTzoQxtHfIKKjxmWgeDa4hUhCP5pyur7sV1AXLRN+RJqbAwHRRzWhc15kz6wJXq8NGg78XiSK/3MqBOYk1RjLmEA5OzmQxcxqlBWGpBQ1+iA2doji8IeUSrsAZfrTkg3mbr+h3xdR4hx1xKU6au7tk1o85foKRv2+bg74FJy2x7hda/ICxctYgznVJm1Qgygs/6Z6DnAuTGeUCije7U04+KfXcM2d3/0r/gdxaRvY9QW4eJTQPuQxD/C4ypv10/+qyinTp3+/hfTWHMiYl2zB3ImIg9ZIp4vIU7Cfo9hyterjBzdWd7yocmr4D7QzrXlog91Ndg6I85wqP+fFEjEIhTWxwZfKsHPnCA88PHDDOh1BeCreUGeL1ZMy5U4CPTj4/jZMvPLKQWEYkwvOGJCQTx7BO8Uwfq6bNVWd6prLG/NYvw55vuIX2W9EQGuxOumtG+OaP+ndlxM+AYTl4VkveCriEplpCq6cgCYc9Ivll8BNtcL9w2f846fIo2yFcRBTo5SZVx5IMxjiu4KTTPlcq4KuZ90ouXLwJSZRNM9Qq5YK6+ple57RGTysaUScfPUUfR+TaGZVvPRSCInOWdvgAeANqG37xIAnbh5sZj2GPVZbvudGfV3T/+9EehOUPIjfObCPXygT4VlAi5ZC6ajHXhaiHyC5UqMlB94izgRZZpT+77YL0ggmuKhQeGDeSi2ZoexhrH7Fp3AsLwiHzxUlEBAH1CUKNj6984KaWO6laHil+XD5xeed2ZIkSB/x+/nd5nmiYpbKueOUck4AWcFCjOwVJsXTBpukYemI2T0lMhIWShSFpP7I+L39Vo3U+Um3+jGkSkzYuw11+PxrGOupXqMmXQd5cYfi yuzN3k/I gTlj8rlHhC9R2p0QpJx+n7IHfEQ9RRO3W+J6s0T0UpjWQXn3opGzqFDl0LX91CaM4hbi0NtFfKf0rX5fpHoOOi4/1nj0zbSpi7+HrgPTI7US6amMqAletB829znaHN7R4rDuj3zyvBtERynE7TsDvuu0kSw== 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 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. Signed-off-by: Andrey Konovalov Reviewed-by: Alexander Potapenko --- lib/stackdepot.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/stackdepot.c b/lib/stackdepot.c index e428f470faf6..81d8733cdbed 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. */ @@ -233,7 +235,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; } @@ -263,6 +265,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; /*