From patchwork Sat Jun 20 21:45:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 191278 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp1710060ilo; Sat, 20 Jun 2020 14:46:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyirzniTxUMK3CX90A06owigbG8XPvKweT+w2UIkCTa36mbCGFyzFJuCZ3UV7gT+hwmNgXU X-Received: by 2002:a25:d483:: with SMTP id m125mr17041454ybf.339.1592689586175; Sat, 20 Jun 2020 14:46:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592689586; cv=none; d=google.com; s=arc-20160816; b=wELrqKzV+b1elofBiYJJBwVzS7Q7twgHWM5VMof84nyuII1oWKrZmlscbQYe1Eah/y WKW8EelSxd1uFM9j3ab6CF9rPT8/Y5nLMw/f9hRWy5ot1RZ9fFSHDmVt7m3UUUNEiXjx dMRoc7kHYolz3Vn9iz64Q692H7cQm8Uz9QPSfrZmdnzuKJYxTawX/O78ftD2sKqb6Td+ JXiwl9HmSl/jQp93mCIEulGEfZizabT/VTN2NSHumYroULiMnoCaRs/XOv67ug1lCbb4 bUVx4rZkycpkZzTG0glB1+J6lRzSLw0NVhVZZs8S/ig8LycLNObdJRSOMFNyo/rNTiwk D+kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:to:from:dkim-signature; bh=DluY8Oq2yB2PRsFlspiwVeg903l4iG/+upHvbfNm14Q=; b=PofVEv6Us/yIe9kY8NoX8pS0kt8Z9ipFUKMzvvy1ui046gShkwKG5XepBWcB4WF81T KBO6KLFuKWvTqnaeqfNnHInt3Ve1UqUn7k4NLQ7Dh+rik5iQsTC28OmLlmJlIHuGJeFu ftg/AU1VmPhU2WZagkqHDOGo0EeHYNouRTTyJfFP1qyj0kwx8F+y7PmXdQ4vwwDDUtp/ BDkTsXrx/scpgXfP4XdRyKl3K/xepPEdNV/H44tjIM+ZqHRR+j4JMOhoNfHip4h+7b4Z guYebxaNQACBeITAomSmvuBft/bFLF2K7gOpcEPJXmn6TCoRLt+sSt8Y9NGyoHrb73aC Fnqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=MOAvclSR; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v10si8793856ybp.34.2020.06.20.14.46.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 20 Jun 2020 14:46:26 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=MOAvclSR; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:36734 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmlJh-0000EW-Ki for patch@linaro.org; Sat, 20 Jun 2020 17:46:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59496) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmlJF-0000Cu-M1 for qemu-devel@nongnu.org; Sat, 20 Jun 2020 17:45:57 -0400 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]:34206) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jmlJD-0007oo-Qh for qemu-devel@nongnu.org; Sat, 20 Jun 2020 17:45:57 -0400 Received: by mail-pl1-x643.google.com with SMTP id n9so5675076plk.1 for ; Sat, 20 Jun 2020 14:45:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=DluY8Oq2yB2PRsFlspiwVeg903l4iG/+upHvbfNm14Q=; b=MOAvclSRYtWG3W0USsiKFVXWL80r3LkxmeG6Xdlr7QkqgvfernjisV9qSwNO9sO5Qp m70fMHU6I8zFxrcEeyHK60wTw9W3ecsZoNOBRIT4wQu4tOV1EDHQf65fdddRecE063pu o/PT2QNsh+9jRc1kmPI0fHxX/NMB8uSOxd1iaaF3YBKnkHZ5S4l9nfRK+znhr2MG+nR4 XWZboUmxfJRPY5MBKRQjfLVqHUDmVHd6N6VHlFMHVou3An7Cu/rzikaqwROXN2PCAGBj bJvqfOMk3abzUvR0DLSSmd6+TZuxZxawl2CxvAcFwIHqlq4hilR+f9HqDJ1vK6d0S8lO 6VIQ== 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=DluY8Oq2yB2PRsFlspiwVeg903l4iG/+upHvbfNm14Q=; b=GItML1FhkZMqvz+y6RdQApUKqukpBDRvgBh435HmhsJ8UXyY86/Fi3D9x53DimVSQ/ xXBQjd+YcpoirnWG+HFLi1MvfYk4D0h4Q4P3cTp/dPr79mkZMtwnREJgrirq8ilXKq08 l06KKdrCLuJrRle3YrxBC5kKIEeCfYDAoujOQ4wSvNucGHPcjYuKbcKrSIHpEqbO0OBq f+aOmyhZGf1A48Ky4DnXHUvI4VuNWA47Kb+D7VkrgnH8q/su2X4D7LDLFq4vxPkhLQdS 8PyBXbHRxgXjfIWsZ+7YmxY5Sqcinb9L9cRqOTryvfowfsaWYqc1svChwCafd43jezJR sG9Q== X-Gm-Message-State: AOAM531+XngAIqxCAimn3uk/7032MKC4vjqc3fRJk81qfI0FN9YwelAS ixOMC6gvdS7MwMGvj0gRii8ytFbnJHQ= X-Received: by 2002:a17:902:ed02:: with SMTP id b2mr13854700pld.326.1592689553448; Sat, 20 Jun 2020 14:45:53 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id q1sm10087959pfk.132.2020.06.20.14.45.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Jun 2020 14:45:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH] tests/qht-bench: Adjust rate computation and comparisons Date: Sat, 20 Jun 2020 14:45:51 -0700 Message-Id: <20200620214551.447392-1-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::643; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x643.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, "Emilio G . Cota" , alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Use <= comparisons vs the threshold, so that threshold UINT64_MAX is always true, corresponding to rate 1.0 being unity. Simplify do_threshold scaling to 2**64, with a special case for 1.0. Cc: Emilio G. Cota Signed-off-by: Richard Henderson --- tests/qht-bench.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) -- 2.25.1 diff --git a/tests/qht-bench.c b/tests/qht-bench.c index eb88a90137..21b1b7de82 100644 --- a/tests/qht-bench.c +++ b/tests/qht-bench.c @@ -132,7 +132,7 @@ static void do_rz(struct thread_info *info) { struct thread_stats *stats = &info->stats; - if (info->r < resize_threshold) { + if (info->r <= resize_threshold) { size_t size = info->resize_down ? resize_min : resize_max; bool resized; @@ -154,7 +154,7 @@ static void do_rw(struct thread_info *info) uint32_t hash; long *p; - if (info->r >= update_threshold) { + if (info->r > update_threshold) { bool read; p = &keys[info->r & (lookup_range - 1)]; @@ -281,11 +281,18 @@ static void pr_params(void) static void do_threshold(double rate, uint64_t *threshold) { + /* + * For 0 <= rate <= 1, scale to fit in a uint64_t. + * + * For rate == 1, returning UINT64_MAX means 100% certainty: all + * uint64_t will match using <=. The largest representable value + * for rate less than 1 is 0.999999999999999889; scaling that + * by 2**64 results in 0xfffffffffffff800. + */ if (rate == 1.0) { *threshold = UINT64_MAX; } else { - *threshold = (rate * 0xffff000000000000ull) - + (rate * 0x0000ffffffffffffull); + *threshold = rate * 0x1p64; } }