Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp694551pxk; Sun, 30 Aug 2020 20:15:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy92V6U4vBCAqWVUIiEk5UWjUWQ4XPz0yfbhdyd46T9kM9jHOwUFh9dl9sF+LuzVVClTq3r X-Received: by 2002:aa7:c805:: with SMTP id a5mr9297899edt.60.1598843750601; Sun, 30 Aug 2020 20:15:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598843750; cv=none; d=google.com; s=arc-20160816; b=0BaH9hCIbg7WdJOEcKXofkY+Y4wIQ8okN3P16SE3eNfrbzW8zrsEINRRv7dOU8AZXM yBIquLYvPpuIJt/0z+bFXHcSHWbl2J2KW88BmhBbFwTh1i7vCserNyX3jLG3izxpvSoA 1WzZEQ/jWPMpabIDSeSRlLtaCAIIXHugtRuWtULETdTmfTWHE4Cpna7a/KIPcRypa2yI tWNYZFHDBdmc4ddN7GUHf4kdsabJei06dhny6w7bZZR9LA2HwWQB8IWnDjOgKh7f8AJ5 5NoEy0C8kheDgoNRALjKd+86gIxsIpwUYWX56BoUDf8CzuM4rgyXEiE9MIIJlYWI9/2m w0mQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=quEu07YMhLFU9MhDraYno+ofhtFhEmR8O8MI6BrmuSw=; b=ApZ29/0zzjDRr3/cUtNpIKPpxXWobusAFPvnBo1jsxFPXnz/2jJPYLgR1HIB3iNVyA GdqOL8+18UNaibV6EIWTaBdjkNNzXqUSfa8F2uF8XilV57DU5D5Z0docpLvJPEkhIg+G ot91CywryUDA+tnO9Zh+6lUBFoMnB01YSjFRopta/z0yFhcBvfNg2sur3bj3LPA6xkuS ed1m73rqYdSDCfFMynLZooH47FaWek7b9laVWCQ5GzpQuhQN+SEw64zG+E+O696hN63C sjtihCfjkiTBJjeJM5xNOnDvZCla1i5LjrJ0P9MJsD5c6PIc/jDUlhigCTsPYOuu8DnJ T8xA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t23si2055543ejf.457.2020.08.30.20.15.28; Sun, 30 Aug 2020 20:15:50 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727935AbgHaDLf (ORCPT + 99 others); Sun, 30 Aug 2020 23:11:35 -0400 Received: from out30-44.freemail.mail.aliyun.com ([115.124.30.44]:38760 "EHLO out30-44.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726712AbgHaDLK (ORCPT ); Sun, 30 Aug 2020 23:11:10 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R311e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e07425;MF=richard.weiyang@linux.alibaba.com;NM=1;PH=DS;RN=4;SR=0;TI=SMTPD_---0U7J4KfP_1598843467; Received: from localhost(mailfrom:richard.weiyang@linux.alibaba.com fp:SMTPD_---0U7J4KfP_1598843467) by smtp.aliyun-inc.com(127.0.0.1); Mon, 31 Aug 2020 11:11:07 +0800 From: Wei Yang To: rostedt@goodmis.org, mingo@redhat.com Cc: linux-kernel@vger.kernel.org, Wei Yang Subject: [PATCH 2/6] ftrace: use fls() to get the bits for dup_hash() Date: Mon, 31 Aug 2020 11:11:00 +0800 Message-Id: <20200831031104.23322-3-richard.weiyang@linux.alibaba.com> X-Mailer: git-send-email 2.20.1 (Apple Git-117) In-Reply-To: <20200831031104.23322-1-richard.weiyang@linux.alibaba.com> References: <20200831031104.23322-1-richard.weiyang@linux.alibaba.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The effect here is to get the number of bits, lets use fls() to do this job. Signed-off-by: Wei Yang --- kernel/trace/ftrace.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 12cb535769bc..9021e16fa079 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -1370,8 +1370,9 @@ static struct ftrace_hash *dup_hash(struct ftrace_hash *src, int size) /* * Make the hash size about 1/2 the # found */ - for (size /= 2; size; size >>= 1) - bits++; + bits = fls(size); + if (bits) + bits--; /* Don't allocate too much */ if (bits > FTRACE_HASH_MAX_BITS) -- 2.20.1 (Apple Git-117)