From patchwork Mon Jan 30 20:49:37 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: 50472 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2391288wrn; Mon, 30 Jan 2023 12:54:51 -0800 (PST) X-Google-Smtp-Source: AK7set9oJ84gl9yOfv1KCpDJah5ONx3DIVE2P2SMn3kvgHizF7T+S5M50uO5e1XbCVpB23VebuNB X-Received: by 2002:a17:907:8a13:b0:887:6c23:193f with SMTP id sc19-20020a1709078a1300b008876c23193fmr8358989ejc.44.1675112090936; Mon, 30 Jan 2023 12:54:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675112090; cv=none; d=google.com; s=arc-20160816; b=ccjvkZs0QsUVZ0HNSraFqfhdhK2ZA2V80vDn/SPMYDzlnIFl+UnfRn5GCJAP7PBi7n omfnmoSwk1Rl3n0gpdW9y6jxyFipgzUu1mSL3KjW8QNwYx7BFhRhb9tPcbUGojFUt+u4 qAAfYIWrPETiR5OweucoJBXBB8+FB3UlrnGjf4usCrrLdwUraaA/4czxFRc0Ftskeo8w 5tFi4zaETMgH0XP2qBV7mUfd3BcxO7ZT+6kKbMkmTAtu0btg5MwNnZ9zYfKbygxO1qR/ Jo3mf8Mxk/PeRn8GvJBaTCJNQ+ejadpR5zRm8hztY4Jrcb4uoiwIFsPzAZ54Mh/7sOBn OZAQ== 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=RlJNrgwkJjY9MAGqUmKKlmI8AUnL0lcVfhP1HY83LkM=; b=Ta1AuIMEVRwrIB0jveqdwm4H7NAxdeoumWah8h9PsHZ0NpyvA7OQWp/G4UyC8/0gIk Y1HnryxkUgWOV61NQxm/PiuAvtvFaXSVsz4mrH5t/4AOs73X+P2ljZO97RB/FyEWSvRQ VwQcaueAr3dKS4st+EdAAfskMuyX+ZuLnD6z5a0Ltt6QX8laNNW90F25TxkgJWFjQ7bm tUF8UpngttuqiujWKxAU1LfQQ2IzO9ViLEzIlHTn41q2QK5NhnNQhDz3c28f9K6zU1eN /WcLHmGiKvXk0TTBDApI6GBCelK/+zF35Q3Gy4Fgi7cMNXxlmtFh058ePQsLFLYB1h34 ZX4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=eYNx9UpT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p13-20020a170907910d00b00889211619fasi3466667ejq.476.2023.01.30.12.54.26; Mon, 30 Jan 2023 12:54:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=eYNx9UpT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230092AbjA3UwQ (ORCPT + 99 others); Mon, 30 Jan 2023 15:52:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229559AbjA3UwK (ORCPT ); Mon, 30 Jan 2023 15:52:10 -0500 Received: from out-108.mta0.migadu.com (out-108.mta0.migadu.com [91.218.175.108]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 071E63B3F5 for ; Mon, 30 Jan 2023 12:51:56 -0800 (PST) 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=1675111915; 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=RlJNrgwkJjY9MAGqUmKKlmI8AUnL0lcVfhP1HY83LkM=; b=eYNx9UpTD8qASdAvQ2avXbDAzDV2XZyf2RCfcvrg11Z3tf9mCrYiiV6w1yAx9dx3/GBwYW pyvA7lWPKBOd+CbhHKC8yhjQP8SgvWhgeotaVOX7oF+PqX3R0B7OR1AjbnJRaZIq6CK/KL 3u69jMJaEnaHOynRgJBlAMbH9ZxnhRg= 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 13/18] lib/stacktrace: drop impossible WARN_ON for depot_init_slab Date: Mon, 30 Jan 2023 21:49:37 +0100 Message-Id: <7e7434a0d4e8a71138aec2c8a3c69a4eebf49935.1675111415.git.andreyknvl@google.com> In-Reply-To: References: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756482335722504960?= X-GMAIL-MSGID: =?utf-8?q?1756482335722504960?= From: Andrey Konovalov depot_init_slab 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_slab 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_slab to its first call site. Also change the return type of depot_init_slab to void as it now always returns true. Signed-off-by: Andrey Konovalov --- lib/stackdepot.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/stackdepot.c b/lib/stackdepot.c index b946ba74fea0..d6be82a5c223 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_slab(void **prealloc) +static void depot_init_slab(void **prealloc) { - if (!*prealloc) - return false; /* * This smp_load_acquire() pairs with smp_store_release() to * |next_slab_inited| below and in depot_alloc_stack(). */ if (smp_load_acquire(&next_slab_inited)) - return true; + return; if (stack_slabs[slab_index] == NULL) { stack_slabs[slab_index] = *prealloc; *prealloc = NULL; @@ -244,7 +242,6 @@ static bool depot_init_slab(void **prealloc) smp_store_release(&next_slab_inited, 1); } } - return true; } /* Allocation of a new stack in raw storage */ @@ -271,7 +268,8 @@ depot_alloc_stack(unsigned long *entries, int size, u32 hash, void **prealloc) if (slab_index + 1 < DEPOT_MAX_SLABS) smp_store_release(&next_slab_inited, 0); } - depot_init_slab(prealloc); + if (*prealloc) + depot_init_slab(prealloc); if (stack_slabs[slab_index] == NULL) return NULL; @@ -436,7 +434,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_slab(&prealloc)); + depot_init_slab(&prealloc); } raw_spin_unlock_irqrestore(&slab_lock, flags);