From patchwork Fri Dec 15 17:55:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 179486 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp9462945dys; Fri, 15 Dec 2023 09:56:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IHZ3Wau8NQx8TBNBAd3b1yHQuUK2+GXvSg6ltmh7PBHQmJbNhzXleeNGnguWOLnQP9RYZwS X-Received: by 2002:a05:6214:29ce:b0:67a:a721:caf8 with SMTP id gh14-20020a05621429ce00b0067aa721caf8mr14700875qvb.89.1702662967926; Fri, 15 Dec 2023 09:56:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702662967; cv=none; d=google.com; s=arc-20160816; b=pSdt0xK2E5B7Evv8HNSFRnkD3NxOvQYuUzf7N+e9st75JJIxVQcSJuj4vRmcswR7XY 5BHzhAXzu/KXdfIJnU8j8ss9t5SUSloC6YWnGAO04MxqAo4FDv09VuU7IcmEDsML+C+R epPl7JfRJiw5s0zI+UJAdD8tbzX9nmt15g6NjSA9YjpeLKLtbPtVCpXV6xs5n90JP67g ++N+2bOnnCQTbuIh7m1Z2ZxlgcRe6DTncHHo1nWhpm3Itb/MVAgxxNu8A+GWrNlf0yxq GVCkz1huc4DG7qpNoqmyUxziNlYh2w12y8mxNRjhkT8LSjKxMSwZ/3uCy3f+uJ8hXfsM 6XWQ== 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=ZYx/LAS6XjBMUzgQkDpC6sHyf/B37H5iznmLwBegu/k=; fh=pL1t9p0RxD5qCgSUniSa3P4+XmpksJYPzX6TE+dndao=; b=WCUt6G70Y9jDHw8d+gpOV6TiLjRpdDPlSFIo5kqeIKVPeNrR4sXdUXHZ0Z6w7ThU7J JldXYcmOGgL/5psETgS5RLcHmMmI0u6j13/pw9gZAi/DRNab4YunXnr1Uyg4H95LuuKs QKFW7ZfnTOK1YZU28E4z6AKyrHMT6Cng+DVLS/yTpPKvoOd40VED1ZGCJ4+hIao1HOLZ GNBFdjuhZhGce9k+jWTz+4X0YWHoSmXtwCrzVvtXur3IA7mzvXm60UvmAb5LwzMJMVux TfR28JVx3Vrv5OuHeffb0pohsA1iRjKOLLQ/VeBWsvokTUjV/pEH1Rq0k4EgBPWQ524/ CHRg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-1477-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1477-ouuuleilei=gmail.com@vger.kernel.org" Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id u2-20020a0cf882000000b0067f01ef623asi5322652qvn.204.2023.12.15.09.56.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 09:56:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-1477-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-1477-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1477-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id B1DAB1C23FC8 for ; Fri, 15 Dec 2023 17:56:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C345845975; Fri, 15 Dec 2023 17:54:55 +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 34E46134CD; Fri, 15 Dec 2023 17:54:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B18D5C433C9; Fri, 15 Dec 2023 17:54:53 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1rECPX-00000002wNp-2yOk; Fri, 15 Dec 2023 12:55:43 -0500 Message-ID: <20231215175543.496986007@goodmis.org> User-Agent: quilt/0.67 Date: Fri, 15 Dec 2023 12:55:03 -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 v4 01/15] ring-buffer: Refactor ring buffer implementation References: <20231215175502.106587604@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: 1785371524650663016 X-GMAIL-MSGID: 1785371524650663016 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 47f9eda99769..196e3f284723 100644 --- a/kernel/trace/ring_buffer.c +++ b/kernel/trace/ring_buffer.c @@ -378,36 +378,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; @@ -555,6 +525,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);