From patchwork Wed Jun 12 14:20:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 10990101 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C908314BB for ; Wed, 12 Jun 2019 14:21:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B8579288FC for ; Wed, 12 Jun 2019 14:21:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ABCA928A0C; Wed, 12 Jun 2019 14:21:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4138E28935 for ; Wed, 12 Jun 2019 14:21:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2409320AbfFLOVq (ORCPT ); Wed, 12 Jun 2019 10:21:46 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:37261 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2409256AbfFLOVp (ORCPT ); Wed, 12 Jun 2019 10:21:45 -0400 Received: by mail-wr1-f66.google.com with SMTP id v14so17127565wrr.4 for ; Wed, 12 Jun 2019 07:21:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=57eLlmQRNMEdLEYvD0lWzbVQFc7//tLNSs65hJjPQ0M=; b=CNjGrH9thqFv1zPn1D0+mlzE3XwepooUjZWV5QGGJNRPyqHR9JlWYhBwr1+NztVRJm qyP85zW4tdDdU9vc+8kjzDHgf2UqLNRZK0QwrQQP/ApKAFQJx3f0hrnGGOrPpI28SbOO 9b3b7zbi+rrdNvhkF4/H5w8Yuv/C7zwAIpsRTu63y+fZ4JkKotgcMjKRWH+oyB0lnar9 cdRrRbBE7kt9f+cvG/REGR03RrLogccDFUUi7V8+X2YP7liAXz/FMBv0cqYCZ9S7aeHY aI3VHCaNEmNjZ3MJh7Xwyehg6lvuxMOc0Yek+TZMqBegstZdZvn+rJbVXm86QGahl/m/ KttA== X-Gm-Message-State: APjAAAXeGsAb72Rh/UE769QGWDOHcNWm8i3e9Rg0erB1tYfhjeEb+yCF E4sjFsTQiX3z17oZGcX+JYI= X-Google-Smtp-Source: APXvYqy4aAKEUGK9ki4WqCRLqZ4I9TlVkrF4bkiRK6Zs9frC4K8Nk/2bTofTHXEBabblvfp8MgG6fg== X-Received: by 2002:a5d:4bc5:: with SMTP id l5mr9486244wrt.214.1560349304093; Wed, 12 Jun 2019 07:21:44 -0700 (PDT) Received: from mamba.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id f10sm27624826wrg.24.2019.06.12.07.21.43 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 12 Jun 2019 07:21:43 -0700 (PDT) From: Yordan Karadzhov To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, y.karadz@gmail.com, Yordan Karadzhov Subject: [PATCH 1/2] kernel-shark: Fix a bug in ksmodel_set_next_bin_edge() part II Date: Wed, 12 Jun 2019 17:20:52 +0300 Message-Id: <20190612142053.14439-1-ykaradzhov@vmware.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Sender: linux-trace-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On a first glance this patch may looks like reverting commit 9336dd6bcd38 (kernel-shark: Fix a bug in ksmodel_set_next_bin_edge()) The point is that for the last bin we want to increment its upper edge used when checking if the bin is empty, but we do not want to touch the lower edge time used by kshark_find_entry_by_time(). Signed-off-by: Yordan Karadzhov --- kernel-shark/src/libkshark-model.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/kernel-shark/src/libkshark-model.c b/kernel-shark/src/libkshark-model.c index 978cd70..0cac924 100644 --- a/kernel-shark/src/libkshark-model.c +++ b/kernel-shark/src/libkshark-model.c @@ -260,20 +260,30 @@ static size_t ksmodel_set_upper_edge(struct kshark_trace_histo *histo) static void ksmodel_set_next_bin_edge(struct kshark_trace_histo *histo, size_t bin, size_t last_row) { - size_t time, next_bin = bin + 1; + size_t time_min, time_max, next_bin = bin + 1; ssize_t row; - /* Calculate the beginning of the next bin. */ - time = histo->min + next_bin * histo->bin_size; + /* Calculate the beginning and the end of the next bin. */ + time_min = histo->min + next_bin * histo->bin_size; + time_max = time_min + histo->bin_size; + /* + * The timestamp of the very last entry of the dataset can be exactly + * equal to the value of the upper edge of the range. This is very + * likely to happen when we use ksmodel_set_in_range_bining(). In this + * case we have to increase the size of the very last bin in order to + * make sure that the last entry of the dataset will fall into it. + */ + if (next_bin == histo->n_bins - 1) + ++time_max; /* * Find the index of the first entry inside - * the next bin (timestamp > time). + * the next bin (timestamp > time_min). */ - row = kshark_find_entry_by_time(time, histo->data, last_row, + row = kshark_find_entry_by_time(time_min, histo->data, last_row, histo->data_size - 1); - if (row < 0 || histo->data[row]->ts >= time + histo->bin_size) { + if (row < 0 || histo->data[row]->ts >= time_max) { /* The bin is empty. */ histo->map[next_bin] = KS_EMPTY_BIN; return; From patchwork Wed Jun 12 14:20:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 10990105 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D2C6E14BB for ; Wed, 12 Jun 2019 14:21:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BED12286B4 for ; Wed, 12 Jun 2019 14:21:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B2FC828944; Wed, 12 Jun 2019 14:21:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 695F12892E for ; Wed, 12 Jun 2019 14:21:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390208AbfFLOVz (ORCPT ); Wed, 12 Jun 2019 10:21:55 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:50236 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2409256AbfFLOVz (ORCPT ); Wed, 12 Jun 2019 10:21:55 -0400 Received: by mail-wm1-f65.google.com with SMTP id c66so6789346wmf.0 for ; Wed, 12 Jun 2019 07:21:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8UZyUGAmhcsrg+rhLvYN5axZRa+lIfrBvi45c+Ubrxw=; b=bXwuCt20p/d9y83F8Ua/j+fjwwzanqHkwwjbuMVoAzl3gJQJ5MFvD+bEDiPXxT0C/O PHXwyUOjqJPt0nkJHhdCRh/DJAw1NDBJ6N3rwuN816P7ObujQMXFTG6L9SpbBaTbQPd+ 6SZI7BR/ekHu7SZ/ls+KFZg/FpkkA0tM6XCr0tPdFgOPOcBRTO/yZ33AFwMi7C1bGuXe n+KWGpiR42hDgHzV6aQxScSu6jy787jHbz7hGvE2A0DiXOHVPGTQo5wlUdltM402WO+X lkRJ369huAm5nnLERnUEFbYuDlMI4exMLrNXygmIYD+L0Zn8wmdVP1d3K3N9LCQa1lax Poig== X-Gm-Message-State: APjAAAX4YwvES/miBFiIZ0cFir4XtCpiYSYLtad4nVNSrYwuyWoZ9lrf T3gytqciSDISfJP9TKAQUUY= X-Google-Smtp-Source: APXvYqzOSOyOXtKbtdJaSOFO/QFaJDq0pvWXSqjJoFPHmYWQ4xujL6kJ+8EPkJufWr7KwSFCttK1PA== X-Received: by 2002:a1c:f20f:: with SMTP id s15mr21530731wmc.33.1560349313124; Wed, 12 Jun 2019 07:21:53 -0700 (PDT) Received: from mamba.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id f10sm27624826wrg.24.2019.06.12.07.21.52 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 12 Jun 2019 07:21:52 -0700 (PDT) From: Yordan Karadzhov To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, y.karadz@gmail.com, Yordan Karadzhov Subject: [PATCH 2/2] kernel-shark: Fix a bug in ksmodel_set_next_bin_edge() part III Date: Wed, 12 Jun 2019 17:20:53 +0300 Message-Id: <20190612142053.14439-2-ykaradzhov@vmware.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190612142053.14439-1-ykaradzhov@vmware.com> References: <20190612142053.14439-1-ykaradzhov@vmware.com> MIME-Version: 1.0 Sender: linux-trace-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP All time stamps of the trace records are coded with 64 bits, however on some systems the size_t type can be 32 bits. Signed-off-by: Yordan Karadzhov --- kernel-shark/src/libkshark-model.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel-shark/src/libkshark-model.c b/kernel-shark/src/libkshark-model.c index 0cac924..dde64de 100644 --- a/kernel-shark/src/libkshark-model.c +++ b/kernel-shark/src/libkshark-model.c @@ -260,7 +260,8 @@ static size_t ksmodel_set_upper_edge(struct kshark_trace_histo *histo) static void ksmodel_set_next_bin_edge(struct kshark_trace_histo *histo, size_t bin, size_t last_row) { - size_t time_min, time_max, next_bin = bin + 1; + uint64_t time_min, time_max; + size_t next_bin = bin + 1; ssize_t row; /* Calculate the beginning and the end of the next bin. */