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: 156990 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp1412165vqx; Mon, 23 Oct 2023 09:30:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGNKfEwXCTXM1fYAwpoKmxA2qhUDA0+8yLAnI9CGcsqFisjLhdtJTEnkFFdptxoR/egzxt9 X-Received: by 2002:a17:902:f543:b0:1ca:77e9:3863 with SMTP id h3-20020a170902f54300b001ca77e93863mr11352692plf.31.1698078603182; Mon, 23 Oct 2023 09:30:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698078603; cv=none; d=google.com; s=arc-20160816; b=yg2pN6ilzlP2zB3xQaqqDjiICXD05n39DJjALOc6MG3cuEqqHjcE1J3urKiFK40Lq2 oUR49/FoPRq0pCW6bSSZ2f6EgIX9URozbHuLdUimoTCr082oEZqUEmAIhJRA2WEI+NEX +1XPwg9maJyR8csFWW6FIZTsiyr+PZi8LtOe9SndxVccEJyDBlNgliDVeWhq018/vIv8 Slask3qguyxfed4CC5lvbJJJJFLV46Xvi1SVjOlqk0fJOTkDFN8PHr8lAOlqSeNK41ge JsoGF7CKC+WIUsyhNo1ESExdnsHiVxx6qmXO2CD+xbs2DpvtjJ8Cj+7KQ9X0za+nQMIr dfHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ApzhSzVlCGqOU4aCEVUKgk2/C6zStSgrVwNwdDBjs8U=; fh=nfQSbTp1dWHt2Ier1Up8UhVNdXOqoJJLNvTrpT3jJEk=; b=D5hr+XiNAg8NFYPWZ9wrLveFx0HSZX7PGXVQzJmA1rzFpx92DYi/iKODS/WsDIo6bD AGs+buoHx4QGT8T5Zqth0Qd8Wk5XUYYYOMcg8m/242Kqcj4M66dJ1BDyTqVep/EUZgSG +5ZrUkV7izPqw0SfPTx7f7Mom+KRaiC9eDNet2/ET/QuVBY1gzmtVGbSz4N8M0pjJSKl lMcx+UmvRma1EZbrdFfLrrQXdSaBOOyBPulePTR0O3ATMqpV6XzH1L2h85Lo2swvqkf6 95DN0KATCdpcSLODVittEcb0X8PztPbXCRe7d8j/vDYw7/I5AMCC+Xnygm6n8TiOa3NS Icag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=NfBcevWE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id x1-20020a1709028ec100b001c62e465391si6489155plo.147.2023.10.23.09.30.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 09:30:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=NfBcevWE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 887D080B26DC; Mon, 23 Oct 2023 09:29:57 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233631AbjJWQ3k (ORCPT + 27 others); Mon, 23 Oct 2023 12:29:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230255AbjJWQ3f (ORCPT ); Mon, 23 Oct 2023 12:29:35 -0400 X-Greylist: delayed 325 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Mon, 23 Oct 2023 09:29:31 PDT Received: from out-209.mta1.migadu.com (out-209.mta1.migadu.com [95.215.58.209]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5799E5 for ; Mon, 23 Oct 2023 09:29:31 -0700 (PDT) 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-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 23 Oct 2023 09:29:57 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780564469487278366 X-GMAIL-MSGID: 1780564469487278366 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; /*