Received: by 10.213.65.68 with SMTP id h4csp773193imn; Tue, 27 Mar 2018 08:30:46 -0700 (PDT) X-Google-Smtp-Source: AG47ELsrFsPPzzB8z7GvKdp8ljZE6e95okDpqoyjOU5i4KXmvLqkKhkvEW8WVfNtJTCX2GsAeq9S X-Received: by 10.98.12.140 with SMTP id 12mr30908634pfm.123.1522164646826; Tue, 27 Mar 2018 08:30:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522164646; cv=none; d=google.com; s=arc-20160816; b=OUbmetd+Cplb8+y7dn3GCGTdzSgH7BoNkYWlpbs5Zla3vFm5ZWlEMLLTRaj7LZlNhU HjCRiw3CBFOxf+9UbTvhK5+zDj8bJMPWh6Sz5eOeVYia7RXZiepA2DOfF8CvDptlNi1P HVIL1fwsgqWb2SvP9Wl8ZWmxnJXpHTwO88mn4qNtg9iJXim7sojN6KpsRfONwPwnx250 bPzaUN5F2X7u8CKjeF+seQuROtb+TSJyPANxmsmdAnOvMi8U+bWtSRUairYRwNPwibcw rSoca8/NShfJ8a4iFDaaidPSbv/65HTHqekgnrx6fGKz3D9tn0HTOXXL7WES1twkRRUu jXVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=bgKRBda5urlGiDwzc5BNYAKhJ2dKiDHtN8sFUqkFWRY=; b=yJ5hF14zMNekcZ2+FYAfeimIWykFRUXB8qDlOtnLD8jI05SrZGLWHbHPV+m2Yqtxml l0chFkhFHzE7L/j2EVm8vMNUPb0xc5SAe2hWE7+AlQoCtNNtWI7A17DedoVphvWtXB/g /2DL4fhe+AgO93LencKvJaiYCAOIWQoRU+Dm30jzH4o7MpOsvqfG/TZZAZcSTgIAXhSg mk2EqrcEthEqqVWODlFBimLye8pnqNoKwLXmswKuZqpHA4EY0R7+Vx8JByLfDpXbzerf WHwRRd1tqTrPyrFWpn2b9RmS7dcY/SgxSxqOZV7kqdpdcnck5gmIgTk0LEodyVpMW4nU iL/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=EIGyzLR/; 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 g3-v6si1420823plp.662.2018.03.27.08.30.30; Tue, 27 Mar 2018 08:30:46 -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=EIGyzLR/; 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 S1752557AbeC0P24 (ORCPT + 99 others); Tue, 27 Mar 2018 11:28:56 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:52679 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751120AbeC0P2z (ORCPT ); Tue, 27 Mar 2018 11:28:55 -0400 Received: by mail-wm0-f66.google.com with SMTP id l9so22489024wmh.2 for ; Tue, 27 Mar 2018 08:28:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=bgKRBda5urlGiDwzc5BNYAKhJ2dKiDHtN8sFUqkFWRY=; b=EIGyzLR/NU7CCi4nkNgNKg8BkqOrpKpyYUWJ5XX1S1NcYae4oNFrAJbmktun23QgW3 Den6VWOG9yFO0awB0qr5u+vUevVxj1YJJqZlnDLDmcoeasdQiE7jXhVfWLtJs3T9wh3M IRlo0qeA4tiin5H9RGqL7Qd4d00FKTjRsXt4BdNn1gkRUDHExkOSbabLjAwjJRQcRW27 4DZeLD0lJ4ztrrw2ePjCJh82YWiM1TzyHGBq4WgHa3ZVcXckezcYuicvXFZ4iWe9WJk/ 0Di6PH4wDu2L+7n80c7rklv8w9/MU6UmUb/qeCstqIKTYKL6p/NMmnJETTsHwZMD81M6 8TMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=bgKRBda5urlGiDwzc5BNYAKhJ2dKiDHtN8sFUqkFWRY=; b=EvZbll2DhuukfgVlNprNuuRmNELiJpR7HOIvVPLE0oLpOX2FS8aWN+u5IBD+7pFHNm x1mSGm2zNdgRJcX+gZmhYCOy5C+EMs/bCCytcuJoRBvjJtdCfVX4VmqGp7GqcJiT4bmz nbxhs0l2mF/Vl2m8g/RjgK0xUijVW4IE1qM9MoMHS6O6Fr16OGhvYzkI+Jmeom78rz4M 37m4UmpcHk7YykHlCQadQdox8WnZwOaWIY/wPkbjOcxmzR3AKp9/nmIiWJfiCDSKLve/ NRv7H46l6c8i7m4iSAzX86NLjkWfV1U+B1j69bQkzHWTYBIdL/ehYKMgOU6ohdDfwy3N h4Dw== X-Gm-Message-State: AElRT7HZcqWofCdq0CvqHm6WfP1fop5J558eQHXiChJRdg+dAv+sxwZH ft5krV++7tLN/B1mZUNA4yP79NfgRussc6y/xDQ= X-Received: by 10.80.208.221 with SMTP id g29mr46022893edf.295.1522164533889; Tue, 27 Mar 2018 08:28:53 -0700 (PDT) MIME-Version: 1.0 Received: by 10.80.139.137 with HTTP; Tue, 27 Mar 2018 08:28:53 -0700 (PDT) In-Reply-To: <213641788.1071.1522157276112.JavaMail.zimbra@efficios.com> References: <20180326191031.14939-1-mathieu.desnoyers@efficios.com> <213641788.1071.1522157276112.JavaMail.zimbra@efficios.com> From: "Joel Fernandes (Google)" Date: Tue, 27 Mar 2018 08:28:53 -0700 Message-ID: Subject: Re: [RFC PATCH] tracepoint: Provide tracepoint_kernel_find_by_name To: Mathieu Desnoyers Cc: rostedt , linux-kernel , Alexei Starovoitov , Peter Zijlstra , Ingo Molnar Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 27, 2018 at 6:27 AM, Mathieu Desnoyers wrote: >>> +static void find_tp(struct tracepoint *tp, void *priv) >>> +{ >>> + struct tp_find_args *args = priv; >>> + >>> + if (!strcmp(tp->name, args->name)) { >>> + WARN_ON_ONCE(args->tp); >>> + args->tp = tp; >> >> I think this runtime check is not needed if it really can't happen >> (linker verifies that already as you mentioned) although I'm not >> opposed if you still want to keep it, because there's no way to break >> out of the outer loop anyway so I guess your call.. > > We can change the outer loop and break from it if needed, that's not > an issue. > >> I would just do: >> >> if (args->tp) >> return; >> >> if find_tp already found the tracepoint. >> >> Tried to also create a duplicate tracepoint and I get: >> CC init/version.o >> AR init/built-in.o >> AR built-in.o >> LD vmlinux.o >> block/blk-core.o:(__tracepoints+0x440): multiple definition of >> `__tracepoint_sched_switch' >> kernel/sched/core.o:(__tracepoints+0x440): first defined here >> Makefile:1032: recipe for target 'vmlinux' failed >> make: *** [vmlinux] Error 1 > > Yeah, as I state in my changelog, I'm very well aware that the linker > is able to catch those. This was the purpose of emitting a > __tracepoint_##name symbol in the tracepoint definition macro. This > WARN_ON_ONCE() is a redundant check for an invariant that we expect > is provided by the linker. Given that it's not a fast path, I would > prefer to keep this redundant check in place, given that an average > factor 2 speedup on a slow path should really not be something we > need to optimize for. IMHO, for slow paths, robustness is more important > than speed (unless the slow path becomes so slow that it really affects > the user). > > I envision that a way to break this invariant would be to compile a > kernel object with gcc -fvisibility=hidden or such. I admit this is > particular scenario is really far fetched, but it illustrates why I > prefer to keep an extra safety net at runtime for linker-based > validations when possible. > > If a faster tracepoint lookup function is needed, we should consider > perfect hashing algorithms done post-build, but so far nobody has > complained about speed of this lookup operation. Anyhow a factor 2 in > the speed of this lookup should really not matter, right ? Yes, I agree with all the great reasons. So lets do it your way then. thanks, - Joel