From patchwork Wed Dec 13 18:17:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 178237 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp7977836dys; Wed, 13 Dec 2023 10:22:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IFjHLZrBqLCls3ObELBkcXWf4HI4KQ1g2JDF5QyJcGUFm00B//OQMtpL2Lkv3FmBZtu9Pb/ X-Received: by 2002:a17:903:2345:b0:1cf:daca:2b5e with SMTP id c5-20020a170903234500b001cfdaca2b5emr8587929plh.38.1702491722701; Wed, 13 Dec 2023 10:22:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702491722; cv=none; d=google.com; s=arc-20160816; b=on0GySkTwxHR6VqxzlhVKEeqIPXQf5ivnkqxV+idUzPPhNR0R+6/AJIah/0II0ewwQ RmfHEeYdwwqjOPF7nm0AVHFhOOkKGHzfZFenm2eETEoasQx5oYh+XcYe7g9VSMRBBi17 3uZtNGNOWlHzRCcjYCmRA3FuPZ0bOm6aD5hu9IwyoOXKGaxU0QDli6PURoh7CCUgduou fxRLkw7gZjf69Mx71HA6FsLnoSsjHaC1934Bwvj6esi4t3EesGnL3Jlpcdxx9ATXcM1e Moxc7dx342z9S8z1+/XZ7c5jeDZjblOWR59+U9uCviex9/vJCTzyZMpoV1GX8fM7QxEC L7tQ== 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=Zm0XVusRrdQrinbBWqzuajF93HZqR/i5W51sFHIm79g=; fh=pL1t9p0RxD5qCgSUniSa3P4+XmpksJYPzX6TE+dndao=; b=KkNvWQRG2V64mviK85lo7tK8+KjpvmrtsVWQILywqrbPquo+TgfQuHd98d7rBSo//D mvu9/EyGaiJO44CZ/TearG6MaTrbl7D4m3tFzKx+T6RVFE8D+o4jkArk+QbOtsxFmTGm M96ScpxdegtaHbrK65/gGSe2BywaCYyIeeUb3t1JqAmBKH4mzOHYgV0AHcOmAy7roD0v G4gSQwZxV8Gosy13FVxLUdnQAmTs6oNdN89LZ3xqReTn2eBwLOkDBc6l8hCM2aKJPWhC mrcwSjACVUsHC/NiGyL7mzytXO4CO9KDrOKnThxOhAT50erMBGEa0inb1I0Zy2S3nVyM xVAw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id l1-20020a17090aec0100b0028b00fb0b82si185157pjy.7.2023.12.13.10.22.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 10:22:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (Postfix) with ESMTP id 9442980898E3; Wed, 13 Dec 2023 10:21:10 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235505AbjLMSU6 (ORCPT + 99 others); Wed, 13 Dec 2023 13:20:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235498AbjLMSUe (ORCPT ); Wed, 13 Dec 2023 13:20:34 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8709F120 for ; Wed, 13 Dec 2023 10:20:37 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2601AC433CC; Wed, 13 Dec 2023 18:20:37 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1rDTrG-00000002a6J-20UT; Wed, 13 Dec 2023 13:21:22 -0500 Message-ID: <20231213182122.260163713@goodmis.org> User-Agent: quilt/0.67 Date: Wed, 13 Dec 2023 13:17:38 -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 v3 01/15] ring-buffer: Refactor ring buffer implementation References: <20231213181737.791847466@goodmis.org> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 howler.vger.email 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 (howler.vger.email [0.0.0.0]); Wed, 13 Dec 2023 10:21:10 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785191960557216342 X-GMAIL-MSGID: 1785191960557216342 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 8f8887f025c9..eee36f90ae25 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; @@ -573,6 +543,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 /*