Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp917304pxp; Wed, 16 Mar 2022 21:14:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxjxnEY1+fllp4dRDMzwq617T+ZGTVEa+482VbJqcR5SbdnKZ8fa5l/uAVoNUivhdMIiPyj X-Received: by 2002:a17:903:1d1:b0:151:9e73:61b1 with SMTP id e17-20020a17090301d100b001519e7361b1mr2699044plh.84.1647490454631; Wed, 16 Mar 2022 21:14:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647490454; cv=none; d=google.com; s=arc-20160816; b=o/epX7w3s8erhipOGsGDSq5l1QdAgW4NLcDFNnvtBiToOIDAVwgU77KYgSuYdnV6OH Qo1Ly2djFMzW1PSQsF/ml+81ORKZFvMl1Hwhhxq2k+UUhdXTzzGVrkXQJ2+LfWqpZKKq Un/tgojxUpZ/fzSgBbq/eWPKYlB9Xd+aPchy7KeRMvbUgld83YCXNjmldUtgYI8/FQOo Am+pFc/m18qM+TtbTWDymSlk9RZOHvZtDeanZaqMDcZ4p8G7/6oiveUOs/CiTcUZcKHl AhubQ3AytadCvHiRelvO1H12tfWAFJgesPSyRizXdiq8shZ5D1x1AA0JagZogvvW6TB1 zTCg== 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=J3ahpJdcVugI8H+3Ysx5hJ96yLWjg5Rf1ntkJSZAd+E=; b=TJMmWTiZoRfqjb5kdSu/k0xh33pwtGmc3m7/q9gpVFUcDGNDmcmeNar9A9goBEYHb+ Dh6prxvDpjrYplqcdlb89EjKNHjybVuedgiYSR7Hi8tZF/Vmb4EzZ0xQE4Ygniz2/d3/ iySzXbIgku1WWrQ8DA6a4YxaSF89zXje2AAHH2GOe1+n+4cxWljPUJxhmw+MhJ0Ma7Gl 6vahD0I3UCRXKPg0AJRHMAnCaXadCcxth1InJVKJxm6hE3mGqRaUONBZsATepUuP3ZIQ UgmhJKoCJ0lu/E3RObSd+I94EGb4BbD2XHNXISogeWIeK5tYDy7LrP8QHgZ4xfq6v5K/ 7isA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=f09BhJCc; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id c15-20020a056a000acf00b004e104694fcfsi3913042pfl.366.2022.03.16.21.14.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Mar 2022 21:14:14 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=f09BhJCc; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C252ABBE27; Wed, 16 Mar 2022 20:52:05 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242111AbiCNM2z (ORCPT + 99 others); Mon, 14 Mar 2022 08:28:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243615AbiCNMVE (ORCPT ); Mon, 14 Mar 2022 08:21:04 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35A4C35245; Mon, 14 Mar 2022 05:16:28 -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 AFF1A60C72; Mon, 14 Mar 2022 12:16:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B8FB1C340E9; Mon, 14 Mar 2022 12:16:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1647260187; bh=eGzBZgdQcdiSVjCSR4mr2bCxnxn8WjIU+tGN2s5k9VE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f09BhJCcXZ9KMjsvHGI3XJ2usBKb485inFmZ63aHb9jecpFudQ1QErNlHeAQvWT9d wLI6Fsj4LZk5V2FB9lIPfMV5qHu5GGrOm3us0goL1lkWK+8toLOvKhhC0Chh9J8foX T3yWctBmOPJrakHLkf0t0sPFCEXT2g3fSdBPbPfw= 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.16 081/121] tracing: Ensure trace buffer is at least 4096 bytes large Date: Mon, 14 Mar 2022 12:54:24 +0100 Message-Id: <20220314112746.382534123@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220314112744.120491875@linuxfoundation.org> References: <20220314112744.120491875@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=-3.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 24683115eade..5816ad79cce8 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -1472,10 +1472,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