Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp290105pxp; Sat, 19 Mar 2022 02:35:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxPAgeZOAEFevUgHruHO5Rz/TDx1euHOkLWzgBVzGKY/M4fkMX3mpfQWyDNDoXGJv5/+Tb0 X-Received: by 2002:a65:6713:0:b0:382:3e2e:9ae9 with SMTP id u19-20020a656713000000b003823e2e9ae9mr3936805pgf.469.1647682528160; Sat, 19 Mar 2022 02:35:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647682528; cv=none; d=google.com; s=arc-20160816; b=Qi3uZCiLp2XxxpkNg4auTlSDWt3/Gvj5FG1JuuoVeatPeGmfK94Vz7EkSmWYam96BI wB4XrRkNmEupWt5TdgQiZ3dz/r/UcNhKZp77TJ6P4YZtMy+mEtdFCHlB6rbK7N3SvH3I pnl+IETmSr5vesbJvpMDH4rxfgly6uPxPRqL87v3U3FbRun9+/fElSMKOmBm3tnnAhy8 UGQBx7W9sVtlyBOxpA00tb/Ms8/8V77RF+2nv8qTqI7FUwZ1WskhEx7Tgin58bKJTeuY JREuRjdHQNL9Y4hw8j+hs+u+BJsGZ2c9NZe+MuyMLF87+g4vCUPrt7Jh9M19UHB8ad/o bCNA== 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=ksuX6MNNVKcpHa2cJxv8Npehy7dLW5BZP8Nd24HsaFA=; b=Zhshoey9mcWBM+euwmWN/XkgRSJduKX3WBLQ/uJfkwO/fgEcKYpb2KH45D+LFV3pY3 lsxech0nR+PObZ8O0cbQG7VpAiFjm/xWwEsSk+W7gLlqMQkQagsJm2xjUW+xBqUHQ9R1 yjNpKbZ1OBy3Zpl6ebwv2ySDdUw2JoVPsSGaiYYF3MYRc4IxMdozfZgB7Z/TtG9kyQ/w 4eygEmBDee1u4DUW0itcuKPvGRBYNh1O+L4dCPdKlJylPjWnM71ZHbIygF4vLYB9Ud4R AlF31zzEhCYlm6gz2s4jMrAtHE734jfgmpjxzkP0tF1mIqKhaI4nzpjeb+6pi3tqomif TbkQ== 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:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s2-20020a056a00178200b004fa7c4d3815si2073659pfg.73.2022.03.19.02.35.15; Sat, 19 Mar 2022 02:35:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240995AbiCRVOW (ORCPT + 99 others); Fri, 18 Mar 2022 17:14:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240990AbiCRVOM (ORCPT ); Fri, 18 Mar 2022 17:14:12 -0400 Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BBF3D53A49; Fri, 18 Mar 2022 14:12:52 -0700 (PDT) Received: by mail-lf1-f43.google.com with SMTP id p15so5228579lfk.8; Fri, 18 Mar 2022 14:12:52 -0700 (PDT) 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=ksuX6MNNVKcpHa2cJxv8Npehy7dLW5BZP8Nd24HsaFA=; b=XSCNq5gPxnqtXW1aGcvA1pn28uVm8lQZLYralUh8/p8/vPtEeeQN2nrW67DCYZEtL4 pdxeZ+ZKHgDTzBFmPDkn0xuitRVLqzN/ibCiPrF8uTNYa38e/5VZgY6XZuQCmbDGAT39 Ic8V+U0QrzKv9cJYGHdoqKKSZHcDHG+LDon862LyGZFk4WJRBN6Y0oywSB39FHp8KOCW O3yIu9L4edG1p4WuKrdxI8uS9N/kG5IdVhvlqf2AK5B0HWMt1U1Z8GyaL4pjXcQnAqVE v747Cn+ROgiNB4x8KqqUUGRWlU3xO99cphcH/5Fk6L0r3DfG7Z0KXLtzBSKTJzFwll9W 94RQ== X-Gm-Message-State: AOAM532CjMjuyCqC52iGPwjnAIm+h0vY9MKmlYiT3qsWDYMjJYVHv3Ae bJJV1P48osQKvQ/+6By7N0hmSGyy46xQ9IXi6Kg= X-Received: by 2002:a05:6512:1195:b0:448:4fcc:34f2 with SMTP id g21-20020a056512119500b004484fcc34f2mr6997466lfr.454.1647637971048; Fri, 18 Mar 2022 14:12:51 -0700 (PDT) MIME-Version: 1.0 References: <20220316224548.500123-1-namhyung@kernel.org> In-Reply-To: From: Namhyung Kim Date: Fri, 18 Mar 2022 14:12:39 -0700 Message-ID: Subject: Re: [PATCH 0/2] locking: Add new lock contention tracepoints (v3) To: Hyeonggon Yoo <42.hyeyoo@gmail.com> Cc: Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , Boqun Feng , LKML , Thomas Gleixner , Steven Rostedt , Byungchul Park , "Paul E. McKenney" , Mathieu Desnoyers , Arnd Bergmann , Radoslaw Burny , linux-arch , bpf Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, 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 Hyeonggon, On Thu, Mar 17, 2022 at 10:32 AM Hyeonggon Yoo <42.hyeyoo@gmail.com> wrote: > > On Wed, Mar 16, 2022 at 03:45:46PM -0700, Namhyung Kim wrote: > > Hello, > > > > There have been some requests for low-overhead kernel lock contention > > monitoring. The kernel has CONFIG_LOCK_STAT to provide such an infra > > either via /proc/lock_stat or tracepoints directly. > > > > However it's not light-weight and hard to be used in production. So > > I'm trying to add new tracepoints for lock contention and using them > > as a base to build a new monitoring system. > > Hello Namhyung, > I like this series so much. > Lock contentions became much more visible without serious overhead. > > For the series: > Tested-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Thanks! > > How would you use these tracepoints, is there a script you use? Not yet. But I'm thinking something similar to your script. Probably I'll extend 'perf lock' command to have this kind of output but it doesn't have lock name and use avg/min/max time instead of histogram. Thanks, Namhyung > For testing, I just wrote a simple bpftrace script: > > $ sudo bpftrace -e 'BEGIN > { > printf("Collecting lockstats... Hit Ctrl-C to end.\n"); > } > > tracepoint:lock:contention_begin > { > @start_us[tid] = nsecs / 1000; > } > > tracepoint:lock:contention_end > { > if (args->ret == 0) { > @stats[kstack] = hist(nsecs / 1000 - @start_us[tid]); > } > } > > END > { > clear(@start_us); > }' > > And it shows its distribution of slowpath wait time like below. Great. > > @stats[ > __traceiter_contention_end+76 > __traceiter_contention_end+76 > queued_spin_lock_slowpath+556 > _raw_spin_lock+108 > rmqueue_bulk+80 > rmqueue+1060 > get_page_from_freelist+372 > __alloc_pages+208 > alloc_pages_vma+160 > alloc_zeroed_user_highpage_movable+72 > do_anonymous_page+92 > handle_pte_fault+320 > __handle_mm_fault+252 > handle_mm_fault+244 > do_page_fault+340 > do_translation_fault+100 > do_mem_abort+76 > el0_da+60 > el0t_64_sync_handler+232 > el0t_64_sync+420 > ]: > [2, 4) 1 |@ | > [4, 8) 30 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | > [8, 16) 25 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | > [16, 32) 33 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| > [32, 64) 29 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | > [64, 128) 13 |@@@@@@@@@@@@@@@@@@@@ | > [128, 256) 2 |@@@ | > > > @stats[ > __traceiter_contention_end+76 > __traceiter_contention_end+76 > rwsem_down_write_slowpath+1216 > down_write_killable+100 > do_mprotect_pkey.constprop.0+176 > __arm64_sys_mprotect+40 > invoke_syscall+80 > el0_svc_common.constprop.0+76 > do_el0_svc+52 > el0_svc+48 > el0t_64_sync_handler+164 > el0t_64_sync+420 > ]: > [1] 13 |@@@@@@@@@@@ | > [2, 4) 42 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | > [4, 8) 5 |@@@@ | > [8, 16) 10 |@@@@@@@@ | > [16, 32) 60 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| > [32, 64) 41 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | > [64, 128) 40 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | > [128, 256) 14 |@@@@@@@@@@@@ | > [256, 512) 7 |@@@@@@ | > [512, 1K) 6 |@@@@@ | > [1K, 2K) 2 |@ | > [2K, 4K) 1 | | > > @stats[ > __traceiter_contention_end+76 > __traceiter_contention_end+76 > queued_spin_lock_slowpath+556 > _raw_spin_lock+108 > futex_wake+168 > do_futex+200 > __arm64_sys_futex+112 > invoke_syscall+80 > el0_svc_common.constprop.0+76 > do_el0_svc+52 > el0_svc+48 > el0t_64_sync_handler+164 > el0t_64_sync+420 > ]: > [0] 3 | | > [1] 2515 |@ | > [2, 4) 8747 |@@@@@ | > [4, 8) 17052 |@@@@@@@@@@ | > [8, 16) 46706 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | > [16, 32) 82105 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| > [32, 64) 46918 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | > [64, 128) 99 | | > [128, 256) 1 | | > [256, 512) 8 | | > [512, 1K) 0 | | > [1K, 2K) 0 | | > [2K, 4K) 0 | | > [4K, 8K) 0 | | > [8K, 16K) 0 | | > [16K, 32K) 5 | | > [32K, 64K) 12 | | > [64K, 128K) 34 | | > [128K, 256K) 68 | | > [256K, 512K) 7 | | >