From patchwork Tue Dec 19 18:54:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 181223 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2156444dyi; Tue, 19 Dec 2023 10:58:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IHnsZjE3sGPOOdtclINylUcWZ5sK6LFlBLAKMKd/ZhyO2dRCD13D3jV33xfLzxeBUqzAnD/ X-Received: by 2002:a17:902:7606:b0:1d0:9c9d:dcdc with SMTP id k6-20020a170902760600b001d09c9ddcdcmr8368595pll.85.1703012324418; Tue, 19 Dec 2023 10:58:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703012324; cv=none; d=google.com; s=arc-20160816; b=fkuZ2Y2o+L31Lmttd92wtOWw5n9CkWjD4ZiuJeyIfTNI+2+6Y3/aYIKOaI9QISqBBw zx4Q45INZJ5wYDjJ+wT4+vq4/dnw4dN/i/Y0LNLnIhQ7dYKHCNUeEmLcI1IWI2EvU+KQ fmTazMntw2uQ/Mz95rSrsVrmuYywGDs21oJcDxEINJZu3McLjsXTqGLJ91GEbUWply05 XURFhqjxJ5keevY3Dqc3nU+YW7NzzUGFAPJkSe2qJ1oYXSj7pLbSDVrAm2EhjgapVsQY oTbR6WIPc7abyTg1WtS/TzawppvqgfSi5pIOcad++9CV6uHgcUHZvcQrfRwY7ijkJjnv WA1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:subject:cc:to:from:date:user-agent:message-id; bh=AD2gymlCy9zrubNbOrrPWL+v13pZCBgVEZXhB4vEWPM=; fh=pL1t9p0RxD5qCgSUniSa3P4+XmpksJYPzX6TE+dndao=; b=uXfl/aykDPUU9PYkocAyvOIjrPKXO/mKhqdHpgktHlrzlTuGRGp7LbCKy+lFt9ydWN 5CaoUkgVCWVeOm+eq9haM0u8bHFumtKhxahwlIPqz5cf3TmUkEQRu2FfDzRa4xuOPC5j 9B+usRrXuPHALuYr1dTra3ahI6TaN7Gqoz2yME5D7clbm/jnpROv2QhrW6zs8dWGp20a 13Fv4wXoa3MgLWeVictv3io0fckl8Mm7wcvPBtYD6i8xSFdiPFimhBG5MqnnufoPNa7C 3CvD17WhqrfMXy4IuF8uRkkeaDo5SRlXwj//N6GmbqZsi83Feb1GsPqSiUli7KqQ+czE bUiw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-5835-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5835-ouuuleilei=gmail.com@vger.kernel.org" Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id h9-20020a170902b94900b001cfd754d79esi20217398pls.79.2023.12.19.10.58.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 10:58:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5835-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-5835-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5835-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 132FDB24F41 for ; Tue, 19 Dec 2023 18:56:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7A1853B2A8; Tue, 19 Dec 2023 18:55:31 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F314B38F8A; Tue, 19 Dec 2023 18:55:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9768FC433CA; Tue, 19 Dec 2023 18:55:28 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1rFfGV-00000003Qzt-3w1F; Tue, 19 Dec 2023 13:56:27 -0500 Message-ID: <20231219185627.723857541@goodmis.org> User-Agent: quilt/0.67 Date: Tue, 19 Dec 2023 13:54:15 -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 v5 01/15] ring-buffer: Refactor ring buffer implementation References: <20231219185414.474197117@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785737851387725330 X-GMAIL-MSGID: 1785737851387725330 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 f7dc74e45ebf..2400c8e68fd3 100644 --- a/kernel/trace/ring_buffer.c +++ b/kernel/trace/ring_buffer.c @@ -379,36 +379,6 @@ static inline bool test_time_stamp(u64 delta) /* Max payload is BUF_PAGE_SIZE - header (8bytes) */ #define BUF_MAX_DATA_SIZE (BUF_PAGE_SIZE - (sizeof(u32) * 2)) -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; @@ -556,6 +526,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); +} + static inline void rb_time_read(rb_time_t *t, u64 *ret) { *ret = local64_read(&t->time);