Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp4053526pxp; Tue, 15 Mar 2022 11:27:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzO6DQpSneLrmclRC3zTb3brSoE71UOGQ8KtmL7x9ooJB3S6b547vKcyMzIqiElTE1gzVkt X-Received: by 2002:a17:907:628e:b0:6d9:c6fa:6168 with SMTP id nd14-20020a170907628e00b006d9c6fa6168mr24573825ejc.132.1647368848931; Tue, 15 Mar 2022 11:27:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647368848; cv=none; d=google.com; s=arc-20160816; b=A9G7XRCTOGT/bns4aggbEXdhjvgk9iJHonHgzgnqhB/VQJMT6RKR8emuEBw396z9Bh IbO1XiyqCSRCT72CPir6jI4Lcqf5f6sp3zr3FE+w0YpCkRiXQcta9ATLhjscuVSYjjUw UN5VSqJruBXULFtvGkKihApC4AYbuwHIExUkhZ2Ii6n2yNsSYj9INr55kHlscDh5VG4J vB4rMbCfcDp+57stSOXMPSBVwPWnQQfuggqwTvSC6nzmBLm5YcWTjK8GPJFS4odB2v96 fFM018Kr/L4r9XZTSJVC8Et6sVC2X8IFanX6aV99aMlenjkWo27K0puB+Lbzkc2bGCr1 JXiQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=sHLSA4LQQEaICvXpH7i81XxQ8Bt+M1bGrBqTX5AzJVY=; b=LSKOuGtGgbATEGBtG+l1YpWWqIkLNWkTR/FmkSOwingaowEeiwCmiEWXbgT1RUEhHh ifEDBWJmPOUeVGNZlQF3PkCmOdYNdApNm/0MU3EPiQsxPU/r0Yqmf/dSBelXLf57mtHZ N/yOykvjIpOoVlDQ1RHQTui1WHMRPaUvHOdIsDTHMwcVlM7lVoVLME4H1ecXqixgtqNC ndKgo9owcPwISfwiSQBkdR0y76NSJbPsE4dxmj3Lhj5HVRYXnS/WX9abzerHZmzZbRWL A/OAkBv4+IlwWlQsdoitaAjJi+XNsQ4iQKmTip0ezJZnkZ9I3C5iY9Jj6gml+vx/yMZa 6PPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="2TT/1bmr"; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r23-20020a170906705700b006d6e5456b4bsi10852465ejj.833.2022.03.15.11.27.01; Tue, 15 Mar 2022 11:27:28 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b="2TT/1bmr"; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239456AbiCNLk6 (ORCPT + 99 others); Mon, 14 Mar 2022 07:40:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239318AbiCNLkn (ORCPT ); Mon, 14 Mar 2022 07:40:43 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30B39483A6; Mon, 14 Mar 2022 04:38:21 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6D4D261170; Mon, 14 Mar 2022 11:38:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5B4A7C340E9; Mon, 14 Mar 2022 11:38:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1647257900; bh=2nf8HXth9T/w8PG6CAV6F7BLmu6qUd7AypFw6oFnjUo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2TT/1bmrfqpwLItlVjzv01smb1+JxKGILQstedokSe+WRdF/3ZB7YWSO+1fyjqUhV Xf54v0FRx+3xZS4sXd6vnkJ4wS9xrYEYq0w2zmf0ylSIIoHZWBWpkKq688AjDmgdDO DR/wTkeTJfl3/QrGgrazjS25RggJRIMBynOfNrrg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sven Schnelle , "Steven Rostedt (Google)" , Sasha Levin Subject: [PATCH 4.19 16/30] tracing: Ensure trace buffer is at least 4096 bytes large Date: Mon, 14 Mar 2022 12:34:34 +0100 Message-Id: <20220314112732.248150763@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220314112731.785042288@linuxfoundation.org> References: <20220314112731.785042288@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 From: Sven Schnelle [ Upstream commit 7acf3a127bb7c65ff39099afd78960e77b2ca5de ] Booting the kernel with 'trace_buf_size=1' give a warning at boot during the ftrace selftests: [ 0.892809] Running postponed tracer tests: [ 0.892893] Testing tracer function: [ 0.901899] Callback from call_rcu_tasks_trace() invoked. [ 0.983829] Callback from call_rcu_tasks_rude() invoked. [ 1.072003] .. bad ring buffer .. corrupted trace buffer .. [ 1.091944] Callback from call_rcu_tasks() invoked. [ 1.097695] PASSED [ 1.097701] Testing dynamic ftrace: .. filter failed count=0 ..FAILED! [ 1.353474] ------------[ cut here ]------------ [ 1.353478] WARNING: CPU: 0 PID: 1 at kernel/trace/trace.c:1951 run_tracer_selftest+0x13c/0x1b0 Therefore enforce a minimum of 4096 bytes to make the selftest pass. Link: https://lkml.kernel.org/r/20220214134456.1751749-1-svens@linux.ibm.com Signed-off-by: Sven Schnelle Signed-off-by: Steven Rostedt (Google) Signed-off-by: Sasha Levin --- kernel/trace/trace.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 19a6b088f1e7..063b434c89d2 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -1118,10 +1118,12 @@ static int __init set_buf_size(char *str) if (!str) return 0; buf_size = memparse(str, &str); - /* nr_entries can not be zero */ - if (buf_size == 0) - return 0; - trace_buf_size = buf_size; + /* + * nr_entries can not be zero and the startup + * tests require some buffer space. Therefore + * ensure we have at least 4096 bytes of buffer. + */ + trace_buf_size = max(4096UL, buf_size); return 1; } __setup("trace_buf_size=", set_buf_size); -- 2.34.1