From patchwork Sat Jun 29 06:27:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Thelen X-Patchwork-Id: 11023731 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 3385A1510 for ; Sat, 29 Jun 2019 06:28:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 24B5D287E9 for ; Sat, 29 Jun 2019 06:28:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 14BE028862; Sat, 29 Jun 2019 06:28:24 +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=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL 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 9A826287E9 for ; Sat, 29 Jun 2019 06:28:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726762AbfF2G2W (ORCPT ); Sat, 29 Jun 2019 02:28:22 -0400 Received: from mail-pg1-f201.google.com ([209.85.215.201]:57201 "EHLO mail-pg1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726719AbfF2G2W (ORCPT ); Sat, 29 Jun 2019 02:28:22 -0400 Received: by mail-pg1-f201.google.com with SMTP id x13so4265108pgk.23 for ; Fri, 28 Jun 2019 23:28:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=P5pwqm0rEV2Up8GDR1U55SfeXGCLtuWbUKbxbKiyJv0=; b=Bf58BNTWi4wxsalWOov+ARnPODu/u4gqHhMD/6cmo4zHvZXRdatasePVMMGnn2bmpt T06dhNlWrYIjIFkbYI5u+Ye60lwW7aT+e/Yt5RS/mKDFmw91gm1TQ+mJxTEUxnu2eb9b lfChMy2bcQGkN2ae4+BQYc/9AOu3jr6o4FtigYdFHy0EdieiAu/mzvVwgNpzq2R1NDes eaTP8pUf4TN8SbFKwdIBSiVr5e3BClqOEi6B9TgZkywYOtDb7IIF64UoH6gnM4R6iPum 888df/EFjQ+nKESI39CqxW6+73j6h3X/8aM++vtDrT9r4VQKegfT+6h+4vdC8ELlkTcG O4LA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=P5pwqm0rEV2Up8GDR1U55SfeXGCLtuWbUKbxbKiyJv0=; b=abrSd7trY+RTWMFY5Y8em5t5aplk8D1U5nqvlmp+kzzmpHt5Ix7Y67j6SJO7YrQXp3 XufZtQnxGIxlKtVYg5Q3eI6DgpHCnokoMNbXjnNKVp1lzEuqH203U5oaAdpzH0AsGel5 piljf4+NRCvsjTjdQe/Yk/THcgsMDy3Cu89d4MBz6Qv8r72FfR8ICrGsw+xPSqLB3KHn PrHmYSp4RbjVFdyjGN1blS9hdzWJXo4eHOHJ2gY1sKMPcwfETsghkXlEbJBIyxRhkYvV /W1lxjwJKz+fFZlcGKlb160YDH3A99bC695X9QPj68+RAJb+JNw9T0ur4mjGsuEAD6X3 o+Ew== X-Gm-Message-State: APjAAAXbKwHmJhAg+pgsnyEtGF6WV/S0VFeDCn8DesQ5Nk6fHLi4HRjm dpUzgkUG1UVr73CEmFy/JWwZ40VNQtGd X-Google-Smtp-Source: APXvYqwNY2hlKUL655n3DWw8QYLhjxCPYB3riRSoQE1soJ96amBtU2KnmCJO1e+dZ+EABgj37wfdd8ayXCXE X-Received: by 2002:a63:5c19:: with SMTP id q25mr13234050pgb.215.1561789700997; Fri, 28 Jun 2019 23:28:20 -0700 (PDT) Date: Fri, 28 Jun 2019 23:27:52 -0700 In-Reply-To: <20190627121542.2dc0d328@gandalf.local.home> Message-Id: <20190629062752.204113-1-gthelen@google.com> Mime-Version: 1.0 References: <20190627121542.2dc0d328@gandalf.local.home> X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog Subject: [PATCH v2] trace-cmd: remove ununsed knuth_hash*() routines From: Greg Thelen To: Steven Rostedt , "Yordan Karadzhov (VMware)" Cc: linux-trace-devel@vger.kernel.org, Greg Thelen 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 Neither 16-bit knuth_hash16() nor the 32-bit knuth_hash() are used. Delete them both. And rename the remaining function: knuth_hash8() => knuth_hash() Signed-off-by: Greg Thelen Reviewed-by: Yordan Karadzhov (VMware) --- kernel-shark/src/libkshark.c | 12 +++++----- lib/trace-cmd/trace-filter-hash.c | 40 +++++++------------------------ 2 files changed, 14 insertions(+), 38 deletions(-) diff --git a/kernel-shark/src/libkshark.c b/kernel-shark/src/libkshark.c index 0f0a1bab4d5c..d2764e813194 100644 --- a/kernel-shark/src/libkshark.c +++ b/kernel-shark/src/libkshark.c @@ -252,13 +252,13 @@ void kshark_free(struct kshark_context *kshark_ctx) free(kshark_ctx); } -static inline uint8_t knuth_hash8(uint32_t val) +static inline uint8_t knuth_hash(uint32_t val) { /* - * Hashing functions, based on Donald E. Knuth's Multiplicative - * hashing. See The Art of Computer Programming (TAOCP). - * Multiplication by the Prime number, closest to the golden - * ratio of 2^8. + * Small table hashing function adapted from Donald E. Knuth's 32 bit + * multiplicative hash. See The Art of Computer Programming (TAOCP). + * Multiplication by the Prime number, closest to the golden ratio of + * 2^8. */ return UINT8_C(val) * UINT8_C(157); } @@ -282,7 +282,7 @@ kshark_add_task(struct kshark_context *kshark_ctx, int pid) struct kshark_task_list *list; uint8_t key; - key = knuth_hash8(pid); + key = knuth_hash(pid); list = kshark_find_task(kshark_ctx, key, pid); if (list) return list; diff --git a/lib/trace-cmd/trace-filter-hash.c b/lib/trace-cmd/trace-filter-hash.c index 39b28790e0bc..45ca68c2959e 100644 --- a/lib/trace-cmd/trace-filter-hash.c +++ b/lib/trace-cmd/trace-filter-hash.c @@ -14,45 +14,21 @@ #define FILTER_HASH_SIZE 256 -/* - * Hashing functions, based on Donald E. Knuth's Multiplicative hashing. - * See The Art of Computer Programming (TAOCP). - */ - -static inline uint8_t knuth_hash8(uint32_t val) +static inline uint8_t knuth_hash(uint32_t val) { /* - * Multiplicative hashing function. - * Multiplication by the Prime number, closest to the golden - * ratio of 2^8. + * Small table hashing function adapted from Donald E. Knuth's 32 bit + * multiplicative hash. See The Art of Computer Programming (TAOCP). + * Multiplication by the Prime number, closest to the golden ratio of + * 2^8. */ return UINT8_C(val) * UINT8_C(157); } -static inline uint16_t knuth_hash16(uint32_t val) -{ - /* - * Multiplicative hashing function. - * Multiplication by the Prime number, closest to the golden - * ratio of 2^16. - */ - return UINT16_C(val) * UINT16_C(40507); -} - -static inline uint32_t knuth_hash(uint32_t val) -{ - /* - * Multiplicative hashing function. - * Multiplication by the Prime number, closest to the golden - * ratio of 2^32. - */ - return val * UINT32_C(2654435761); -} - struct tracecmd_filter_id_item * tracecmd_filter_id_find(struct tracecmd_filter_id *hash, int id) { - int key = knuth_hash8(id); + int key = knuth_hash(id); struct tracecmd_filter_id_item *item = hash->hash[key]; while (item) { @@ -66,7 +42,7 @@ tracecmd_filter_id_find(struct tracecmd_filter_id *hash, int id) void tracecmd_filter_id_add(struct tracecmd_filter_id *hash, int id) { - int key = knuth_hash8(id); + int key = knuth_hash(id); struct tracecmd_filter_id_item *item; item = calloc(1, sizeof(*item)); @@ -81,7 +57,7 @@ void tracecmd_filter_id_add(struct tracecmd_filter_id *hash, int id) void tracecmd_filter_id_remove(struct tracecmd_filter_id *hash, int id) { - int key = knuth_hash8(id); + int key = knuth_hash(id); struct tracecmd_filter_id_item **next = &hash->hash[key]; struct tracecmd_filter_id_item *item;