Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp2187373pxb; Wed, 9 Feb 2022 12:45:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJxTL7bdZaEJDiB9K0irASIsKp29X9PpP11JMzWUOITvuSJLFyRdJVmwkYz651xsUh4v5Ax4 X-Received: by 2002:a62:5804:: with SMTP id m4mr3584998pfb.81.1644439540501; Wed, 09 Feb 2022 12:45:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644439540; cv=none; d=google.com; s=arc-20160816; b=JXA2hkDQ8Z/0OWfATpy/dD2rf28nwA/jCB8pS+1YEfDQWqmycbgRiJrQVhsL1ac5Ip c1cH9p7UWdilVVvV8HIuDs31Ae+OG0XBCwvahVd8DQjca9YLoPm6MHPP8vyb0ntkJdeU dShYgME6f+SSekhkXNxm47Ic/ZzasIATzeGJGofvO0A6eJ9c+7Oc5Zwbsbu8znJw534e QUCrAhvkhjQrICI7ebretsWjuuL3aj1efot10CUeJJhjE6alT914B2tnWmp7Iy6xX1ss IMQt4t4dBRvVuTZW91X7tjpcADSJrpSxJ7SUAs+Vo7HGvoyvD/VXcULdjKZvpayu40PR +1gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=TAb9RMF5rdP3oF08yRzn8MffJjQ5kNb8IB5u5y/hypk=; b=N3MJ326z1u+zIMupDMsTopxXtYbZ987DWXofWtPYrXT1pDtO+f7MEg6XQ6Uqo3X7O8 SXEtKNx6enlz0qm+8Irn9Ta641oZ0Pa582VV64LEOYFid9z05ccz6MvPqDWHxksDad1t F7TcOudDWOz4+nXnzJddjE4yuMQRlS8+S//jcbsxwS1bGaq1qKeQ7b1PugnRTh3DaOM9 gIZIFf1mB55JslfCon1FGRgoDItXrnTWAWUvwhWWMB9E8HRPxg5jF7FjsbHDFZQe3y/a +JFwvRwsaM+slVlkCYLz/uFj/PRiVLaiXwI6EE1hc3AwlJDuQCL/0waqrRz8YMMgmgJB uw0w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id e3si15968909plo.65.2022.02.09.12.45.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 12:45:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2CD99E0918CA; Wed, 9 Feb 2022 12:11:37 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235649AbiBITbv (ORCPT + 99 others); Wed, 9 Feb 2022 14:31:51 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:35180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235883AbiBITbf (ORCPT ); Wed, 9 Feb 2022 14:31:35 -0500 Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF6B9C1DC06A; Wed, 9 Feb 2022 11:22:57 -0800 (PST) Received: by mail-lj1-f175.google.com with SMTP id t14so4842705ljh.8; Wed, 09 Feb 2022 11:22:57 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=TAb9RMF5rdP3oF08yRzn8MffJjQ5kNb8IB5u5y/hypk=; b=1MyEJIKn09+g71ZGo4sfbjB6JpK4pIgqZv140B6IXhwCbq87UNojDO+Z4kzQExxmCl lPVaxagvpIkvOihaA6lfkZG8dRJ0q4NWO98Ox7WehBxX4fXR71PaO3vLUXneWIT23MkM yKzhQYWWRwRBBfM1ttRzzn1bbJRQ5yrR/R6lJs0xIJyQHsdJxqSc/9LOAeIBqjDvaBMs Y1qGCcdIbGof/eIJ/gK03TgSP1LZBUjF0iY135Ic9XodIsoLsHhg1TtDZWiMI74NryOP L8KUDPYF5n6aYmvHlpy1ZPii2hQ4Ulk5zhRYhQ7Z5L/MlvTX6nrCGtCcEXlFg1a0cCNe ZhHA== X-Gm-Message-State: AOAM532H1fR2XRsXn+PrPcWmvfr3Mhxti0GS5WSfekNQkvgOaBzwTsWb iW+YOsl2iX9VbWUrBlIJvtCgyv+pwQHJWBxPGVI= X-Received: by 2002:a2e:5352:: with SMTP id t18mr2459533ljd.241.1644434575676; Wed, 09 Feb 2022 11:22:55 -0800 (PST) MIME-Version: 1.0 References: <20220208184208.79303-1-namhyung@kernel.org> <20220209090908.GK23216@worktop.programming.kicks-ass.net> <24fe6a08-5931-8e8d-8d77-459388c4654e@redhat.com> <919214156.50301.1644431371345.JavaMail.zimbra@efficios.com> <69e5f778-8715-4acf-c027-58b6ec4a9e77@redhat.com> In-Reply-To: <69e5f778-8715-4acf-c027-58b6ec4a9e77@redhat.com> From: Namhyung Kim Date: Wed, 9 Feb 2022 11:22:44 -0800 Message-ID: Subject: Re: [RFC 00/12] locking: Separate lock tracepoints from lockdep/lock_stat (v1) To: Waiman Long Cc: Mathieu Desnoyers , Peter Zijlstra , Ingo Molnar , Will Deacon , Boqun Feng , linux-kernel , Thomas Gleixner , rostedt , Byungchul Park , Radoslaw Burny , Tejun Heo , rcu , cgroups , linux-btrfs , intel-gfx@lists.freedesktop.org, "Paul E. McKenney" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On Wed, Feb 9, 2022 at 11:02 AM Waiman Long wrote: > > On 2/9/22 13:29, Mathieu Desnoyers wrote: > > ----- On Feb 9, 2022, at 1:19 PM, Waiman Long longman@redhat.com wrote: > > > >> On 2/9/22 04:09, Peter Zijlstra wrote: > >>> On Tue, Feb 08, 2022 at 10:41:56AM -0800, Namhyung Kim wrote: > >>> > >>>> Eventually I'm mostly interested in the contended locks only and I > >>>> want to reduce the overhead in the fast path. By moving that, it'd be > >>>> easy to track contended locks with timing by using two tracepoints. > >>> So why not put in two new tracepoints and call it a day? > >>> > >>> Why muck about with all that lockdep stuff just to preserve the name > >>> (and in the process continue to blow up data structures etc..). This > >>> leaves distros in a bind, will they enable this config and provide > >>> tracepoints while bloating the data structures and destroying things > >>> like lockref (which relies on sizeof(spinlock_t)), or not provide this > >>> at all. > >>> > >>> Yes, the name is convenient, but it's just not worth it IMO. It makes > >>> the whole proposition too much of a trade-off. > >>> > >>> Would it not be possible to reconstruct enough useful information from > >>> the lock callsite? > >>> > >> I second that as I don't want to see the size of a spinlock exceeds 4 > >> bytes in a production system. > >> > >> Instead of storing additional information (e.g. lock name) directly into > >> the lock itself. Maybe we can store it elsewhere and use the lock > >> address as the key to locate it in a hash table. We can certainly extend > >> the various lock init functions to do that. It will be trickier for > >> statically initialized locks, but we can probably find a way to do that too. > > If we go down that route, it would be nice if we can support a few different > > use-cases for various tracers out there. > > > > One use-case (a) requires the ability to query the lock name based on its address as key. > > For this a hash table is a good fit. This would allow tracers like ftrace to > > output lock names in its human-readable output which is formatted within the kernel. > > > > Another use-case (b) is to be able to "dump" the lock { name, address } tuples > > into the trace stream (we call this statedump events in lttng), and do the > > translation from address to name at post-processing. This simply requires > > that this information is available for iteration for both the core kernel > > and module locks, so the tracer can dump this information on trace start > > and module load. > > > > Use-case (b) is very similar to what is done for the kernel tracepoints. Based > > on this, implementing the init code that iterates on those sections and populates > > a hash table for use-case (a) should be easy enough. > > Yes, that are good use cases for this type of functionality. I do need > to think about how to do it for statically initialized lock first. Thank you all for the review and good suggestions. I'm also concerning dynamic allocated locks in a data structure. If we keep the info in a hash table, we should delete it when the lock is gone. I'm not sure we have a good place to hook it up all. Thanks, Namhyung