Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp4270012ybe; Mon, 9 Sep 2019 06:57:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqz46is7m5JiRGWkgTC4kQUTq89EYlRttsGx8lVwGwXdLLif6YcVKuiZgJwbAfLgoK27a9HX X-Received: by 2002:a50:bb22:: with SMTP id y31mr25130791ede.58.1568037448141; Mon, 09 Sep 2019 06:57:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568037448; cv=none; d=google.com; s=arc-20160816; b=IpDStg68arPRyEVCi1dG4XlXBzVlXoJ+0DBCrptzg4sV3uCfaXS+Wjr4ZMZjdO7LDi aB+IN/xTCt4Ihznpyo3z0RiQsCbMamzsPNS2a5T6Wb9pEnnlXICXhX8Cv+mpG4fldpaG GitQvPUvLm9ScOecThQ0PFxu+Fs/9RLsjAFYjCvv2GL4uPrMGY5CvowZVeCseRrXpzQj MJ0JB6xJF+Tk6puVCeQthq/Kx+6y7wEdTSq3Sn+k2ZhH9q+5Fh/v7E42nfNvXaQ5v6+Q dV8417HXw1sDFUIAspABtX/oUaRYK8XjLpfLFMTD+KxWmue9TDL5gE9tk5CblMX2mxQm DI+g== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=uWI+gzhvQ/sFr1tmoKeGjXR/vGqSIS/dhZvWWkXThpY=; b=DucOO7FKWua8aMtOCjMdLyYKpvDkmmlapvPI2bJV1s04hYv51NikXYudRfAMcoeKrJ vZouZ2hu03LlzaJ6tunDjhOgY4H2IIhnlmp/P9s4oq7WLtZ/UC0THCehrttpxwdAam7a l3r8vECFHvubrr62KDe75u+HCBzMYsre35Qm/k98PoBnMDjaNkhcfQDIZJ5GowYtHBpR KYCcAIqzcmKm8qB5E1LqJel61ZNFirOJ2zxvYYIWwGonJrtTY3P1dhk91zYCiypsiQyD Fo5h1LRdE3l0RKtFnBt6GoORR65p6y+a1dTOdfcWKbfwJ0ou3VaaBpztLFKIR8Lh3bL/ l33g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=WwJljbZT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g40si8868519edg.397.2019.09.09.06.57.03; Mon, 09 Sep 2019 06:57:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=WwJljbZT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731934AbfIIAck (ORCPT + 99 others); Sun, 8 Sep 2019 20:32:40 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:34564 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731753AbfIIAck (ORCPT ); Sun, 8 Sep 2019 20:32:40 -0400 Received: by mail-pg1-f193.google.com with SMTP id n9so6784036pgc.1 for ; Sun, 08 Sep 2019 17:32:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=uWI+gzhvQ/sFr1tmoKeGjXR/vGqSIS/dhZvWWkXThpY=; b=WwJljbZT7E8v22P6J6wXYmaqc58XRYZESj8eX5VdIG015eFHaHNOtSNKwABgRxRFWw EnYbrt1LzeBZdGQ4QL5l51YHAzHbOglalONyNsNGrJb29nc4NHtXdrwXwSfRYBLI4/eV wiVmdl1gHeAJKbzfpO2BtSJLYdzUHNgj4Ty6pBPPN8Bn2h6cZEQhxsguaaLQE1n0bXyr bJWxPz0oQ2SrttfV7XHNEbd8xFfu6QpCp09w/Krz0mKgUV4LDNDQMZxHQqBWA9fEGY/a lUwy6uIEYYMw7VUchN98DqBrdPtTvjOONLNRrV0eij2OpVLDopXyMfLjZRVM2JEt9CZz 9KvQ== 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=uWI+gzhvQ/sFr1tmoKeGjXR/vGqSIS/dhZvWWkXThpY=; b=sSepTzmDWEsGK61fnIfi5iDlC0cbFsYwGCpSuQO1jFSk3YkgFB5mG3v0Yh/usfyyhs F4R+3YUcvOQGcXja4X5rryevYUNg54IEGp21IIr44PeaTW3BUx1QhVJc3OGBvUMz04k1 eosrQrbCKWUNF/gVglkXyPv63HMP1SferIyKausAMk8pE6IRv8YnEvRiVS8bxp0zsLph iPfw9o0+N0gwJd8nKfFVzuBOjDcqPJy5ZumcPI7aV2BN3i/nCj/oTctNtUsoS6UTC2q8 1/P721mjBOJ/98PwDz8yH5fIAUPgmPciZMoZXIcpx6YMKR/dFkoxMcMuNRghUkOk+7zs ivJw== X-Gm-Message-State: APjAAAUsaio9knGhCTHThJ5Y/Od44JCsSOY+e87F2x4g5+AhXY/TXiMd HZlH7kYkHlwJrAKLAFY1Uo8= X-Received: by 2002:a63:6c02:: with SMTP id h2mr19794497pgc.61.1567989159256; Sun, 08 Sep 2019 17:32:39 -0700 (PDT) Received: from localhost.localdomain ([149.28.153.17]) by smtp.gmail.com with ESMTPSA id 7sm2033610pfi.91.2019.09.08.17.32.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Sep 2019 17:32:38 -0700 (PDT) From: Changbin Du To: Steven Rostedt Cc: Ingo Molnar , linux-kernel@vger.kernel.org, Changbin Du Subject: [PATCH v2] ftrace: simplify ftrace hash lookup code Date: Mon, 9 Sep 2019 08:31:59 +0800 Message-Id: <20190909003159.10574-1-changbin.du@gmail.com> X-Mailer: git-send-email 2.20.1 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 Function ftrace_lookup_ip() will check empty hash table. So we don't need extra check outside. Signed-off-by: Changbin Du --- v2: fix incorrect code remove. --- kernel/trace/ftrace.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index f9821a3374e9..92aab854d3b1 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -1463,8 +1463,7 @@ static bool hash_contains_ip(unsigned long ip, */ return (ftrace_hash_empty(hash->filter_hash) || __ftrace_lookup_ip(hash->filter_hash, ip)) && - (ftrace_hash_empty(hash->notrace_hash) || - !__ftrace_lookup_ip(hash->notrace_hash, ip)); + !ftrace_lookup_ip(hash->notrace_hash, ip); } /* @@ -6036,11 +6035,7 @@ clear_func_from_hash(struct ftrace_init_func *func, struct ftrace_hash *hash) { struct ftrace_func_entry *entry; - if (ftrace_hash_empty(hash)) - return; - - entry = __ftrace_lookup_ip(hash, func->ip); - + entry = ftrace_lookup_ip(hash, func->ip); /* * Do not allow this rec to match again. * Yeah, it may waste some memory, but will be removed -- 2.20.1