From patchwork Sun Dec 10 03:54:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 176263 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp6353783vqy; Sat, 9 Dec 2023 20:04:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IHHxnIROJvr90RxzP/1pbUgLg4ARfGbTOGhrk2VGhWKVLJA26YMPCng4/MdYaS9zwETTy13 X-Received: by 2002:a05:6a20:7b12:b0:190:adc:7fd0 with SMTP id s18-20020a056a207b1200b001900adc7fd0mr776257pzh.21.1702181068053; Sat, 09 Dec 2023 20:04:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702181068; cv=none; d=google.com; s=arc-20160816; b=G0rGcBvQgj3aBcMyKjfYMnTXS5dLI46OdyXI3pujDIhiRbI1oV86JCNDgJA9DbDyjD nkeDcX6pHS1FPqqDwPgFDBkvHF8nD0ltHA75XPn6bEGZkYcV2Cp17AM8qHyjSxTv+oVR mnRIMST+1sTaFU+SD9u9x55FHkyIKArOf3t0mrblPHl7WehMDdPGqbB9jlb6iJP/umRQ gnCyNZ4VvLK39lyBYkqddrHADS5bQpTC0SxNxcfqNTp2jyPi5sIS7SrZc9uJwPT2FtYl +EmZzirlBM3T0Q61+uHxqrvqHt8hU3acMWbUMqqi6P1MxOIOLK8YzRBC0ndQogopdcTT VRVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:subject:cc:to:from:date :user-agent:message-id; bh=3haQajqhXyxgR+U+Llw5uM+GUSgl3jpHXB2knl5dWFw=; fh=pL1t9p0RxD5qCgSUniSa3P4+XmpksJYPzX6TE+dndao=; b=UuEgufho77kaup8BUZMo1cSlxQMWq581z2JVdGgXbfE9Qqujxjze+mYkVGz/zHdGNw 9rEialaIM3byUGaMLlqFwhHqSD8vj4FiM1hU6xcHjKX/FY32+AgzMSMWZB5PkYY2qBO4 pH/GpsH4GhjTld+GOW3LHH4HFdN6SSHX10/b1jICvd+vxuJGN8nuiqezIA3I4c8/zpu+ 9B9F1+rLmT8+9lYeEK5PHmBeZCRpiGuK9bc8sa4ZJSTj2GWe1wgEy51Wcn++hkzQ6WmV O20dvVYXYllfCzvcywGxlcZPL+OcdiPgeug1k5NLZ4Y/uFI4c+hOYgz0g1KzgQwN7f0T jvXA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id mp5-20020a17090b190500b00286922ce5cdsi4108659pjb.108.2023.12.09.20.04.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Dec 2023 20:04:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id C26AD809501A; Sat, 9 Dec 2023 20:04:26 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231510AbjLJEEI (ORCPT + 99 others); Sat, 9 Dec 2023 23:04:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231280AbjLJEEG (ORCPT ); Sat, 9 Dec 2023 23:04:06 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 615F210E for ; Sat, 9 Dec 2023 20:04:12 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C490AC433C9; Sun, 10 Dec 2023 04:04:11 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1rCB3g-000000021Lp-3INx; Sat, 09 Dec 2023 23:04:48 -0500 Message-ID: <20231210040448.569462486@goodmis.org> User-Agent: quilt/0.67 Date: Sat, 09 Dec 2023 22:54:05 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Tzvetomir Stoyanov , Vincent Donnefort , Kent Overstreet Subject: [PATCH 01/14] ring-buffer: Refactor ring buffer implementation References: <20231210035404.053677508@goodmis.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Sat, 09 Dec 2023 20:04:26 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784866215488797695 X-GMAIL-MSGID: 1784866215488797695 From: "Tzvetomir Stoyanov (VMware)" In order to introduce sub-buffer size per ring buffer, some internal refactoring is needed. As ring_buffer_print_page_header() will depend on the trace_buffer structure, it is moved after the structure definition. Link: https://lore.kernel.org/linux-trace-devel/20211213094825.61876-2-tz.stoyanov@gmail.com Signed-off-by: Tzvetomir Stoyanov (VMware) Signed-off-by: Steven Rostedt (Google) --- kernel/trace/ring_buffer.c | 60 +++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c index 3a5026702179..d59d14e67da1 100644 --- a/kernel/trace/ring_buffer.c +++ b/kernel/trace/ring_buffer.c @@ -381,36 +381,6 @@ static inline bool test_time_stamp(u64 delta) /* Events may have a timestamp attached to them */ #define BUF_MAX_EVENT_SIZE (BUF_MAX_DATA_SIZE - RB_LEN_TIME_EXTEND) -int ring_buffer_print_page_header(struct trace_seq *s) -{ - struct buffer_data_page field; - - trace_seq_printf(s, "\tfield: u64 timestamp;\t" - "offset:0;\tsize:%u;\tsigned:%u;\n", - (unsigned int)sizeof(field.time_stamp), - (unsigned int)is_signed_type(u64)); - - trace_seq_printf(s, "\tfield: local_t commit;\t" - "offset:%u;\tsize:%u;\tsigned:%u;\n", - (unsigned int)offsetof(typeof(field), commit), - (unsigned int)sizeof(field.commit), - (unsigned int)is_signed_type(long)); - - trace_seq_printf(s, "\tfield: int overwrite;\t" - "offset:%u;\tsize:%u;\tsigned:%u;\n", - (unsigned int)offsetof(typeof(field), commit), - 1, - (unsigned int)is_signed_type(long)); - - trace_seq_printf(s, "\tfield: char data;\t" - "offset:%u;\tsize:%u;\tsigned:%u;\n", - (unsigned int)offsetof(typeof(field), data), - (unsigned int)BUF_PAGE_SIZE, - (unsigned int)is_signed_type(char)); - - return !trace_seq_has_overflowed(s); -} - struct rb_irq_work { struct irq_work work; wait_queue_head_t waiters; @@ -576,6 +546,36 @@ struct ring_buffer_iter { int missed_events; }; +int ring_buffer_print_page_header(struct trace_seq *s) +{ + struct buffer_data_page field; + + trace_seq_printf(s, "\tfield: u64 timestamp;\t" + "offset:0;\tsize:%u;\tsigned:%u;\n", + (unsigned int)sizeof(field.time_stamp), + (unsigned int)is_signed_type(u64)); + + trace_seq_printf(s, "\tfield: local_t commit;\t" + "offset:%u;\tsize:%u;\tsigned:%u;\n", + (unsigned int)offsetof(typeof(field), commit), + (unsigned int)sizeof(field.commit), + (unsigned int)is_signed_type(long)); + + trace_seq_printf(s, "\tfield: int overwrite;\t" + "offset:%u;\tsize:%u;\tsigned:%u;\n", + (unsigned int)offsetof(typeof(field), commit), + 1, + (unsigned int)is_signed_type(long)); + + trace_seq_printf(s, "\tfield: char data;\t" + "offset:%u;\tsize:%u;\tsigned:%u;\n", + (unsigned int)offsetof(typeof(field), data), + (unsigned int)BUF_PAGE_SIZE, + (unsigned int)is_signed_type(char)); + + return !trace_seq_has_overflowed(s); +} + #ifdef RB_TIME_32 /*