Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp5994342ybe; Tue, 10 Sep 2019 11:53:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqzYbr69n0IfNOh+Trmsvasah8rXWEBsrLsj/JkpPtVXElMWL2P+cBVtztCNgRtHao2EbesH X-Received: by 2002:a50:cfc7:: with SMTP id i7mr23696496edk.89.1568141610778; Tue, 10 Sep 2019 11:53:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568141610; cv=none; d=google.com; s=arc-20160816; b=RWkb4A5VysacTujTUXkyOkSZo2ZMX0yyFzWs/he8cUbeMZ9a3ESUWqRiegyG5Xt1iP xI/vsd+9f9qF+8jk23idV47JNNkDT4Y/0oTaRolDBfaxgL3LvLobOffT1AJb4C2F6clj QbVoOqYrHGPUK7d8DhZ16aRGnGChEeR9Bf4s3Zn/0tlSwDRLC1NU6cC4maDZgKo2GnWi zxAVy1p4LhlHXlq2qQJ714GQ+pwjOumfLYEZXKvbJHBkhyWCC7J0yJ/y2mMaKlYogk2l tT/s22CHFZu2SvLS8RWgZLNzSoDpBEjxhRfdZDCdvmO5q7iM7qvGh9jFfsIXcKcWQt6t 4n/A== 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:subject:cc:to:from:date; bh=PwpNX4SYREokakm9GKvpoJWiZrseOUqotDseBzW1EHY=; b=TOApej5YnNzbewTkdAJqTXNckqv8+7NTZO31SD6FE7aPpqLMAvkCGSW3Vnc9RAerZA CJvv9loaIMQ23g7L1UQLe+kZoayE64bUcWf+x1dkYkxqFrVqGXY1JxQt6LPL7PsMonl3 u3Ewzh2+hNXzsUCc0wta1a1968wk/OU4Qd0S5PP9P7ckU5FvwbrlO5XqzULjjItd5Kiu tBYbRhHzfHFcYerASzRz/obp/FnVGedoSjKNYiagocfofYclPgF9mpNJQbIX82efe1VK cBn0Cw0nKS535US54IvWLeTW1RtEhD/tFCh5UrXKxsXBXwmjFRVrI08snR8hguoGoVv8 IFxg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z13si9894547eju.97.2019.09.10.11.53.06; Tue, 10 Sep 2019 11:53:30 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732048AbfIJJ2I (ORCPT + 99 others); Tue, 10 Sep 2019 05:28:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:46982 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726060AbfIJJ2H (ORCPT ); Tue, 10 Sep 2019 05:28:07 -0400 Received: from oasis.local.home (unknown [148.69.85.38]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 34EC620872; Tue, 10 Sep 2019 09:28:06 +0000 (UTC) Date: Tue, 10 Sep 2019 05:28:04 -0400 From: Steven Rostedt To: Changbin Du Cc: Ingo Molnar , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] ftrace: simplify ftrace hash lookup code Message-ID: <20190910052804.57308909@oasis.local.home> In-Reply-To: <20190910003321.d3q65j756z3vzhiw@mail.google.com> References: <20190909003159.10574-1-changbin.du@gmail.com> <20190909105424.6769b552@oasis.local.home> <20190910003321.d3q65j756z3vzhiw@mail.google.com> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 10 Sep 2019 08:33:23 +0800 Changbin Du wrote: > > > > bool ftrace_lookup_ip(struct ftrace_hash *hash, unsigned long ip, bool empty_result) > > { > > if (ftrace_hash_empty(hash)) > > return empty_result; > > > > return __ftrace_lookup_ip(hash, ip); > > } > > > We must add another similar function since ftrace_lookup_ip() returns a pointer. > > bool ftrace_contains_ip(struct ftrace_hash *hash, unsigned long ip, > bool empty_result) > { > if (ftrace_hash_empty(hash)) > return empty_result; > > return !!__ftrace_lookup_ip(hash, ip); > } > > But after this, it's a little overkill I think. It is not much simpler than before. > Do you still want this then? > > Or... static struct ftrace_func_entry empty_func_entry; #define EMPTY_FUNC_ENTRY = &empty_func_entry; [..] * @empty_result: return NULL if false or EMPTY_FUNC_ENTRY on true [..] * @empty_result should be false, unless this is used for testing if the ip * exists in the hash, and an empty hash should be considered true. * This is useful when the empty hash is considered to contain all addresses. [..] struct ftrace_func_entry * ftrace_lookup_ip(struct ftrace_hash *hash, unsigned long ip, bool empty_result) { if (ftrace_hash_empty(hash)) return empty_result ? EMPTY_FUNC_ENTRY : NULL; return __ftrace_lookup_ip(hash, ip); } But looking at this more, I'm going back to not touching the code in this location, because __ftrace_lookup_ip() is static, where as ftrace_lookup_ip() is not, and this is in a very fast path, and I rather keep it open coded. Lets just drop the first hunk of your patch. The second hunk is fine. -- Steve