Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1797363rdb; Thu, 7 Dec 2023 09:01:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IGgv6qe2q5OacsxvspxoXLuZlQlTTBdpShiWZ+W42rwVfH/ZHTv8Y1K735Ub8Yzlqpw27no X-Received: by 2002:a05:6808:1984:b0:3b8:b2cf:3106 with SMTP id bj4-20020a056808198400b003b8b2cf3106mr3872254oib.25.1701968510167; Thu, 07 Dec 2023 09:01:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701968510; cv=none; d=google.com; s=arc-20160816; b=Qr8DwKx75CY618OyLAr1oD5/2/vBH+Pi/8qVxB3VmpSE0x4nSJAnGQ0PGIFwQ2r5Kr oNhhRMuxETPY9jUmHahkShH3ErUz1xRZpr/aPVlccs9jMLU03EnpFPqKeWKcs2XpCKWQ n+lCsICIz/ipO17nCaUlxScSPR2PZRnvAn4PE7WLG68NCFRLYZ2sH7cenCiXvofnyTkp KBvibDGJpuexV6yMtY3ERXXKjxlw4ISTDXIxeds9tBfWz6WtqZsmDx09XJrjET9zZvIB XGkejFh9EiYKzgPFMbEP9isV3sJpcihqzlFYF/vttDXHEPVVp/hJmWbedQ6msNkgYw1+ h9/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=zD2jPgn9YZsHnKOdKt2RP0gGZZORaADKGh8IdYyE8xQ=; fh=qbzsVzxdAcVUa08l0Bin988nynk0e5kgU6BdyhnLQg0=; b=k/RKI6EeD5MV3nY7H9JYMi9MDoLCXWsjEQrDVZn/w8CfOEAPVRcythBCU4aQBMvxOc eEQqX99Tzk0Pg/V2zSLHGKTsa4CYX0D2YwsUiYFrBZY1O4s+z85DL0fG5maHvxR9/rKd qW+rU8cgPXXu90IBZnJ2d0LCeFL4j8LXUZx1q3BkzDt+z1H5XQ17x+CLa3DLLu3xyTBe +sz3qE7sqahU6bdNEWH6jIddi9fplaaFVK7n1f5W962ms7ssgSoi7opK8cWsmGHV+48R 79Z56HqR6woBYkX0h4eLMz2icEx3mNX+1beTH68tkQxGhqFv4wgvipd7jBZvVfpshlmA icZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="A2wuqRv/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id bi30-20020a056808189e00b003a7ef91b24asi49768oib.137.2023.12.07.09.01.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 09:01:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="A2wuqRv/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id DE4F98029568; Thu, 7 Dec 2023 09:01:46 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232933AbjLGRBc (ORCPT + 99 others); Thu, 7 Dec 2023 12:01:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233096AbjLGRBa (ORCPT ); Thu, 7 Dec 2023 12:01:30 -0500 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4FAA010EB for ; Thu, 7 Dec 2023 09:01:36 -0800 (PST) Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1d0aaa979f0so8564755ad.0 for ; Thu, 07 Dec 2023 09:01:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701968496; x=1702573296; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=zD2jPgn9YZsHnKOdKt2RP0gGZZORaADKGh8IdYyE8xQ=; b=A2wuqRv/gue2wtS7ikes6ve2kRez/sTuaZOdcvTstV5uld/1yu8r4G8Bof+pV1Qrm0 tC93GreRKphb83iyLWiYhA6kVl09YAiVx1Qhz8hJ8v2lyY+7mNJVc8AhWkahMiwPjrbh YXRgX8s5eAqfgx5SCEbBGc9Mlg9g7OLAl/zCHZtW9MV4mcmz/J2XUyW+wbWe9+v9fAJX GfpQQwVfNqYwXpPoWMdyjLrO7CmzQwqUfBxB+8vLIDTXkVm/4osj+FGLTnu9iiBTXca1 zLi3tF1bjHxQ7cFsi3L2gZ/QhuTaPkTpE93xmwXwmAYFLgC2+ww2iuRIPi3GTr04hbsE U5qQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701968496; x=1702573296; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=zD2jPgn9YZsHnKOdKt2RP0gGZZORaADKGh8IdYyE8xQ=; b=m2EvAza5xOvpanV7A6OtYiuBfenQwSbFQsoIMLYNDJ5S8Ly3jSOd+P6Ig/8d/8QRFW 5ymROL72tQBF7Twz2JJAx18GBFVoFDpbl25AbUbj0C1AlV+y9Gdv7tfeLv9FLF6rxirm 12PoDKj0m0o6vJJBaM88Ono9mb5VhgWI1NMx1GBMeR/lERBeuFb5F/6m7sYDjwvowSnG ukkObwkcCPlKP/bpkvxRE/4Np1JJjMheetSPHtMVZrDgb3VJI2ruiY8VYaLEabZpVHxz WDafzV0HBBGoiJ1mXJ5AhmL11F9+S4V3USs8mpwCsx/kDIJ1BaOHzaNq+DokBkDNiEsO KYIg== X-Gm-Message-State: AOJu0Yyir7gN9zFrm1TH0lnw72FdKPW7jYfzA36NzGQa3/c/ILphhrbp E5jYQpnVeJ03K97zVxbi5WE= X-Received: by 2002:a17:902:daca:b0:1d0:69d5:57da with SMTP id q10-20020a170902daca00b001d069d557damr3122779plx.67.1701968495532; Thu, 07 Dec 2023 09:01:35 -0800 (PST) Received: from DESKTOP-IM4PCEA.localdomain ([49.206.132.94]) by smtp.gmail.com with ESMTPSA id d3-20020a170903230300b001d08bbcf78bsm42325plh.74.2023.12.07.09.01.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 09:01:35 -0800 (PST) Date: Thu, 7 Dec 2023 22:31:30 +0530 From: "" To: Peter Zijlstra Cc: badolevishal1116@gmail.com, chinmoyghosh2001@gmail.com, linux-kernel@vger.kernel.org, mingo@redhat.com, rostedt@goodmis.org, vimal.kumar32@gmail.com, will@kernel.org Subject: Re: [PATCH v2] rt_spin_lock: To list the correct owner of rt_spin_lock Message-ID: <20231207170130.GA78@DESKTOP-IM4PCEA.localdomain> References: <20220619142038.1274-1-mintupatel89@gmail.com> <20220627161136.3468-1-mintupatel89@gmail.com> <20231206185837.GB9899@noisy.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231206185837.GB9899@noisy.programming.kicks-ass.net> X-Spam-Status: No, score=1.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, FROM_MISSP_FREEMAIL,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, 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 lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 07 Dec 2023 09:01:47 -0800 (PST) X-Spam-Level: * On Wed, Dec 06, 2023 at 07:58:37PM +0100, Peter Zijlstra wrote: > On Mon, Jun 27, 2022 at 09:41:38PM +0530, Mintu Patel wrote: > > rt_spin_lock is actually mutex on RT Kernel so it goes for contention > > for lock. Currently owners of rt_spin_lock are decided before actual > > acquiring of lock. This patch would depict the correct owner of > > rt_spin_lock. The patch would help in solving crashes and deadlock > > due to race condition of lock > > > > acquiring rt_spin_lock acquired the lock released the lock > > <--------> <-------> > > contention period Held period > > > > Thread1 Thread2 > > _try_to_take_rt_mutex+0x95c+0x74 enqueue_task_dl+0x8cc/0x8dc > > rt_spin_lock_slowlock_locked+0xac+2 rt_mutex_setprio+0x28c/0x574 > > rt_spin_lock_slowlock+0x5c/0x90 task_blocks_rt_mutex+0x240/0x310 > > rt_spin_lock+0x58/0x5c rt_spin_lock_slowlock_locked+0xac/0x2 > > driverA_acquire_lock+0x28/0x56 rt_spin_lock_slowlock+0x5c/0x90 > > rt_spin_lock+0x58/0x5c > > driverB_acquire_lock+0x48/0x6c > > > > As per above call traces sample, Thread1 acquired the rt_spin_lock and > > went to critical section on the other hand Thread2 kept trying to acquire > > the same rt_spin_lock held by Thread1 ie contention period is too high. > > Finally Thread2 entered to dl queue due to high held time of the lock by > > Thread1. The below patch would help us to know the correct owner of > > rt_spin_lock and point us the driver's critical section. Respective > > driver need to be debugged for longer held period of lock. > > > > ex: cat /sys/kernel/debug/tracing/trace > > > > kworker/u13:0-150 [003] .....11 202.761025: rt_spinlock_acquire: > > Process: kworker/u13:0 is acquiring lock: &kbdev->hwaccess_lock > > kworker/u13:0-150 [003] .....11 202.761039: rt_spinlock_acquired: > > Process: kworker/u13:0 has acquired lock: &kbdev->hwaccess_lock > > kworker/u13:0-150 [003] .....11 202.761042: rt_spinlock_released: > > Process: kworker/u13:0 has released lock: &kbdev->hwaccess_lock > > > > The above is word salad and makes no sense. No other lock has special > tracing like this, so rt_lock doesn't need it either. > Hi Peter, As per current implementation of rt_spin_lock tracing mechanism on RTLinux, if more than one threads are trying to acquire a rt_spin_lock, then multiple threads are assigned as owners of the same lock, more over only one thread is actual owner of lock and others are still contending for the same lock. Such trace logs can mislead the developers during debugging of critical issues like deadlock, crashes etc The above patch would generate rt_spin_lock locking traces which would depict correct owner of the lock and other thread details which are trying to acquire the lock. Regards, Mintu Patel