Received: by 2002:ab2:6f44:0:b0:1fd:c486:4f03 with SMTP id l4csp49326lqq; Wed, 12 Jun 2024 16:22:16 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWT69Vvo1gcehheAV9iiiC33YGdn0D79hKPbG6p/uN/jzr6Z7m6ICLZRyuwcZN6tYuN6l7aLa0W1M7jODT487+lnw2XFcw0Or0c2eURQA== X-Google-Smtp-Source: AGHT+IGI+nLiMyCGw6YhCrBsZyAAX5KYHhvSpDPzyTVnXnyH6/L81RcuEvl4XOaO9D4reDn3as6s X-Received: by 2002:ac2:4255:0:b0:52c:823f:2a10 with SMTP id 2adb3069b0e04-52c9a3bfbacmr2024324e87.1.1718234536764; Wed, 12 Jun 2024 16:22:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718234536; cv=pass; d=google.com; s=arc-20160816; b=S3/4MhpbLGO3RVsX56FD1c8/MwWTEWztikr8hNaJPQ83srsYs+pKzdVT07iQlp+0LG pLW34wl5TpL6660LLfDY33CSrm24zDn6eeAu2uoQ6fGjBv55DSGugRTQJPdb4t2CNFZb FtUKDWvFAUi+05w4kpFZ75AudLKY4HQTibZTLlcSOyVRDVMAMXovlemhnCZzFK/S9tl/ IXnnHgL+AbYh5We2IHoKPBSORiEKG2u78MqNGR1xamgJmkBilnEJ/pT4nxReY+0eZIu2 3yz8g3Wr31AFR3qDVx50tZ25Mertc/dfPrZ1as42rzGHHjroEH6fUKisO7yeTialUZai Dd+w== ARC-Message-Signature: i=2; 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=lfQmOjGGOqpMFMIcxnpWUZNR62d/ZVEZaCLpHcNMGRg=; fh=VQi8WXJrSHXxsfwqC9oAfi6LEiQC0Qv/w+aqrHCHJLs=; b=ysN3odT0PA1nKyB+2G/I0Slg77Mcp9kD1/MNZgAiivIsySUeUFrzWqwCvWeLqvaroF jPaLAgVm7Xy3jG0/SoSqH+UK/7g3PxqvPtdUxp9KkgaJSJBx0UxytnXyDVsQT41+G3/U rcnJYUXTpqbQaunhbP4mO/vnHxKRZaTic29QWNTTdpPA3ynlIcQcEwQ1SNUQeyq6sdHl L+BnOBJv75LhAWYvvgl++h8oHsjVLI6JO2aIJEf4cr3liq40eTwvWsRmkFSBUhhKcNzn dVr2KjmcBhFbzA99GUrQTuupi5AWgAB+MzXlK0ECZqMy5bFzOH+9gYow0ZAhYF1W6P3C TLNA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-212369-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-212369-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a6f56e3b4cbsi4843066b.774.2024.06.12.16.22.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 16:22:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-212369-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-212369-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-212369-linux.lists.archive=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 am.mirrors.kernel.org (Postfix) with ESMTPS id 430D31F23450 for ; Wed, 12 Jun 2024 23:22:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D127A136997; Wed, 12 Jun 2024 23:20:11 +0000 (UTC) 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 9691312D76E; Wed, 12 Jun 2024 23:20:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718234407; cv=none; b=Modzz7PxtRdU3Cjig/Rofzi2oynw+4T+SPpd73NiZDf98+4fBo7O3b1RN8bke3v1sTyHeM1GM/y4xJjIvnU/YvXh1/kezAScUztGPZ3HtMK+oQ4vDuYsPwyDBTzqfjolpicFnqhRLN+Jx9ZBMzM6j7/pqXY5oemBj6/mttU5s5U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718234407; c=relaxed/simple; bh=+k1Ovci6p6/I4LM80e9A+R9QOVvPuVbEFeW9HWxETJY=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=d2K7fyyWpczC8+2SxNBhJTMxPBGMLNXOIBXNP/0vWjtKTzvM+oUvIpu/lkmOOkR4TrqXeYJhKPKh0yXaRgXRRbVkqwkxYZ/3NvwouFQU2JFigXcXOtvD7ATA563fovqeYySfC26C0j6VFLzQjjzPQuVkdGBbaS95DTQ69ePBB3A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6A71EC4AF5F; Wed, 12 Jun 2024 23:20:07 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1sHXGU-00000001deQ-2fi3; Wed, 12 Jun 2024 19:20:26 -0400 Message-ID: <20240612232026.496176678@goodmis.org> User-Agent: quilt/0.68 Date: Wed, 12 Jun 2024 19:19:43 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Vincent Donnefort , Joel Fernandes , Daniel Bristot de Oliveira , Ingo Molnar , Peter Zijlstra , suleiman@google.com, Thomas Gleixner , Vineeth Pillai , Youssef Esmat , Beau Belgrave , Alexander Graf , Baoquan He , Borislav Petkov , "Paul E. McKenney" , David Howells , Mike Rapoport , Dave Hansen , Tony Luck , Guenter Roeck , Ross Zwisler , Kees Cook Subject: [PATCH v6 09/13] ring-buffer: Save text and data locations in mapped meta data References: <20240612231934.608252486@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 From: "Steven Rostedt (Google)" When a ring buffer is mapped to a specific address, save the address of a text function and some data. This will be used to determine the delta between the last boot and the current boot for pointers to functions as well as to data. Signed-off-by: Steven Rostedt (Google) --- kernel/trace/ring_buffer.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c index 804dfbdeef84..8c287430411d 100644 --- a/kernel/trace/ring_buffer.c +++ b/kernel/trace/ring_buffer.c @@ -45,6 +45,8 @@ static void update_pages_handler(struct work_struct *work); struct ring_buffer_meta { + unsigned long text_addr; + unsigned long data_addr; unsigned long first_buffer; unsigned long head_buffer; unsigned long commit_buffer; @@ -542,6 +544,9 @@ struct trace_buffer { unsigned long range_addr_start; unsigned long range_addr_end; + long last_text_delta; + long last_data_delta; + unsigned int subbuf_size; unsigned int subbuf_order; unsigned int max_data_size; @@ -1821,10 +1826,15 @@ static void rb_meta_validate_events(struct ring_buffer_per_cpu *cpu_buffer) } } +/* Used to calculate data delta */ +static char rb_data_ptr[] = ""; + static void rb_range_meta_init(struct trace_buffer *buffer, int nr_pages) { struct ring_buffer_meta *meta; unsigned long delta; + unsigned long this_text = (unsigned long)rb_range_meta_init; + unsigned long this_data = (unsigned long)rb_data_ptr; void *subbuf; int cpu; int i; @@ -1841,6 +1851,10 @@ static void rb_range_meta_init(struct trace_buffer *buffer, int nr_pages) meta->first_buffer += delta; meta->head_buffer += delta; meta->commit_buffer += delta; + buffer->last_text_delta = this_text - meta->text_addr; + buffer->last_data_delta = this_data - meta->data_addr; + meta->text_addr = this_text; + meta->data_addr = this_data; continue; } @@ -1857,6 +1871,8 @@ static void rb_range_meta_init(struct trace_buffer *buffer, int nr_pages) subbuf = rb_subbufs_from_meta(meta); meta->first_buffer = (unsigned long)subbuf; + meta->text_addr = this_text; + meta->data_addr = this_data; /* * The buffers[] array holds the order of the sub-buffers -- 2.43.0