Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp549949pxb; Wed, 27 Oct 2021 07:58:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzIaQC+PBjXftMT3uiTeZDl+KoVoMxXycghEoyfayqGPPviwzMg8AlRcg6K7+z0b9rw/POc X-Received: by 2002:a17:90b:180b:: with SMTP id lw11mr5427909pjb.9.1635346688645; Wed, 27 Oct 2021 07:58:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635346688; cv=none; d=google.com; s=arc-20160816; b=cqthIcsVVZ5dQPbeXxcRC3+wIR9vS5QHrmAXVl6nBDvVhkWw0Ix4OGA4r985l/mBp2 q8NGA7AlrioqVhEdmJMhPkr1ae3oOzPdT30Km4pPqOKLoUeI4vwmr+f/g2rVk62BLRIG SUiqTYe27qPKTE4RfT5NxPVd8/0pEtnSGqPjnIEcR6WBQqezq/NL/zHr7IWGHzyu9RQH 4Ug0iRm+kkie4tBAYX5Ys3Z540gc/uyvakPwD0aVqywFg6ULgFUPdiuzv9qxNd3IItCj hDd1QtNDY8oDZROh/MN9YbUckflRBHYHa1tplln1hnsxpQDpIMoqhqFaXpLT1++QjYsv slwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=hx2CTswgytxvss7kxEurcgmP5KcmJvBjnBSk15OJ7pE=; b=PZpApzx9gg6JTFrTYXIVc8M2VYcwYkHTAYl7fg+e2CIbkgkh99CgCWZGBOxrjLxC9Z EMPgAbc15PMZAKylUI3WneLZFceMMhgpKwlSJxF6DR4x3DSOrnMeErbtQtZmjeGSZ7ph a0iSsCgNyYxy6FEbhQ/CQdXvn7wqtx2UezgDRaEtXm6nFYb+FPVup6+KLChuGds+3sxB jPEYeVtZ0qVbHRec0eerpXZSza7ALPS2k/wZhwjgs7Sf/7SV4agv2e3HJPOKCofdTpoP 3V11M4EfpjXXVWr1t7kEejJXLuqjgpS/K3kCD1zLrOjKBhO0mw9ZrUi0SuCRyPKDhvYw BGAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=EXGwIRd4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j71si226466pgd.11.2021.10.27.07.57.55; Wed, 27 Oct 2021 07:58:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=EXGwIRd4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231575AbhJ0Bd6 (ORCPT + 99 others); Tue, 26 Oct 2021 21:33:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237353AbhJ0Bd5 (ORCPT ); Tue, 26 Oct 2021 21:33:57 -0400 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C784C061745 for ; Tue, 26 Oct 2021 18:31:33 -0700 (PDT) Received: by mail-pj1-x1032.google.com with SMTP id v1-20020a17090a088100b001a21156830bso3799821pjc.1 for ; Tue, 26 Oct 2021 18:31:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=hx2CTswgytxvss7kxEurcgmP5KcmJvBjnBSk15OJ7pE=; b=EXGwIRd4lsCuLvvRdiNRqffudQ8CM9ZJvYGUorXhwpiBZil4EbFzcNtL9Xvx3pz9M4 WSiggrp/PXpWi6Mld8Kqw/lAltNh9dryQmEgfnyRc04qeulm74CT9Sr5zohzDNhZ/7CY 74IVE6QNDELB8g1ZyOmVNofiRYPkOVKZhtaD/QFZuHnVHZupzbdN1S8WRVq8+dKd5CON +Uru4oNtlzHo5AwIwXu0yt6FD0nwqZxB6SV+ynhIj5hflchXNbyMiJTwFUOUNgM99qLF WJrVPzSe01sqhcnxIjKLmdq+dKTy1+LZCVrtbizb2fTdwM9bK4MsL9bVmIiI/n6sW65C IE8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=hx2CTswgytxvss7kxEurcgmP5KcmJvBjnBSk15OJ7pE=; b=qUzY9FH2eHvJ9DmBimT8b6EvJexZ4Gh4fPzsp8N5qkwx7xB82Y5ASiya8d1WVyab3V PwTXed4JnTbD25K0M1IWos8UQLaZIGjeAG+anVVj+JDo8rU01EKVhWdfCbSlBC8cNNXp dqkxXhlAiyQyuq0syvOuiQ6AxWI2gWQ5BZv8zeal847j60ISgGYdIirHz6o0hnDsMIp2 xIUP1G7e2qYXnpbLzGSKDvCGr/GJYaIsfAi+9k6uGLHSWrn5wrl5kFpcQlmTPRJ+8LJh DBtw75TQHW5s0pQ7DotKvijxWM75JTAkSAXGUMxfX31Yyg1do9sM9HsYhIRZui/McPx5 fgkQ== X-Gm-Message-State: AOAM532z0eHcwK0df8Cy+II7Qj/r7+XYQLiGsWlMYC5Tn5h72lbb3Lrx /dW0oIJUGcneXh+3po707r5EOb31vi2Gv/NOIJIOKQ== X-Received: by 2002:a17:90a:b288:: with SMTP id c8mr2480230pjr.67.1635298292469; Tue, 26 Oct 2021 18:31:32 -0700 (PDT) MIME-Version: 1.0 References: <20211025200852.3002369-1-kaleshsingh@google.com> <20211025200852.3002369-7-kaleshsingh@google.com> <20211026151451.7f3e09a4@gandalf.local.home> <20211026201846.08990d1d@rorschach.local.home> <20211026211511.403d76ca@rorschach.local.home> In-Reply-To: <20211026211511.403d76ca@rorschach.local.home> From: Kalesh Singh Date: Tue, 26 Oct 2021 18:31:21 -0700 Message-ID: Subject: Re: [PATCH v4 6/8] tracing/histogram: Optimize division by a power of 2 To: Steven Rostedt Cc: surenb@google.com, hridya@google.com, namhyung@kernel.org, kernel-team@android.com, Jonathan Corbet , Ingo Molnar , Shuah Khan , Masami Hiramatsu , Tom Zanussi , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 26, 2021 at 6:15 PM Steven Rostedt wrote: > > On Tue, 26 Oct 2021 18:09:22 -0700 > Kalesh Singh wrote: > > > > delta = mult * div / 2^20 > > > > > > That is if mult is a power of two, then there would be no rounding > > > errors, and the delta is zero, making the max infinite: > > That should have been (as shown in the algorithm) > > delta = mult * div - 2 ^ 20 > > As mult is 2^20 / div; and the above should end up zero if there's no > rounding issues, as it would be: > > delta = (2^20 / div) * div - 2^20 Good catch. We're checking if we get back the exact value. And IIUC max_div is an arbitrary value we decide on that's <= 2^shift? Is there a rule of thumb for choosing this? Thanks, Kalesh > > -- Steve