From patchwork Fri Feb 10 21:16:00 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: 55591 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1181675wrn; Fri, 10 Feb 2023 13:19:47 -0800 (PST) X-Google-Smtp-Source: AK7set93w1GmTVmx7J84+feeHXXAUE80NR/DensWAJjZHKJ8b6N3/uX6gJbuOycTew6ykCFCx4j2 X-Received: by 2002:a17:907:160e:b0:8aa:c035:a651 with SMTP id hb14-20020a170907160e00b008aac035a651mr14438390ejc.37.1676063987675; Fri, 10 Feb 2023 13:19:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676063987; cv=none; d=google.com; s=arc-20160816; b=grPCTNqbJ31N6CQavjtMHo2AIu8fY94I+fwJNK1wdsXVIecPt37SeyeoOyVUr92a42 /nJ64tfHNC0lJ02wv5JkcUZZ1uCQUyEl/0A1GxhO0B6z9+kgTY6rRkxKiacvSX2/gNF6 MeCCXnng2AfwAA05mJ+pEmYL9fWXdItNbPtpuzsA5lxAtnquJz3U/TVsfMlacKlAuIgd S+6c6ERlGD1t1rLZvrvDLD64vxjRf06nGBrMprphTY9hT434SChvZ2ZcNXKKlg9fmcsn nYxl5PZFpib+1fo6O14i9uAOlDJWYZv3pen+uuonLxQIw7SveA4BrrYOTSnAJb6QVvKl qZEg== 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=QNTpFR8imhU+1RyFIUQnZTnn23HrW1qgGxbRYaqWOq4=; b=XDqDiZIzopNYKKy62012h4bAW6EJ93+TnhS2Ygppi4uYDywEyk2Y5M9cPmSBplJ5Kk rIJEP2PW8zKrT8FzUvD6XtLgdwNSnp8KvUm+Ei/bqtXl8dCBKmSJD2VIBE2A8dpGL8ME jDU5x/eiTNQ+Y+f87eZyLvgqlb2HGVKsrQk8lesz5ahToMlYiYwsE2y/4eIglEbkQdEb JRpS8R07Dp3WHCQ3lECb8LBdigA0uU3Vq+TX4VsYDugBdfFVDtTXlLQ5m7l5SHcUVB+Z cRMPutamFYb8hB+IN264Jjo0hBnBqqXwAPvdKq6SxtZGMkYsxaaPzjKfSse8qlrRXMAk m2ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=b9EI77+L; 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 gc37-20020a1709072b2500b0087a9f5fa831si6384979ejc.926.2023.02.10.13.19.24; Fri, 10 Feb 2023 13:19:47 -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=b9EI77+L; 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 S233371AbjBJVSu (ORCPT + 99 others); Fri, 10 Feb 2023 16:18:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233898AbjBJVSs (ORCPT ); Fri, 10 Feb 2023 16:18:48 -0500 Received: from out-174.mta1.migadu.com (out-174.mta1.migadu.com [IPv6:2001:41d0:203:375::ae]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39E6124106 for ; Fri, 10 Feb 2023 13:18:20 -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=1676063897; 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=QNTpFR8imhU+1RyFIUQnZTnn23HrW1qgGxbRYaqWOq4=; b=b9EI77+Lu2ejg1Id6cPrNsMBDYr8WIpJ2zMEg4RXlgJI+QYF6OL/oaxKk1OH2WIRdUewQW zBxE8rT/+Ts7luOzOazTc5KLDee/mIDM5G27VvuS9X7RoT9lIJeLwV8TTioXm6vGFwrCjU VRzh0cOmh0kJxe7ubs0kkTWdypYXNt4= 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 v2 12/18] lib/stacktrace: drop impossible WARN_ON for depot_init_pool Date: Fri, 10 Feb 2023 22:16:00 +0100 Message-Id: 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?1757480471450460358?= X-GMAIL-MSGID: =?utf-8?q?1757480471450460358?= From: Andrey Konovalov depot_init_pool 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_pool 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_pool to its first call site. Also change the return type of depot_init_pool to void as it now always returns true. Signed-off-by: Andrey Konovalov Reviewed-by: Alexander Potapenko --- lib/stackdepot.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/stackdepot.c b/lib/stackdepot.c index 7f5f08bb6c3a..d4d988276b91 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_pool(void **prealloc) +static void depot_init_pool(void **prealloc) { - if (!*prealloc) - return false; /* * This smp_load_acquire() pairs with smp_store_release() to * |next_pool_inited| below and in depot_alloc_stack(). */ if (smp_load_acquire(&next_pool_inited)) - return true; + return; if (stack_pools[pool_index] == NULL) { stack_pools[pool_index] = *prealloc; *prealloc = NULL; @@ -243,7 +241,6 @@ static bool depot_init_pool(void **prealloc) */ smp_store_release(&next_pool_inited, 1); } - return true; } /* Allocation of a new stack in raw storage */ @@ -270,7 +267,8 @@ depot_alloc_stack(unsigned long *entries, int size, u32 hash, void **prealloc) if (pool_index + 1 < DEPOT_MAX_POOLS) smp_store_release(&next_pool_inited, 0); } - depot_init_pool(prealloc); + if (*prealloc) + depot_init_pool(prealloc); if (stack_pools[pool_index] == NULL) return NULL; @@ -435,7 +433,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_pool(&prealloc)); + depot_init_pool(&prealloc); } raw_spin_unlock_irqrestore(&pool_lock, flags);