From patchwork Thu Feb 21 12:42:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 10824039 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 A59791390 for ; Thu, 21 Feb 2019 12:42:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 969BF2EC7E for ; Thu, 21 Feb 2019 12:42:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8AB342F00B; Thu, 21 Feb 2019 12:42:21 +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 34F1C2EC7E for ; Thu, 21 Feb 2019 12:42:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725932AbfBUMmV (ORCPT ); Thu, 21 Feb 2019 07:42:21 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:44682 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725920AbfBUMmU (ORCPT ); Thu, 21 Feb 2019 07:42:20 -0500 Received: by mail-wr1-f65.google.com with SMTP id w2so15251322wrt.11 for ; Thu, 21 Feb 2019 04:42:19 -0800 (PST) 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; bh=4kQJpN+KUQE58ceT6NtlUhUDUnVRmifNoacwSxV2NUM=; b=sv4zzRBMlLiCD3ayPhU9D8rh2qUMmZmx2DgFaW0v937aw9uOAZGTzXuBf0KvN8IPrX 1DWK8yQ58e3rJj3puqtp7Ywcokp1ZY3cuYDV9rQVV8zstZr4AqeIpyY5cO533lIzPEec nLl2Viu6riwPRTM01YqZzVkZUNGLKuHtXaDE53u0Wz/78Zloo1yYXUcsF4O1B9l98lb2 z89LBPyeEoWA0D36MVNsH6HKofyCls9a2bay8nI4Z2GLRUGM7J8MHMiZmo+vffXtAkNy PyR1AL3suiC7EGuAR2XwwL3aV6GiuI+oRVCLw6XeFqCU1aOV1CxlW+LDONkp/SdEYZWT +/nQ== X-Gm-Message-State: AHQUAuamK8LDSbmG1tjmw8SXgFTAA3Hj0f163Zedv3tO1VswRR24+lLf NVAoaBplb+KUR9ejRHAZ9WI1Ys26 X-Google-Smtp-Source: AHgI3IZzI3gBxdCikWt79f4hH9ww471DCHBLUpeFwIOgO2AMA9hinae0QpS3ByYEwIP5D0XPSQILxQ== X-Received: by 2002:a05:6000:14d:: with SMTP id r13mr1537792wrx.231.1550752939072; Thu, 21 Feb 2019 04:42:19 -0800 (PST) Received: from mamba.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id b4sm1359517wrr.64.2019.02.21.04.42.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 04:42:18 -0800 (PST) From: Yordan Karadzhov To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, Yordan Karadzhov Subject: [PATCH 1/3] kernel-shark: Fix a bug in ksmodel_shift_backward() Date: Thu, 21 Feb 2019 14:42:03 +0200 Message-Id: <20190221124205.21115-2-ykaradzhov@vmware.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190221124205.21115-1-ykaradzhov@vmware.com> References: <20190221124205.21115-1-ykaradzhov@vmware.com> 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 Bin 0 of the new model has to be set after copying the overlaping bins from the old model. Otherwise the new content of Bin 0 will be copied into Bin "n". This bug has no effect because ksmodel_shift_backward() has a second bug in the loop over the non-overlapping bins. The second bug will be fixed in the following patch. Fixes: f97e31f00 ("kernel-shark-qt: Introduce the visualization model ..") Signed-off-by: Yordan Karadzhov --- kernel-shark/src/libkshark-model.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/kernel-shark/src/libkshark-model.c b/kernel-shark/src/libkshark-model.c index b71a9b8..a185d6b 100644 --- a/kernel-shark/src/libkshark-model.c +++ b/kernel-shark/src/libkshark-model.c @@ -557,17 +557,18 @@ void ksmodel_shift_backward(struct kshark_trace_histo *histo, size_t n) ksmodel_fill(histo, histo->data, histo->data_size); return; } - /* Set the new Lower Overflow bin. */ - ksmodel_set_lower_edge(histo); /* - * Copy the the mapping indexes of all overlaping bins starting from + * Copy the mapping indexes of all overlaping bins starting from * bin "0" of the old histo. Note that the number of overlaping bins * is histo->n_bins - n. */ memmove(&histo->map[n], &histo->map[0], sizeof(histo->map[0]) * (histo->n_bins - n)); + /* Set the new Lower Overflow bin. */ + ksmodel_set_lower_edge(histo); + /* Calculate only the content of the new (non-overlapping) bins. */ for (bin = 0; bin < n; ++bin) { ksmodel_set_next_bin_edge(histo, bin, last_row); From patchwork Thu Feb 21 12:42:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 10824041 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 C34141390 for ; Thu, 21 Feb 2019 12:42:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B3BA82EC7E for ; Thu, 21 Feb 2019 12:42:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A7DF32F00B; Thu, 21 Feb 2019 12:42:25 +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 523D72EC7E for ; Thu, 21 Feb 2019 12:42:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726151AbfBUMmZ (ORCPT ); Thu, 21 Feb 2019 07:42:25 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:46824 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725920AbfBUMmY (ORCPT ); Thu, 21 Feb 2019 07:42:24 -0500 Received: by mail-wr1-f68.google.com with SMTP id i16so21632546wrs.13 for ; Thu, 21 Feb 2019 04:42:23 -0800 (PST) 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; bh=MIFDGcZ18A3JgbTqtauIpl7P9OseZ+du+XJa2TArfgM=; b=XKt9UDTyrqlTJ0TDMh3ZTkWA2m6kcABTP2xn6Ap+pRb7moPYFp2pA9Kv67bJjJv9YL h4eK89zIlKhl7hx2akqz3NdMijE0cbBZ690lzHiR/6qtPuVA7xOeaEOXFaILl39ENHL3 qMI6TGjWHCYROf2cjJrBBykpZgTGQJe/DtHm6GNZiUQv/JvWrkz70RsaimN07KRVaVRn 2kWqneHs2+jUN4DgEztxq6HHPZSJAb1cmod0ifYxOflnLhzwUziHJGf1VR4cpAFDinjM zs3lRI0lEhrdJTllgLJkC33nNEz2ePmifpLbdcjktttcuCAABSIjz7Uq3kBVGrKDcQ4a h/Yw== X-Gm-Message-State: AHQUAuYY4uxYpSFbzKdZeWseshjz3dJzICio61CJiZg3PF0bkQYH/ckr 3hSk6/AECKblbwnMNLDIDPE= X-Google-Smtp-Source: AHgI3IZsEj+7gY4p6i0/a0X9a2zakY8idgaHGonY0+NoBWOPCp41hZxag6V9qnf2qeRCfSxbIWExAA== X-Received: by 2002:a1c:9ed7:: with SMTP id h206mr9745707wme.28.1550752943273; Thu, 21 Feb 2019 04:42:23 -0800 (PST) Received: from mamba.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id b4sm1359517wrr.64.2019.02.21.04.42.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 04:42:22 -0800 (PST) From: Yordan Karadzhov To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, Yordan Karadzhov Subject: [PATCH 2/3] kernel-shark: Fix a bug in shift_XXX methods of the visualization model Date: Thu, 21 Feb 2019 14:42:04 +0200 Message-Id: <20190221124205.21115-3-ykaradzhov@vmware.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190221124205.21115-1-ykaradzhov@vmware.com> References: <20190221124205.21115-1-ykaradzhov@vmware.com> 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 In ksmodel_shift_forward() and ksmodel_shift_backward() we are supposed to recalculate only the content of the new (non-overlapping) Bins. However the loop does not take into account that the static function used to do the job actually calculates next Bin (bin + 1). The result is this misunderstanding is that we recalculate also the first overlapping Bin (n). This wipes up the effect of the bug fixed by the previous patch. Fixes: f97e31f00 ("kernel-shark-qt: Introduce the visualization model ..") Signed-off-by: Yordan Karadzhov --- kernel-shark/src/libkshark-model.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/kernel-shark/src/libkshark-model.c b/kernel-shark/src/libkshark-model.c index a185d6b..b6d3612 100644 --- a/kernel-shark/src/libkshark-model.c +++ b/kernel-shark/src/libkshark-model.c @@ -505,7 +505,11 @@ void ksmodel_shift_forward(struct kshark_trace_histo *histo, size_t n) * bin. */ bin = histo->n_bins - n - 1; - for (; bin < histo->n_bins; ++bin) { + for (; bin < histo->n_bins - 1; ++bin) { + /* + * Note that this function will set the bin having index + * "bin + 1". + */ ksmodel_set_next_bin_edge(histo, bin, last_row); if (histo->map[bin + 1] > 0) last_row = histo->map[bin + 1]; @@ -570,7 +574,11 @@ void ksmodel_shift_backward(struct kshark_trace_histo *histo, size_t n) ksmodel_set_lower_edge(histo); /* Calculate only the content of the new (non-overlapping) bins. */ - for (bin = 0; bin < n; ++bin) { + for (bin = 0; bin < n - 1; ++bin) { + /* + * Note that this function will set the bin having index + * "bin + 1". + */ ksmodel_set_next_bin_edge(histo, bin, last_row); if (histo->map[bin + 1] > 0) last_row = histo->map[bin + 1]; From patchwork Thu Feb 21 12:42:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 10824043 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 7D5E613B5 for ; Thu, 21 Feb 2019 12:42:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6BF492EC7E for ; Thu, 21 Feb 2019 12:42:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6033A2F00B; Thu, 21 Feb 2019 12:42:27 +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 022BA2EC7E for ; Thu, 21 Feb 2019 12:42:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725991AbfBUMm0 (ORCPT ); Thu, 21 Feb 2019 07:42:26 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:44705 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725920AbfBUMm0 (ORCPT ); Thu, 21 Feb 2019 07:42:26 -0500 Received: by mail-wr1-f67.google.com with SMTP id w2so15251943wrt.11 for ; Thu, 21 Feb 2019 04:42:25 -0800 (PST) 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; bh=Zvty2bF86Z/urDeaR/L5i5e76KnWvFrHOsKzFJIF2vc=; b=SsRVgWJQcAr/CRZ/FYDuwkvbWucunECMob8NdMQAiwgv8cOBAMhoJjXwP0WzgaIOGi Sp2nWoXtQ0lV6ADaSVVogIVY6iVdfxN7OW8V8S8YoBu5XSe+4+NYyunT2paLC3NHn30M 9Ec0I5LW1Ta3713DthEWrgD4AxFGkbS4rwKz/5y7wlc1n/wKOWxsjD+ZtciIqWElB3Jl SPdBbZ8Gb5WIqI32gf4MfjNRS+FxqAIXxJ93LxYQ+jt/RHBaheJ01s+Ip5+niGzpuXWR cMVaVfgtCp3s4kyQJ2Yqm4O60iq/2tluP+naiv14QkvV9qeAjaksNKL3cLOWon6qJx03 4tZA== X-Gm-Message-State: AHQUAuY70K8rSpAWJnL0P1pR8aKOKFXg6wJAU+MCQDyHb0bCX/Uex6iA 4oud5oR21i5GdUXqPzGDOFBDMjsU X-Google-Smtp-Source: AHgI3IZgVb5rB5tjKmpJaxuXoNDWydqcKSqryWMouvoBZjO3sSQnSxyIc32muTeQmmhqTp95d9f6zw== X-Received: by 2002:a1c:4844:: with SMTP id v65mr11045416wma.66.1550752944767; Thu, 21 Feb 2019 04:42:24 -0800 (PST) Received: from mamba.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id b4sm1359517wrr.64.2019.02.21.04.42.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 04:42:24 -0800 (PST) From: Yordan Karadzhov To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, Yordan Karadzhov Subject: [PATCH 3/3] kernel-shark: Fix a bug in ksmodel_set_next_bin_edge() Date: Thu, 21 Feb 2019 14:42:05 +0200 Message-Id: <20190221124205.21115-4-ykaradzhov@vmware.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190221124205.21115-1-ykaradzhov@vmware.com> References: <20190221124205.21115-1-ykaradzhov@vmware.com> 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 The modification of the last bin of the model makes no sense (this is my mistake). The comment above the code that is doing this modification is partially correct, however it speaks about increasing the size of the last bin, while the code below the comment changes the lower edge of this bin. The actual increase of the size of the last bin is done in ksmodel_set_upper_edge() where the lower edge of the Upper Overflow bin gets shifted (max + 1). This effectively increases the size of the last bin. Reported-by: Tzvetomir Stoyanov Fixes: f97e31f00 ("kernel-shark-qt: Introduce the visualization model ..") Signed-off-by: Yordan Karadzhov Acked-by: Slavomir Kaslev Reviewed-by: Slavomir Kaslev --- kernel-shark/src/libkshark-model.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/kernel-shark/src/libkshark-model.c b/kernel-shark/src/libkshark-model.c index b6d3612..4bd1e2c 100644 --- a/kernel-shark/src/libkshark-model.c +++ b/kernel-shark/src/libkshark-model.c @@ -266,15 +266,6 @@ static void ksmodel_set_next_bin_edge(struct kshark_trace_histo *histo, /* Calculate the beginning of the next bin. */ time = histo->min + next_bin * 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; /* * Find the index of the first entry inside * the next bin (timestamp > time).