Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp6008299ybe; Tue, 10 Sep 2019 12:05:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqzynQeIRWofGqOMQT2O92py9TQBZhDATd740FudYmIWm0tYTKo7PqeYDM+IfznCWyUPxios X-Received: by 2002:a05:6402:1e7:: with SMTP id i7mr33632650edy.103.1568142316491; Tue, 10 Sep 2019 12:05:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568142316; cv=none; d=google.com; s=arc-20160816; b=NP2K9yuKsFhPWin9XpRJnR9l5X+Q51dgIWdjfoo+IEJwxFub1nD+MZYD3CevRB1kRv W86+vdQ9rzQbQsuHe6+wBoM5uYDdkrnoTiqBtxc2+CF88PUD/whLH/idAqnJHkzwRQkn cxyrl7S8runOmQotIdXD1Opn6ADCgOU4Uc+QcgKTh9OtWzdXxC0tHd1FQ24jLFrx0+FN A3BkcVTG3YZ+Xejr7sh/nRQh8yszO5s7TlBtncW1kS8DWJzeds1OldYWUGJGg1p0zVbx sUgd3ITb9CgjuDQ/ASHaJe/QHbn21GJXB0yrI1bjzx9NYyw5VTIUO/eR2VXDEXMZWp7Z lQ8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=86T4EY0x21kDNmxHuLO5jp762W67PTiLmWNWsIfvTKY=; b=DmbY5XruLQND+Vt5hVIVwIRzA8e47gkWfDvGyY7JcaqwTAcJukLHSJ0Cbk50xnN6Qb LEVg9UtZHt8Fl/j/i/2MphWkP0NAk4ipOIBKXnf9KuRVAerhYfPhlvn5Bf/+4xuHtkjN D70/kaMQtEsE3tkli3BilSkhur9EYEcV08eMQ9gP0vLycd5FrbjlHOoNED/iAiVFNJkG yeC+KCSZ3a3Gv0zkBItA4iQgMHgEKh6zqIqyiMGZTRKOg93bMOdxDptYt8roDhwOLf32 wiU2cP4HhUET2mF8uyBjIAp2l4fAz9IoVQakQDlFyYodbbDJIbgk2+iYjjLex07o3GMv Ifiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=SPstgmGF; 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 rk9si8992288ejb.79.2019.09.10.12.04.51; Tue, 10 Sep 2019 12:05:16 -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=SPstgmGF; 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 S1731773AbfIJO3p (ORCPT + 99 others); Tue, 10 Sep 2019 10:29:45 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:45175 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725957AbfIJO3p (ORCPT ); Tue, 10 Sep 2019 10:29:45 -0400 Received: by mail-pg1-f195.google.com with SMTP id 4so9841590pgm.12 for ; Tue, 10 Sep 2019 07:29:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=86T4EY0x21kDNmxHuLO5jp762W67PTiLmWNWsIfvTKY=; b=SPstgmGFZl9jfQC+Cn4h8Sbu7aPf7Uf+TuN8fM4Qwko1cE4LSkS5z2QmXQM9qT9xUW aBfPF2xzgnhyzM8u/k5d9I40FxpwcKo7/mnxJ1yqicls642NnsovipNDHzcNMBDbfRMu t0UJs/+xJbl9YwGvPSXydPXgTyxi2ROlLlDTJAwLee1fbaF2WAAL+pRjlrOmTbrOwKQI +kKLgM6X37BlVEs84a+8beKxQJ/NVfrBVyrW3AdLwIA+0WJKVMD6zPyqgX02Zhd86Fs8 K5D9sR/yabKS5xhaGGNNJeQszIvYvpqWVHJVaJ6Rc//T4YstVyaymXKxo73/KG/xrvjW b2pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=86T4EY0x21kDNmxHuLO5jp762W67PTiLmWNWsIfvTKY=; b=Jkkmtyw8U+9IG/oxSIMEkEx3NJyzSoNcZIdvFZvtrQLl3c18UEEMeLYB4gsUJ+2VxK y4FnJtYuQtGDyYyN+AlnAwKIFGq9V1O+aM4DkgPnPGV6mIive/JhXmJqmwNdwD8dlJ+Q vc9wcpPbUBzwrN54SG9K4zm6UMldwJS3AD/xBWJwKCuRkIW+ufEOqRnRF8ELtQX1BIh5 Snyz2nqh08tL8c79M4FX3KMi5BMizTNcEpfbKwejfIUOv5Cy+Wymp7yI+cMj8Vg20fXn 3TGpVO63HNDWXCd6IE7K8MHJEmnEB5VsFeyAGfEgY+o6XnQis//RmnDnNjTm/r3FiEHo hL1A== X-Gm-Message-State: APjAAAWDxtWVMmvz7LA7InOfslaL/Uh7sr+cUoOZo4F44H3vqEveqBCM 1596EczTXA9Mgi6MQ0N1O9xNZLVFKzG24Q== X-Received: by 2002:a65:62d1:: with SMTP id m17mr29380346pgv.271.1568125784847; Tue, 10 Sep 2019 07:29:44 -0700 (PDT) Received: from mail.google.com ([149.28.153.17]) by smtp.gmail.com with ESMTPSA id k64sm27061590pge.65.2019.09.10.07.29.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Sep 2019 07:29:44 -0700 (PDT) Date: Tue, 10 Sep 2019 22:29:38 +0800 From: Changbin Du To: Steven Rostedt Cc: Changbin Du , Ingo Molnar , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] ftrace: simplify ftrace hash lookup code Message-ID: <20190910142937.7mg72wco36ycpjs7@mail.google.com> References: <20190909003159.10574-1-changbin.du@gmail.com> <20190909105424.6769b552@oasis.local.home> <20190910003321.d3q65j756z3vzhiw@mail.google.com> <20190910052804.57308909@oasis.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190910052804.57308909@oasis.local.home> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 10, 2019 at 05:28:04AM -0400, Steven Rostedt wrote: > 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. > Sure, I will send a update short later. Thanks for your suggestions. > > -- Steve -- Cheers, Changbin Du