From nobody Sun Jun 28 10:34:48 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4BE43C433EF for ; Tue, 8 Feb 2022 18:42:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385079AbiBHSm0 (ORCPT ); Tue, 8 Feb 2022 13:42:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385145AbiBHSmQ (ORCPT ); Tue, 8 Feb 2022 13:42:16 -0500 Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C765AC06157B for ; Tue, 8 Feb 2022 10:42:15 -0800 (PST) Received: by mail-pf1-x42e.google.com with SMTP id d187so20395283pfa.10 for ; Tue, 08 Feb 2022 10:42:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/az7RkqUaZSIeoYuZW+qHEklI+WUcZiVSMlf0uKOOFw=; b=qyGzrxWYkcjR9EjdCMY7JyklNmxBpprp+ecWJHJrwG59QRTpk5dwSJl1iTlvN+Aio1 axlCeZukQjMTgLi9WJw/+XDmDV6YdFYNYM4h7GbFDLDqzUE04ENYp+S79t16HySfB2C8 KY2jv3Ukg8u+lCttMknubxu++olrKCGQsLdq9GUz4oj58Ux6MG4z81m4xlZ8OhYMAQFn XCZPFexwpIqouDYs2QwIyJrxG4POSqeeP7C9KdROfpX1dz8Vl7oTa2sipnQVxzFoplQ+ CSMSzpTVn42nOjV3Yr4BgKcXpEH694+pKu8Ppj9JgnUOAVpvnoyJ3J+K6XbfCgwHvktz PZnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=/az7RkqUaZSIeoYuZW+qHEklI+WUcZiVSMlf0uKOOFw=; b=OPZK/9h2UnMZnkbRVzLECZIGNFjYolCASOioohRbJdNtwVWolbGBDiX0NoSyc1TpLN I4QZzm41WeWeN4N1zAfsy0KGPrH7MXmA6A9SnYPmGm8G9wDPAqEw9qijzn/ma17JyzDY TxH2VXk64CdIpK+sUAlqao3KjfxhNqmcIALSlsN6VDBhWzI97ZpC+QWttVLH/EvcyBQW nDD65g2PQQyBy0nxrcVFYHupxCS0TLcgapY02uR4L0gF5x/qtQoIagFMrOI6l696SDlS 0AS3BUmFEKBXtKA0Pp1tY+oZSaCO+9Vq2bufVIoTE6QgFaZ7smVfeXMPvYKXY7+uGhdr yHQg== X-Gm-Message-State: AOAM5311r3eDZMq+qtGG7tsK6G0LfokS7g/0bvinH8CVNsoqp86TD903 eanNTnuXdqibL94Z+YUSfLs= X-Google-Smtp-Source: ABdhPJzSf8azOcibcMQR3hC2U8BwjcmVF8bdrFUc+fFNq39d3azlPmEKvXXHIQzD8nA5B9tqHK9Umw== X-Received: by 2002:a63:b141:: with SMTP id g1mr4598118pgp.269.1644345735222; Tue, 08 Feb 2022 10:42:15 -0800 (PST) Received: from balhae.hsd1.ca.comcast.net ([2601:647:4800:c6f0:347f:e607:176:4358]) by smtp.gmail.com with ESMTPSA id l14sm3517027pjf.1.2022.02.08.10.42.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 10:42:14 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , Boqun Feng Cc: LKML , Thomas Gleixner , Steven Rostedt , Byungchul Park , "Paul E. McKenney" , Mathieu Desnoyers , Radoslaw Burny Subject: [PATCH 01/12] locking: Pass correct outer wait type info Date: Tue, 8 Feb 2022 10:41:57 -0800 Message-Id: <20220208184208.79303-2-namhyung@kernel.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208184208.79303-1-namhyung@kernel.org> References: <20220208184208.79303-1-namhyung@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" In lockdep_init_map_wait(), it didn't pass the given outer argument to lockdep_init_map_type and use LD_WAIT_INV unconditionally. It seems like a copy-and-paste bug, let's fix it. Signed-off-by: Namhyung Kim --- include/linux/lockdep.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h index 467b94257105..0cc2b338a006 100644 --- a/include/linux/lockdep.h +++ b/include/linux/lockdep.h @@ -192,7 +192,7 @@ static inline void lockdep_init_map_waits(struct lockdep_map *lock, const char *name, struct lock_class_key *key, int subclass, u8 inner, u8 outer) { - lockdep_init_map_type(lock, name, key, subclass, inner, LD_WAIT_INV, LD_L= OCK_NORMAL); + lockdep_init_map_type(lock, name, key, subclass, inner, outer, LD_LOCK_NO= RMAL); } =20 static inline void --=20 2.35.0.263.gb82422642f-goog From nobody Sun Jun 28 10:34:48 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8B9FC433EF for ; Tue, 8 Feb 2022 18:42:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385195AbiBHSmg (ORCPT ); Tue, 8 Feb 2022 13:42:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385146AbiBHSmT (ORCPT ); Tue, 8 Feb 2022 13:42:19 -0500 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8095C0612C3; Tue, 8 Feb 2022 10:42:17 -0800 (PST) Received: by mail-pj1-x102c.google.com with SMTP id y15-20020a17090a474f00b001b88562650aso2105924pjg.0; Tue, 08 Feb 2022 10:42:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DVqQIGXek9gqjDYZ5x5feEwzLs2GJZs4gUa7i+kzwxU=; b=eZkvb8+7UyFnR21L5G1zcGI8qmb7Z6a9FPI1whMSBLG+SQouRtRGXHvgWofofksj4X gZB5sFr6ghXQvJW/Qq3wOP/ubVYRVVqZWpEXOJmHLHA+9yVi2iic/bTxbCgLKsYFNUWx nWOGj1PItndZXy9CxHYxkoPIZYgXs+AvTDgCbI5hEiHLb/9u/ASKrijJAysQub7y88RG FMA3a1+KBL0mqLyGYcIfSihA58L1nbkquzmiHjIu9u28yKitN1sxuU6vO4J9BW61CWiX 1gvLzqO7GENqtEdf8SQH8I9Z6MeL3HfDxjye5PqXcFHWOAn5lm2GV0kMVKD8KMbkYT/q pwKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=DVqQIGXek9gqjDYZ5x5feEwzLs2GJZs4gUa7i+kzwxU=; b=QEzwdvk1lVt9FjghcctL+1QZHRinBTR8kAjnaN6x7kbm6JQIbh968JAVLQahrbsdv4 q2jjAPfYYLU/I0lnutC/UUK1D0euVn4fG+nSi22WPU6FfYmMGN7zUChbZUxXYoQ38btF 21YfoBvSnTtLAACnTPzzo1eHN78v9kfMpwp2vg2sBZURkkf0MpiEqmN98neNGdW46T8A 00PGXUuVNci6JbLcAlPE7Ce6XgUQ8fXCysGx4VPeNQE5t6kiXQBK1mp81R1hdwRSPJ84 LLfOVAj6CwGzU5qsov9sMVJKS4Fn1UElKqMfB35ILqGXBjqsvi0ACRMynIODYxTAbHG/ rLIA== X-Gm-Message-State: AOAM532y7BOlvAlkN0hAQLFL/YS4hOdcgPhTDkjigRnrIST91gE/PUeq zPmZkq6uD4YHd7kKFFSDqLs= X-Google-Smtp-Source: ABdhPJwsjxQ3u2LpAw1F/tqKqnFKbzNVq4Q+hoDFw5+tcDW6bW7HXozAs0DUWSMEaDvFGixXm0DrNg== X-Received: by 2002:a17:903:20ca:: with SMTP id i10mr6101929plb.112.1644345737400; Tue, 08 Feb 2022 10:42:17 -0800 (PST) Received: from balhae.hsd1.ca.comcast.net ([2601:647:4800:c6f0:347f:e607:176:4358]) by smtp.gmail.com with ESMTPSA id l14sm3517027pjf.1.2022.02.08.10.42.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 10:42:16 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , Boqun Feng Cc: LKML , Thomas Gleixner , Steven Rostedt , Byungchul Park , "Paul E. McKenney" , Mathieu Desnoyers , Radoslaw Burny , Tejun Heo , Zefan Li , Johannes Weiner , cgroups@vger.kernel.org Subject: [PATCH 02/12] cgroup: rstat: Make cgroup_rstat_cpu_lock name readable Date: Tue, 8 Feb 2022 10:41:58 -0800 Message-Id: <20220208184208.79303-3-namhyung@kernel.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208184208.79303-1-namhyung@kernel.org> References: <20220208184208.79303-1-namhyung@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The raw_spin_lock_init() uses the argument to name its lockdep map. But passing per_cpu_ptr() macro directly makes it a very very long name as it expanded like below: ({ do { const void *__vpp_verify =3D (typeof((&cgroup_rstat_cpu_lock) ... Let's fix it by passing a local variable instead. With this change, the name now looks like: cgrp_rstat_cpu_lock Cc: Tejun Heo Cc: Zefan Li Cc: Johannes Weiner Cc: cgroups@vger.kernel.org Signed-off-by: Namhyung Kim Acked-by: Tejun Heo --- kernel/cgroup/rstat.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/kernel/cgroup/rstat.c b/kernel/cgroup/rstat.c index 9d331ba44870..d1845f1196c9 100644 --- a/kernel/cgroup/rstat.c +++ b/kernel/cgroup/rstat.c @@ -286,9 +286,12 @@ void cgroup_rstat_exit(struct cgroup *cgrp) void __init cgroup_rstat_boot(void) { int cpu; + raw_spinlock_t *cgrp_rstat_cpu_lock; =20 - for_each_possible_cpu(cpu) - raw_spin_lock_init(per_cpu_ptr(&cgroup_rstat_cpu_lock, cpu)); + for_each_possible_cpu(cpu) { + cgrp_rstat_cpu_lock =3D per_cpu_ptr(&cgroup_rstat_cpu_lock, cpu); + raw_spin_lock_init(cgrp_rstat_cpu_lock); + } } =20 /* --=20 2.35.0.263.gb82422642f-goog From nobody Sun Jun 28 10:34:48 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9C0B8C433F5 for ; Tue, 8 Feb 2022 18:42:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385189AbiBHSmb (ORCPT ); Tue, 8 Feb 2022 13:42:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356333AbiBHSmW (ORCPT ); Tue, 8 Feb 2022 13:42:22 -0500 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8287C0612AA for ; Tue, 8 Feb 2022 10:42:19 -0800 (PST) Received: by mail-pl1-x62e.google.com with SMTP id t9so81124plg.13 for ; Tue, 08 Feb 2022 10:42:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IzYAh6mtxyAZ2drjtva0WxDIoe1TxiIdW6u31Cu1VZ0=; b=Rn7TMd/F12tHX5PTTIfciknUnwo2d7sRReHQLBHclrIbs4kzH1kmWQfBKSijxIYqNK 9CmfuIRHZSF3joepIGkZW8ahirN3q1TzibCOEBECrLRobrWRJI8tCZ5W1dzfI8wylYQE d0flpx4A9y3tzSBvR49MoHK7mbPF4EtMP1QAUBDtdVigkbhe7d+V89KqIWBctTMKY8Sk kp8OlmWqElx4SkCpRznucWmMQMjaE+vZwDax5fDsxrwCovsgwA3z/0krvCKpIvUtWUcD twN6kX5t0DC0Kw8WJFwWG3HrDuXRy0m69JjLJB0SQNsZ4m9+ZClz0rLcsfIY+JxmS+EM 4KTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=IzYAh6mtxyAZ2drjtva0WxDIoe1TxiIdW6u31Cu1VZ0=; b=ePluCcSFRbfZjbXAgfo9oQ1i4SNEq2ROSh4YZttYrdMm1tPR+KKqq1UTgb3Zs+1wXU vy6SEiN5dIH82vm8pIKvOyH73MUk/3J/R0jFgYolQrdEoge2pmoZj4/wAev6DIoYEDKK Q7GPv95sUgJCQj4HsWLx0+iTkEKWKbVoviVxYDtvjxHDK2BV4FEoJckmCrn9mhi3NjHs qDt+urYBZim7BoXrlxC16EoEqyJ1u1nR12dYFrdQgkHDLv7uCl9ym7jx5cluL3SUQPmj tuV1gg2TURLfpf/IjPGNkZIpvL390tepxm7g9vCZQ4EG/ntlAExAiOkMjHDLHn/To+z1 bv6Q== X-Gm-Message-State: AOAM533vLexharKkhnATUI32EX0ObMK4vbA4szPR4P9pVJYh8VmDtjgv 6vkCU2xcPs0X1s7qtjBXiXCc7t5TySU= X-Google-Smtp-Source: ABdhPJyDr72d0npd7vA3/hqnRU5jkANyKzduN67CIKfYJwax2Iq8Ps0vZjn5x17osa4MIjO33IkbMw== X-Received: by 2002:a17:902:e801:: with SMTP id u1mr5662822plg.124.1644345739249; Tue, 08 Feb 2022 10:42:19 -0800 (PST) Received: from balhae.hsd1.ca.comcast.net ([2601:647:4800:c6f0:347f:e607:176:4358]) by smtp.gmail.com with ESMTPSA id l14sm3517027pjf.1.2022.02.08.10.42.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 10:42:18 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , Boqun Feng Cc: LKML , Thomas Gleixner , Steven Rostedt , Byungchul Park , "Paul E. McKenney" , Mathieu Desnoyers , Radoslaw Burny Subject: [PATCH 03/12] timer: Protect lockdep functions with #ifdef Date: Tue, 8 Feb 2022 10:41:59 -0800 Message-Id: <20220208184208.79303-4-namhyung@kernel.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208184208.79303-1-namhyung@kernel.org> References: <20220208184208.79303-1-namhyung@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" With upcoming lock tracepoints config, it'd define some of lockdep functions without enabling CONFIG_LOCKDEP actually. The existing code assumes those functions will be removed by the preprocessor but it's not the case anymore. Let's protect the code with #ifdef's explicitly. Cc: Thomas Gleixner Signed-off-by: Namhyung Kim --- kernel/time/timer.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/kernel/time/timer.c b/kernel/time/timer.c index 85f1021ad459..4af95dbf6435 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -794,7 +794,10 @@ static void do_init_timer(struct timer_list *timer, if (WARN_ON_ONCE(flags & ~TIMER_INIT_FLAGS)) flags &=3D TIMER_INIT_FLAGS; timer->flags =3D flags | raw_smp_processor_id(); + +#ifdef CONFIG_LOCKDEP lockdep_init_map(&timer->lockdep_map, name, key, 0); +#endif } =20 /** @@ -1409,19 +1412,22 @@ static void call_timer_fn(struct timer_list *timer, struct lockdep_map lockdep_map; =20 lockdep_copy_map(&lockdep_map, &timer->lockdep_map); -#endif + /* * Couple the lock chain with the lock chain at * del_timer_sync() by acquiring the lock_map around the fn() * call here and in del_timer_sync(). */ lock_map_acquire(&lockdep_map); +#endif =20 trace_timer_expire_entry(timer, baseclk); fn(timer); trace_timer_expire_exit(timer); =20 +#ifdef CONFIG_LOCKDEP lock_map_release(&lockdep_map); +#endif =20 if (count !=3D preempt_count()) { WARN_ONCE(1, "timer: %pS preempt leak: %08x -> %08x\n", --=20 2.35.0.263.gb82422642f-goog From nobody Sun Jun 28 10:34:48 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1D9F4C433EF for ; Tue, 8 Feb 2022 18:42:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385214AbiBHSmm (ORCPT ); Tue, 8 Feb 2022 13:42:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385150AbiBHSmY (ORCPT ); Tue, 8 Feb 2022 13:42:24 -0500 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DECDBC0612BD for ; Tue, 8 Feb 2022 10:42:21 -0800 (PST) Received: by mail-pl1-x631.google.com with SMTP id t9so81194plg.13 for ; Tue, 08 Feb 2022 10:42:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OMn1l57PTLxYtwc+HI0U7xszWZxDsxBNDoAjSgoqiTo=; b=o9SjEHZADcNSyr7kIMSmxDmrRyunOK4Zze+YfvQDfD0E1RbBUkq5KMXUjAJaTDzc2Q QPt2sooIHMYmaeKYTQudDqJdHnxnWMWXQyerNxcun7+ba6IewVEyBBW+zzRA4P3iiERs 5Z1dc6Doq7qvWiLulDd8c6DELwPasB5LQS72mwm/NmQiiyc4SnDte9xpse/XUL9Va2EW cGIy6R28reZmUrPUCYplNtPdYEthpfCC7kZXD4WzcdSzVAZIMGbuj+SmgoupsKn7wh35 QDC89kCsEazDy2uoEN/KNOCJfkerIA8UdikgAT3pFwngcECBea3ov9YPTOoWUHXhLCiB xjFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=OMn1l57PTLxYtwc+HI0U7xszWZxDsxBNDoAjSgoqiTo=; b=duy/0twHFPo4IjEHBzMlpIbDUVrYHntcXJ1iw40y5nj0Kf2dLE9FSU2Qss4642qwJy RLu64nX016Zo8F2XdhI4FoHAEJNUx8/6irEiBBLUuxdVNnz1RRkSTUgXN1vM1nj40c0O z3A8LNTNSi8TSRJdKWmFqN7MpI+t1odm8ceNo4+538Kk3smgQeMb7nzWS0PSjU+51IA+ MVhyjPVG8803JoW4iBCb66DZl/WGWbEWmS7OQA/JrG2xob0ciH0PJaxVrbw/2AlWqNlQ 1Yk7AyNUUqRWwg27tDPgxY2h3sKvf2YDorMzuvRae6D/svPx4N5U7jLr40dSdgID9GBu OUpA== X-Gm-Message-State: AOAM531qEfcmeaho2Kdyab+LgDmyC2hDjX+WdeVnhL+1MCAkfrdimkbI yel3UMeFRdkf2BnCmTYhfpg= X-Google-Smtp-Source: ABdhPJzREdedAjALPPJFwvhAPxPktZZFP+RvyCXQKKUdPFesrs5xzql+otLdPMXYFEFYwaeis5dU2Q== X-Received: by 2002:a17:902:da8e:: with SMTP id j14mr6023931plx.53.1644345741417; Tue, 08 Feb 2022 10:42:21 -0800 (PST) Received: from balhae.hsd1.ca.comcast.net ([2601:647:4800:c6f0:347f:e607:176:4358]) by smtp.gmail.com with ESMTPSA id l14sm3517027pjf.1.2022.02.08.10.42.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 10:42:20 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , Boqun Feng Cc: LKML , Thomas Gleixner , Steven Rostedt , Byungchul Park , "Paul E. McKenney" , Mathieu Desnoyers , Radoslaw Burny , Tejun Heo , Lai Jiangshan Subject: [PATCH 04/12] workqueue: Protect lockdep functions with #ifdef Date: Tue, 8 Feb 2022 10:42:00 -0800 Message-Id: <20220208184208.79303-5-namhyung@kernel.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208184208.79303-1-namhyung@kernel.org> References: <20220208184208.79303-1-namhyung@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" With upcoming lock tracepoints config, it'd define some of lockdep functions without enabling CONFIG_LOCKDEP actually. The existing code assumes those functions will be removed by the preprocessor but it's not the case anymore. Let's protect the code with #ifdef's explicitly. Cc: Tejun Heo Cc: Lai Jiangshan Signed-off-by: Namhyung Kim --- kernel/workqueue.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 33f1106b4f99..405e27385f74 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -2279,8 +2279,11 @@ __acquires(&pool->lock) =20 raw_spin_unlock_irq(&pool->lock); =20 +#ifdef CONFIG_LOCKDEP lock_map_acquire(&pwq->wq->lockdep_map); lock_map_acquire(&lockdep_map); +#endif + /* * Strictly speaking we should mark the invariant state without holding * any locks, that is, before these two lock_map_acquire()'s. @@ -2310,8 +2313,11 @@ __acquires(&pool->lock) * point will only record its address. */ trace_workqueue_execute_end(work, worker->current_func); + +#ifdef CONFIG_LOCKDEP lock_map_release(&lockdep_map); lock_map_release(&pwq->wq->lockdep_map); +#endif =20 if (unlikely(in_atomic() || lockdep_depth(current) > 0)) { pr_err("BUG: workqueue leaked lock or atomic: %s/0x%08x/%d\n" @@ -2824,8 +2830,10 @@ void flush_workqueue(struct workqueue_struct *wq) if (WARN_ON(!wq_online)) return; =20 +#ifdef CONFIG_LOCKDEP lock_map_acquire(&wq->lockdep_map); lock_map_release(&wq->lockdep_map); +#endif =20 mutex_lock(&wq->mutex); =20 @@ -3052,6 +3060,7 @@ static bool start_flush_work(struct work_struct *work= , struct wq_barrier *barr, insert_wq_barrier(pwq, barr, work, worker); raw_spin_unlock_irq(&pool->lock); =20 +#ifdef CONFIG_LOCKDEP /* * Force a lock recursion deadlock when using flush_work() inside a * single-threaded or rescuer equipped workqueue. @@ -3066,6 +3075,8 @@ static bool start_flush_work(struct work_struct *work= , struct wq_barrier *barr, lock_map_acquire(&pwq->wq->lockdep_map); lock_map_release(&pwq->wq->lockdep_map); } +#endif + rcu_read_unlock(); return true; already_gone: @@ -3084,10 +3095,12 @@ static bool __flush_work(struct work_struct *work, = bool from_cancel) if (WARN_ON(!work->func)) return false; =20 +#ifdef CONFIG_LOCKDEP if (!from_cancel) { lock_map_acquire(&work->lockdep_map); lock_map_release(&work->lockdep_map); } +#endif =20 if (start_flush_work(work, &barr, from_cancel)) { wait_for_completion(&barr.done); --=20 2.35.0.263.gb82422642f-goog From nobody Sun Jun 28 10:34:48 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 786CDC433EF for ; Tue, 8 Feb 2022 18:42:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385237AbiBHSmr (ORCPT ); Tue, 8 Feb 2022 13:42:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385162AbiBHSm0 (ORCPT ); Tue, 8 Feb 2022 13:42:26 -0500 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25001C0611DA for ; Tue, 8 Feb 2022 10:42:24 -0800 (PST) Received: by mail-pj1-x1030.google.com with SMTP id m7so57845pjk.0 for ; Tue, 08 Feb 2022 10:42:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sJjbNLxKnq2MLHtlOHVGr5cmsCqOoxOU5S439s399rs=; b=mP+JA2jOmXnN0QJajfkIUt/2J+YY274d73Tpsayrg0OPhRz09HHxfcvuU3B3mwiqnY hzY0Lbl2ZeFudSA8gidRqmKkzOBsskPWAA95Zhxz8AtGg7QzLr/mkOq6pIW/roTuds6T RD8W3Hr++o41fiElpLT3ULAynuFkC4d6yBwqaZvLGC9j+mi5ijc3EeXbJLUotnx9rN39 HARmHpca2ynWd/QIQHy20dDcT4nFTlWV+f9iNzfI+mRidIjU2ZEa1iTlRQilY+y877y9 i75AiuaSyy8HT1tgf4RtYq2nyiarZfbhBBea1TzXMYz7ONYn80/FFFIyDt9ns+5pFD0M /PlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=sJjbNLxKnq2MLHtlOHVGr5cmsCqOoxOU5S439s399rs=; b=rMHwDzSk51n4xwP6B06IAZwLSnMAShJdqjh9BrDhEF+TxS5ocsSrF/dQv/Hi8a/0f1 AtFmY4ovbwc7za/L0731kEjlcL5PPhjoc/0/xJsF+rdiP/PduZNQzdFTXR+b902Higi4 dio0cD6zqb5naU03pbqr0n0T/yR00BM2KMZK88ax3W3PTreTuNdV2wongevQG0kkTOP3 OpJoeXmyGmxSd+VAUaEJ0yvQg8b4T2vvDZNidDt35J3dS35S5OrLDQjoOZxKOycq3qXI PDvA78i6tWISa5QzA2mMOpQGsWaFK5m6iloUDbnXhX3ZFNdKqYzv3qJaQCN9jRFQ03LG apoA== X-Gm-Message-State: AOAM5336klqFd6X4SDdhKuiFDTvh6bUYjHpH260x4OLVkH6XOg/+ujBh O4evhTGIwGarbsy4ixKz4A8= X-Google-Smtp-Source: ABdhPJzBjlE3rwJV9oAI24HmL30J4frNkDJPBvRKrr6l9+m4t4xU0yXmOxL4eqLQrp0Uc4O4QKknBA== X-Received: by 2002:a17:902:e74e:: with SMTP id p14mr5639468plf.95.1644345743659; Tue, 08 Feb 2022 10:42:23 -0800 (PST) Received: from balhae.hsd1.ca.comcast.net ([2601:647:4800:c6f0:347f:e607:176:4358]) by smtp.gmail.com with ESMTPSA id l14sm3517027pjf.1.2022.02.08.10.42.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 10:42:23 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , Boqun Feng Cc: LKML , Thomas Gleixner , Steven Rostedt , Byungchul Park , "Paul E. McKenney" , Mathieu Desnoyers , Radoslaw Burny , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , intel-gfx@lists.freedesktop.org Subject: [PATCH 05/12] drm/i915: Protect lockdep functions with #ifdef Date: Tue, 8 Feb 2022 10:42:01 -0800 Message-Id: <20220208184208.79303-6-namhyung@kernel.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208184208.79303-1-namhyung@kernel.org> References: <20220208184208.79303-1-namhyung@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" With upcoming lock tracepoints config, it'd define some of lockdep functions without enabling CONFIG_LOCKDEP actually. The existing code assumes those functions will be removed by the preprocessor but it's not the case anymore. Let's protect the code with #ifdef's explicitly. Cc: Jani Nikula Cc: Joonas Lahtinen Cc: Rodrigo Vivi Cc: Tvrtko Ursulin Cc: intel-gfx@lists.freedesktop.org Signed-off-by: Namhyung Kim --- drivers/gpu/drm/i915/intel_wakeref.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/i915/intel_wakeref.c b/drivers/gpu/drm/i915/in= tel_wakeref.c index dfd87d082218..6e4b8d036283 100644 --- a/drivers/gpu/drm/i915/intel_wakeref.c +++ b/drivers/gpu/drm/i915/intel_wakeref.c @@ -106,8 +106,11 @@ void __intel_wakeref_init(struct intel_wakeref *wf, wf->wakeref =3D 0; =20 INIT_DELAYED_WORK(&wf->work, __intel_wakeref_put_work); + +#ifdef CONFIG_LOCKDEP lockdep_init_map(&wf->work.work.lockdep_map, "wakeref.work", &key->work, 0); +#endif } =20 int intel_wakeref_wait_for_idle(struct intel_wakeref *wf) --=20 2.35.0.263.gb82422642f-goog From nobody Sun Jun 28 10:34:48 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D3AAEC433EF for ; Tue, 8 Feb 2022 18:42:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385211AbiBHSmu (ORCPT ); Tue, 8 Feb 2022 13:42:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385169AbiBHSm1 (ORCPT ); Tue, 8 Feb 2022 13:42:27 -0500 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 357C0C06157B; Tue, 8 Feb 2022 10:42:26 -0800 (PST) Received: by mail-pj1-x102d.google.com with SMTP id a11-20020a17090a740b00b001b8b506c42fso2884740pjg.0; Tue, 08 Feb 2022 10:42:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BAFCLl44fuoxxYIbM7z13GRiD2jvm+2v6+Mst7t4c6A=; b=BR0bLF6l0VyVosnd3r23R+nnmNHQOzJjnTJP4b1DFMSAnxYr/f0XSkrRmPozt/cnsS PT+x7cZh507gC/oRmrXsz8pbFFBn60Y5z4WPkbA6BX6LcCSiivZDWtGInLLlD3RIVszs /WwL9btwpc4N2tsFnk3jpOwMmdq7ztkBTAJ+2K3unppP4FcZkyINRG6QwW8+Z9oc+uox veQePbEt6ZZg2SNNkwoSpwNv8sISw91I7UdZwFd2L8Mfa8MBsDwv1R/cjy77ZZQgO6pD IgMRHEwaJqII6CA+sNvsykcHcObHxQc/vw7bY0cVBFoCC0GVGDl/kM3bf3J/Xs0Lcuyc lsqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=BAFCLl44fuoxxYIbM7z13GRiD2jvm+2v6+Mst7t4c6A=; b=K+D/uCLX8kkzWaTyVhBC5MhP/Bu47+gMLMUmCmCfaJSWGbQdsVDL2rOIni0+ypms04 2e9N+unYBdWvyRzwUxByylrYwI9NEJ1ndfMxL2MydfZs1cJ9H7sJm1P68XJXW1RUBxah bKOuCMODrilAw6dmcWS8JJOvaDtnyH8mJW7R76A+fVWJ9YdaFTRcRGouLN95ETDXHF0o MCoilH5oBgFB44F6uKzs45py6fbmm+DY9ntMTNDsoXg7+Z6Dd8/RQk4EpMy08EO6Y6NC muygCmBGlTdGCJSBxEQBcVIsveFHz5HdJvGfUTGL/Uv5jcuYzedijEqr915mz6ar/RM1 KIdQ== X-Gm-Message-State: AOAM533JDF9bDhJB6G7xe0oIDJ+0H/GePuQhtSVJufS20I4QrfQjLxM6 Vmrw9KgsgglVQLVx4BRXJLE= X-Google-Smtp-Source: ABdhPJzr/qYoYdcJ+93z4PimG/A6Ax5bD+A5VU9smm/HkouB79uvdewlBom8blFAcKvjJSRLH4cogw== X-Received: by 2002:a17:903:24e:: with SMTP id j14mr1810437plh.10.1644345745682; Tue, 08 Feb 2022 10:42:25 -0800 (PST) Received: from balhae.hsd1.ca.comcast.net ([2601:647:4800:c6f0:347f:e607:176:4358]) by smtp.gmail.com with ESMTPSA id l14sm3517027pjf.1.2022.02.08.10.42.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 10:42:25 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , Boqun Feng Cc: LKML , Thomas Gleixner , Steven Rostedt , Byungchul Park , "Paul E. McKenney" , Mathieu Desnoyers , Radoslaw Burny , Chris Mason , Josef Bacik , David Sterba , linux-btrfs@vger.kernel.org Subject: [PATCH 06/12] btrfs: change lockdep class size check using ks->names Date: Tue, 8 Feb 2022 10:42:02 -0800 Message-Id: <20220208184208.79303-7-namhyung@kernel.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208184208.79303-1-namhyung@kernel.org> References: <20220208184208.79303-1-namhyung@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" With upcoming lock tracepoints config, it'd allow some lockdep annotation code without enabling CONFIG_LOCKDEP actually. In that config, size of the struct lock_class_key would be 0. But it'd cause divide-by-zero in btrfs_set_buffer_lockdep_class() due to ARRAY_SIZE macro. Let's change it to use ks->names[] instead. It should have the same size as with ks->keys[]. Cc: Chris Mason Cc: Josef Bacik Cc: David Sterba Cc: linux-btrfs@vger.kernel.org Signed-off-by: Namhyung Kim --- fs/btrfs/disk-io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 87a5addbedf6..be41e35bee92 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -190,7 +190,7 @@ void btrfs_set_buffer_lockdep_class(u64 objectid, struc= t extent_buffer *eb, { struct btrfs_lockdep_keyset *ks; =20 - BUG_ON(level >=3D ARRAY_SIZE(ks->keys)); + BUG_ON(level >=3D ARRAY_SIZE(ks->names)); =20 /* find the matching keyset, id 0 is the default entry */ for (ks =3D btrfs_lockdep_keysets; ks->id; ks++) --=20 2.35.0.263.gb82422642f-goog From nobody Sun Jun 28 10:34:48 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2A900C433F5 for ; Tue, 8 Feb 2022 18:42:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385248AbiBHSmz (ORCPT ); Tue, 8 Feb 2022 13:42:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350202AbiBHSmb (ORCPT ); Tue, 8 Feb 2022 13:42:31 -0500 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88902C0612C0 for ; Tue, 8 Feb 2022 10:42:29 -0800 (PST) Received: by mail-pl1-x632.google.com with SMTP id w1so112372plb.6 for ; Tue, 08 Feb 2022 10:42:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PtfxXV8dKCbzToaKyltKN5n+I8WYCzRTP+RYfb80lWg=; b=oWkalnBFnnEXPv1omeHjJzsscCOhw+elYEOrghS9R4Y3R3dYzO58yDyVT0VanujVBk p3lMrXpxAd2bcRjVMfCsmxIB4AYTHVSYUi3JWrsfRZVeigCmH9HOLhl2TV2Szt9vw/Az iqKOwomHC9e7YYMjUj+Myhd2U9+XzAAVMZpzEqTRzuJKX8fkWUMpCCMHDgsMchUphqxc I6tefsEBhbQli4qElXCsOnOv6ju8IvN1JW6hNHiNDnziemkyjODuKYL/OA+YUTIeRvcu sHcDtGR+1A3UO0DzwgKTrAX3zEsdZoPzjKVhLwl6oDpn4eJbtGC/xBSvDW5bMy4G0xEq kVfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=PtfxXV8dKCbzToaKyltKN5n+I8WYCzRTP+RYfb80lWg=; b=vbOqe+9AZkXn8SaW9K0iwhgG7d+M4Dj/yWTUtptwg4AT23S+w+D6LWfG859g5KCQ5J Wn+EyEk0uKpjzEPQmz3HYFZRKLafV9H8r6pinSaW6hZa72GjkHRPb4UJTj2FdyjjTzQc JxulgALI9+SoGlXA5fh5zj+tgz2vo/Kcu59Ufy5U8gJcDh1SJ/sMA/bHUgwQB+G3XDVX mRlL36CLqV7DOXIGtWowFWDlSDLHRQoGW8/ixah7Fn3elhsWD4wEO88D8gpJ+FK5Lkq7 hYycz8eM4DvOOvOv1T0Nz45bFDvpkPLH43FH5sntapOx0abZJGFLX2TWPmWyrmt4XH70 HEZw== X-Gm-Message-State: AOAM532gxROUHuJ9k4g99/bw8dupPiuEHku6FESfmRQVR0fKeywoqaUH WwO/XelbsmfgFXfWyCcz2dk= X-Google-Smtp-Source: ABdhPJyR8Wokd+Cs2LppyxZr/Tuo/8Dv1HMy56zQXZBpistDEZT4/sqKJTnxH6gd3rEoogHFyZqrIg== X-Received: by 2002:a17:90a:5407:: with SMTP id z7mr2838451pjh.7.1644345748699; Tue, 08 Feb 2022 10:42:28 -0800 (PST) Received: from balhae.hsd1.ca.comcast.net ([2601:647:4800:c6f0:347f:e607:176:4358]) by smtp.gmail.com with ESMTPSA id l14sm3517027pjf.1.2022.02.08.10.42.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 10:42:27 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , Boqun Feng Cc: LKML , Thomas Gleixner , Steven Rostedt , Byungchul Park , "Paul E. McKenney" , Mathieu Desnoyers , Radoslaw Burny Subject: [PATCH 07/12] locking: Introduce CONFIG_LOCK_INFO Date: Tue, 8 Feb 2022 10:42:03 -0800 Message-Id: <20220208184208.79303-8-namhyung@kernel.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208184208.79303-1-namhyung@kernel.org> References: <20220208184208.79303-1-namhyung@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This is a preparatory work to have tracepoints separated from the lockdep. I'd like to keep minimal information of locks (name, for now) to be used by the tracepoints in the lockdep_map structure. To make the work easier, CONFIG_LOCK_INFO was added to indicate that it needs to save the lock info. And convert existing code using lock information to depend on it rather than CONFIG_LOCKDEP and/or CONFIG_DEBUG_LOCK_ALLOC directly. Future users of the lock information should select it too. Signed-off-by: Namhyung Kim --- drivers/gpu/drm/drm_connector.c | 2 +- drivers/gpu/drm/i915/i915_sw_fence.h | 2 +- drivers/gpu/drm/i915/selftests/lib_sw_fence.h | 2 +- drivers/net/wireless/intel/iwlwifi/iwl-trans.c | 4 ++-- drivers/net/wireless/intel/iwlwifi/iwl-trans.h | 2 +- drivers/tty/tty_ldsem.c | 2 +- fs/btrfs/disk-io.c | 2 +- fs/btrfs/disk-io.h | 2 +- fs/cifs/connect.c | 2 +- fs/kernfs/file.c | 2 +- include/linux/completion.h | 2 +- include/linux/jbd2.h | 2 +- include/linux/kernfs.h | 2 +- include/linux/kthread.h | 2 +- include/linux/local_lock_internal.h | 8 ++++---- include/linux/mmu_notifier.h | 2 +- include/linux/mutex.h | 8 ++++---- include/linux/percpu-rwsem.h | 4 ++-- include/linux/regmap.h | 4 ++-- include/linux/rtmutex.h | 6 +++--- include/linux/rwlock_api_smp.h | 4 ++-- include/linux/rwlock_rt.h | 4 ++-- include/linux/rwlock_types.h | 6 +++--- include/linux/rwsem.h | 6 +++--- include/linux/seqlock.h | 4 ++-- include/linux/spinlock_api_smp.h | 4 ++-- include/linux/spinlock_rt.h | 4 ++-- include/linux/spinlock_types.h | 4 ++-- include/linux/spinlock_types_raw.h | 4 ++-- include/linux/swait.h | 2 +- include/linux/tty_ldisc.h | 2 +- include/linux/wait.h | 2 +- include/linux/ww_mutex.h | 6 +++--- include/media/v4l2-ctrls.h | 2 +- include/net/sock.h | 2 +- kernel/locking/mutex-debug.c | 2 +- kernel/locking/mutex.c | 16 ++++++++-------- kernel/locking/percpu-rwsem.c | 2 +- kernel/locking/rtmutex_api.c | 10 +++++----- kernel/locking/rwsem.c | 4 ++-- kernel/locking/spinlock.c | 2 +- kernel/locking/spinlock_debug.c | 4 ++-- kernel/locking/spinlock_rt.c | 8 ++++---- kernel/locking/ww_rt_mutex.c | 2 +- kernel/printk/printk.c | 4 ++-- lib/Kconfig.debug | 5 +++++ mm/memcontrol.c | 2 +- mm/mmu_notifier.c | 2 +- net/core/dev.c | 2 +- net/sunrpc/svcsock.c | 2 +- net/sunrpc/xprtsock.c | 2 +- 51 files changed, 96 insertions(+), 91 deletions(-) diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connecto= r.c index a50c82bc2b2f..94931b32a491 100644 --- a/drivers/gpu/drm/drm_connector.c +++ b/drivers/gpu/drm/drm_connector.c @@ -676,7 +676,7 @@ const char *drm_get_connector_force_name(enum drm_conne= ctor_force force) } } =20 -#ifdef CONFIG_LOCKDEP +#ifdef CONFIG_LOCK_INFO static struct lockdep_map connector_list_iter_dep_map =3D { .name =3D "drm_connector_list_iter" }; diff --git a/drivers/gpu/drm/i915/i915_sw_fence.h b/drivers/gpu/drm/i915/i9= 15_sw_fence.h index a7c603bc1b01..8c05d161a069 100644 --- a/drivers/gpu/drm/i915/i915_sw_fence.h +++ b/drivers/gpu/drm/i915/i915_sw_fence.h @@ -43,7 +43,7 @@ void __i915_sw_fence_init(struct i915_sw_fence *fence, i915_sw_fence_notify_t fn, const char *name, struct lock_class_key *key); -#ifdef CONFIG_LOCKDEP +#ifdef CONFIG_LOCK_INFO #define i915_sw_fence_init(fence, fn) \ do { \ static struct lock_class_key __key; \ diff --git a/drivers/gpu/drm/i915/selftests/lib_sw_fence.h b/drivers/gpu/dr= m/i915/selftests/lib_sw_fence.h index e54d6bc23dc3..ad7de5187830 100644 --- a/drivers/gpu/drm/i915/selftests/lib_sw_fence.h +++ b/drivers/gpu/drm/i915/selftests/lib_sw_fence.h @@ -12,7 +12,7 @@ =20 #include "../i915_sw_fence.h" =20 -#ifdef CONFIG_LOCKDEP +#ifdef CONFIG_LOCK_INFO #define onstack_fence_init(fence) \ do { \ static struct lock_class_key __key; \ diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-trans.c b/drivers/net/w= ireless/intel/iwlwifi/iwl-trans.c index 9236f9106826..c0e7038a939f 100644 --- a/drivers/net/wireless/intel/iwlwifi/iwl-trans.c +++ b/drivers/net/wireless/intel/iwlwifi/iwl-trans.c @@ -21,7 +21,7 @@ struct iwl_trans *iwl_trans_alloc(unsigned int priv_size, const struct iwl_cfg_trans_params *cfg_trans) { struct iwl_trans *trans; -#ifdef CONFIG_LOCKDEP +#ifdef CONFIG_LOCK_INFO static struct lock_class_key __key; #endif =20 @@ -31,7 +31,7 @@ struct iwl_trans *iwl_trans_alloc(unsigned int priv_size, =20 trans->trans_cfg =3D cfg_trans; =20 -#ifdef CONFIG_LOCKDEP +#ifdef CONFIG_LOCK_INFO lockdep_init_map(&trans->sync_cmd_lockdep_map, "sync_cmd_lockdep_map", &__key, 0); #endif diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-trans.h b/drivers/net/w= ireless/intel/iwlwifi/iwl-trans.h index 1bcaa3598785..47ef1e852d85 100644 --- a/drivers/net/wireless/intel/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/intel/iwlwifi/iwl-trans.h @@ -1011,7 +1011,7 @@ struct iwl_trans { =20 struct dentry *dbgfs_dir; =20 -#ifdef CONFIG_LOCKDEP +#ifdef CONFIG_LOCK_INFO struct lockdep_map sync_cmd_lockdep_map; #endif =20 diff --git a/drivers/tty/tty_ldsem.c b/drivers/tty/tty_ldsem.c index 3be428c16260..87c44f3f0c27 100644 --- a/drivers/tty/tty_ldsem.c +++ b/drivers/tty/tty_ldsem.c @@ -57,7 +57,7 @@ struct ldsem_waiter { void __init_ldsem(struct ld_semaphore *sem, const char *name, struct lock_class_key *key) { -#ifdef CONFIG_DEBUG_LOCK_ALLOC +#ifdef CONFIG_LOCK_INFO /* * Make sure we are not reinitializing a held semaphore: */ diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index be41e35bee92..2a3a257ced49 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -144,7 +144,7 @@ struct async_submit_bio { * same as our lockdep setup here. If BTRFS_MAX_LEVEL changes, this code * needs update as well. */ -#ifdef CONFIG_DEBUG_LOCK_ALLOC +#ifdef CONFIG_LOCK_INFO # if BTRFS_MAX_LEVEL !=3D 8 # error # endif diff --git a/fs/btrfs/disk-io.h b/fs/btrfs/disk-io.h index 5e8bef4b7563..31ff5e95cb92 100644 --- a/fs/btrfs/disk-io.h +++ b/fs/btrfs/disk-io.h @@ -148,7 +148,7 @@ int btrfs_init_root_free_objectid(struct btrfs_root *ro= ot); int __init btrfs_end_io_wq_init(void); void __cold btrfs_end_io_wq_exit(void); =20 -#ifdef CONFIG_DEBUG_LOCK_ALLOC +#ifdef CONFIG_LOCK_INFO void btrfs_set_buffer_lockdep_class(u64 objectid, struct extent_buffer *eb, int level); #else diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 11a22a30ee14..b117027019b2 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -2573,7 +2573,7 @@ cifs_match_super(struct super_block *sb, void *data) return rc; } =20 -#ifdef CONFIG_DEBUG_LOCK_ALLOC +#ifdef CONFIG_LOCK_INFO static struct lock_class_key cifs_key[2]; static struct lock_class_key cifs_slock_key[2]; =20 diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c index 9414a7a60a9f..5cb58ec61ba8 100644 --- a/fs/kernfs/file.c +++ b/fs/kernfs/file.c @@ -994,7 +994,7 @@ struct kernfs_node *__kernfs_create_file(struct kernfs_= node *parent, kn->ns =3D ns; kn->priv =3D priv; =20 -#ifdef CONFIG_DEBUG_LOCK_ALLOC +#ifdef CONFIG_LOCK_INFO if (key) { lockdep_init_map(&kn->dep_map, "kn->active", key, 0); kn->flags |=3D KERNFS_LOCKDEP; diff --git a/include/linux/completion.h b/include/linux/completion.h index 51d9ab079629..b6c408e62291 100644 --- a/include/linux/completion.h +++ b/include/linux/completion.h @@ -64,7 +64,7 @@ static inline void complete_release(struct completion *x)= {} * This macro declares and initializes a completion structure on the kernel * stack. */ -#ifdef CONFIG_LOCKDEP +#ifdef CONFIG_LOCK_INFO # define DECLARE_COMPLETION_ONSTACK(work) \ struct completion work =3D COMPLETION_INITIALIZER_ONSTACK(work) # define DECLARE_COMPLETION_ONSTACK_MAP(work, map) \ diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h index fd933c45281a..990a87ff8ab0 100644 --- a/include/linux/jbd2.h +++ b/include/linux/jbd2.h @@ -1275,7 +1275,7 @@ struct journal_s */ __u32 j_csum_seed; =20 -#ifdef CONFIG_DEBUG_LOCK_ALLOC +#ifdef CONFIG_LOCK_INFO /** * @j_trans_commit_map: * diff --git a/include/linux/kernfs.h b/include/linux/kernfs.h index 861c4f0f8a29..48c5c02395cf 100644 --- a/include/linux/kernfs.h +++ b/include/linux/kernfs.h @@ -131,7 +131,7 @@ struct kernfs_elem_attr { struct kernfs_node { atomic_t count; atomic_t active; -#ifdef CONFIG_DEBUG_LOCK_ALLOC +#ifdef CONFIG_LOCK_INFO struct lockdep_map dep_map; #endif /* diff --git a/include/linux/kthread.h b/include/linux/kthread.h index 3df4ea04716f..d0d5ca007c7a 100644 --- a/include/linux/kthread.h +++ b/include/linux/kthread.h @@ -172,7 +172,7 @@ struct kthread_delayed_work { * kthread_worker.lock needs its own lockdep class key when defined on * stack with lockdep enabled. Use the following macros in such cases. */ -#ifdef CONFIG_LOCKDEP +#ifdef CONFIG_LOCK_INFO # define KTHREAD_WORKER_INIT_ONSTACK(worker) \ ({ kthread_init_worker(&worker); worker; }) # define DEFINE_KTHREAD_WORKER_ONSTACK(worker) \ diff --git a/include/linux/local_lock_internal.h b/include/linux/local_lock= _internal.h index 975e33b793a7..56f03f588aa7 100644 --- a/include/linux/local_lock_internal.h +++ b/include/linux/local_lock_internal.h @@ -9,13 +9,13 @@ #ifndef CONFIG_PREEMPT_RT =20 typedef struct { -#ifdef CONFIG_DEBUG_LOCK_ALLOC +#ifdef CONFIG_LOCK_INFO struct lockdep_map dep_map; struct task_struct *owner; #endif } local_lock_t; =20 -#ifdef CONFIG_DEBUG_LOCK_ALLOC +#ifdef CONFIG_LOCK_INFO # define LOCAL_LOCK_DEBUG_INIT(lockname) \ .dep_map =3D { \ .name =3D #lockname, \ @@ -42,12 +42,12 @@ static inline void local_lock_debug_init(local_lock_t *= l) { l->owner =3D NULL; } -#else /* CONFIG_DEBUG_LOCK_ALLOC */ +#else /* CONFIG_LOCK_INFO */ # define LOCAL_LOCK_DEBUG_INIT(lockname) static inline void local_lock_acquire(local_lock_t *l) { } static inline void local_lock_release(local_lock_t *l) { } static inline void local_lock_debug_init(local_lock_t *l) { } -#endif /* !CONFIG_DEBUG_LOCK_ALLOC */ +#endif /* !CONFIG_LOCK_INFO */ =20 #define INIT_LOCAL_LOCK(lockname) { LOCAL_LOCK_DEBUG_INIT(lockname) } =20 diff --git a/include/linux/mmu_notifier.h b/include/linux/mmu_notifier.h index 45fc2c81e370..ff88b1f5b173 100644 --- a/include/linux/mmu_notifier.h +++ b/include/linux/mmu_notifier.h @@ -264,7 +264,7 @@ struct mmu_interval_notifier { =20 #ifdef CONFIG_MMU_NOTIFIER =20 -#ifdef CONFIG_LOCKDEP +#ifdef CONFIG_LOCK_INFO extern struct lockdep_map __mmu_notifier_invalidate_range_start_map; #endif =20 diff --git a/include/linux/mutex.h b/include/linux/mutex.h index 8f226d460f51..369c1abbf3d0 100644 --- a/include/linux/mutex.h +++ b/include/linux/mutex.h @@ -20,7 +20,7 @@ #include #include =20 -#ifdef CONFIG_DEBUG_LOCK_ALLOC +#ifdef CONFIG_LOCK_INFO # define __DEP_MAP_MUTEX_INITIALIZER(lockname) \ , .dep_map =3D { \ .name =3D #lockname, \ @@ -70,7 +70,7 @@ struct mutex { #ifdef CONFIG_DEBUG_MUTEXES void *magic; #endif -#ifdef CONFIG_DEBUG_LOCK_ALLOC +#ifdef CONFIG_LOCK_INFO struct lockdep_map dep_map; #endif }; @@ -134,7 +134,7 @@ extern bool mutex_is_locked(struct mutex *lock); =20 struct mutex { struct rt_mutex_base rtmutex; -#ifdef CONFIG_DEBUG_LOCK_ALLOC +#ifdef CONFIG_LOCK_INFO struct lockdep_map dep_map; #endif }; @@ -174,7 +174,7 @@ do { \ * See kernel/locking/mutex.c for detailed documentation of these APIs. * Also see Documentation/locking/mutex-design.rst. */ -#ifdef CONFIG_DEBUG_LOCK_ALLOC +#ifdef CONFIG_LOCK_INFO extern void mutex_lock_nested(struct mutex *lock, unsigned int subclass); extern void _mutex_lock_nest_lock(struct mutex *lock, struct lockdep_map *= nest_lock); =20 diff --git a/include/linux/percpu-rwsem.h b/include/linux/percpu-rwsem.h index 5fda40f97fe9..9d2427579d9a 100644 --- a/include/linux/percpu-rwsem.h +++ b/include/linux/percpu-rwsem.h @@ -15,12 +15,12 @@ struct percpu_rw_semaphore { struct rcuwait writer; wait_queue_head_t waiters; atomic_t block; -#ifdef CONFIG_DEBUG_LOCK_ALLOC +#ifdef CONFIG_LOCK_INFO struct lockdep_map dep_map; #endif }; =20 -#ifdef CONFIG_DEBUG_LOCK_ALLOC +#ifdef CONFIG_LOCK_INFO #define __PERCPU_RWSEM_DEP_MAP_INIT(lockname) .dep_map =3D { .name =3D #lo= ckname }, #else #define __PERCPU_RWSEM_DEP_MAP_INIT(lockname) diff --git a/include/linux/regmap.h b/include/linux/regmap.h index 22652e5fbc38..174493a0512a 100644 --- a/include/linux/regmap.h +++ b/include/linux/regmap.h @@ -666,12 +666,12 @@ struct regmap *__devm_regmap_init_spi_avmm(struct spi= _device *spi, const char *lock_name); /* * Wrapper for regmap_init macros to include a unique lockdep key and name - * for each call. No-op if CONFIG_LOCKDEP is not set. + * for each call. No-op if CONFIG_LOCK_INFO is not set. * * @fn: Real function to call (in the form __[*_]regmap_init[_*]) * @name: Config variable name (#config in the calling macro) **/ -#ifdef CONFIG_LOCKDEP +#ifdef CONFIG_LOCK_INFO #define __regmap_lockdep_wrapper(fn, name, ...) \ ( \ ({ \ diff --git a/include/linux/rtmutex.h b/include/linux/rtmutex.h index 7d049883a08a..8eafdd6dcf35 100644 --- a/include/linux/rtmutex.h +++ b/include/linux/rtmutex.h @@ -56,7 +56,7 @@ extern void rt_mutex_base_init(struct rt_mutex_base *rtb); */ struct rt_mutex { struct rt_mutex_base rtmutex; -#ifdef CONFIG_DEBUG_LOCK_ALLOC +#ifdef CONFIG_LOCK_INFO struct lockdep_map dep_map; #endif }; @@ -76,7 +76,7 @@ do { \ __rt_mutex_init(mutex, __func__, &__key); \ } while (0) =20 -#ifdef CONFIG_DEBUG_LOCK_ALLOC +#ifdef CONFIG_LOCK_INFO #define __DEP_MAP_RT_MUTEX_INITIALIZER(mutexname) \ .dep_map =3D { \ .name =3D #mutexname, \ @@ -97,7 +97,7 @@ do { \ =20 extern void __rt_mutex_init(struct rt_mutex *lock, const char *name, struc= t lock_class_key *key); =20 -#ifdef CONFIG_DEBUG_LOCK_ALLOC +#ifdef CONFIG_LOCK_INFO extern void rt_mutex_lock_nested(struct rt_mutex *lock, unsigned int subcl= ass); extern void _rt_mutex_lock_nest_lock(struct rt_mutex *lock, struct lockdep= _map *nest_lock); #define rt_mutex_lock(lock) rt_mutex_lock_nested(lock, 0) diff --git a/include/linux/rwlock_api_smp.h b/include/linux/rwlock_api_smp.h index dceb0a59b692..7fb42c921669 100644 --- a/include/linux/rwlock_api_smp.h +++ b/include/linux/rwlock_api_smp.h @@ -142,7 +142,7 @@ static inline int __raw_write_trylock(rwlock_t *lock) * even on CONFIG_PREEMPT, because lockdep assumes that interrupts are * not re-enabled during lock-acquire (which the preempt-spin-ops do): */ -#if !defined(CONFIG_GENERIC_LOCKBREAK) || defined(CONFIG_DEBUG_LOCK_ALLOC) +#if !defined(CONFIG_GENERIC_LOCKBREAK) || defined(CONFIG_LOCK_INFO) =20 static inline void __raw_read_lock(rwlock_t *lock) { @@ -217,7 +217,7 @@ static inline void __raw_write_lock_nested(rwlock_t *lo= ck, int subclass) LOCK_CONTENDED(lock, do_raw_write_trylock, do_raw_write_lock); } =20 -#endif /* !CONFIG_GENERIC_LOCKBREAK || CONFIG_DEBUG_LOCK_ALLOC */ +#endif /* !CONFIG_GENERIC_LOCKBREAK || CONFIG_LOCK_INFO */ =20 static inline void __raw_write_unlock(rwlock_t *lock) { diff --git a/include/linux/rwlock_rt.h b/include/linux/rwlock_rt.h index 8544ff05e594..140c418c51b5 100644 --- a/include/linux/rwlock_rt.h +++ b/include/linux/rwlock_rt.h @@ -6,7 +6,7 @@ #error Do not #include directly. Use . #endif =20 -#ifdef CONFIG_DEBUG_LOCK_ALLOC +#ifdef CONFIG_LOCK_INFO extern void __rt_rwlock_init(rwlock_t *rwlock, const char *name, struct lock_class_key *key); #else @@ -84,7 +84,7 @@ static __always_inline void write_lock(rwlock_t *rwlock) rt_write_lock(rwlock); } =20 -#ifdef CONFIG_DEBUG_LOCK_ALLOC +#ifdef CONFIG_LOCK_INFO static __always_inline void write_lock_nested(rwlock_t *rwlock, int subcla= ss) { rt_write_lock_nested(rwlock, subclass); diff --git a/include/linux/rwlock_types.h b/include/linux/rwlock_types.h index 1948442e7750..3e621bfd7cd0 100644 --- a/include/linux/rwlock_types.h +++ b/include/linux/rwlock_types.h @@ -5,7 +5,7 @@ # error "Do not include directly, include spinlock_types.h" #endif =20 -#ifdef CONFIG_DEBUG_LOCK_ALLOC +#ifdef CONFIG_LOCK_INFO # define RW_DEP_MAP_INIT(lockname) \ .dep_map =3D { \ .name =3D #lockname, \ @@ -28,7 +28,7 @@ typedef struct { unsigned int magic, owner_cpu; void *owner; #endif -#ifdef CONFIG_DEBUG_LOCK_ALLOC +#ifdef CONFIG_LOCK_INFO struct lockdep_map dep_map; #endif } rwlock_t; @@ -57,7 +57,7 @@ typedef struct { typedef struct { struct rwbase_rt rwbase; atomic_t readers; -#ifdef CONFIG_DEBUG_LOCK_ALLOC +#ifdef CONFIG_LOCK_INFO struct lockdep_map dep_map; #endif } rwlock_t; diff --git a/include/linux/rwsem.h b/include/linux/rwsem.h index f9348769e558..c488485861f5 100644 --- a/include/linux/rwsem.h +++ b/include/linux/rwsem.h @@ -16,7 +16,7 @@ #include #include =20 -#ifdef CONFIG_DEBUG_LOCK_ALLOC +#ifdef CONFIG_LOCK_INFO # define __RWSEM_DEP_MAP_INIT(lockname) \ .dep_map =3D { \ .name =3D #lockname, \ @@ -60,7 +60,7 @@ struct rw_semaphore { #ifdef CONFIG_DEBUG_RWSEMS void *magic; #endif -#ifdef CONFIG_DEBUG_LOCK_ALLOC +#ifdef CONFIG_LOCK_INFO struct lockdep_map dep_map; #endif }; @@ -127,7 +127,7 @@ static inline int rwsem_is_contended(struct rw_semaphor= e *sem) =20 struct rw_semaphore { struct rwbase_rt rwbase; -#ifdef CONFIG_DEBUG_LOCK_ALLOC +#ifdef CONFIG_LOCK_INFO struct lockdep_map dep_map; #endif }; diff --git a/include/linux/seqlock.h b/include/linux/seqlock.h index 37ded6b8fee6..c673f807965e 100644 --- a/include/linux/seqlock.h +++ b/include/linux/seqlock.h @@ -64,7 +64,7 @@ */ typedef struct seqcount { unsigned sequence; -#ifdef CONFIG_DEBUG_LOCK_ALLOC +#ifdef CONFIG_LOCK_INFO struct lockdep_map dep_map; #endif } seqcount_t; @@ -79,7 +79,7 @@ static inline void __seqcount_init(seqcount_t *s, const c= har *name, s->sequence =3D 0; } =20 -#ifdef CONFIG_DEBUG_LOCK_ALLOC +#ifdef CONFIG_LOCK_INFO =20 # define SEQCOUNT_DEP_MAP_INIT(lockname) \ .dep_map =3D { .name =3D #lockname } diff --git a/include/linux/spinlock_api_smp.h b/include/linux/spinlock_api_= smp.h index 51fa0dab68c4..94e5ddbcc2d1 100644 --- a/include/linux/spinlock_api_smp.h +++ b/include/linux/spinlock_api_smp.h @@ -99,7 +99,7 @@ static inline int __raw_spin_trylock(raw_spinlock_t *lock) * even on CONFIG_PREEMPTION, because lockdep assumes that interrupts are * not re-enabled during lock-acquire (which the preempt-spin-ops do): */ -#if !defined(CONFIG_GENERIC_LOCKBREAK) || defined(CONFIG_DEBUG_LOCK_ALLOC) +#if !defined(CONFIG_GENERIC_LOCKBREAK) || defined(CONFIG_LOCK_INFO) =20 static inline unsigned long __raw_spin_lock_irqsave(raw_spinlock_t *lock) { @@ -134,7 +134,7 @@ static inline void __raw_spin_lock(raw_spinlock_t *lock) LOCK_CONTENDED(lock, do_raw_spin_trylock, do_raw_spin_lock); } =20 -#endif /* !CONFIG_GENERIC_LOCKBREAK || CONFIG_DEBUG_LOCK_ALLOC */ +#endif /* !CONFIG_GENERIC_LOCKBREAK || CONFIG_LOCK_INFO */ =20 static inline void __raw_spin_unlock(raw_spinlock_t *lock) { diff --git a/include/linux/spinlock_rt.h b/include/linux/spinlock_rt.h index 835aedaf68ac..2605668e0fdd 100644 --- a/include/linux/spinlock_rt.h +++ b/include/linux/spinlock_rt.h @@ -6,7 +6,7 @@ #error Do not include directly. Use spinlock.h #endif =20 -#ifdef CONFIG_DEBUG_LOCK_ALLOC +#ifdef CONFIG_LOCK_INFO extern void __rt_spin_lock_init(spinlock_t *lock, const char *name, struct lock_class_key *key, bool percpu); #else @@ -45,7 +45,7 @@ static __always_inline void spin_lock(spinlock_t *lock) rt_spin_lock(lock); } =20 -#ifdef CONFIG_LOCKDEP +#ifdef CONFIG_LOCK_INFO # define __spin_lock_nested(lock, subclass) \ rt_spin_lock_nested(lock, subclass) =20 diff --git a/include/linux/spinlock_types.h b/include/linux/spinlock_types.h index 2dfa35ffec76..fb9e778a0ee5 100644 --- a/include/linux/spinlock_types.h +++ b/include/linux/spinlock_types.h @@ -18,7 +18,7 @@ typedef struct spinlock { union { struct raw_spinlock rlock; =20 -#ifdef CONFIG_DEBUG_LOCK_ALLOC +#ifdef CONFIG_LOCK_INFO # define LOCK_PADSIZE (offsetof(struct raw_spinlock, dep_map)) struct { u8 __padding[LOCK_PADSIZE]; @@ -49,7 +49,7 @@ typedef struct spinlock { =20 typedef struct spinlock { struct rt_mutex_base lock; -#ifdef CONFIG_DEBUG_LOCK_ALLOC +#ifdef CONFIG_LOCK_INFO struct lockdep_map dep_map; #endif } spinlock_t; diff --git a/include/linux/spinlock_types_raw.h b/include/linux/spinlock_ty= pes_raw.h index 91cb36b65a17..564092a30cc4 100644 --- a/include/linux/spinlock_types_raw.h +++ b/include/linux/spinlock_types_raw.h @@ -17,7 +17,7 @@ typedef struct raw_spinlock { unsigned int magic, owner_cpu; void *owner; #endif -#ifdef CONFIG_DEBUG_LOCK_ALLOC +#ifdef CONFIG_LOCK_INFO struct lockdep_map dep_map; #endif } raw_spinlock_t; @@ -26,7 +26,7 @@ typedef struct raw_spinlock { =20 #define SPINLOCK_OWNER_INIT ((void *)-1L) =20 -#ifdef CONFIG_DEBUG_LOCK_ALLOC +#ifdef CONFIG_LOCK_INFO # define RAW_SPIN_DEP_MAP_INIT(lockname) \ .dep_map =3D { \ .name =3D #lockname, \ diff --git a/include/linux/swait.h b/include/linux/swait.h index 6a8c22b8c2a5..643c9fe68d63 100644 --- a/include/linux/swait.h +++ b/include/linux/swait.h @@ -75,7 +75,7 @@ extern void __init_swait_queue_head(struct swait_queue_he= ad *q, const char *name __init_swait_queue_head((q), #q, &__key); \ } while (0) =20 -#ifdef CONFIG_LOCKDEP +#ifdef CONFIG_LOCK_INFO # define __SWAIT_QUEUE_HEAD_INIT_ONSTACK(name) \ ({ init_swait_queue_head(&name); name; }) # define DECLARE_SWAIT_QUEUE_HEAD_ONSTACK(name) \ diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h index e85002b56752..5af6fb3649ab 100644 --- a/include/linux/tty_ldisc.h +++ b/include/linux/tty_ldisc.h @@ -20,7 +20,7 @@ struct ld_semaphore { unsigned int wait_readers; struct list_head read_wait; struct list_head write_wait; -#ifdef CONFIG_DEBUG_LOCK_ALLOC +#ifdef CONFIG_LOCK_INFO struct lockdep_map dep_map; #endif }; diff --git a/include/linux/wait.h b/include/linux/wait.h index 851e07da2583..aa811a05b070 100644 --- a/include/linux/wait.h +++ b/include/linux/wait.h @@ -70,7 +70,7 @@ extern void __init_waitqueue_head(struct wait_queue_head = *wq_head, const char *n __init_waitqueue_head((wq_head), #wq_head, &__key); \ } while (0) =20 -#ifdef CONFIG_LOCKDEP +#ifdef CONFIG_LOCK_INFO # define __WAIT_QUEUE_HEAD_INIT_ONSTACK(name) \ ({ init_waitqueue_head(&name); name; }) # define DECLARE_WAIT_QUEUE_HEAD_ONSTACK(name) \ diff --git a/include/linux/ww_mutex.h b/include/linux/ww_mutex.h index bb763085479a..12a6ad18176d 100644 --- a/include/linux/ww_mutex.h +++ b/include/linux/ww_mutex.h @@ -63,7 +63,7 @@ struct ww_acquire_ctx { struct ww_class *ww_class; void *contending_lock; #endif -#ifdef CONFIG_DEBUG_LOCK_ALLOC +#ifdef CONFIG_LOCK_INFO struct lockdep_map dep_map; #endif #ifdef CONFIG_DEBUG_WW_MUTEX_SLOWPATH @@ -142,7 +142,7 @@ static inline void ww_acquire_init(struct ww_acquire_ct= x *ctx, ctx->done_acquire =3D 0; ctx->contending_lock =3D NULL; #endif -#ifdef CONFIG_DEBUG_LOCK_ALLOC +#ifdef CONFIG_LOCK_INFO debug_check_no_locks_freed((void *)ctx, sizeof(*ctx)); lockdep_init_map(&ctx->dep_map, ww_class->acquire_name, &ww_class->acquire_key, 0); @@ -184,7 +184,7 @@ static inline void ww_acquire_done(struct ww_acquire_ct= x *ctx) */ static inline void ww_acquire_fini(struct ww_acquire_ctx *ctx) { -#ifdef CONFIG_DEBUG_LOCK_ALLOC +#ifdef CONFIG_LOCK_INFO mutex_release(&ctx->dep_map, _THIS_IP_); #endif #ifdef DEBUG_WW_MUTEXES diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h index b3ce438f1329..f2c30a4fe203 100644 --- a/include/media/v4l2-ctrls.h +++ b/include/media/v4l2-ctrls.h @@ -489,7 +489,7 @@ int v4l2_ctrl_handler_init_class(struct v4l2_ctrl_handl= er *hdl, unsigned int nr_of_controls_hint, struct lock_class_key *key, const char *name); =20 -#ifdef CONFIG_LOCKDEP +#ifdef CONFIG_LOCK_INFO =20 /** * v4l2_ctrl_handler_init - helper function to create a static struct diff --git a/include/net/sock.h b/include/net/sock.h index ff9b508d9c5f..e88c7de283ed 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -103,7 +103,7 @@ typedef struct { * the slock as a lock variant (in addition to * the slock itself): */ -#ifdef CONFIG_DEBUG_LOCK_ALLOC +#ifdef CONFIG_LOCK_INFO struct lockdep_map dep_map; #endif } socket_lock_t; diff --git a/kernel/locking/mutex-debug.c b/kernel/locking/mutex-debug.c index bc8abb8549d2..33fc3c06b714 100644 --- a/kernel/locking/mutex-debug.c +++ b/kernel/locking/mutex-debug.c @@ -79,7 +79,7 @@ void debug_mutex_unlock(struct mutex *lock) void debug_mutex_init(struct mutex *lock, const char *name, struct lock_class_key *key) { -#ifdef CONFIG_DEBUG_LOCK_ALLOC +#ifdef CONFIG_LOCK_INFO /* * Make sure we are not reinitializing a held lock: */ diff --git a/kernel/locking/mutex.c b/kernel/locking/mutex.c index 5e3585950ec8..8733b96ce20a 100644 --- a/kernel/locking/mutex.c +++ b/kernel/locking/mutex.c @@ -149,7 +149,7 @@ static inline bool __mutex_trylock(struct mutex *lock) return !__mutex_trylock_common(lock, false); } =20 -#ifndef CONFIG_DEBUG_LOCK_ALLOC +#ifndef CONFIG_LOCK_INFO /* * Lockdep annotations are contained to the slow paths for simplicity. * There is nothing that would stop spreading the lockdep annotations outw= ards @@ -245,7 +245,7 @@ static void __mutex_handoff(struct mutex *lock, struct = task_struct *task) } } =20 -#ifndef CONFIG_DEBUG_LOCK_ALLOC +#ifndef CONFIG_LOCK_INFO /* * We split the mutex lock/unlock logic into separate fastpath and * slowpath functions, to reduce the register pressure on the fastpath. @@ -533,7 +533,7 @@ static noinline void __sched __mutex_unlock_slowpath(st= ruct mutex *lock, unsigne */ void __sched mutex_unlock(struct mutex *lock) { -#ifndef CONFIG_DEBUG_LOCK_ALLOC +#ifndef CONFIG_LOCK_INFO if (__mutex_unlock_fast(lock)) return; #endif @@ -591,7 +591,7 @@ __mutex_lock_common(struct mutex *lock, unsigned int st= ate, unsigned int subclas if (ww_ctx->acquired =3D=3D 0) ww_ctx->wounded =3D 0; =20 -#ifdef CONFIG_DEBUG_LOCK_ALLOC +#ifdef CONFIG_LOCK_INFO nest_lock =3D &ww_ctx->dep_map; #endif } @@ -778,7 +778,7 @@ int ww_mutex_trylock(struct ww_mutex *ww, struct ww_acq= uire_ctx *ww_ctx) } EXPORT_SYMBOL(ww_mutex_trylock); =20 -#ifdef CONFIG_DEBUG_LOCK_ALLOC +#ifdef CONFIG_LOCK_INFO void __sched mutex_lock_nested(struct mutex *lock, unsigned int subclass) { @@ -937,7 +937,7 @@ static noinline void __sched __mutex_unlock_slowpath(st= ruct mutex *lock, unsigne wake_up_q(&wake_q); } =20 -#ifndef CONFIG_DEBUG_LOCK_ALLOC +#ifndef CONFIG_LOCK_INFO /* * Here come the less common (and hence less performance-critical) APIs: * mutex_lock_interruptible() and mutex_trylock(). @@ -1078,7 +1078,7 @@ int __sched mutex_trylock(struct mutex *lock) } EXPORT_SYMBOL(mutex_trylock); =20 -#ifndef CONFIG_DEBUG_LOCK_ALLOC +#ifndef CONFIG_LOCK_INFO int __sched ww_mutex_lock(struct ww_mutex *lock, struct ww_acquire_ctx *ctx) { @@ -1109,7 +1109,7 @@ ww_mutex_lock_interruptible(struct ww_mutex *lock, st= ruct ww_acquire_ctx *ctx) } EXPORT_SYMBOL(ww_mutex_lock_interruptible); =20 -#endif /* !CONFIG_DEBUG_LOCK_ALLOC */ +#endif /* !CONFIG_LOCK_INFO */ #endif /* !CONFIG_PREEMPT_RT */ =20 /** diff --git a/kernel/locking/percpu-rwsem.c b/kernel/locking/percpu-rwsem.c index 70a32a576f3f..98ff434a5f95 100644 --- a/kernel/locking/percpu-rwsem.c +++ b/kernel/locking/percpu-rwsem.c @@ -20,7 +20,7 @@ int __percpu_init_rwsem(struct percpu_rw_semaphore *sem, rcuwait_init(&sem->writer); init_waitqueue_head(&sem->waiters); atomic_set(&sem->block, 0); -#ifdef CONFIG_DEBUG_LOCK_ALLOC +#ifdef CONFIG_LOCK_INFO debug_check_no_locks_freed((void *)sem, sizeof(*sem)); lockdep_init_map(&sem->dep_map, name, key, 0); #endif diff --git a/kernel/locking/rtmutex_api.c b/kernel/locking/rtmutex_api.c index 900220941caa..ce08dabf4f93 100644 --- a/kernel/locking/rtmutex_api.c +++ b/kernel/locking/rtmutex_api.c @@ -40,7 +40,7 @@ void rt_mutex_base_init(struct rt_mutex_base *rtb) } EXPORT_SYMBOL(rt_mutex_base_init); =20 -#ifdef CONFIG_DEBUG_LOCK_ALLOC +#ifdef CONFIG_LOCK_INFO /** * rt_mutex_lock_nested - lock a rt_mutex * @@ -59,7 +59,7 @@ void __sched _rt_mutex_lock_nest_lock(struct rt_mutex *lo= ck, struct lockdep_map } EXPORT_SYMBOL_GPL(_rt_mutex_lock_nest_lock); =20 -#else /* !CONFIG_DEBUG_LOCK_ALLOC */ +#else /* !CONFIG_LOCK_INFO */ =20 /** * rt_mutex_lock - lock a rt_mutex @@ -517,7 +517,7 @@ static __always_inline int __mutex_lock_common(struct m= utex *lock, return ret; } =20 -#ifdef CONFIG_DEBUG_LOCK_ALLOC +#ifdef CONFIG_LOCK_INFO void __sched mutex_lock_nested(struct mutex *lock, unsigned int subclass) { __mutex_lock_common(lock, TASK_UNINTERRUPTIBLE, subclass, NULL, _RET_IP_); @@ -557,7 +557,7 @@ void __sched mutex_lock_io_nested(struct mutex *lock, u= nsigned int subclass) } EXPORT_SYMBOL_GPL(mutex_lock_io_nested); =20 -#else /* CONFIG_DEBUG_LOCK_ALLOC */ +#else /* CONFIG_LOCK_INFO */ =20 void __sched mutex_lock(struct mutex *lock) { @@ -585,7 +585,7 @@ void __sched mutex_lock_io(struct mutex *lock) io_schedule_finish(token); } EXPORT_SYMBOL(mutex_lock_io); -#endif /* !CONFIG_DEBUG_LOCK_ALLOC */ +#endif /* !CONFIG_LOCK_INFO */ =20 int __sched mutex_trylock(struct mutex *lock) { diff --git a/kernel/locking/rwsem.c b/kernel/locking/rwsem.c index 69aba4abe104..8da694940165 100644 --- a/kernel/locking/rwsem.c +++ b/kernel/locking/rwsem.c @@ -304,7 +304,7 @@ rwsem_owner_flags(struct rw_semaphore *sem, unsigned lo= ng *pflags) void __init_rwsem(struct rw_semaphore *sem, const char *name, struct lock_class_key *key) { -#ifdef CONFIG_DEBUG_LOCK_ALLOC +#ifdef CONFIG_LOCK_INFO /* * Make sure we are not reinitializing a held semaphore: */ @@ -1378,7 +1378,7 @@ void __init_rwsem(struct rw_semaphore *sem, const cha= r *name, { init_rwbase_rt(&(sem)->rwbase); =20 -#ifdef CONFIG_DEBUG_LOCK_ALLOC +#ifdef CONFIG_LOCK_INFO debug_check_no_locks_freed((void *)sem, sizeof(*sem)); lockdep_init_map_wait(&sem->dep_map, name, key, 0, LD_WAIT_SLEEP); #endif diff --git a/kernel/locking/spinlock.c b/kernel/locking/spinlock.c index 7f49baaa4979..e814ca0b76c3 100644 --- a/kernel/locking/spinlock.c +++ b/kernel/locking/spinlock.c @@ -34,7 +34,7 @@ EXPORT_PER_CPU_SYMBOL(__mmiowb_state); * even on CONFIG_PREEMPT, because lockdep assumes that interrupts are * not re-enabled during lock-acquire (which the preempt-spin-ops do): */ -#if !defined(CONFIG_GENERIC_LOCKBREAK) || defined(CONFIG_DEBUG_LOCK_ALLOC) +#if !defined(CONFIG_GENERIC_LOCKBREAK) || defined(CONFIG_LOCK_INFO) /* * The __lock_function inlines are taken from * spinlock : include/linux/spinlock_api_smp.h diff --git a/kernel/locking/spinlock_debug.c b/kernel/locking/spinlock_debu= g.c index 14235671a1a7..011f66515693 100644 --- a/kernel/locking/spinlock_debug.c +++ b/kernel/locking/spinlock_debug.c @@ -16,7 +16,7 @@ void __raw_spin_lock_init(raw_spinlock_t *lock, const char *name, struct lock_class_key *key, short inner) { -#ifdef CONFIG_DEBUG_LOCK_ALLOC +#ifdef CONFIG_LOCK_INFO /* * Make sure we are not reinitializing a held lock: */ @@ -35,7 +35,7 @@ EXPORT_SYMBOL(__raw_spin_lock_init); void __rwlock_init(rwlock_t *lock, const char *name, struct lock_class_key *key) { -#ifdef CONFIG_DEBUG_LOCK_ALLOC +#ifdef CONFIG_LOCK_INFO /* * Make sure we are not reinitializing a held lock: */ diff --git a/kernel/locking/spinlock_rt.c b/kernel/locking/spinlock_rt.c index 48a19ed8486d..22cd3eb36c98 100644 --- a/kernel/locking/spinlock_rt.c +++ b/kernel/locking/spinlock_rt.c @@ -56,7 +56,7 @@ void __sched rt_spin_lock(spinlock_t *lock) } EXPORT_SYMBOL(rt_spin_lock); =20 -#ifdef CONFIG_DEBUG_LOCK_ALLOC +#ifdef CONFIG_LOCK_INFO void __sched rt_spin_lock_nested(spinlock_t *lock, int subclass) { spin_acquire(&lock->dep_map, subclass, 0, _RET_IP_); @@ -129,7 +129,7 @@ int __sched rt_spin_trylock_bh(spinlock_t *lock) } EXPORT_SYMBOL(rt_spin_trylock_bh); =20 -#ifdef CONFIG_DEBUG_LOCK_ALLOC +#ifdef CONFIG_LOCK_INFO void __rt_spin_lock_init(spinlock_t *lock, const char *name, struct lock_class_key *key, bool percpu) { @@ -239,7 +239,7 @@ void __sched rt_write_lock(rwlock_t *rwlock) } EXPORT_SYMBOL(rt_write_lock); =20 -#ifdef CONFIG_DEBUG_LOCK_ALLOC +#ifdef CONFIG_LOCK_INFO void __sched rt_write_lock_nested(rwlock_t *rwlock, int subclass) { rtlock_might_resched(); @@ -269,7 +269,7 @@ void __sched rt_write_unlock(rwlock_t *rwlock) } EXPORT_SYMBOL(rt_write_unlock); =20 -#ifdef CONFIG_DEBUG_LOCK_ALLOC +#ifdef CONFIG_LOCK_INFO void __rt_rwlock_init(rwlock_t *rwlock, const char *name, struct lock_class_key *key) { diff --git a/kernel/locking/ww_rt_mutex.c b/kernel/locking/ww_rt_mutex.c index d1473c624105..aecb2e4e5f07 100644 --- a/kernel/locking/ww_rt_mutex.c +++ b/kernel/locking/ww_rt_mutex.c @@ -56,7 +56,7 @@ __ww_rt_mutex_lock(struct ww_mutex *lock, struct ww_acqui= re_ctx *ww_ctx, if (ww_ctx->acquired =3D=3D 0) ww_ctx->wounded =3D 0; =20 -#ifdef CONFIG_DEBUG_LOCK_ALLOC +#ifdef CONFIG_LOCK_INFO nest_lock =3D &ww_ctx->dep_map; #endif } diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 82abfaf3c2aa..e45664e0ca30 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -93,7 +93,7 @@ EXPORT_SYMBOL_GPL(console_drivers); */ int __read_mostly suppress_printk; =20 -#ifdef CONFIG_LOCKDEP +#ifdef CONFIG_LOCK_INFO static struct lockdep_map console_lock_dep_map =3D { .name =3D "console_lock" }; @@ -1752,7 +1752,7 @@ SYSCALL_DEFINE3(syslog, int, type, char __user *, buf= , int, len) * They allow to pass console_lock to another printk() call using a busy w= ait. */ =20 -#ifdef CONFIG_LOCKDEP +#ifdef CONFIG_LOCK_INFO static struct lockdep_map console_owner_dep_map =3D { .name =3D "console_owner" }; diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 14b89aa37c5c..5f64ffe23c35 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -1394,6 +1394,7 @@ config LOCKDEP select STACKTRACE select KALLSYMS select KALLSYMS_ALL + select LOCK_INFO =20 config LOCKDEP_SMALL bool @@ -1447,6 +1448,10 @@ config DEBUG_LOCKDEP additional runtime checks to debug itself, at the price of more runtime overhead. =20 +config LOCK_INFO + bool + default n + config DEBUG_ATOMIC_SLEEP bool "Sleep inside atomic section checking" select PREEMPT_COUNT diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 09d342c7cbd0..d4ecfdd5eb8f 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -1671,7 +1671,7 @@ static int mem_cgroup_soft_reclaim(struct mem_cgroup = *root_memcg, return total; } =20 -#ifdef CONFIG_LOCKDEP +#ifdef CONFIG_LOCK_INFO static struct lockdep_map memcg_oom_lock_dep_map =3D { .name =3D "memcg_oom_lock", }; diff --git a/mm/mmu_notifier.c b/mm/mmu_notifier.c index 459d195d2ff6..26da67834cba 100644 --- a/mm/mmu_notifier.c +++ b/mm/mmu_notifier.c @@ -22,7 +22,7 @@ /* global SRCU for all MMs */ DEFINE_STATIC_SRCU(srcu); =20 -#ifdef CONFIG_LOCKDEP +#ifdef CONFIG_LOCK_INFO struct lockdep_map __mmu_notifier_invalidate_range_start_map =3D { .name =3D "mmu_notifier_invalidate_range_start" }; diff --git a/net/core/dev.c b/net/core/dev.c index 1baab07820f6..7548a6c606ca 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -406,7 +406,7 @@ static RAW_NOTIFIER_HEAD(netdev_chain); DEFINE_PER_CPU_ALIGNED(struct softnet_data, softnet_data); EXPORT_PER_CPU_SYMBOL(softnet_data); =20 -#ifdef CONFIG_LOCKDEP +#ifdef CONFIG_LOCK_INFO /* * register_netdevice() inits txq->_xmit_lock and sets lockdep class * according to dev->type diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c index 478f857cdaed..14d87c2d0df1 100644 --- a/net/sunrpc/svcsock.c +++ b/net/sunrpc/svcsock.c @@ -74,7 +74,7 @@ static void svc_sock_free(struct svc_xprt *); static struct svc_xprt *svc_create_socket(struct svc_serv *, int, struct net *, struct sockaddr *, int, int); -#ifdef CONFIG_DEBUG_LOCK_ALLOC +#ifdef CONFIG_LOCK_INFO static struct lock_class_key svc_key[2]; static struct lock_class_key svc_slock_key[2]; =20 diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c index d8ee06a9650a..cd66a6608ba2 100644 --- a/net/sunrpc/xprtsock.c +++ b/net/sunrpc/xprtsock.c @@ -1719,7 +1719,7 @@ static void xs_local_set_port(struct rpc_xprt *xprt, = unsigned short port) { } =20 -#ifdef CONFIG_DEBUG_LOCK_ALLOC +#ifdef CONFIG_LOCK_INFO static struct lock_class_key xs_key[3]; static struct lock_class_key xs_slock_key[3]; =20 --=20 2.35.0.263.gb82422642f-goog From nobody Sun Jun 28 10:34:48 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A689C433EF for ; Tue, 8 Feb 2022 18:43:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385267AbiBHSm7 (ORCPT ); Tue, 8 Feb 2022 13:42:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385145AbiBHSmd (ORCPT ); Tue, 8 Feb 2022 13:42:33 -0500 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96D1BC061579 for ; Tue, 8 Feb 2022 10:42:32 -0800 (PST) Received: by mail-pf1-x430.google.com with SMTP id b3so1919534pfg.7 for ; Tue, 08 Feb 2022 10:42:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bV0qidYdKe49UwnnplwX5EgJUDf8zdhBMjx8WUJKWzs=; b=OHMzOVmuzS8R5vdjMnFQ83YEp0mRe52PlihZ6rxSISxMAiPFQkMYZTgLEk10Xm0usa o3hNE+BxWkLxBMsUZ/aRwqhOL9Vg0cn7OW7gLLh52bbdsf6/zJDpCrC7702jkr0M6AnH R2O1+OOGo5OSy/hMAiTKCaiqG4dq5JzQE2cvGPL2DtYv4/7J3cT7s1kSorRfmhhphEd9 S/p2V/Z3OKSuft2IZomKHbhtTtD+NqCMtZPUccAoGl427hbooDuLd85z1FwVeI/tzTgl oc3lTysydSvotK2YYva1QthZGhJsxaKHJYKnFj6zv7i+kOCG/g9qnEKR42Qo34BFLF7e xvaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=bV0qidYdKe49UwnnplwX5EgJUDf8zdhBMjx8WUJKWzs=; b=LcEXKiBZQmmppD9miRochJe15d//FJ2KPnkAvE412sii/5WpbhaMVjLJqXyOTHY0s1 Ao3QBvSSsxmFTkxDWCJbH5fPi16iDM+GmAVSqeWClZncHe811o2+hHSiHR2n1UyXTHAY +x/oya7gFwCVhUktp7OPdONgUyrsvrGa4FhfkHkjHhxrOMAQHLIQ8lHzmiBW8Nt+B7/1 U/vTbY2WqM2aEF4ox/HfqL/DJla+oEKTHpvRcLRuAASAIUNiIXfZlkhnQpFeQQr5oRp7 YusAYOYJZgWVQfOGepBQO+IlSv6ujKkSPrftkj2bTl7YcLlcMlRPKAqJcFoc4PCy/RFU EnsA== X-Gm-Message-State: AOAM5313YyW9FLFpKAlMXnRY0SqMUXzKChZEwJgAo5ONrw5Sm7G0A96w 3pwOzUj8idd3FrxYS8nrXE8= X-Google-Smtp-Source: ABdhPJwqqGldEtUv1AKOwY1WV0H+ee56iUVLuA0Ex2r17FXyGt0+fH3AWdP72NQIVFRaVsBpoZp8Yg== X-Received: by 2002:a63:e643:: with SMTP id p3mr4485222pgj.7.1644345752133; Tue, 08 Feb 2022 10:42:32 -0800 (PST) Received: from balhae.hsd1.ca.comcast.net ([2601:647:4800:c6f0:347f:e607:176:4358]) by smtp.gmail.com with ESMTPSA id l14sm3517027pjf.1.2022.02.08.10.42.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 10:42:31 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , Boqun Feng Cc: LKML , Thomas Gleixner , Steven Rostedt , Byungchul Park , "Paul E. McKenney" , Mathieu Desnoyers , Radoslaw Burny Subject: [PATCH 08/12] locking/mutex: Init name properly w/ CONFIG_LOCK_INFO Date: Tue, 8 Feb 2022 10:42:04 -0800 Message-Id: <20220208184208.79303-9-namhyung@kernel.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208184208.79303-1-namhyung@kernel.org> References: <20220208184208.79303-1-namhyung@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The mutex.dep_map.name was set in debug_mutex_init() which is defined only if CONFIG_DEBUG_MUTEXES is on. Let's fix it to work with CONFIG_LOCK_INFO as well. Signed-off-by: Namhyung Kim --- kernel/locking/mutex.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/kernel/locking/mutex.h b/kernel/locking/mutex.h index 0b2a79c4013b..b7b584ecdfef 100644 --- a/kernel/locking/mutex.h +++ b/kernel/locking/mutex.h @@ -41,5 +41,12 @@ extern void debug_mutex_init(struct mutex *lock, const c= har *name, # define debug_mutex_add_waiter(lock, waiter, ti) do { } while (0) # define debug_mutex_remove_waiter(lock, waiter, ti) do { } while (0) # define debug_mutex_unlock(lock) do { } while (0) + +#ifdef CONFIG_LOCK_INFO +# define debug_mutex_init(lock, name, key) \ + lockdep_set_class_and_name(lock, key, name) +#else # define debug_mutex_init(lock, name, key) do { } while (0) +#endif /* !CONFIG_LOCK_INFO */ + #endif /* !CONFIG_DEBUG_MUTEXES */ --=20 2.35.0.263.gb82422642f-goog From nobody Sun Jun 28 10:34:48 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4D3C0C433F5 for ; Tue, 8 Feb 2022 18:43:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385247AbiBHSnG (ORCPT ); Tue, 8 Feb 2022 13:43:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385192AbiBHSmf (ORCPT ); Tue, 8 Feb 2022 13:42:35 -0500 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A22AAC0613C9 for ; Tue, 8 Feb 2022 10:42:34 -0800 (PST) Received: by mail-pj1-x102f.google.com with SMTP id v13-20020a17090ac90d00b001b87bc106bdso2780112pjt.4 for ; Tue, 08 Feb 2022 10:42:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Yy80CGDeGmOdUiLaU44tdYuu65avXredLZvHqvqZxvA=; b=HY74ArTf2vfe81gaRsrqYSZLWy3/H/uLYAxkGNA5eJ1YodBldaI1Fleh4a0U0VLuEQ waa+glfVUrpkQfwXaA93xK2aiCn0HqUcLXTQ/oKcqc3eDtEtuDN3KLFz14ElozqV/pAO NUYTaN0/AzeEwY83KBHL6R2K10TJWsX7exn0l0YrDObSW6Ujo61OWuYT7wHlJWmcLomb 8VWB+4T3hTSeZK8F/gg/yXj1JM6K8ulRwATWXEuSsW4LP1R1IqHzJro5RV5+z52+67QR vtBlkRXMCLZrYZXVXO/qnBpqAVqrIRUl/q7dlrSwZybH+SVSLmxbIgE8uV670YHX/aW2 voIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=Yy80CGDeGmOdUiLaU44tdYuu65avXredLZvHqvqZxvA=; b=d0CB81DL4L9DZ4O0cXK7Y3PF4i4zNw+XL8YcZ7jO4y8ehpw5Na3dZ1dp+3KZfG9IHn cBdGZH4JaC+CbROXrbDyhUsJ/GMQdKQxKCSXBJnH3IKwsLiBLDYMtU8M+3bv4aGz0oM0 cB8uOnvIkNnkpKQ6Yn46alQxER89rNINtK8U1WDe7OmDWhexND+c4ONvF7LCiSy1KniP nZ/SD5wZ0wjhHZ34iOmlp6IlIrbrGem9LjkS07KziD3PYHPub3jndPkNGvfyZZagTNfF 305yJaj8rwhHBUNF7RlW6/3pJxGRPutLVW9EmUsbNY65QXhEegD2m9c9vyF1Rf3koN4E OE2g== X-Gm-Message-State: AOAM532l0b7rka07FEeSjnHAQzFcFoU0CfBHMddPtVmgjgEhiKA3IzVE tEF+MoRlCc5MHcctmC340Ec= X-Google-Smtp-Source: ABdhPJx//nw1FHxKSCWCl0iqwLXA7gNvU2rmisOZhMUCKOjSgk8nR0BBgNFCC/ggGKpKwrm8GSu+Ew== X-Received: by 2002:a17:902:da85:: with SMTP id j5mr5683614plx.81.1644345754103; Tue, 08 Feb 2022 10:42:34 -0800 (PST) Received: from balhae.hsd1.ca.comcast.net ([2601:647:4800:c6f0:347f:e607:176:4358]) by smtp.gmail.com with ESMTPSA id l14sm3517027pjf.1.2022.02.08.10.42.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 10:42:33 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , Boqun Feng Cc: LKML , Thomas Gleixner , Steven Rostedt , Byungchul Park , "Paul E. McKenney" , Mathieu Desnoyers , Radoslaw Burny Subject: [PATCH 09/12] locking: Add more static lockdep init macros Date: Tue, 8 Feb 2022 10:42:05 -0800 Message-Id: <20220208184208.79303-10-namhyung@kernel.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208184208.79303-1-namhyung@kernel.org> References: <20220208184208.79303-1-namhyung@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add STATIC_LOCKDEP_MAP_INIT_{WAIT,TYPE} macros and use it for various lock init codes. This helps having different implementations of CONFIG_LOCK_INFO like lockdep and tracepoints. Signed-off-by: Namhyung Kim --- drivers/gpu/drm/drm_connector.c | 5 ++--- include/linux/local_lock_internal.h | 10 ++++------ include/linux/lockdep.h | 23 +++++++++++++++++------ include/linux/mutex.h | 6 ++---- include/linux/rtmutex.h | 8 +++----- include/linux/rwlock_types.h | 5 +---- include/linux/rwsem.h | 8 +++----- include/linux/spinlock_types_raw.h | 24 ++++++++---------------- kernel/printk/printk.c | 10 ++++------ kernel/rcu/update.c | 27 +++++++++------------------ mm/memcontrol.c | 5 ++--- 11 files changed, 55 insertions(+), 76 deletions(-) diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connecto= r.c index 94931b32a491..7f470de2ef2b 100644 --- a/drivers/gpu/drm/drm_connector.c +++ b/drivers/gpu/drm/drm_connector.c @@ -677,9 +677,8 @@ const char *drm_get_connector_force_name(enum drm_conne= ctor_force force) } =20 #ifdef CONFIG_LOCK_INFO -static struct lockdep_map connector_list_iter_dep_map =3D { - .name =3D "drm_connector_list_iter" -}; +static struct lockdep_map connector_list_iter_dep_map =3D + STATIC_LOCKDEP_MAP_INIT("drm_connector_list_iter", NULL); #endif =20 /** diff --git a/include/linux/local_lock_internal.h b/include/linux/local_lock= _internal.h index 56f03f588aa7..dd280fcfadec 100644 --- a/include/linux/local_lock_internal.h +++ b/include/linux/local_lock_internal.h @@ -16,12 +16,10 @@ typedef struct { } local_lock_t; =20 #ifdef CONFIG_LOCK_INFO -# define LOCAL_LOCK_DEBUG_INIT(lockname) \ - .dep_map =3D { \ - .name =3D #lockname, \ - .wait_type_inner =3D LD_WAIT_CONFIG, \ - .lock_type =3D LD_LOCK_PERCPU, \ - }, \ +# define LOCAL_LOCK_DEBUG_INIT(lockname) \ + .dep_map =3D STATIC_LOCKDEP_MAP_INIT_TYPE(#lockname, NULL, \ + LD_WAIT_CONFIG, LD_WAIT_INV, \ + LD_LOCK_PERCPU), \ .owner =3D NULL, =20 static inline void local_lock_acquire(local_lock_t *l) diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h index 0cc2b338a006..38cbef7601c7 100644 --- a/include/linux/lockdep.h +++ b/include/linux/lockdep.h @@ -237,6 +237,19 @@ static inline void lockdep_init_map(struct lockdep_map= *lock, const char *name, #define lockdep_set_novalidate_class(lock) \ lockdep_set_class_and_name(lock, &__lockdep_no_validate__, #lock) =20 +/* + * To initialize a lockdep_map statically use this macro. + * Note that _name must not be NULL. + */ +#define STATIC_LOCKDEP_MAP_INIT(_name, _key) \ + { .name =3D (_name), .key =3D (void *)(_key), } + +#define STATIC_LOCKDEP_MAP_INIT_WAIT(_name, _key, _inner) \ + { .name =3D (_name), .key =3D (void *)(_key), .wait_type_inner =3D (_inne= r), } + +#define STATIC_LOCKDEP_MAP_INIT_TYPE(_name, _key, _inner, _outer, _type) \ + { .name =3D (_name), .key =3D (void *)(_key), .wait_type_inner =3D (_inne= r), \ + .wait_type_outer =3D (_outer), .lock_type =3D (_type), } /* * Compare locking classes */ @@ -377,6 +390,10 @@ static inline void lockdep_set_selftest_task(struct ta= sk_struct *task) =20 #define lockdep_set_novalidate_class(lock) do { } while (0) =20 +#define STATIC_LOCKDEP_MAP_INIT(_name, _key) { } +#define STATIC_LOCKDEP_MAP_INIT_WAIT(_name, _key, _inner) { } +#define STATIC_LOCKDEP_MAP_INIT_TYPE(_name, _key, _inner, _outer, _type) {= } + /* * We don't define lockdep_match_class() and lockdep_match_key() for !LOCK= DEP * case since the result is not well defined and the caller should rather @@ -432,12 +449,6 @@ enum xhlock_context_t { }; =20 #define lockdep_init_map_crosslock(m, n, k, s) do {} while (0) -/* - * To initialize a lockdep_map statically use this macro. - * Note that _name must not be NULL. - */ -#define STATIC_LOCKDEP_MAP_INIT(_name, _key) \ - { .name =3D (_name), .key =3D (void *)(_key), } =20 static inline void lockdep_invariant_state(bool force) {} static inline void lockdep_free_task(struct task_struct *task) {} diff --git a/include/linux/mutex.h b/include/linux/mutex.h index 369c1abbf3d0..b2d018250a41 100644 --- a/include/linux/mutex.h +++ b/include/linux/mutex.h @@ -22,10 +22,8 @@ =20 #ifdef CONFIG_LOCK_INFO # define __DEP_MAP_MUTEX_INITIALIZER(lockname) \ - , .dep_map =3D { \ - .name =3D #lockname, \ - .wait_type_inner =3D LD_WAIT_SLEEP, \ - } + , .dep_map =3D STATIC_LOCKDEP_MAP_INIT_WAIT(#lockname, \ + NULL, LD_WAIT_SLEEP) #else # define __DEP_MAP_MUTEX_INITIALIZER(lockname) #endif diff --git a/include/linux/rtmutex.h b/include/linux/rtmutex.h index 8eafdd6dcf35..887ffcd5fc09 100644 --- a/include/linux/rtmutex.h +++ b/include/linux/rtmutex.h @@ -77,11 +77,9 @@ do { \ } while (0) =20 #ifdef CONFIG_LOCK_INFO -#define __DEP_MAP_RT_MUTEX_INITIALIZER(mutexname) \ - .dep_map =3D { \ - .name =3D #mutexname, \ - .wait_type_inner =3D LD_WAIT_SLEEP, \ - } +#define __DEP_MAP_RT_MUTEX_INITIALIZER(mutexname) \ + .dep_map =3D STATIC_LOCKDEP_MAP_INIT_WAIT(#mutexname, \ + NULL, LD_WAIT_SLEEP) #else #define __DEP_MAP_RT_MUTEX_INITIALIZER(mutexname) #endif diff --git a/include/linux/rwlock_types.h b/include/linux/rwlock_types.h index 3e621bfd7cd0..438d8639a229 100644 --- a/include/linux/rwlock_types.h +++ b/include/linux/rwlock_types.h @@ -7,10 +7,7 @@ =20 #ifdef CONFIG_LOCK_INFO # define RW_DEP_MAP_INIT(lockname) \ - .dep_map =3D { \ - .name =3D #lockname, \ - .wait_type_inner =3D LD_WAIT_CONFIG, \ - } + .dep_map =3D STATIC_LOCKDEP_MAP_INIT_WAIT(#lockname, NULL, LD_WAIT_CONFIG) #else # define RW_DEP_MAP_INIT(lockname) #endif diff --git a/include/linux/rwsem.h b/include/linux/rwsem.h index c488485861f5..39126e6d97a1 100644 --- a/include/linux/rwsem.h +++ b/include/linux/rwsem.h @@ -17,11 +17,9 @@ #include =20 #ifdef CONFIG_LOCK_INFO -# define __RWSEM_DEP_MAP_INIT(lockname) \ - .dep_map =3D { \ - .name =3D #lockname, \ - .wait_type_inner =3D LD_WAIT_SLEEP, \ - }, +# define __RWSEM_DEP_MAP_INIT(lockname) \ + .dep_map =3D STATIC_LOCKDEP_MAP_INIT_WAIT(#lockname, \ + NULL, LD_WAIT_SLEEP), #else # define __RWSEM_DEP_MAP_INIT(lockname) #endif diff --git a/include/linux/spinlock_types_raw.h b/include/linux/spinlock_ty= pes_raw.h index 564092a30cc4..006250640e76 100644 --- a/include/linux/spinlock_types_raw.h +++ b/include/linux/spinlock_types_raw.h @@ -27,23 +27,15 @@ typedef struct raw_spinlock { #define SPINLOCK_OWNER_INIT ((void *)-1L) =20 #ifdef CONFIG_LOCK_INFO -# define RAW_SPIN_DEP_MAP_INIT(lockname) \ - .dep_map =3D { \ - .name =3D #lockname, \ - .wait_type_inner =3D LD_WAIT_SPIN, \ - } -# define SPIN_DEP_MAP_INIT(lockname) \ - .dep_map =3D { \ - .name =3D #lockname, \ - .wait_type_inner =3D LD_WAIT_CONFIG, \ - } +# define RAW_SPIN_DEP_MAP_INIT(lockname) \ + .dep_map =3D STATIC_LOCKDEP_MAP_INIT_WAIT(#lockname, NULL, LD_WAIT_SPIN) =20 -# define LOCAL_SPIN_DEP_MAP_INIT(lockname) \ - .dep_map =3D { \ - .name =3D #lockname, \ - .wait_type_inner =3D LD_WAIT_CONFIG, \ - .lock_type =3D LD_LOCK_PERCPU, \ - } +# define SPIN_DEP_MAP_INIT(lockname) \ + .dep_map =3D STATIC_LOCKDEP_MAP_INIT_WAIT(#lockname, NULL, LD_WAIT_CONFIG) + +# define LOCAL_SPIN_DEP_MAP_INIT(lockname) \ + .dep_map =3D STATIC_LOCKDEP_MAP_INIT_TYPE(#lockname, NULL, LD_WAIT_CONFIG= ,\ + LD_WAIT_INV, LD_LOCK_PERCPU) #else # define RAW_SPIN_DEP_MAP_INIT(lockname) # define SPIN_DEP_MAP_INIT(lockname) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index e45664e0ca30..7889df01a378 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -94,9 +94,8 @@ EXPORT_SYMBOL_GPL(console_drivers); int __read_mostly suppress_printk; =20 #ifdef CONFIG_LOCK_INFO -static struct lockdep_map console_lock_dep_map =3D { - .name =3D "console_lock" -}; +static struct lockdep_map console_lock_dep_map =3D + STATIC_LOCKDEP_MAP_INIT("console_lock", NULL); #endif =20 enum devkmsg_log_bits { @@ -1753,9 +1752,8 @@ SYSCALL_DEFINE3(syslog, int, type, char __user *, buf= , int, len) */ =20 #ifdef CONFIG_LOCK_INFO -static struct lockdep_map console_owner_dep_map =3D { - .name =3D "console_owner" -}; +static struct lockdep_map console_owner_dep_map =3D + STATIC_LOCKDEP_MAP_INIT("console_owner", NULL); #endif =20 static DEFINE_RAW_SPINLOCK(console_owner_lock); diff --git a/kernel/rcu/update.c b/kernel/rcu/update.c index 156892c22bb5..8202ab6ddb4c 100644 --- a/kernel/rcu/update.c +++ b/kernel/rcu/update.c @@ -243,30 +243,21 @@ core_initcall(rcu_set_runtime_mode); =20 #ifdef CONFIG_DEBUG_LOCK_ALLOC static struct lock_class_key rcu_lock_key; -struct lockdep_map rcu_lock_map =3D { - .name =3D "rcu_read_lock", - .key =3D &rcu_lock_key, - .wait_type_outer =3D LD_WAIT_FREE, - .wait_type_inner =3D LD_WAIT_CONFIG, /* PREEMPT_RT implies PREEMPT_RCU */ -}; +struct lockdep_map rcu_lock_map =3D /* PREEMPT_RT implies PREEMPT_RCU */ + STATIC_LOCKDEP_MAP_INIT_TYPE("rcu_read_lock", &rcu_lock_key, + LD_WAIT_CONFIG, LD_WAIT_FREE, 0); EXPORT_SYMBOL_GPL(rcu_lock_map); =20 static struct lock_class_key rcu_bh_lock_key; -struct lockdep_map rcu_bh_lock_map =3D { - .name =3D "rcu_read_lock_bh", - .key =3D &rcu_bh_lock_key, - .wait_type_outer =3D LD_WAIT_FREE, - .wait_type_inner =3D LD_WAIT_CONFIG, /* PREEMPT_RT makes BH preemptible. = */ -}; +struct lockdep_map rcu_bh_lock_map =3D /* PREEMPT_RT makes BH preemptable.= */ + STATIC_LOCKDEP_MAP_INIT_TYPE("rcu_read_lock_bh", &rcu_bh_lock_key, + LD_WAIT_CONFIG, LD_WAIT_FREE, 0); EXPORT_SYMBOL_GPL(rcu_bh_lock_map); =20 static struct lock_class_key rcu_sched_lock_key; -struct lockdep_map rcu_sched_lock_map =3D { - .name =3D "rcu_read_lock_sched", - .key =3D &rcu_sched_lock_key, - .wait_type_outer =3D LD_WAIT_FREE, - .wait_type_inner =3D LD_WAIT_SPIN, -}; +struct lockdep_map rcu_sched_lock_map =3D + STATIC_LOCKDEP_MAP_INIT_TYPE("rcu_read_lock_sched", &rcu_sched_lock_key, + LD_WAIT_SPIN, LD_WAIT_FREE, 0); EXPORT_SYMBOL_GPL(rcu_sched_lock_map); =20 // Tell lockdep when RCU callbacks are being invoked. diff --git a/mm/memcontrol.c b/mm/memcontrol.c index d4ecfdd5eb8f..a561a6c66b2f 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -1672,9 +1672,8 @@ static int mem_cgroup_soft_reclaim(struct mem_cgroup = *root_memcg, } =20 #ifdef CONFIG_LOCK_INFO -static struct lockdep_map memcg_oom_lock_dep_map =3D { - .name =3D "memcg_oom_lock", -}; +static struct lockdep_map memcg_oom_lock_dep_map =3D + STATIC_LOCKDEP_MAP_INIT("memcg_oom_lock", NULL); #endif =20 static DEFINE_SPINLOCK(memcg_oom_lock); --=20 2.35.0.263.gb82422642f-goog From nobody Sun Jun 28 10:34:48 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95C31C433EF for ; Tue, 8 Feb 2022 18:43:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385297AbiBHSnK (ORCPT ); Tue, 8 Feb 2022 13:43:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385196AbiBHSmh (ORCPT ); Tue, 8 Feb 2022 13:42:37 -0500 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE599C0613CA for ; Tue, 8 Feb 2022 10:42:36 -0800 (PST) Received: by mail-pj1-x102f.google.com with SMTP id g15-20020a17090a67cf00b001b7d5b6bedaso3782593pjm.4 for ; Tue, 08 Feb 2022 10:42:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EQBAIvQLg20+7U3cvyTRGOoJ39hD5GGWkL0kfjAijZk=; b=bhx9naFDbe84/mR55A9dfCO8CUPQeMOP3i7A7qKzsbCfC2+TsdcjdwCSdGzbdm2RJ3 yy3CoEaidsWBzxHX5oUnedOm9T2ab4tXNd4z7w/qeCAAQahqmFpcPjttwgTMIuwZf+pN ckxpfu3PBAwzacrmKWm3B8onLVewVDSGvnGvuuQRcCYyl32+IFndUhWCP7+tgkcWWG4K 5ZWieC6sOcVfSEfq2p6QqSZzUMg2Ypxmn63vNMi3dWEKQbZ/Op5ryYiG2pZ/4pLIAFC8 A48gryz27XoiN5Z7qy9O5NO3HLUCI12c/vagvfRGu3ToimoYjc0xU3a4z2grAuBACcvg 19NQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=EQBAIvQLg20+7U3cvyTRGOoJ39hD5GGWkL0kfjAijZk=; b=SseyJPcv3vZ1kSBqOlsdODZr4rDiKcf+aQNoSrLXpsZ1YEe8qqKat8DF9PUXZuCQGD n2tT63+0iYrME9LUhS1w1qn2+XoiuVieiQ01BCkRKXO/aFhuK8vOIMFGcKxpkYCKbvCc XRBVkV6K80Xckb7jGQwILh1jbNZSR8fvxcSYhMDXsg4iWqxZCkFvb24jvvD3BFK8/x4p ZavlXBlXMJT/mcFU11DeF5oJ8eK5GrmcBML8N/blzfwVSX3MCQoWZV3wmJ+LeE16n9P8 RW58eWnaewfwmtjdRxlakovJbgMGeGplgObfV1WvBEpkFJKPjFJ6lGlgaL3F9k5BpTAa m3sg== X-Gm-Message-State: AOAM533uGzAG9Nd60pLawbQKGntcD2jjqgI7d87yZAylkPm98ETbdAC6 1HMQLENlTLLswzngrXbw2Qw= X-Google-Smtp-Source: ABdhPJwbxVriXvJ1GSzkVzUCiYV40o7Vpjul0Cag/SEPWfUKtbaSlRG71F1XxlsfMIMb2dvAOfNrqg== X-Received: by 2002:a17:903:22d0:: with SMTP id y16mr6043279plg.65.1644345756135; Tue, 08 Feb 2022 10:42:36 -0800 (PST) Received: from balhae.hsd1.ca.comcast.net ([2601:647:4800:c6f0:347f:e607:176:4358]) by smtp.gmail.com with ESMTPSA id l14sm3517027pjf.1.2022.02.08.10.42.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 10:42:35 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , Boqun Feng Cc: LKML , Thomas Gleixner , Steven Rostedt , Byungchul Park , "Paul E. McKenney" , Mathieu Desnoyers , Radoslaw Burny Subject: [PATCH 10/12] locking: Add CONFIG_LOCK_TRACEPOINTS option Date: Tue, 8 Feb 2022 10:42:06 -0800 Message-Id: <20220208184208.79303-11-namhyung@kernel.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208184208.79303-1-namhyung@kernel.org> References: <20220208184208.79303-1-namhyung@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This option enables the following tracepoints for lock analysis. This can be used to trace lock/unlock pairs and their contentions without enabling LOCKDEP and LOCK_STAT. * lock_acquire * lock_release * lock_contended * lock_acquired It selects CONFIG_LOCK_INFO to have lock names properly, and make the lockdep functions inline to check if the corresponding tracepoint is enabled before calling the function. Then it could avoid unnecessary overhead setting up the arguments in the tracepoint when disabled. Signed-off-by: Namhyung Kim --- include/linux/lockdep.h | 141 +++++++++++++++++++++++++++++++++- include/linux/lockdep_types.h | 8 +- include/trace/events/lock.h | 4 +- kernel/locking/Makefile | 1 + kernel/locking/lockdep.c | 40 +++++++++- lib/Kconfig.debug | 9 +++ 6 files changed, 195 insertions(+), 8 deletions(-) diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h index 38cbef7601c7..4e728d2957db 100644 --- a/include/linux/lockdep.h +++ b/include/linux/lockdep.h @@ -14,6 +14,8 @@ #include #include =20 +#include + struct task_struct; =20 /* for sysctl */ @@ -367,12 +369,104 @@ static inline void lockdep_set_selftest_task(struct = task_struct *task) { } =20 +#ifdef CONFIG_LOCK_TRACEPOINTS +DECLARE_TRACEPOINT(lock_acquire); +DECLARE_TRACEPOINT(lock_release); + +extern void __lock_acquire(struct lockdep_map *lock, unsigned int subclass, + int trylock, int read, int check, + struct lockdep_map *nest_lock, unsigned long ip); +extern void __lock_release(struct lockdep_map *lock, unsigned long ip); + +static inline void lock_acquire(struct lockdep_map *lock, unsigned int sub= class, + int trylock, int read, int check, + struct lockdep_map *nest_lock, unsigned long ip) +{ + if (tracepoint_enabled(lock_acquire)) + __lock_acquire(lock, subclass, trylock, read, check, nest_lock, ip); +} + +static inline void lock_release(struct lockdep_map *lock, unsigned long ip) +{ + if (tracepoint_enabled(lock_release)) + __lock_release(lock, ip); +} +#else /* !CONFIG_LOCK_TRACEPOINTS */ # define lock_acquire(l, s, t, r, c, n, i) do { } while (0) # define lock_release(l, i) do { } while (0) +#endif /* CONFIG_LOCK_TRACEPOINTS */ + # define lock_downgrade(l, i) do { } while (0) # define lock_set_class(l, n, k, s, i) do { } while (0) # define lock_set_subclass(l, s, i) do { } while (0) # define lockdep_init() do { } while (0) + +#ifdef CONFIG_LOCK_INFO + +static inline void +lockdep_init_map_type(struct lockdep_map *lock, const char *name, + struct lock_class_key *key, int subclass, + u8 inner, u8 outer, u8 type) +{ + if (!name) + name =3D "NULL"; + + lock->name =3D name; +} + +static inline void +lockdep_init_map_waits(struct lockdep_map *lock, const char *name, + struct lock_class_key *key, int subclass, + u8 inner, u8 outer) +{ + lockdep_init_map_type(lock, name, key, subclass, inner, outer, 0); +} + +static inline void +lockdep_init_map_wait(struct lockdep_map *lock, const char *name, + struct lock_class_key *key, int subclass, u8 inner) +{ + lockdep_init_map_waits(lock, name, key, subclass, inner, 0); +} + +static inline void +lockdep_init_map(struct lockdep_map *lock, const char *name, + struct lock_class_key *key, int subclass) +{ + lockdep_init_map_wait(lock, name, key, subclass, 0); +} + +/* Reinitialize a lock name - other info will be ignore. */ +# define lockdep_set_class(lock, key) \ + lockdep_init_map(&(lock)->dep_map, #key, key, 0) + +# define lockdep_set_class_and_name(lock, key, name) \ + lockdep_init_map(&(lock)->dep_map, name, key, 0) + +# define lockdep_set_class_and_subclass(lock, key, sub) \ + lockdep_init_map(&(lock)->dep_map, #key, key, sub) + +# define lockdep_set_subclass(lock, sub) \ + lockdep_init_map(&(lock)->dep_map, #lock, NULL, sub) + +# define lockdep_set_novalidate_class(lock) \ + lockdep_set_class_and_name(lock, NULL, #lock) + +/* + * To initialize a lockdep_map statically use this macro. + * Note that _name must not be NULL. + */ +# define STATIC_LOCKDEP_MAP_INIT(_name, _key) \ + { .name =3D (_name), } + +# define STATIC_LOCKDEP_MAP_INIT_WAIT(_name, _key, _inner) \ + { .name =3D (_name), } + +# define STATIC_LOCKDEP_MAP_INIT_TYPE(_name, _key, _inner, _outer, _type) \ + { .name =3D (_name), } + +#else /* !CONFIG_LOCK_INFO */ + # define lockdep_init_map_type(lock, name, key, sub, inner, outer, type) \ do { (void)(name); (void)(key); } while (0) # define lockdep_init_map_waits(lock, name, key, sub, inner, outer) \ @@ -394,6 +488,8 @@ static inline void lockdep_set_selftest_task(struct tas= k_struct *task) #define STATIC_LOCKDEP_MAP_INIT_WAIT(_name, _key, _inner) { } #define STATIC_LOCKDEP_MAP_INIT_TYPE(_name, _key, _inner, _outer, _type) {= } =20 +#endif /* CONFIG_LOCK_INFO */ + /* * We don't define lockdep_match_class() and lockdep_match_key() for !LOCK= DEP * case since the result is not well defined and the caller should rather @@ -479,7 +575,48 @@ do { \ ____err; \ }) =20 -#else /* CONFIG_LOCK_STAT */ +#elif defined(CONFIG_LOCK_TRACEPOINTS) + +DECLARE_TRACEPOINT(lock_contended); +DECLARE_TRACEPOINT(lock_acquired); + +extern void __lock_contended(struct lockdep_map *lock, unsigned long ip); +extern void __lock_acquired(struct lockdep_map *lock, unsigned long ip); + +static inline void lock_contended(struct lockdep_map *lock, unsigned long = ip) +{ + if (tracepoint_enabled(lock_contended)) + __lock_contended(lock, ip); +} + +static inline void lock_acquired(struct lockdep_map *lock, unsigned long i= p) +{ + if (tracepoint_enabled(lock_acquired)) + __lock_acquired(lock, ip); +} + +#define LOCK_CONTENDED(_lock, try, lock) \ +do { \ + if (!try(_lock)) { \ + lock_contended(&(_lock)->dep_map, _RET_IP_); \ + lock(_lock); \ + } \ + lock_acquired(&(_lock)->dep_map, _RET_IP_); \ +} while (0) + +#define LOCK_CONTENDED_RETURN(_lock, try, lock) \ +({ \ + int ____err =3D 0; \ + if (!try(_lock)) { \ + lock_contended(&(_lock)->dep_map, _RET_IP_); \ + ____err =3D lock(_lock); \ + } \ + if (!____err) \ + lock_acquired(&(_lock)->dep_map, _RET_IP_); \ + ____err; \ +}) + +#else /* !CONFIG_LOCK_STAT && !CONFIG_LOCK_TRACEPOINTS */ =20 #define lock_contended(lockdep_map, ip) do {} while (0) #define lock_acquired(lockdep_map, ip) do {} while (0) @@ -490,7 +627,7 @@ do { \ #define LOCK_CONTENDED_RETURN(_lock, try, lock) \ lock(_lock) =20 -#endif /* CONFIG_LOCK_STAT */ +#endif /* CONFIG_LOCK_STAT || CONFIG_LOCK_TRACEPOINTS */ =20 #ifdef CONFIG_PROVE_LOCKING extern void print_irqtrace_events(struct task_struct *curr); diff --git a/include/linux/lockdep_types.h b/include/linux/lockdep_types.h index d22430840b53..340138c9023e 100644 --- a/include/linux/lockdep_types.h +++ b/include/linux/lockdep_types.h @@ -197,9 +197,13 @@ struct pin_cookie { unsigned int val; }; struct lock_class_key { }; =20 /* - * The lockdep_map takes no space if lockdep is disabled: + * The lockdep_map takes no space if lockdep and lock_info is disabled: */ -struct lockdep_map { }; +struct lockdep_map { +#ifdef CONFIG_LOCK_INFO + const char *name; +#endif +}; =20 struct pin_cookie { }; =20 diff --git a/include/trace/events/lock.h b/include/trace/events/lock.h index d7512129a324..74667841ae02 100644 --- a/include/trace/events/lock.h +++ b/include/trace/events/lock.h @@ -8,7 +8,7 @@ #include #include =20 -#ifdef CONFIG_LOCKDEP +#if defined(CONFIG_LOCKDEP) || defined(CONFIG_LOCK_TRACEPOINTS) =20 TRACE_EVENT(lock_acquire, =20 @@ -62,7 +62,7 @@ DEFINE_EVENT(lock, lock_release, TP_ARGS(lock, ip) ); =20 -#ifdef CONFIG_LOCK_STAT +#if defined(CONFIG_LOCK_STAT) || defined(CONFIG_LOCK_TRACEPOINTS) =20 DEFINE_EVENT(lock, lock_contended, =20 diff --git a/kernel/locking/Makefile b/kernel/locking/Makefile index d51cabf28f38..d772a37470a6 100644 --- a/kernel/locking/Makefile +++ b/kernel/locking/Makefile @@ -17,6 +17,7 @@ endif obj-$(CONFIG_DEBUG_IRQFLAGS) +=3D irqflag-debug.o obj-$(CONFIG_DEBUG_MUTEXES) +=3D mutex-debug.o obj-$(CONFIG_LOCKDEP) +=3D lockdep.o +obj-$(CONFIG_LOCK_TRACEPOINTS) +=3D lockdep.o ifeq ($(CONFIG_PROC_FS),y) obj-$(CONFIG_LOCKDEP) +=3D lockdep_proc.o endif diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index 2e6892ec3756..f234e981d1c7 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -58,11 +58,13 @@ =20 #include =20 -#include "lockdep_internals.h" - #define CREATE_TRACE_POINTS #include =20 +#ifdef CONFIG_LOCKDEP + +#include "lockdep_internals.h" + #ifdef CONFIG_PROVE_LOCKING int prove_locking =3D 1; module_param(prove_locking, int, 0644); @@ -6566,3 +6568,37 @@ void lockdep_rcu_suspicious(const char *file, const = int line, const char *s) dump_stack(); } EXPORT_SYMBOL_GPL(lockdep_rcu_suspicious); + +#elif defined(CONFIG_LOCK_TRACEPOINTS) + +void __lock_acquire(struct lockdep_map *lock, unsigned int subclass, + int trylock, int read, int check, + struct lockdep_map *nest_lock, unsigned long ip) +{ + trace_lock_acquire(lock, subclass, trylock, read, check, nest_lock, ip); +} +EXPORT_SYMBOL_GPL(__lock_acquire); +EXPORT_TRACEPOINT_SYMBOL_GPL(lock_acquire); + +void __lock_release(struct lockdep_map *lock, unsigned long ip) +{ + trace_lock_release(lock, ip); +} +EXPORT_SYMBOL_GPL(__lock_release); +EXPORT_TRACEPOINT_SYMBOL_GPL(lock_release); + +void __lock_contended(struct lockdep_map *lock, unsigned long ip) +{ + trace_lock_contended(lock, ip); +} +EXPORT_SYMBOL_GPL(__lock_contended); +EXPORT_TRACEPOINT_SYMBOL_GPL(lock_contended); + +void __lock_acquired(struct lockdep_map *lock, unsigned long ip) +{ + trace_lock_acquired(lock, ip); +} +EXPORT_SYMBOL_GPL(__lock_acquired); +EXPORT_TRACEPOINT_SYMBOL_GPL(lock_acquired); + +#endif /* CONFIG_LOCKDEP */ diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 5f64ffe23c35..749de6c1ba50 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -1452,6 +1452,15 @@ config LOCK_INFO bool default n =20 +config LOCK_TRACEPOINTS + bool "Enable lock tracepoints" + depends on !LOCKDEP + select LOCK_INFO + help + This enables all lock events required by "perf lock", subcommand of + perf, without enabling LOCKDEP and LOCK_STAT. If you want to use + "perf lock", you also need to turn on CONFIG_EVENT_TRACING. + config DEBUG_ATOMIC_SLEEP bool "Sleep inside atomic section checking" select PREEMPT_COUNT --=20 2.35.0.263.gb82422642f-goog From nobody Sun Jun 28 10:34:48 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CDC41C433EF for ; Tue, 8 Feb 2022 18:43:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385331AbiBHSnY (ORCPT ); Tue, 8 Feb 2022 13:43:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385149AbiBHSmk (ORCPT ); Tue, 8 Feb 2022 13:42:40 -0500 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C60BEC06157A for ; Tue, 8 Feb 2022 10:42:38 -0800 (PST) Received: by mail-pj1-x102f.google.com with SMTP id t14-20020a17090a3e4e00b001b8f6032d96so2581760pjm.2 for ; Tue, 08 Feb 2022 10:42:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=m+nDZJr8SEJtsWfN1yVA4KOFdHwD0VQADvkkthoRg+M=; b=KB/87uei61VMwaWppjncveFQx/oSsAXg1oiXolXm0mKbaiFuIhZpMjBytxmd+uq1zx uLyZ8+xv68msR6i6Z6njmHR07Vk4PJyswy0Y7t/2JE1ipbqyI4yGvHN5slcw6mxKn0AY lq0Bm8yAgJZBEbVLyqQfoV2PlWWd9ROFKpYJTtyeP2ADNlSmbfuDiA4qPF+X5uAXxLh3 znz5vDr9Gg9sKJ2HfBOho7AXyrulA3AMqHgZoa/n7cDfBw2/2QRWUj5OIov0TXGg3L8C C+CqbwSvvn5GGin6vLR8OHcDomFgZPBNedV0uQlDZHWo0BsP2yQXS3eLF3ZubDkI5Iw1 1bLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=m+nDZJr8SEJtsWfN1yVA4KOFdHwD0VQADvkkthoRg+M=; b=xnww8OJPvj17eMBhk3Hw3kA9JP/J3PwSXvYrpUW/OI85u9FDlPkEIWkwdpXu13uzKA lJvPwrHTSfrV9aKkuhUWt6I50CeuX59FWRmoNH4k6tg0mkl2YyE5A3h5JRdl+Q9cglFh ODg451FElk/GJmM522+3DBNmnkhpAmmq8aAD0MYSbKU8exS5GgHgZdFDCxSggLdwO98w PYyDznaN0t9wMENdJMyoS4Dhi/QwdM0lECC1LtKxYuoljIkySi+DdiOudjhlFEEnmakp AjQk2I1KyuB5nM/lpv6BTjCJSZvaLE0jz5xZ9tCazXHjNU8KVQ7Pkn6/HYkMwILaJzF7 OqNA== X-Gm-Message-State: AOAM532z6eoGhYBrzSf3a6h/kvecuAvuRQIYJaBZfIzCSbBs/emBeGBQ NL8jgT+ZRKZDh2C2K5jxTeM= X-Google-Smtp-Source: ABdhPJx8IXHu0Wt8sa8qBcpvSblT/DhVP1JBe6SVn/iFh3WkcxQnViK1hIEmSHuaCt6BAieWNDGRaw== X-Received: by 2002:a17:90b:3908:: with SMTP id ob8mr2823394pjb.73.1644345758273; Tue, 08 Feb 2022 10:42:38 -0800 (PST) Received: from balhae.hsd1.ca.comcast.net ([2601:647:4800:c6f0:347f:e607:176:4358]) by smtp.gmail.com with ESMTPSA id l14sm3517027pjf.1.2022.02.08.10.42.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 10:42:37 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , Boqun Feng Cc: LKML , Thomas Gleixner , Steven Rostedt , Byungchul Park , "Paul E. McKenney" , Mathieu Desnoyers , Radoslaw Burny Subject: [PATCH 11/12] locking/mutex: Revive fast functions for CONFIG_LOCK_TRACEPOINTS Date: Tue, 8 Feb 2022 10:42:07 -0800 Message-Id: <20220208184208.79303-12-namhyung@kernel.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208184208.79303-1-namhyung@kernel.org> References: <20220208184208.79303-1-namhyung@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The CONFIG_LOCK_TRACEPOINTS used the same path as CONFIG_DEBUG_ALLOC or CONFIG_LOCKDEP but it caused performance impact on mutex as it removes _fast variants at the beginning. I'm not entirely sure why it removed the fast versions when lockdep is on. It seems easy to add the required annotation when the fast version is succeeded as far as the tracpoints are concerned. It reduces around 2% of elapsed time when I ran a micro-benchmark. It was `perf bench sched messaging -p -l 1000000` and it had a pretty low lock contention rate (under 1% of total lock acquisition). So the improvement should come from the fast path. Signed-off-by: Namhyung Kim --- include/linux/mutex.h | 2 +- kernel/locking/mutex.c | 30 ++++++++++++++++++++---------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/include/linux/mutex.h b/include/linux/mutex.h index b2d018250a41..49bde305453e 100644 --- a/include/linux/mutex.h +++ b/include/linux/mutex.h @@ -172,7 +172,7 @@ do { \ * See kernel/locking/mutex.c for detailed documentation of these APIs. * Also see Documentation/locking/mutex-design.rst. */ -#ifdef CONFIG_LOCK_INFO +#ifdef CONFIG_DEBUG_LOCK_ALLOC extern void mutex_lock_nested(struct mutex *lock, unsigned int subclass); extern void _mutex_lock_nest_lock(struct mutex *lock, struct lockdep_map *= nest_lock); =20 diff --git a/kernel/locking/mutex.c b/kernel/locking/mutex.c index 8733b96ce20a..f8bc4ae312a0 100644 --- a/kernel/locking/mutex.c +++ b/kernel/locking/mutex.c @@ -149,7 +149,7 @@ static inline bool __mutex_trylock(struct mutex *lock) return !__mutex_trylock_common(lock, false); } =20 -#ifndef CONFIG_LOCK_INFO +#ifndef CONFIG_DEBUG_LOCK_ALLOC /* * Lockdep annotations are contained to the slow paths for simplicity. * There is nothing that would stop spreading the lockdep annotations outw= ards @@ -245,7 +245,7 @@ static void __mutex_handoff(struct mutex *lock, struct = task_struct *task) } } =20 -#ifndef CONFIG_LOCK_INFO +#ifndef CONFIG_DEBUG_LOCK_ALLOC /* * We split the mutex lock/unlock logic into separate fastpath and * slowpath functions, to reduce the register pressure on the fastpath. @@ -281,6 +281,8 @@ void __sched mutex_lock(struct mutex *lock) =20 if (!__mutex_trylock_fast(lock)) __mutex_lock_slowpath(lock); + else + mutex_acquire(&lock->dep_map, 0, 0, _RET_IP_); } EXPORT_SYMBOL(mutex_lock); #endif @@ -533,9 +535,11 @@ static noinline void __sched __mutex_unlock_slowpath(s= truct mutex *lock, unsigne */ void __sched mutex_unlock(struct mutex *lock) { -#ifndef CONFIG_LOCK_INFO - if (__mutex_unlock_fast(lock)) +#ifndef CONFIG_DEBUG_LOCK_ALLOC + if (__mutex_unlock_fast(lock)) { + mutex_release(&lock->dep_map, _RET_IP_); return; + } #endif __mutex_unlock_slowpath(lock, _RET_IP_); } @@ -591,7 +595,7 @@ __mutex_lock_common(struct mutex *lock, unsigned int st= ate, unsigned int subclas if (ww_ctx->acquired =3D=3D 0) ww_ctx->wounded =3D 0; =20 -#ifdef CONFIG_LOCK_INFO +#ifdef CONFIG_DEBUG_LOCK_ALLOC nest_lock =3D &ww_ctx->dep_map; #endif } @@ -778,7 +782,7 @@ int ww_mutex_trylock(struct ww_mutex *ww, struct ww_acq= uire_ctx *ww_ctx) } EXPORT_SYMBOL(ww_mutex_trylock); =20 -#ifdef CONFIG_LOCK_INFO +#ifdef CONFIG_DEBUG_LOCK_ALLOC void __sched mutex_lock_nested(struct mutex *lock, unsigned int subclass) { @@ -937,7 +941,7 @@ static noinline void __sched __mutex_unlock_slowpath(st= ruct mutex *lock, unsigne wake_up_q(&wake_q); } =20 -#ifndef CONFIG_LOCK_INFO +#ifndef CONFIG_DEBUG_LOCK_ALLOC /* * Here come the less common (and hence less performance-critical) APIs: * mutex_lock_interruptible() and mutex_trylock(). @@ -964,8 +968,10 @@ int __sched mutex_lock_interruptible(struct mutex *loc= k) { might_sleep(); =20 - if (__mutex_trylock_fast(lock)) + if (__mutex_trylock_fast(lock)) { + mutex_acquire(&lock->dep_map, 0, 0, _RET_IP_); return 0; + } =20 return __mutex_lock_interruptible_slowpath(lock); } @@ -988,8 +994,10 @@ int __sched mutex_lock_killable(struct mutex *lock) { might_sleep(); =20 - if (__mutex_trylock_fast(lock)) + if (__mutex_trylock_fast(lock)) { + mutex_acquire(&lock->dep_map, 0, 0, _RET_IP_); return 0; + } =20 return __mutex_lock_killable_slowpath(lock); } @@ -1078,7 +1086,7 @@ int __sched mutex_trylock(struct mutex *lock) } EXPORT_SYMBOL(mutex_trylock); =20 -#ifndef CONFIG_LOCK_INFO +#ifndef CONFIG_DEBUG_LOCK_ALLOC int __sched ww_mutex_lock(struct ww_mutex *lock, struct ww_acquire_ctx *ctx) { @@ -1087,6 +1095,7 @@ ww_mutex_lock(struct ww_mutex *lock, struct ww_acquir= e_ctx *ctx) if (__mutex_trylock_fast(&lock->base)) { if (ctx) ww_mutex_set_context_fastpath(lock, ctx); + mutex_acquire(&lock->base.dep_map, 0, 0, _RET_IP_); return 0; } =20 @@ -1102,6 +1111,7 @@ ww_mutex_lock_interruptible(struct ww_mutex *lock, st= ruct ww_acquire_ctx *ctx) if (__mutex_trylock_fast(&lock->base)) { if (ctx) ww_mutex_set_context_fastpath(lock, ctx); + mutex_acquire(&lock->base.dep_map, 0, 0, _RET_IP_); return 0; } =20 --=20 2.35.0.263.gb82422642f-goog From nobody Sun Jun 28 10:34:48 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9E190C433EF for ; Tue, 8 Feb 2022 18:43:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385169AbiBHSnR (ORCPT ); Tue, 8 Feb 2022 13:43:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385203AbiBHSml (ORCPT ); Tue, 8 Feb 2022 13:42:41 -0500 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8DB91C0613CA for ; Tue, 8 Feb 2022 10:42:40 -0800 (PST) Received: by mail-pf1-x42d.google.com with SMTP id c10so1544162pfi.9 for ; Tue, 08 Feb 2022 10:42:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YblOd1MvT8NiXh69QNSwkAqyNRZA5ZxOXoJicXqw4d8=; b=NmS6X3F31vgYNbuvcdntXgrQDZoNYzdGA3tlzav9IIoi3N7XJZD9ch+GwUFveURRO2 SROdeY6g0phlVdCYFSm7tHfzc2bnxucgeidgKsbSPIVqIz82VL7kjq/jujlpBo1zW8Yj 0FVqx74858ngYvm1FafXinri2hKxU80QWAMRlgCnzjAEQ+eZg2iB2DUR9g9ASjrWe3XH ti0FdUij8/Y/YQLdin+Ha1/OlT2Wx+0V066N4D8JrADhJr5fR6hfdtC3YZ6I2mgF8cQZ hO5cb/8pEB5tL8YHGqxPPWbviDFmHcbCcpf3dQWE1K8kn6sFJq+P6BocsRXus8tVxji+ EFfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=YblOd1MvT8NiXh69QNSwkAqyNRZA5ZxOXoJicXqw4d8=; b=dihZTktS99yy6VhodAYac5asmp4Gb6Po14ZXBWcDeJ0PNw16lxe2dAvHJOt0DGd6d6 ucLKbuu5gDhsRj/Kwrhuej+cte5hStNvZO8T+738+KZHjeM++aH93TwkIiwFn2ratJHE 01ownudYJ1TjXZuIr7+EmZZY1lE7aWZ6qgt8+oE6Vq9eIONN1kl1d0GrG7d9Wikg46Xk Wcm2eLxl3rh7Yfuu1/aKzRhDd1yGV4ThlOGpshiQnbM8GiVwdaX3zc8jmXWf6t9ZODW1 Fx2vxHHbr9GtFW2ii46SJqjkn+LJHhnoN6ihEERYdE0igfdjEus5axN7MA2zkmlcKRz6 Sv7Q== X-Gm-Message-State: AOAM532hBCIxcjY0KKYwMymzhOVpMx8HcNBAb1H1GQlWa5fEqsXvmmld Z49W7dGzANDkRFB36e86EtA= X-Google-Smtp-Source: ABdhPJxQBzd9hdEXIalI27JyMmk9v8rfHzVUxtK1Qw9o5ag3vEDO7T2BDzJVlNsoq2zRUL9/fCbNdw== X-Received: by 2002:a63:ec58:: with SMTP id r24mr4592854pgj.353.1644345760093; Tue, 08 Feb 2022 10:42:40 -0800 (PST) Received: from balhae.hsd1.ca.comcast.net ([2601:647:4800:c6f0:347f:e607:176:4358]) by smtp.gmail.com with ESMTPSA id l14sm3517027pjf.1.2022.02.08.10.42.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 10:42:39 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , Boqun Feng Cc: LKML , Thomas Gleixner , Steven Rostedt , Byungchul Park , "Paul E. McKenney" , Mathieu Desnoyers , Radoslaw Burny Subject: [PATCH 12/12] locking: Move lock_acquired() from the fast path Date: Tue, 8 Feb 2022 10:42:08 -0800 Message-Id: <20220208184208.79303-13-namhyung@kernel.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208184208.79303-1-namhyung@kernel.org> References: <20220208184208.79303-1-namhyung@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The lock_acquired() function is used by CONFIG_LOCK_STAT to track wait time for contended locks. So it's meaningful only if the given lock is in the slow path (contended). Let's move the call into the if block so that we can skip it in the fast path. This also move the tracepoint to be called only after lock_contended(). It might affect bounce_acquired stats rarely (if it's on a different cpu than when you call lock_acquire) but I'm not sure it's possible in uncontended cases. Otherwise, this should have no functional changes in the LOCKDEP and LOCK_STAT. Userspace tools that use the tracepoint might see the difference, but I think most of them can handle the missing lock_acquired() in non-contended case properly as it's the case when using a trylock function to grab a lock. At least it seems ok for the perf tools ('perf lock' command specifically). Add similar change in the __mutex_lock_common() so that it can call lock_acquired() only after lock_contended(). Signed-off-by: Namhyung Kim --- Documentation/locking/lockstat.rst | 4 ++-- include/linux/lockdep.h | 12 ++++++------ kernel/locking/mutex.c | 4 +--- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/Documentation/locking/lockstat.rst b/Documentation/locking/loc= kstat.rst index 536eab8dbd99..3638ad1113c2 100644 --- a/Documentation/locking/lockstat.rst +++ b/Documentation/locking/lockstat.rst @@ -28,11 +28,11 @@ The graph below shows the relation between the lock fun= ctions and the various | __contended | | | + | | + | __acquired | _______/ |/ | - __acquired - | . . diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h index 4e728d2957db..63b75ad2e17c 100644 --- a/include/linux/lockdep.h +++ b/include/linux/lockdep.h @@ -559,8 +559,8 @@ do { \ if (!try(_lock)) { \ lock_contended(&(_lock)->dep_map, _RET_IP_); \ lock(_lock); \ + lock_acquired(&(_lock)->dep_map, _RET_IP_); \ } \ - lock_acquired(&(_lock)->dep_map, _RET_IP_); \ } while (0) =20 #define LOCK_CONTENDED_RETURN(_lock, try, lock) \ @@ -569,9 +569,9 @@ do { \ if (!try(_lock)) { \ lock_contended(&(_lock)->dep_map, _RET_IP_); \ ____err =3D lock(_lock); \ + if (!____err) \ + lock_acquired(&(_lock)->dep_map, _RET_IP_); \ } \ - if (!____err) \ - lock_acquired(&(_lock)->dep_map, _RET_IP_); \ ____err; \ }) =20 @@ -600,8 +600,8 @@ do { \ if (!try(_lock)) { \ lock_contended(&(_lock)->dep_map, _RET_IP_); \ lock(_lock); \ + lock_acquired(&(_lock)->dep_map, _RET_IP_); \ } \ - lock_acquired(&(_lock)->dep_map, _RET_IP_); \ } while (0) =20 #define LOCK_CONTENDED_RETURN(_lock, try, lock) \ @@ -610,9 +610,9 @@ do { \ if (!try(_lock)) { \ lock_contended(&(_lock)->dep_map, _RET_IP_); \ ____err =3D lock(_lock); \ + if (!____err) \ + lock_acquired(&(_lock)->dep_map, _RET_IP_); \ } \ - if (!____err) \ - lock_acquired(&(_lock)->dep_map, _RET_IP_); \ ____err; \ }) =20 diff --git a/kernel/locking/mutex.c b/kernel/locking/mutex.c index f8bc4ae312a0..e67b5a16440b 100644 --- a/kernel/locking/mutex.c +++ b/kernel/locking/mutex.c @@ -605,8 +605,6 @@ __mutex_lock_common(struct mutex *lock, unsigned int st= ate, unsigned int subclas =20 if (__mutex_trylock(lock) || mutex_optimistic_spin(lock, ww_ctx, NULL)) { - /* got the lock, yay! */ - lock_acquired(&lock->dep_map, ip); if (ww_ctx) ww_mutex_set_context_fastpath(ww, ww_ctx); preempt_enable(); @@ -708,10 +706,10 @@ __mutex_lock_common(struct mutex *lock, unsigned int = state, unsigned int subclas =20 debug_mutex_free_waiter(&waiter); =20 -skip_wait: /* got the lock - cleanup and rejoice! */ lock_acquired(&lock->dep_map, ip); =20 +skip_wait: if (ww_ctx) ww_mutex_lock_acquired(ww, ww_ctx); =20 --=20 2.35.0.263.gb82422642f-goog