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 C549BC47080 for ; Tue, 8 Feb 2022 22:34:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388446AbiBHWc6 (ORCPT ); Tue, 8 Feb 2022 17:32:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386195AbiBHTnj (ORCPT ); Tue, 8 Feb 2022 14:43:39 -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 97E49C0613CB for ; Tue, 8 Feb 2022 11:43:38 -0800 (PST) Received: by mail-pf1-x42d.google.com with SMTP id i30so243639pfk.8 for ; Tue, 08 Feb 2022 11:43: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=/az7RkqUaZSIeoYuZW+qHEklI+WUcZiVSMlf0uKOOFw=; b=JOsxju/wOm454arqDgajrlARrWDaVLj0HR7UVryPAnxH7XH7HS8UGf5OS/oLAwCAnd yhIdC/jNbcvc8TgSJjnkcLoa4wCNqJd0xR5Ou3Tv7VZ1HwFWoACM9svSynMCHE/yPwRE 9/cLp0vFcYNRrCPRNTtT+N0Cqn/9QBZnVT83EykUzknVIZhwNfYd7CmYfrZBtLvOZV8/ nZT1nZCnitQrXPUkF9pOg5bbo0LXk/RmmiAzf3OZftfm19cajiJoZPz09/QUz6Hh7hN1 XhDXXR3tfcozRmC1cj3Q/1tHicZQnip4coOUaiJiBBgtRMISyd7VVW3vHj1wiK8UuyNz nSCA== 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=6yhl3xIyMN3Zzt0v0OT1Xyip3FLYPuXS9hVPGfTOfxFS94vE6k5hw/UtAUiOWXOxDN r1A3jyg0TgUzmgGoplmAffbStdxeXLZWBvRMfdo14hz+Ue3qJw/4f2pxaQ0VVqHE4cEI oHkCyE4R8BnD3d/PKrqMY1Hs12I+tzMDYO0GaExhodOBb0q1qssRm7EtOkKZzMKM/nDb YSLfKH3iDzeD88hGr6J7yeGcQ+WXkqsLEaw0CmsE5q12OWEtzQCB8pij14UjV9ElCIZq mMRWLsyEL7Jgmh9oT2cYZakywoHpAUU9QaDynYFGpzQG3UqiHeGJbEVE65++wdnhx9ZF 3rTw== X-Gm-Message-State: AOAM532fIvTu9a6gLloKdmfaG7zRlC6oMS4Yz/tvI8UZlSbZ0GynNBOi my2bgyoiUlwrrzR1XtY44MM= X-Google-Smtp-Source: ABdhPJw2un2/IIK5To0WebGHV3SG+FNgAkkT4/lDOq/MmV3Nb41SBSDz0MTtmaYkhZzNNFqr33k7Pg== X-Received: by 2002:a63:1d4:: with SMTP id 203mr4763109pgb.462.1644349418094; Tue, 08 Feb 2022 11:43: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 w11sm16876839pfu.50.2022.02.08.11.43.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 11:43: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 01/12] locking: Pass correct outer wait type info Date: Tue, 8 Feb 2022 11:43:13 -0800 Message-Id: <20220208194324.85333-2-namhyung@kernel.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208194324.85333-1-namhyung@kernel.org> References: <20220208194324.85333-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 18CEEC433EF for ; Tue, 8 Feb 2022 22:25:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387574AbiBHWZS (ORCPT ); Tue, 8 Feb 2022 17:25:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386197AbiBHTnl (ORCPT ); Tue, 8 Feb 2022 14:43:41 -0500 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD47AC0613CB; Tue, 8 Feb 2022 11:43:40 -0800 (PST) Received: by mail-pf1-x433.google.com with SMTP id z13so302851pfa.3; Tue, 08 Feb 2022 11:43: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=Ufb8JerL9tDT7g1v4aJC4XJXyEpEyj9Y7QxoUEiNuQM=; b=l8GUnslAu32x2n2gXuW8E6fzALxUMJ0TwywQoY3fKUoNyKJBqq58O/62kH0swgU77u DbHskTdVQLu0Tdr9fEJ2kCUH9L/S//grixVe8rw4M3vpH1XFpXDTqUJYyKMEILKF1MkG hNgLMNVINDbz/fRhL7lq0u7gY3Q1eRgLlyHbu5XWBWVJD7moK9FcLDHoF21NtVZMRtp5 wWo93xO3wzaNO8NKVWPxd2UX00xbuNMSUxt45F9VVuVGAAxCzn4Ya+E2pjQbOiAsQzlG YHCeOJSR/NtzKWhs/gvZ0VKN22ynW8TsN+SOc0Ur0FgHjnIbTvjt2eQHzwWd/JDEO7iN CgtA== 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=Ufb8JerL9tDT7g1v4aJC4XJXyEpEyj9Y7QxoUEiNuQM=; b=csvpIatJnEJoQKMXVojIT0mD9sQV1EC8REOW0yI1irlbsKUgmKxHOnP6kW5P/uW3Ct a6wu3mKHUxOK9GubuUfkbyTyVD9/WX/BeUGNYI7AQSeNDTpXH1MbVKW4gCOq1aH7b0Bw TmhIANCAo/A0te++7j4IsOSpyUJBn9smV0v+RAyStbMiG7xr6hSMUvRAag+BjD1wadSk vrji/mTSfaSUw0ID3vZISlS2znIYGz6b7pom3OjzIs9vVxg1mMHAsCJUgVue5hDddeOZ I2vUQw0Q2TxJzVtAo5HBx95h9aSj/Lec6jiURvefH/2HcIWQuQgJzWIr1BKV6sVRDn7y A/ig== X-Gm-Message-State: AOAM530j0J9Uio0fbfmev4RML+gxc9a3O0b5tcumNhhh404s1KMW4ln3 sLMhXRkUkd3mRFG4yGpkRbQ= X-Google-Smtp-Source: ABdhPJwrwivlWofm2UOfe8OdlqbFVCbp5LnU7jaGnUKTctny/cMMRUv76SfiAeYangOlGnt5tOCHAw== X-Received: by 2002:a65:4d0d:: with SMTP id i13mr4696818pgt.483.1644349420393; Tue, 08 Feb 2022 11:43: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 w11sm16876839pfu.50.2022.02.08.11.43.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 11:43: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 , Zefan Li , Johannes Weiner , cgroups@vger.kernel.org, Tejun Heo Subject: [PATCH 02/12] cgroup: rstat: Make cgroup_rstat_cpu_lock name readable Date: Tue, 8 Feb 2022 11:43:14 -0800 Message-Id: <20220208194324.85333-3-namhyung@kernel.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208194324.85333-1-namhyung@kernel.org> References: <20220208194324.85333-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: Zefan Li Cc: Johannes Weiner Cc: cgroups@vger.kernel.org Acked-by: Tejun Heo Signed-off-by: Namhyung Kim Acked-by: Waiman Long --- kernel/cgroup/rstat.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/kernel/cgroup/rstat.c b/kernel/cgroup/rstat.c index 9d331ba44870..371f54a59c38 100644 --- a/kernel/cgroup/rstat.c +++ b/kernel/cgroup/rstat.c @@ -286,9 +286,17 @@ 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) { + /* + * raw_spin_lock_init() uses the argument to name the lock in + * lockdep results. Passing per_cpu_ptr() directly created a + * cryptic name as the macro was expanded before stringified. + */ + 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 F3B55C3526E for ; Tue, 8 Feb 2022 22:29:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387260AbiBHW1k (ORCPT ); Tue, 8 Feb 2022 17:27:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386199AbiBHTnn (ORCPT ); Tue, 8 Feb 2022 14:43:43 -0500 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1487C0613CB for ; Tue, 8 Feb 2022 11:43:42 -0800 (PST) Received: by mail-pj1-x1036.google.com with SMTP id c8-20020a17090a674800b001b91184b732so477022pjm.5 for ; Tue, 08 Feb 2022 11:43:42 -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=Z59AvqUCCa7UbRG2nJztf5OxSI9qQovj8CB7b/+6lPnCSxvE10jTasby5VST/dsbG1 OVAlzmtRVmJN3/xEluUeFGgv1tku1k8Nky1bf3K3UyyMEpAv+4GM/d3AktiTvQIyazqO 5j10K6DkStDMQzABmX4PqlAbgIRA6ciTLM7NS6tIMDt/dmzNEbNc3VkwyT9Qn+EJxZ85 ktaf1EYyxRpltgGfKwJJdoDhXWsasI/9JyvWq2tCFdcmgLPYumpRIDSQiOnjS8z/KHie 7ZKsxkOiOyeOUpXGax2FJI5NkjnTyMtx31xhASonu1EuJA+sL7BBAK3xT03dxNzO4c6a 8g8g== 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=798saKTHREHNW+qICWqHQ8FXa3iqOvuVjDPa3yU2ABYor4A+nVFeKlTtrK4GXGfeqB L9xpoNvvU7qoCVOQk+WlW5BjjXQy0MXKjhL4D6z/GIgAJkFeFcLjJN2uuLkSON83SHLS K4ir4Ug0ytSqxjtRwMhvsnDtGBlHCGUZKWBUh33YC3/AV1BLov/Y5pNhTPgJ4Tntvpim 5H7xjvjsYGMfw66pnjp2H9MmGI1eyEZDAae07+l9rpjVb6O37vtujO/5ZH00FLiV3tBA AplvbzclveJzWXBAuPiRmYU5luvITDTVD8badcV6IexTlwM8/ynm9/34YydhDxkNKgX7 1dnA== X-Gm-Message-State: AOAM53172iod4rzI5P7vFZiJ9hSOFhpShT+MTHNhCGnQnyXfgkNyZzH+ 0PTRY9C98fzsESp4N3rPm+8= X-Google-Smtp-Source: ABdhPJxHfW73Un1j2m77knqGc5baEAyVhu9540XuJH25WpcdoAtQ7dfy05NOE3I/jDz5uR2KU/cH5w== X-Received: by 2002:a17:903:248:: with SMTP id j8mr3728183plh.123.1644349422264; Tue, 08 Feb 2022 11:43:42 -0800 (PST) Received: from balhae.hsd1.ca.comcast.net ([2601:647:4800:c6f0:347f:e607:176:4358]) by smtp.gmail.com with ESMTPSA id w11sm16876839pfu.50.2022.02.08.11.43.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 11:43:41 -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 11:43:15 -0800 Message-Id: <20220208194324.85333-4-namhyung@kernel.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208194324.85333-1-namhyung@kernel.org> References: <20220208194324.85333-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 8B3C9C4707F for ; Tue, 8 Feb 2022 22:29:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387517AbiBHW2a (ORCPT ); Tue, 8 Feb 2022 17:28:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386201AbiBHTnp (ORCPT ); Tue, 8 Feb 2022 14:43:45 -0500 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B357CC0613CB for ; Tue, 8 Feb 2022 11:43:44 -0800 (PST) Received: by mail-pf1-x433.google.com with SMTP id n23so320475pfo.1 for ; Tue, 08 Feb 2022 11:43:44 -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=eB1ulFLlG3MvjHSKqJMMPP76xZ5tzmritayHnxYj4pjoQSG31cYP4slT9wT97U7F0R tp0KYs48AvrVX4+VZj7CEwvYxNYoDtC2XN9IbBEi19IVT6jFC+dCWJWh2LhsinDz6s0Y WWnGw0c7L2wyr5fDrnnrYoT9AbQOeiBA1xVP2mSS6jhy8I81TidsErrdFVJ1xE013E1u yfS+FM+wkCjg3S5Q+FluIUilTHtzPX0I4W+T1MTf61x6x+jZTCd9E+JRKOvjiYz0RkOR m8V4+FLxsZc0S4V9/pF3CBOZZ3wDhIngfKi9ZRYAe3qEXvtjSm3p2Qd56MsIYlERVOvQ P6pg== 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=2Zvye8aT5ttDjsmR5xpxUykf34f3DQ/tvcWVgevfZ13x643fNf/30rfZqOX98665bZ 7/VOLl5o75gNp+06ay9bnRbLJLJvuL6YmdcIm/izBoX/X3JiaLEQapPbtvQDpMCb0oRI YdQh0La/5McxYlkz1WUfLld7sDHeUVs0BhFiByhqsiSjbQn2cux8dWh5v0+jyyU91+ml 1MDYQDKbQbg8Nf6zFDUgMZI6H39SUG80THbccRZTFsr4yfX7j7leDWfqYrX8CitWYS+d dkg8tS9zPiabhhgtHlQ7sHXu5WHay4xpwG7PgbXstjxItzYCJ7xpaVkJ9yrETZTA0Of+ +azg== X-Gm-Message-State: AOAM533MQDqLMdv4sK1WXC+qLYF52qNPM2GVWWicVXA9YhdjX3kK1sOj POIwa0J+pv5J2cQ3stJbAYY= X-Google-Smtp-Source: ABdhPJxa3EJBSsbwQz/XZzLop6zZQaddVuKoxQrvRvkGQbStZq8FBYijx/2PQqDl+XAyFFBowzvwOw== X-Received: by 2002:a05:6a00:23d5:: with SMTP id g21mr5835863pfc.78.1644349424241; Tue, 08 Feb 2022 11:43:44 -0800 (PST) Received: from balhae.hsd1.ca.comcast.net ([2601:647:4800:c6f0:347f:e607:176:4358]) by smtp.gmail.com with ESMTPSA id w11sm16876839pfu.50.2022.02.08.11.43.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 11:43:43 -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 11:43:16 -0800 Message-Id: <20220208194324.85333-5-namhyung@kernel.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208194324.85333-1-namhyung@kernel.org> References: <20220208194324.85333-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 546A6C433F5 for ; Tue, 8 Feb 2022 22:35:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346659AbiBHWfH (ORCPT ); Tue, 8 Feb 2022 17:35:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386203AbiBHTnr (ORCPT ); Tue, 8 Feb 2022 14:43:47 -0500 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C82EDC0613CB for ; Tue, 8 Feb 2022 11:43:46 -0800 (PST) Received: by mail-pj1-x1029.google.com with SMTP id v5-20020a17090a4ec500b001b8b702df57so2937103pjl.2 for ; Tue, 08 Feb 2022 11:43:46 -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=FCaFfDHqOKbbM+LTbZb/y7018/XOb/NmUt5E6W+YnPsqxKsfSDMkWZB/l0fglbgasl clQebc8o6nC+U2ONdp4ydBS2u9mOTBEPiyiovDrjfweqhsE4OQLY6vnmZL4LYFkMGbp4 zx0Ldh7CVLEFZaAg0EkxPR7V58GWFRcK38oNqFb+kXJM/NXJ/LE0zDxE1iwSW9o0UhKv 5mYjmoD1oql0ihFJrAlulXXNG0pefXs1oTT0rJ79JaxEBu0b7PhNtIS7oKe589fqyeuz iQS0o2k9uDlyVH34IVZDep+1o0VwKMV1j7oN9lcKwBo0mpIgqI5YGnPdeRoXaSL3qxo7 v8aQ== 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=wqzzijdvJFyh0RSjuzhNSR5XP+/H1fdf0/x0d4HzwfnVPrg4HNlb73kwSVrbCZAFwG Nv6SB+ex6XsC3DQaVgMLbDr3FPgUJumB7Kh/PuNIyOjB0mMIg9d+CQqtCb+U/Jz/Pn9p d+BoFtB01s9HlBwLW0mtt/6b1Zkoj6En9CVslh3ANrxjU15tg3+XHCGp1EkI6S6zXDwf HjBcS/+oSHzKl1QVB3ZfV8yZmYdg9MUQWKBKxWM6m9vHNZ0PLWvwYRsQw9AuTcwReRIa chgt6KRxICdVTpSvE6hAZoBanINThLJJ17E4ohfr/C9/DNFbwazciFskj4SKoHSbIEsT Lddg== X-Gm-Message-State: AOAM531xSExTNXEJjNo9lk37lcwq41N7pPeKIfEHHOymk52zyo73XDlj XI9MZSvimhAJ5Vi86SjPhvA= X-Google-Smtp-Source: ABdhPJxcdJhuyvcGJERiilgb8k7uMGXZtduHdT/KN0RWAWmAOJukqmIGccAe7pKgqTm7G6G9cfXrHQ== X-Received: by 2002:a17:90b:4c06:: with SMTP id na6mr3057583pjb.174.1644349426360; Tue, 08 Feb 2022 11:43:46 -0800 (PST) Received: from balhae.hsd1.ca.comcast.net ([2601:647:4800:c6f0:347f:e607:176:4358]) by smtp.gmail.com with ESMTPSA id w11sm16876839pfu.50.2022.02.08.11.43.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 11:43:45 -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 11:43:17 -0800 Message-Id: <20220208194324.85333-6-namhyung@kernel.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208194324.85333-1-namhyung@kernel.org> References: <20220208194324.85333-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 B7922C4167E for ; Tue, 8 Feb 2022 22:34:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388069AbiBHWcO (ORCPT ); Tue, 8 Feb 2022 17:32:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386205AbiBHTnt (ORCPT ); Tue, 8 Feb 2022 14:43:49 -0500 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7AD6C0613CB; Tue, 8 Feb 2022 11:43:48 -0800 (PST) Received: by mail-pj1-x1029.google.com with SMTP id y15-20020a17090a474f00b001b88562650aso2203146pjg.0; Tue, 08 Feb 2022 11:43:48 -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=47Zt1ciDlAfZ4CsVaghTCf8CTxEeHu+p/hM6Ax63pg8=; b=SMmHEK9AqUbqZLIwucjvRyGysfK96AdDbYtNYRCgagZmSxwc1w2HIUufH1A8ItRgep Jz5mDipLmvR9OY5cEMy1DwAGNkeDaQQn8Reuo1OukFlRbZB+oN+A1Q9D7cLj9Mbid/G7 R3DxXDARvZCk6cSJL4vMoQduuaAowtBA/tRJtoqA5ha8uM2TW4qXxT/GVLp9w73Dv/n7 3d5yBVIg8yaLMeshP38X1FNuWWahuIsRvFClqT+LI52wWuuToWlLAF9RzkdHnWbT8zdF BcA/Me+ULcQlKO1W4biSCA9doeTMeXKKfNQ+72B2MxdxTiF6pYTzdxDNRYV028gfR1nq Sq7A== 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=47Zt1ciDlAfZ4CsVaghTCf8CTxEeHu+p/hM6Ax63pg8=; b=Vskd9rXTdoWmq77k7M2RTdDJTGZbF4qUWwI4TPST5GLM5xg23Kp/p0+WhsyT/Nc1QL jSw7rjP8pdGO79iBoTnYZ9XQuBP2USw354lehNg02C4HhLRlV5mu5zjsnY7CnO4AJ7SZ YyApipqbMWOo41cPoKal5Vo72hHtO3POjpZW37zxnEmPlQAT5CpHph1gxg/edBCsHOSz iH/nf07Xj5zKNirzTD/U3iw5FdR7mN0JAZTqjf1huhvjzg3qKk+F9Rpk5FFGu5W9VIid T+hu6I4GgYfVpZy83tGqRjNUz0XWfv6EU95UKEYlVJjErzHdahVu7IgofWvIwO70w+J/ kGHw== X-Gm-Message-State: AOAM532I5eoe59PwKwPwavNRtQkEIfSuxf4iTqk4R/RWbeQKwpwpdQds Ir84hqDjbDhr//cNv4XTQpI= X-Google-Smtp-Source: ABdhPJzd2Xi0GuGR4M7cbShojHTa5914O2E9YTB2ynvlq39JbRXCTw81IBVhXHOA5wx+3FrqqomSiQ== X-Received: by 2002:a17:902:9343:: with SMTP id g3mr5950056plp.11.1644349428375; Tue, 08 Feb 2022 11:43:48 -0800 (PST) Received: from balhae.hsd1.ca.comcast.net ([2601:647:4800:c6f0:347f:e607:176:4358]) by smtp.gmail.com with ESMTPSA id w11sm16876839pfu.50.2022.02.08.11.43.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 11:43:47 -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 , linux-btrfs@vger.kernel.org, David Sterba Subject: [PATCH 06/12] btrfs: change lockdep class size check using ks->names Date: Tue, 8 Feb 2022 11:43:18 -0800 Message-Id: <20220208194324.85333-7-namhyung@kernel.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208194324.85333-1-namhyung@kernel.org> References: <20220208194324.85333-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: linux-btrfs@vger.kernel.org Acked-by: David Sterba 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 44963C433F5 for ; Tue, 8 Feb 2022 22:27:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385946AbiBHW1L (ORCPT ); Tue, 8 Feb 2022 17:27:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386210AbiBHTnx (ORCPT ); Tue, 8 Feb 2022 14:43:53 -0500 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CAF9C0613CB for ; Tue, 8 Feb 2022 11:43:51 -0800 (PST) Received: by mail-pl1-x62f.google.com with SMTP id x3so260097pll.3 for ; Tue, 08 Feb 2022 11:43:51 -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=XUq514eRiY9wbsvgrpwwKkARfww22ZpIfFHny81Qbx3Tw7LIwx9vrgumGG6VHb9w0t cC5kocX99lLRPvEBY09ZpEZRgmC2cqGqcw8Lx4D0VxABOQx7DequWFPBlNucVtDx4u0t I6wR8Jg5UlDd/PCuVvz+OHFqpSvZkTjHHBnCvRyqhqgQQy5Sl7K0N+zCpOeHImOIoHYu 0IyqIlgnvXqhR76TGMsZz08h5LeQEjGtUdJMfSTdfDAUA5ujJhwZWjKcd0MT/6kXvuTz V90HLlabqJZwgqPPRARGR7hKPzfjzpgRLRPul3nY8FTCzvV0T1W2vrz0NUxc6v0wJi83 EFzQ== 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=f84nelbophVl1hKOX28nseADQeiicLQeSY0a8mPufROhUodYUVbmozIfbZ/iDfR+9V d2uBRzCQSJiXuOBQGpW/GImXQQpqpG2blXURU+qPr+iZzMXpPKmcdTOj0YfyIDjVFT0B o2AxYuZz/nz2S8B2ueze3i4m1b5lXHpWZt4PPbYKZqsngapTIOMB+wQi/dM3GB+wZpKu PmwDZcjnrkiJLWozBgc7H5UNOhZiiG5t+OctBYrEtE/+wdfdCLFDPoxsuHLRxeTVNR7e lp7aHjhpRRUBhIYYEEzj3yKTKwHiNEHjBVWXqXYLKKaFGXcK7oQ6xQV4yzGyaNlfTR7F u3rA== X-Gm-Message-State: AOAM5339TtqUCG2JPGU8jr0JLIjIWsUuQ3SVuqv5HfFgfP6SnFtTBlSU I5gdPk9mbyWfInXGE6QjT+8= X-Google-Smtp-Source: ABdhPJzEptAvXS5zwLxHTE/rqGD7+OXvH0aJTUABsMWsfAa4ZduPphnGoFO8o/nHHQqmEMGP3S+Bfg== X-Received: by 2002:a17:903:1212:: with SMTP id l18mr5764427plh.45.1644349430346; Tue, 08 Feb 2022 11:43:50 -0800 (PST) Received: from balhae.hsd1.ca.comcast.net ([2601:647:4800:c6f0:347f:e607:176:4358]) by smtp.gmail.com with ESMTPSA id w11sm16876839pfu.50.2022.02.08.11.43.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 11:43:49 -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 11:43:19 -0800 Message-Id: <20220208194324.85333-8-namhyung@kernel.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208194324.85333-1-namhyung@kernel.org> References: <20220208194324.85333-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 3D806C3527C for ; Tue, 8 Feb 2022 22:29:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388052AbiBHW32 (ORCPT ); Tue, 8 Feb 2022 17:29:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386211AbiBHTnx (ORCPT ); Tue, 8 Feb 2022 14:43:53 -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 A9CFEC0612C0 for ; Tue, 8 Feb 2022 11:43:52 -0800 (PST) Received: by mail-pf1-x42d.google.com with SMTP id i186so376051pfe.0 for ; Tue, 08 Feb 2022 11:43:52 -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=eGq2LniziG9CjJRR2kTkUUuXbdtcfXwGY3muW0HW5G6quReyWc8n0x/6jxJm4o6G9e MigJKTIYPndMz6+XXV4Z/wNFIeXVhetAdOwSuPpcY63ffM8enPP/S6vrfJCJIgumNNpN d8LVPIWU9RYH6Fg0TWL/DErpNecQCxtzz4OajZM09Ztmmut3hoI0NYZakKJJZdb32xpj p8mPEWS03LuOi7GMBUMX4aGJynBMiraEr1N4gAwhZpWZZ+QJklVcwhzWMbSe81zPoDcY RrmOlUBijIBUGcAWoVwwl4qPDYaN9uMWcsiX8+S34/M06LEz3b1dF44r6laiwL3KXNJT mzyQ== 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=u0CPWeFM7CVrKmvbMY0hwqxR/qc+VANSAZmdDHXVDXjXRaDLEMLVC2BULjD+UMutcC 76yU9ofJw8bVTPpKRPjCXdrn4CXuOMEKVuqRlu/gASV9EOJaxvUqJZoE42j8zhFeJdmO VO4vW+a309m5+DojYTOM+3gtkRaBAdwvFKd6Up3piBhQGzh8Zq61UKw2lOzPEDCKZh2S y7583Wv19Cm9Ods/6LDq2Ua/XQBzUV9et7v4WdNNdiKdunYAswU3sqQOdcGWiW9aX6wO /Z89StcHXuQCk3BYv4ixjnXSec0yUtC7wmyHySk9GfYegWMIzH4p25KaXCVw3Kmz9KUp AFKA== X-Gm-Message-State: AOAM531KI1xQs7T9WIfV/+wGnC1S/gT93xTcJP3hmVaHGqzncpW3tmf/ jfBPFAYrNxxJRi2xYkceN/g= X-Google-Smtp-Source: ABdhPJwwj1bI0GWTB5NFt+lgqtppvKAhgRCsL3+JuDgFUYN27r8SV7aTKy49jo1clxPqwm+ioSRXlA== X-Received: by 2002:a63:6b81:: with SMTP id g123mr4707638pgc.562.1644349432191; Tue, 08 Feb 2022 11:43:52 -0800 (PST) Received: from balhae.hsd1.ca.comcast.net ([2601:647:4800:c6f0:347f:e607:176:4358]) by smtp.gmail.com with ESMTPSA id w11sm16876839pfu.50.2022.02.08.11.43.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 11:43:51 -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 11:43:20 -0800 Message-Id: <20220208194324.85333-9-namhyung@kernel.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208194324.85333-1-namhyung@kernel.org> References: <20220208194324.85333-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 E95ADC47081 for ; Tue, 8 Feb 2022 22:34:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388520AbiBHWdF (ORCPT ); Tue, 8 Feb 2022 17:33:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386215AbiBHTnz (ORCPT ); Tue, 8 Feb 2022 14:43:55 -0500 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A04E8C0613CB for ; Tue, 8 Feb 2022 11:43:54 -0800 (PST) Received: by mail-pf1-x433.google.com with SMTP id c10so234587pfi.9 for ; Tue, 08 Feb 2022 11:43:54 -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=coFrZx+umVb8C/9VoaeNS8agdUuDH1jjXrRj9GBST7lfrgMyXv+urqHK84NA+cqHK2 YPP8ni+X5Tj3wenKzAOVxLCtqjfiED+u36ZZ9ETh3Bwnpy4r2M/jDQIWtW0kD7tvva6G pjqXROY4r0loXEnFtL3ug4ia+hY746GpzMeAFbHuyUR4/gs28nIldej+IlIS5Y156+Fz 5Y+DXajDA+R/a+8V2WhjcIXodpHFPeTJcw8LsNLBv2zyWhu0/h6Ya6/k+ydhZ94Sax7g +DICq7kdEw6BwaGWi6hz1N7nDIXFOPBr0r4QYmYf8NMT52ruOU6Kv8biZ560q5sTpmpH wRrA== 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=fds3bzHD+7AYHSnr5zKyX29d4hr2d7puTCGzchel4RlQNyTGKITGy+4NkUg1vUAtiW p4E+Lu9z3fjTefucWqUvkC/v3kIdgVxufHoBIYzP5K/sP9RStnXD1nMZ6W89Fb+1eE+k D/QE1SQ88zeI8pE8HPzOCIVML0MfdsjoVn2uRS9DozPUpCll3s0Ba7KOEg9raBMJs5y6 UsXmDulyZ+GEhSNUEST/Fh6did+kHx5bEmBnj8UjOOQA/xjqF/YyWWH7IjliznhQsieA uNvGxHShN0UXabi3iZWazYT5tNRayhHDrW+XKLPxQ1WO0xCeAZO2C++LK30HzAJRJ4bS QFmw== X-Gm-Message-State: AOAM533ngFyDB9/hyAFJ2nmHrMFcNbFwu4LO/Js0DW+8wv3jFeo+4WBy OfCAbwxhouNfSzP8VKiSub0= X-Google-Smtp-Source: ABdhPJywJ/lu8GWNpkww16VbmJlUtxqslBTWQrZ6DMFizoxzO0kUsn0kJ6BhawqySiiptym920qTOw== X-Received: by 2002:a63:6942:: with SMTP id e63mr4761524pgc.226.1644349434067; Tue, 08 Feb 2022 11:43:54 -0800 (PST) Received: from balhae.hsd1.ca.comcast.net ([2601:647:4800:c6f0:347f:e607:176:4358]) by smtp.gmail.com with ESMTPSA id w11sm16876839pfu.50.2022.02.08.11.43.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 11:43:53 -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 11:43:21 -0800 Message-Id: <20220208194324.85333-10-namhyung@kernel.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208194324.85333-1-namhyung@kernel.org> References: <20220208194324.85333-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 5EF40C433FE for ; Tue, 8 Feb 2022 22:34:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388932AbiBHWdl (ORCPT ); Tue, 8 Feb 2022 17:33:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386217AbiBHTn5 (ORCPT ); Tue, 8 Feb 2022 14:43:57 -0500 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A896CC0613CB for ; Tue, 8 Feb 2022 11:43:56 -0800 (PST) Received: by mail-pl1-x634.google.com with SMTP id y7so265902plp.2 for ; Tue, 08 Feb 2022 11:43:56 -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=CVu9Gz+7ny2CqqZn2AmzB3OZOJ8utvXtXJT+uTffuOURUE7m4sHaUmMxkTYnuAhjoE WpvdEV50nl2YkgqjdIKaYtuRoS3DB4UiLkqWjg/dv4A+P3BReIxixbAewFUz2NQQubFe KQD5fRBJmUpctn8R3PjppV/eI3j0rSXbamBOg2pu/94SJA4cfQBIt6b9fZP60mKKypUB pzmXNpsKN5p1sAx5d1LjmQkGihT8h7oNOAHEGN3TYqf7AvNBnnOiuPJqolor6KiojPLv 39Y4hiOKcfBzu+T0JM4gSp34xrYGPzsM06mtkCY6KPhOnsuzaH9X2Qc1v45E0KMUOFtp 3P2w== 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=s1N/M/TJAr22BItTOg36HQRYZ2rQoKYwUaia9AH8Tj57LuFQja93/97zUL6JdaS/e9 aRE8YITynTeQxBmsfGgzUhwARKcHlMMOkfwsmTBi4I+FK7kYG/ceiBUM4y73qWW5gYmc tKKkEqJFZOa3FRkdSt7d+52jmZX93vcdcw+1A9i/u40joPVNkLnoB+Ttd3sisTkY9BkI pWAzKKN4Bw9/sx0HWnTr5YhKcVETxNXMoETqGRoAXbFhirRCkPq1htLiDvLARZozxf37 mGT9rHmtonEycvX/Vnz7jB1C7ytVU7+bpCcMvy1Jh1Qjpl3VGGOfL608IYFocpKxV688 KiAw== X-Gm-Message-State: AOAM533kcTkneyU9GkjP4mIaaPvAfYLSraMzwLXyj2AnYOvh58KSMTRZ 0dsul55qpxYW+5SW+I29nas= X-Google-Smtp-Source: ABdhPJyICADZ4Q8xypnNJExN/AykweFdN/mOihQHXR6DZjO77wctgdJUTCWQBnfu9A3Uju2fskiKyA== X-Received: by 2002:a17:903:2d2:: with SMTP id s18mr6187922plk.56.1644349436130; Tue, 08 Feb 2022 11:43:56 -0800 (PST) Received: from balhae.hsd1.ca.comcast.net ([2601:647:4800:c6f0:347f:e607:176:4358]) by smtp.gmail.com with ESMTPSA id w11sm16876839pfu.50.2022.02.08.11.43.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 11:43:55 -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 11:43:22 -0800 Message-Id: <20220208194324.85333-11-namhyung@kernel.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208194324.85333-1-namhyung@kernel.org> References: <20220208194324.85333-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 1C8BBC43219 for ; Tue, 8 Feb 2022 22:34:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388174AbiBHWc1 (ORCPT ); Tue, 8 Feb 2022 17:32:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386219AbiBHTn7 (ORCPT ); Tue, 8 Feb 2022 14:43:59 -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 8E651C0613CB for ; Tue, 8 Feb 2022 11:43:58 -0800 (PST) Received: by mail-pj1-x102c.google.com with SMTP id qe15so135630pjb.3 for ; Tue, 08 Feb 2022 11:43:58 -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=KIWKaeu5lVDhyRByVq+Pe2NXQKxY7H7Aa5F2qlk9aEux7BT74ca5PXzOVfwTMs8G0d aIQ/1GcK0JRJBaF5uURR1HltBeHPcOSTkM+qj2Wy2E2pVBP2v1/zaiXMgUvue/Uo5xt+ YABUPItp8vr+PKjsZfQRekvc/Uo4MSz6cnYvNxWYFCmDeQdeWEcIV2qwsZgCZQNazxRB 7GjDpffuHBV+YJNDTRnZViM6bl+vVxv1pwIxFmP8Qfps1Dk3ZcJAflTlrUHisnm9REo2 Cyb3jnnlNXscoB2YoKpvgdpT9OeYaWYj3SlrnSkaA+OTsgpqORsrfdmey/0HhrZ83jE/ vQqQ== 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=tt3zlOjdFyQ7I7WpbmLzKqKbO1Ib0EEm4OwUZPC8Pt6jkdoSh9PZ00zZNas2DfnYKu plSQ58XHLPik5VqdxTd/BoCXrel35aHu+FkOalGJ/E/oX7Zr3+3JadMU+kCCrNIVFshQ I29bAXo3bx6y7ybZupDNeIuJE/LZPZQT1f3DpejJsFRbYyX+n+FaF8zZvZsFMtiENnxO vRmG+jKQUtcJb/82h9Xt/+cpHUFUTA0MStQwjINi8MHTognm3WEmP5mZ6WveWs2IiXxz hSm/YutCDBdKI9qMGO6OoosG5pJ54NReQ21Bk+zyRIxyfE3SxYpDKfpt2Lkejp9qg5sQ GJTQ== X-Gm-Message-State: AOAM5306b2Iw4TKUY+7dSgR11Us3B0yGfxXE/Un7qkYi8L24Tv5PdgyI qUrZ3cxurCKPYlUU8YtIDnk= X-Google-Smtp-Source: ABdhPJxfAWIl+DPBI2EOdOQgu6DTp1/Md6wPiyy/z2kttS9Zsr3fF3IE+mW+xojQu5VQE4/u/rovaw== X-Received: by 2002:a17:90b:3b42:: with SMTP id ot2mr3048087pjb.147.1644349437992; Tue, 08 Feb 2022 11:43:57 -0800 (PST) Received: from balhae.hsd1.ca.comcast.net ([2601:647:4800:c6f0:347f:e607:176:4358]) by smtp.gmail.com with ESMTPSA id w11sm16876839pfu.50.2022.02.08.11.43.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 11:43:57 -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 11:43:23 -0800 Message-Id: <20220208194324.85333-12-namhyung@kernel.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208194324.85333-1-namhyung@kernel.org> References: <20220208194324.85333-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 0FD16C433EF for ; Tue, 8 Feb 2022 22:35:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384465AbiBHWeW (ORCPT ); Tue, 8 Feb 2022 17:34:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386224AbiBHToD (ORCPT ); Tue, 8 Feb 2022 14:44:03 -0500 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14669C0613CB for ; Tue, 8 Feb 2022 11:44:02 -0800 (PST) Received: by mail-pf1-x42b.google.com with SMTP id n23so321745pfo.1 for ; Tue, 08 Feb 2022 11:44:02 -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=oFWxPltJgO7Yyjjqxn8nZJZOd67ZLTQvioVscHLVnXkmdXa7iezFJuEhtQLNA1/g3j EFngKn54zgAF+trHsmNcjk3jMcWhVtFT0yX3iEJpoRotKrbKH4Pk7H8n/jr4xIZUF63j 1dRyduxXMMhbl1Chu1b/1pvRWwQ7iHNFPsqQDUTCePMPICjmZxRsHur+mIbSI5dLw8CO Nh1NEeFvfcU4jnVlqed/v6LuOdfRyE+zdlI220FrxUoGpFXvLTWeyB44tDkof33lSASK 4gPy7MC07EK0zZ/so08sD/vnkTuNpDaSf+5BmQ8QzEbMAwWmmy2HUDdpBKaD0LQuy6XR 7RUA== 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=w/y3QK/zmnX7BKzFxExT4AGI1A4Q0DHkAIOhF++tTaVTdLiufkPU8CK3F8WPI4xNyp pIgmhHtVOyd7drzDYVwqFiZK0vWfL4iwr9r5akrm5Iu4E9JtYdlRO2ha6j+877+SdV+v bau1bKx7bvOadtsgMxWqwysnRFPr8FRu9VVfDwCFzHWObm8G5G4KA9xIhdTsDvnAQ66A /r1cjKMWwVX1izWZEROSFmjyH1DoNog56zPe1Km670uNBQqVVqtGPq7XZH1stG3hsX38 //LQyyiZkkRNgdPws454BK7+zYpY4WVXSmdth3UH9Wgg4q+7ti9sZHh581ZVU8KoCI8F t7/w== X-Gm-Message-State: AOAM533nCzwqU9FxSJ+B9onXsIuBeQHzBsUcfEWxKv9cmwE2M2E4vp6K 37KxEFPOzO3UMc3UubWwMpE= X-Google-Smtp-Source: ABdhPJwUo0N6U6Zq/adD98J6NPWalNyeAX/ePj0YT7DO2jYUnhPNw4w625Hk8Jxpoa3sLKMzFYhILA== X-Received: by 2002:a63:a102:: with SMTP id b2mr4753591pgf.459.1644349441578; Tue, 08 Feb 2022 11:44:01 -0800 (PST) Received: from balhae.hsd1.ca.comcast.net ([2601:647:4800:c6f0:347f:e607:176:4358]) by smtp.gmail.com with ESMTPSA id w11sm16876839pfu.50.2022.02.08.11.43.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 11:44:01 -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 11:43:24 -0800 Message-Id: <20220208194324.85333-13-namhyung@kernel.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208194324.85333-1-namhyung@kernel.org> References: <20220208194324.85333-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