Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp2186763pxb; Wed, 9 Feb 2022 12:44:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJwJf2bvNPU3bEaKhNHM6HM76QUCIzfEjfg4EcGTzNewzLUetB7c6Ks+c+ZtzKrnuocl9qDx X-Received: by 2002:a62:b618:: with SMTP id j24mr4115014pff.69.1644439495304; Wed, 09 Feb 2022 12:44:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644439495; cv=none; d=google.com; s=arc-20160816; b=aGo8tm0D2xfCEY0jn/DsvmYppHRJEnPR1d7GvCJ+3i/jthPvfrjE3sLUWa7qVLgJce ik6JAw7egrBW1iAJHeLswLcatPHyzItESwnl8UN+raUAJ0FFDZIP4Ch9Exq11KYJ/Bso x4XVBwoMNTvxzIcgozkfe0pWhHCOd8pZqZn/4WNkSzPigp7lDqV/rkF9koaj7xiT/e10 Mk6rNe66/94uQgw4dbo1J9pvzw1cxf/UxF/CH3Z6D2baY5TZnZ4mL0wNYP89qFPtAq6y okOC290ykDc6OCby4I3/YoKtG5H2WYWoTRNZcCF0SYQ0vg5oDWk9loUQZ54sazmJInkt YY8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:thread-index:thread-topic :content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date:dkim-signature:dkim-filter; bh=XjlwNl1On6TmPijh5BHJldK1Cy6f5rlPU65IQRBXecc=; b=m+pwpau2dZXgr8HczIMRHJ/A12TKIZtvnUtAwOnwCk/C9AgFzGRJulFfyWJIQX0NZi fcFqqk+0T0pjsuK8EDjJSQyBTf+PLsjWgih0OwUog9GMPkRhVuHFYRouDfCItwpulS71 Z22gXXnIUAYR8I8MBUgybszl9znD4zHYFNGTpjK2WB2cM1oWkDuYN9c7qGUoKP42NgZh ME9twZGkbKvP3GNtBYTS06k2F2GKYbO8I6vTB/IN7ZMG3gcMIQqTKKEtzYDlxDI7jmOh VdI9g9oKywkhsazJQMqr0Ox23b6qR1Z4aFfyyVuXKFbnqB/hmAr4hIvSxQ25vYgpDRgl 33Sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=default header.b=lcJ6LjDx; 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=efficios.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id d70si6513578pgc.586.2022.02.09.12.44.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 12:44:55 -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; dkim=pass header.i=@efficios.com header.s=default header.b=lcJ6LjDx; 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=efficios.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 37191E090D4D; Wed, 9 Feb 2022 12:11:24 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232674AbiBIT3P (ORCPT + 99 others); Wed, 9 Feb 2022 14:29:15 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:44580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238091AbiBIT23 (ORCPT ); Wed, 9 Feb 2022 14:28:29 -0500 Received: from mail.efficios.com (mail.efficios.com [167.114.26.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4AB0CC03FED5; Wed, 9 Feb 2022 11:28:12 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 9169C3B494A; Wed, 9 Feb 2022 14:28:11 -0500 (EST) Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail03.efficios.com [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id Bq5hzq76zMBx; Wed, 9 Feb 2022 14:28:11 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id E99E43B4AC7; Wed, 9 Feb 2022 14:28:10 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com E99E43B4AC7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1644434891; bh=XjlwNl1On6TmPijh5BHJldK1Cy6f5rlPU65IQRBXecc=; h=Date:From:To:Message-ID:MIME-Version; b=lcJ6LjDxmssvDwIKOUoMlicr5d+aywJSmXlRJTfbmH4xgmPoedFrQV6r3q9tKD4a/ 1dpN6ymkorGYD/RLPPgIwIdyLfChfI76yVxI9JFrZhlPb9f0m8Oc9zLtHilxIKXZBQ jwKiwRDxiDvRaUtKcxU1/za8f4GK7gbP62qkVEdK0YvR7hWR+wQ+zLFLMFuwjteyOH cMGzzJ09LJP7kAVUHeFlpfr4ABMeEU0uDrDGCpZfG8rK+Cczk81jLml32FeeqyTNrq bab+3bK6c37tOu2GAzhkpLNpJPKTcXxyJtwFznXm3SstTE8AhxT/olKl2Jd8w1Sndl yJW42XHRsAMyQ== X-Virus-Scanned: amavisd-new at efficios.com Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail03.efficios.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id qTEEX-tAWWFU; Wed, 9 Feb 2022 14:28:10 -0500 (EST) Received: from mail03.efficios.com (mail03.efficios.com [167.114.26.124]) by mail.efficios.com (Postfix) with ESMTP id D2A0A3B4B38; Wed, 9 Feb 2022 14:28:10 -0500 (EST) Date: Wed, 9 Feb 2022 14:28:10 -0500 (EST) From: Mathieu Desnoyers To: Namhyung Kim Cc: Waiman Long , 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 , paulmck Message-ID: <718973621.50447.1644434890744.JavaMail.zimbra@efficios.com> In-Reply-To: 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> Subject: Re: [RFC 00/12] locking: Separate lock tracepoints from lockdep/lock_stat (v1) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [167.114.26.124] X-Mailer: Zimbra 8.8.15_GA_4203 (ZimbraWebClient - FF96 (Linux)/8.8.15_GA_4203) Thread-Topic: locking: Separate lock tracepoints from lockdep/lock_stat (v1) Thread-Index: XmneyW/Z8kaQOCvcLgzEg6AAvUOeRA== X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, 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 ----- On Feb 9, 2022, at 2:22 PM, Namhyung Kim namhyung@kernel.org wrote: > 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. I was wondering about this use case as well. Can we make it mandatory to declare the lock "class" (including the name) statically, even though the lock per-se is allocated dynamically ? Then the initialization of the lock embedded within the data structure would simply refer to the lock class definition. But perhaps I am missing something here. Thanks, Mathieu -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com