Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp4898105pxv; Tue, 29 Jun 2021 19:29:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw9a3d0nZxHH/+ZBlZDuOWSC78pOE81taWZ8y4iEdpW7imc4H0b4Dju49feSg+TEzOlmmym X-Received: by 2002:a92:a005:: with SMTP id e5mr8777479ili.22.1625020181100; Tue, 29 Jun 2021 19:29:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625020181; cv=none; d=google.com; s=arc-20160816; b=oSWZmXT1AAiBS+Pq1/g8RdsspQRtW4dCT+tj66B/b7IYg7yAA8/R7wN+WKW5n5+DMc EFpSm0FEPCQ29aTggJyP7O17dcSrWRLPk7eZXNjZIRrGawapOHM3cJWhTqj6Rp3zbuYW +0IrvWqztgnPjlNmr0KX9tnNHDv0bKpMIyDWWBGbCarDPv69fIzc2VbyGeKvoPgdl5VZ MXaTo/x/4Aaora4cXP46tukhCmTvjdtxzezHRvcqi8AUrjdKq3PtJ1kmhJr9g7yoocep 2egVQifhNh2We9/wrGKUnV2lyPwhkwupXZZz8XOo2kHE6r8Rvn78BfAKZQ6mLB/7fbap LMPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:references:cc :to:subject:from:dkim-signature; bh=cxkrysUl98zvEOYEsdrLNnYjN5TtIhoiFh8RRDC3JNQ=; b=XavPAsgNj/L4HM7vEAq92AQm56iJ4YxGA1vV4YNutA0HIpOjl6059ktXlTFuSzEJ07 V2LO3c8+UayAeJK7teDjr3qOATi5FOqro5bi98T8goXyeMvhJfDlPVqJCe41t5f+PHSB uYQxlMBoq5gnZ6h93cSXAAX/jo6WSxfsecv4TDtSMnxzHRC9PVppVbMrpz88RofT2bZY EcCKdeMqrTEhK3rpCP3MJ1GYnzX9sTq0w9iWfhBB77P1dnfCbUnKcqEMuSnU+w/Ah/O7 fgDuiHLYS8vq7nisGTPRD2u/H2Kw03sP71I3fDe6h2aPcHf938wNiGqkDnfMnUkYR0sS Qakg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=N6P79qBA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t17si22582599ilp.132.2021.06.29.19.29.29; Tue, 29 Jun 2021 19:29:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=N6P79qBA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232137AbhF3CDf (ORCPT + 99 others); Tue, 29 Jun 2021 22:03:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:30644 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231765AbhF3CDe (ORCPT ); Tue, 29 Jun 2021 22:03:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625018466; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cxkrysUl98zvEOYEsdrLNnYjN5TtIhoiFh8RRDC3JNQ=; b=N6P79qBAbSUruQ4OhKle51W4aj7QBSBprvOR0Y4hUKBwo6UjLh6VLnh1Fc8BBynYtdETxq 7SVc6K3gW+Hl14vkc++LFsWuGCTUc5Ba33uoICAwpTdJ6zIlWxZ16mejW5f9zpLeFdfF4n JzK5taN/8tT0nqBWIMhNsFu1CkiM3OE= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-241-KGyjc47RMAarmtGOaRclcg-1; Tue, 29 Jun 2021 22:01:04 -0400 X-MC-Unique: KGyjc47RMAarmtGOaRclcg-1 Received: by mail-qv1-f72.google.com with SMTP id eb2-20020ad44e420000b029025a58adfc6bso327663qvb.9 for ; Tue, 29 Jun 2021 19:01:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=cxkrysUl98zvEOYEsdrLNnYjN5TtIhoiFh8RRDC3JNQ=; b=JxkPD3QoXMkeMwt8gwdkofGaEk4K0sfIUaZb/tti+XHzObUN3t05lffgA6qiRvmb50 NRrKq6Q5+hVGQy+kZq3QKQnCPkm/jY84A4YXnk60cMx8LJ4iLJjBrqjlZtn6GbcZN1R9 vTWIrtlhuzEU7OT0qGIqmI3TImQ2A9Nvlh1ADemDROBquXv5Umdl2fc6S4ob89bNJ0Qb 6A4+MnJ/vKq0pcWg0laHKLiZSH8eXanfpDtWuzqcVYYoHN6kg9McqfrA8rP1zTaBW5vl 9CtH+ORBmwtldue8bAxy/iTUAXQ0c01B8+Cg88Y5aurwOdSrsaegfIZ9DPWyVn2FMrrA Zl6Q== X-Gm-Message-State: AOAM533+YhRujC0kBPmZtWlxSEdPQ6vVmnPS3+rQDlDqiFzfFHbOWTS6 MltHm8zZWbZqnM+An4VTE3sIJdRNmGLWkxsD6Ttz7eX2Y24GsFiKhPWv9MV2jxRkBT8TwRLUieC pYLjtntUfAMWLNq+7ZCJk7hAb06my53Y0jIwJJ/chjpk71n+dDb48+s+LNnIr65hXW3BB4kk/ X-Received: by 2002:a05:622a:1701:: with SMTP id h1mr29531156qtk.36.1625018463698; Tue, 29 Jun 2021 19:01:03 -0700 (PDT) X-Received: by 2002:a05:622a:1701:: with SMTP id h1mr29531126qtk.36.1625018463298; Tue, 29 Jun 2021 19:01:03 -0700 (PDT) Received: from llong.remote.csb ([2601:191:8500:76c0::cdbc]) by smtp.gmail.com with ESMTPSA id 19sm6594444qtt.87.2021.06.29.19.01.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 29 Jun 2021 19:01:02 -0700 (PDT) From: Waiman Long X-Google-Original-From: Waiman Long Subject: Re: [RFC PATCH] spinlock_debug: Save stacktrace at lock acquisition To: Guru Das Srinagesh , Peter Zijlstra , Ingo Molnar , Will Deacon , Boqun Feng Cc: linux-kernel@vger.kernel.org References: <1625016485-32581-1-git-send-email-gurus@codeaurora.org> Message-ID: <98f4a7f1-bce7-8e74-c124-7f5183b8cdfc@redhat.com> Date: Tue, 29 Jun 2021 22:01:01 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.9.0 MIME-Version: 1.0 In-Reply-To: <1625016485-32581-1-git-send-email-gurus@codeaurora.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/29/21 9:28 PM, Guru Das Srinagesh wrote: > In case of spinlock recursion bugs, knowing which entity acquired the > lock initially is key to debugging. Therefore, save the stack frames > when the lock is acquired and print them when spinlock recursion is > detected. > > Signed-off-by: Guru Das Srinagesh > --- > include/linux/spinlock_types.h | 3 +++ > kernel/locking/spinlock_debug.c | 9 +++++++++ > 2 files changed, 12 insertions(+) > > diff --git a/include/linux/spinlock_types.h b/include/linux/spinlock_types.h > index b981caa..8a68d55 100644 > --- a/include/linux/spinlock_types.h > +++ b/include/linux/spinlock_types.h > @@ -22,6 +22,9 @@ typedef struct raw_spinlock { > #ifdef CONFIG_DEBUG_SPINLOCK > unsigned int magic, owner_cpu; > void *owner; > +#define MAX_STACK_LEN 16 > + int stack_len; > + unsigned long stack_trace[MAX_STACK_LEN]; > #endif Nak Locking problem like this should be detected by the lockdep code. Adding 136 bytes (64-bit archs) to the size of a spinlock is just too big an overhead. Regards, Longman