Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp653074lqt; Thu, 6 Jun 2024 14:23:03 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXWp2K8HJDMAVKaIUfHRd2+fk/Z+CzH5xm4RvmHgViVfoo96JiadiqTwclbhLji/kfdpQFuFEphHzaAeeRryWCHXXwDtlw10yQBoVwTrA== X-Google-Smtp-Source: AGHT+IEdu7MY+nU5ycggoGeuEfFSh50V7WfQazUGyj+vSJ0oVpW3DlmkxfK3+bvILui+c5m1FfvD X-Received: by 2002:a2e:a989:0:b0:2ea:823d:c33a with SMTP id 38308e7fff4ca-2eadce84e96mr7247141fa.33.1717708982881; Thu, 06 Jun 2024 14:23:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717708982; cv=pass; d=google.com; s=arc-20160816; b=fR3K6GgAxceN7SpCbpMLx3SVcpYcCfJieFuRihs72+BGa3mU+cijzPJF96YBY/9snz IIS8VORKxsDpt7RSstsrfzP7azg4IgBJ69LN3gbngfPe7pr5EwD78m7uMMR44Ij+d+as nNWj8ljhWSmdp3lj+mruC/8vZY6/fbogZcCabRRkFsl+6iX9AYD2ZzrOtqzxynoFNYhk Mp1MHoSRERLoYXFwjUUHQ5Dcv9m6Wd7s+uHlwcBruvVRUtuBNGT5uGNTbjGviFCjluZ0 bxv2bdUV8q7x4OqmoZs/izkKwV1fIE+g6/6RTa5ru7EzzH5UFkFaIY3nigoD2KzI1yQ5 4uNg== 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=GdQcJuYxLU9axzyjhHo+YPUVfY0EfeiOpWuIf0Lh3sM=; fh=VQi8WXJrSHXxsfwqC9oAfi6LEiQC0Qv/w+aqrHCHJLs=; b=qC/S6epQksOGIuGSxWRb2g6Zrxsd9o4QU5z267rxnieO+V2eSHkP7OY+hHAjzvx4Lx thUCZ9kQ4oLM0fU1rCf/mXOjUortiAZaMszH8qeFD9EoOegaXnQVmNVaxGGnf1ANVDyh RQyiYTGPTJwY7jsM1/SYQKB4ur37ef6vVr60sBD2mVD7IB4UuhhzLtqFWNl0Z3rolGMq QHkw/dXABNyVIfSQRaLy7UktuSQLIgTr3Y0KhwBAuXssU8z59goGFeFZIXOZHT+bqklL B5r2izekmB4xxM5BtzwLApMZFvjt2dnvzdhXuW3Vh9BOP44tY3GKTXOJN2AqLCougQ+e OdSg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-205050-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-205050-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-a6c806db0c4si106060366b.485.2024.06.06.14.23.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 14:23:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-205050-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-205050-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-205050-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 1AF2B1F21E31 for ; Thu, 6 Jun 2024 21:23:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2019D19AA74; Thu, 6 Jun 2024 21:21:35 +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 9E86F199235; Thu, 6 Jun 2024 21:21:32 +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=1717708892; cv=none; b=eBJIxA3W93xZX/bb/3I4jynXUGBd+eYttlAJhelChKCsyQ2MXf8TRst8cXwEwt/MvYkj0MZJetK1yUinpRZ2vDmb7/oS+xfWV7K9qUhJYwo4kME4OJFTC36d9qlfePRBJRtHYKSCLrhy6rg+/l+9bu5FsdT9lGUTnLd0iiHRq4E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717708892; c=relaxed/simple; bh=hhcl7c8oP1owNFT9VWQhRHHHzboa6jfxuRfaThVIEqg=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=Uo+pBhSGCruX7BUJGkl7vce1FkV3l+1ssy3UPMH1HYUp+Yak6drOqsNR82rmKEjrrfjW3xD0jqhzxd+HuLpzzCABsZXVtoPc+CWhy/5q4FpgJGv4p0uSAEmT3WX0O3Qhcbk7UPEjL8/vRSfKlUgBSvgEbmHgRfxVd29EXIbvmyg= 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 3DFD1C4AF66; Thu, 6 Jun 2024 21:21:32 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1sFKYD-00000000qLh-2f9Z; Thu, 06 Jun 2024 17:21:37 -0400 Message-ID: <20240606212137.495904786@goodmis.org> User-Agent: quilt/0.68 Date: Thu, 06 Jun 2024 17:17:44 -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 v3 09/13] ring-buffer: Save text and data locations in mapped meta data References: <20240606211735.684785459@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 1e959ff71855..755ef278276b 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; @@ -541,6 +543,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; @@ -1819,10 +1824,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; @@ -1839,6 +1849,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; } @@ -1855,6 +1869,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