From patchwork Thu Mar 7 15:05:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 10843065 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 57D621823 for ; Thu, 7 Mar 2019 15:05:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 41FD22F337 for ; Thu, 7 Mar 2019 15:05:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3640B2F340; Thu, 7 Mar 2019 15:05:42 +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 D91332F346 for ; Thu, 7 Mar 2019 15:05:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726234AbfCGPFl (ORCPT ); Thu, 7 Mar 2019 10:05:41 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:40376 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726127AbfCGPFl (ORCPT ); Thu, 7 Mar 2019 10:05:41 -0500 Received: by mail-wm1-f68.google.com with SMTP id g20so9487162wmh.5 for ; Thu, 07 Mar 2019 07:05:40 -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:mime-version:content-transfer-encoding; bh=ThKcWGp17T1PGZIGkYv9fgJ3BuOcNijCTQQSZYbvuBQ=; b=GHHycF8T44mOkFd7JSmVfbJUxpPEoGTms1x/Pyq9mbvENUKFTOy+o8g4cyGNg/6n/V VIXxY5ECS7PQlVHZrh2S0K0OqXwEW40e6puUHNwyCtKY9yUu6DBB6keFZSPqPFjo5nIS Pls7R37TOFuH7VZDFtdoLHfHlihilRP+GtGCUyPLmcVDIaXLeDasIpOZ8fnezjD7ubZc UysBKuP4bRmjudpcWOF0vrutoQkCTY0odfV3xEcmsXvy0uqNxeqyqY6WYu/0rhe0ny0X btzVpCZxdGVN331hDXkJo0NIPg4wQsbSfFGkOI1jTdOJziYFoTc8fb0OsfrVII//47A+ 5vWA== X-Gm-Message-State: APjAAAVrUVEXG2oakPFXSloWMLhxv4S8G0o9byMfQ6BLXnX2hsr1xmlo 7D8UTUiSfo1nlqOJMHbB5z8= X-Google-Smtp-Source: APXvYqzSjkxds6HixxnbT2jVWjiY8m8/AszlmFBM0TVhwpu9tcxnP68uSTft2NSte1a+H17rFhu3Ng== X-Received: by 2002:a1c:4e19:: with SMTP id g25mr6298701wmh.106.1551971139896; Thu, 07 Mar 2019 07:05:39 -0800 (PST) Received: from localhost.localdomain ([95.87.198.56]) by smtp.gmail.com with ESMTPSA id d15sm10281274wrw.36.2019.03.07.07.05.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Mar 2019 07:05:39 -0800 (PST) From: Yordan Karadzhov To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, Yordan Karadzhov Subject: [PATCH 2/4] kernel-shark: Fix a bug in ksmodel_zoom Date: Thu, 7 Mar 2019 17:05:09 +0200 Message-Id: <20190307150511.17246-3-ykaradzhov@vmware.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190307150511.17246-1-ykaradzhov@vmware.com> References: <20190307150511.17246-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 When zooming-in the model is supposed to avoid over-zooming by recalculation the Scale factor. The new value of the Scale factor is supposed to be such that the size of the bin cannot be smaller than 5 ns. This patch fixes a naive bug in the way the new scale value is calculated. The bug was introduced in f97e31f00 ("kernel-shark-qt: Introduce the visualization model used by the Qt-based KS") but had no effect until 94efea960 ("kernel-shark-qt: Handle the case when the range of the model is too small") because the ridiculous value of the Scale factor resulted in a very small model range and because of this such modification of the model was always rejected. Fixes: f97e31f00 ("kernel-shark-qt: Introduce the visualization model used by the Qt-based KS") Signed-off-by: Yordan Karadzhov --- kernel-shark/src/libkshark-model.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel-shark/src/libkshark-model.c b/kernel-shark/src/libkshark-model.c index 4bd1e2c..7574cbe 100644 --- a/kernel-shark/src/libkshark-model.c +++ b/kernel-shark/src/libkshark-model.c @@ -648,8 +648,8 @@ static void ksmodel_zoom(struct kshark_trace_histo *histo, * Avoid overzooming. If needed, adjust the Scale factor to a the value * which provides bin_size >= 5. */ - if (zoom_in && range * (1 - r) < histo->n_bins * 5) - r = 1 - (histo->n_bins * 5) / range; + if (zoom_in && int (range * (1. - r)) < histo->n_bins * 5) + r = 1. - (histo->n_bins * 5.) / range; /* * Now calculate the new range of the histo. Use the bin of the marker