Received: by 2002:a05:7208:c250:b0:86:f851:443 with SMTP id w16csp45302rbd; Tue, 11 Jun 2024 12:30:20 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWKhu+mbPx2F44wKXg74i4WlEaBn3Z0Fy3tjmDEISaKD15WzMWyFvfdUIUIbBonTiG7wa6P6+pH3XsONF0IF81ZU0f/lWJoh8mgbcwmzQ== X-Google-Smtp-Source: AGHT+IHrUn/v399gzi+4fJsiiyLedBpzcwGKQjFBXwdhoY592KPb+FTC7LoCkVseGtRedUT20icg X-Received: by 2002:a17:906:a40b:b0:a6f:5ae:b77 with SMTP id a640c23a62f3a-a6f34ca97d4mr251960266b.14.1718134220046; Tue, 11 Jun 2024 12:30:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718134220; cv=pass; d=google.com; s=arc-20160816; b=ms0HZ7e+5NHHNNfKc5JO13XRhidJdr4q7Ujq1qCD0/frQcjkilzjlG+3ltaUV+TXiM Paffip3cfyOyNxM5bwEL3O5N2DwP0e8lOwlSXJBpO3Pjd18Wl+gAKE/cWDWjrCMThQlF 8R+cPBHv3ByfgJMdpU55ONORzzF8GRHSaf/0PKFc1HKTe57xpByXx80Ot2M/52suGVqW 7Pg77Bqf7pXn8A3BhUCJqDiDfxkYpNECnzQq9urLvecO2yBbZT0iy6jMPcsiHyXDPqrp HtzeIcoVejkKJkl3rUKT/0aVywobpqml+pWet1IWDMrpppmmXBSG1FC8yWC+nYfKPZ7/ NwmA== 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=xmq/e6gXqVyHKCVTA1nQDz4SWfYYogxv14MpKLnVbVs=; fh=VQi8WXJrSHXxsfwqC9oAfi6LEiQC0Qv/w+aqrHCHJLs=; b=S2pc0FYljdLRujcU28PC7pyam8ZWIqgDKrmBf0eC60JMqceeLL71d1AriXQI+JvNmm g1LrY75oAkpUI9ZtxJaw8rzg/WmrocvefRugxo5JhKosDk+fR5IsKpdhYbjzyj7i1dKM nUhPSrUE46IIYlXQoiqwyDUM2Fnd6V3WYFyd3G1PHa1M0PfsG4o8JJD2o1IbvyZiPCcl 4NVjguZDTzgvFemGACWCFSCp9aKrLXTX0ID427MP6F24JTtdCPr53r2ADblAExc9G7s7 Fiq6LVmNjkMhS2Z6hjr9YdnOGCAM7XRTDu1JA2X0k7SfE8vqThXRaUO9afa4UF1aT7+l QWyQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-210506-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-210506-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-a6f28ae199bsi162201066b.665.2024.06.11.12.30.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 12:30:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-210506-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-210506-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-210506-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 898D21F24868 for ; Tue, 11 Jun 2024 19:30:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C1F8A154C07; Tue, 11 Jun 2024 19:28:54 +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 7ADC21514DA; Tue, 11 Jun 2024 19:28:52 +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=1718134132; cv=none; b=jYIz2AZs+D6Ex+XhYQKyu2n2uA1gpZvrDnnfTVcvZpqTKudfq5xqFuH6etsWHUWNccTkwzk8nKIOlCe7rZT1iuZnGxnMPmfAt8ZbFoM/m+ml9kviDs/YgSrghNLSMF+tqqY7NoEkfqQBJhDn+6LxrCqaMt42ac7dbECIaGYAXF4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718134132; c=relaxed/simple; bh=6Jl2ShtXKa6oe/J9WMbsmRq2sqkbA26nLPiNq2QCH+s=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=NYwKOMjqscdxbiGzwwg2lg9WR7q6dGuCxBV/Qc2UVbkudH9/yjqxXtzflClaSfWMeCyb7l3ojtfcOFm1fA4XF/h8CAyQIyg4jf+HdqU8PJLUKV40L8vWVqQfE4GdJ32Z8uWGAxK1+Lt5X1at4IU92L+845XCnH6BWwlw6IKcnOE= 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 59ACAC4AF61; Tue, 11 Jun 2024 19:28:52 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1sH7B6-00000001Ttw-3Q2q; Tue, 11 Jun 2024 15:29:08 -0400 Message-ID: <20240611192908.678828426@goodmis.org> User-Agent: quilt/0.68 Date: Tue, 11 Jun 2024 15:28:37 -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 v4 09/13] ring-buffer: Save text and data locations in mapped meta data References: <20240611192828.691638177@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 86f03c0ba4c0..ab6b8a0ee8e1 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