Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp3125490pxp; Mon, 14 Mar 2022 11:21:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwBmo3TGzqi2xd4kOijYG0NaGz9nlw0PcdQten3YFWmTbqAysc7AUvuSGRYz9TADgzXYJOd X-Received: by 2002:a05:6a00:124e:b0:4f7:6d35:c1d5 with SMTP id u14-20020a056a00124e00b004f76d35c1d5mr24015096pfi.83.1647282090182; Mon, 14 Mar 2022 11:21:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647282090; cv=none; d=google.com; s=arc-20160816; b=m+LmddSF8OzyOQcQEJX/hD6Vv0MvaETWMYEtjMLjvEwPL9E6F0UV6Xejk5NJ6EqyWA hMe2ES9xR92Nzpw5nDDw4DOQbvCEk4GycCUX5L+xEODvbnp6FaY1Sf9DRC+GWo7iEKq7 CndKYvRsdPY/D+UflVHLPuh2sjDQbLK0sOjPVpWFq6agXlcNUkplPTQSZESe3Is6MQt9 S0FJftVW5V/yYtJ6RuNEOivNbj/wgi2DDtsscKBuaw6Z91FoYcg81qmwJFq6pnSTlG3i XaGAw8GEd/6INogWKWgS7OwEgv/9Gzkl90nRKu9lrVbhnlGH728mEYdLquvu192XCWZe k7Tw== 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=B21LjVwXueKXqlJI9E9Lr+ZieQnDTPEa3cjDBvutE/g=; b=DfscOzqZmCzLsuxAnjdiadCQQ/XuzJAPkjxZatogd6ghDIgKicuByus9ncRlosw/H1 gfME6fGrXpab28k8ImiYV3oVszSZrsIHrsu/x4mhDi53OZpH5MZBYJyVgry5qWOo0OWe bmxTIi5pvvkAWB/MM9TpXJHQUemaanvUqZTO/N3mD4fLUedOcrwKJi9DTgcIU/4OKKds K2ePHhANiE9xe16Y9mgcVIvvDnBGBz6MfYCO4u3hD0Qz2lQiR5UKkjCBub2lHtFXDH26 jtZKdk5WVOcMWqvDwd4vh4kUO+GSgDAk+O2ndG+jnDGIswrLuT6o+ramOaJuJNsUYxq2 uUJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EZ2kAYsZ; 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 bj25-20020a056a02019900b0037450b454b1si17006548pgb.878.2022.03.14.11.21.16; Mon, 14 Mar 2022 11:21:30 -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=EZ2kAYsZ; 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 S242334AbiCNMS5 (ORCPT + 99 others); Mon, 14 Mar 2022 08:18:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242473AbiCNMKD (ORCPT ); Mon, 14 Mar 2022 08:10:03 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7708F193F3; Mon, 14 Mar 2022 05:08:29 -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 D27896130F; Mon, 14 Mar 2022 12:08:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C38A7C340E9; Mon, 14 Mar 2022 12:08:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1647259708; bh=/gwCmlsi5Q06s9CqoiM/ulAmAa9EkDtF9xcqhREj8NM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EZ2kAYsZWn5pGBpEMTOGlyOGug1JtEFIp1uW7+pqTdKtyHXafWNyZGzTY/34kQlZj 6WwLccZ+5+JHLgo2SLT7gQxITSzk021s6Prgs3SMrzFid3GWp/KtBSZMFOfIsy+4/r husk1lPFUwdw4+oooPQ5x/wjqqTmQQ1qk/MV/E6c= 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 5.15 070/110] tracing: Ensure trace buffer is at least 4096 bytes large Date: Mon, 14 Mar 2022 12:54:12 +0100 Message-Id: <20220314112744.989605523@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220314112743.029192918@linuxfoundation.org> References: <20220314112743.029192918@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 86fb77c2ace5..01002656f1ae 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -1496,10 +1496,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