Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp936213lqs; Wed, 6 Mar 2024 00:58:12 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW/MEPWrdUVA/IUVcCa1lk3jGQFqxGwC+295wjmr6cPuRcsmxOlTJprChdvyH5sr6sWVgSEUlNNIDfsbN6jcX74BM1x7g0fA/YKK8xF2g== X-Google-Smtp-Source: AGHT+IH73MSagnmSvzZ7O7HXUbNMxd3ZDa039mNQBpt/Zjr0sMSWMNQ3dc79y3zumUYOd81SAdwY X-Received: by 2002:a05:6402:34d2:b0:566:f742:e0f0 with SMTP id w18-20020a05640234d200b00566f742e0f0mr8691366edc.41.1709715492002; Wed, 06 Mar 2024 00:58:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709715491; cv=pass; d=google.com; s=arc-20160816; b=e2J3/kwTko+Xg+Jj4cLUdSwNIGrsX8RXewCQyprwWyyTOlQ8kqPujT+aMK6QFMBZ1T hcYGXoQljqZx9Q62f+MuWHOzKTY/C3sTW36S0kO8UxU8yF0/6ZtFUyUKgD+fy8IU1THj baLWT3lRjmGkg203EoPTuqybtA2XrB+iRwIO/1XuFaDNQepwAhYVbJz5Ouj1DOjyZYES +lHCcbh+Ta97RpSFrllbEUvhlTuPydtNey2B4X/z9CQmeBLTf89CkvoRUqtOzP+6QH+f qUJ9Lri7zzjQSgN72r4+k9OUpX7Wh9+y/S5qlXPCKxXGfjtUBFjApA35+7QGyoB8Zkt8 Sd0A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:references :in-reply-to:message-id:date:subject:cc:to:from; bh=wYwglYqfeifxk6lW+gBTi4yrQI/O7ARWxzTDfqjUyi8=; fh=H2KRUF8uSM4+6+w6W9vKW2QB11XTfop4gd9hLuyjokE=; b=HyWvzVdPWsT7L4SOryPJ5Lppq3i382pzSN/sjJQvtSK6APLNy9eldCX11cRfEsyf8E HsUjnt6vBImMNYicw+QzlbnVqT3TloYauxpKw3mcOjFX0PVL/WSSH9YXan7NGk95RMxd pW6Q4LwOiUEZlCMuaTMnREXeTRRZ7XzNvdBKqG5kit7/jIa/ujPp8kdHxNuH+lxTrgOA TnXMLRWqTAe29yGRHWmrAYPCzg9M/jLY3Xx3MihjwtueZJgXA9Nb/2ysIJLW9q+NjSXA rciN0N8dDKKSkmQP2yp1IMNFCWfCY6fbM9qgo/2q8trwKg8dcBr/Xm6XKod0O9HCy9ih 21dA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=sk.com); spf=pass (google.com: domain of linux-ext4+bounces-1528-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1528-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id x63-20020a50bac5000000b005665ba112d3si5934420ede.476.2024.03.06.00.58.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 00:58:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4+bounces-1528-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=sk.com); spf=pass (google.com: domain of linux-ext4+bounces-1528-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1528-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 8C6301F21289 for ; Wed, 6 Mar 2024 08:58:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5602A5FDD4; Wed, 6 Mar 2024 08:55:38 +0000 (UTC) X-Original-To: linux-ext4@vger.kernel.org Received: from invmail4.hynix.com (exvmail4.hynix.com [166.125.252.92]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 04EAF5DF17; Wed, 6 Mar 2024 08:55:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=166.125.252.92 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709715337; cv=none; b=ZSSKevU4neT9Vx9b2K/XQXXyqLrHa+IYi3/IoPxnitLG8noL0YD70J36TPtQiV1evBK0cjFfzJOH2XPdvVEhhziX45i2UfmIl50J6QSwE+NLG53eWayZIKWBNqq+J8QiZOlaTJ2NfQmS97jKbxB7HH+q8JN3D+DJvpGLPT3eoJ4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709715337; c=relaxed/simple; bh=ZnDomY68etRURkOftpc7pgxDDdwCW9QdH8k+FPh35/w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=bbXUeq3A0wK/iE7CGh5yIYxGACHJQAYIRWDPJ1Uy1zGcr3pEQ09+1gkb0NlToeM2h3zJgun42d1YVUcM0iQLMfsgCcGfxwDi1GBs0YinfBNT0H+RthvzKBum8alpySoSu70+VGHPTjc2DOjjNlg8TAW8cdOzHl38Y1E1STqunnI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sk.com; spf=pass smtp.mailfrom=sk.com; arc=none smtp.client-ip=166.125.252.92 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sk.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sk.com X-AuditID: a67dfc5b-d85ff70000001748-68-65e82f7c9f1f From: Byungchul Park To: linux-kernel@vger.kernel.org Cc: kernel_team@skhynix.com, torvalds@linux-foundation.org, damien.lemoal@opensource.wdc.com, linux-ide@vger.kernel.org, adilger.kernel@dilger.ca, linux-ext4@vger.kernel.org, mingo@redhat.com, peterz@infradead.org, will@kernel.org, tglx@linutronix.de, rostedt@goodmis.org, joel@joelfernandes.org, sashal@kernel.org, daniel.vetter@ffwll.ch, duyuyang@gmail.com, johannes.berg@intel.com, tj@kernel.org, tytso@mit.edu, willy@infradead.org, david@fromorbit.com, amir73il@gmail.com, gregkh@linuxfoundation.org, kernel-team@lge.com, linux-mm@kvack.org, akpm@linux-foundation.org, mhocko@kernel.org, minchan@kernel.org, hannes@cmpxchg.org, vdavydov.dev@gmail.com, sj@kernel.org, jglisse@redhat.com, dennis@kernel.org, cl@linux.com, penberg@kernel.org, rientjes@google.com, vbabka@suse.cz, ngupta@vflare.org, linux-block@vger.kernel.org, josef@toxicpanda.com, linux-fsdevel@vger.kernel.org, jack@suse.cz, jlayton@kernel.org, dan.j.williams@intel.com, hch@infradead.org, djwong@kernel.org, dri-devel@lists.freedesktop.org, rodrigosiqueiramelo@gmail.com, melissa.srw@gmail.com, hamohammed.sa@gmail.com, 42.hyeyoo@gmail.com, chris.p.wilson@intel.com, gwan-gyeong.mun@intel.com, max.byungchul.park@gmail.com, boqun.feng@gmail.com, longman@redhat.com, hdanton@sina.com, her0gyugyu@gmail.com Subject: [PATCH v13 04/27] dept: Add lock dependency tracker APIs Date: Wed, 6 Mar 2024 17:54:50 +0900 Message-Id: <20240306085513.41482-5-byungchul@sk.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240306085513.41482-1-byungchul@sk.com> References: <20240306085513.41482-1-byungchul@sk.com> X-Brightmail-Tracker: H4sIAAAAAAAAAzWSfUzMcRzHfb+/p+s4fjusrzDc1qwsYuFjzPP4mdmYfzxtOvpNN1dxJTK2 S5dF5SEqEusq51Qcd1EeyinSeUgPtyR1Uxqlqyz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Subscribe: List-Unsubscribe: Wrapped the base APIs for easier annotation on typical lock. Signed-off-by: Byungchul Park --- include/linux/dept_ldt.h | 77 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 include/linux/dept_ldt.h diff --git a/include/linux/dept_ldt.h b/include/linux/dept_ldt.h new file mode 100644 index 000000000000..062613e89fc3 --- /dev/null +++ b/include/linux/dept_ldt.h @@ -0,0 +1,77 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Lock Dependency Tracker + * + * Started by Byungchul Park : + * + * Copyright (c) 2020 LG Electronics, Inc., Byungchul Park + */ + +#ifndef __LINUX_DEPT_LDT_H +#define __LINUX_DEPT_LDT_H + +#include + +#ifdef CONFIG_DEPT +#define LDT_EVT_L 1UL +#define LDT_EVT_R 2UL +#define LDT_EVT_W 1UL +#define LDT_EVT_RW (LDT_EVT_R | LDT_EVT_W) +#define LDT_EVT_ALL (LDT_EVT_L | LDT_EVT_RW) + +#define ldt_init(m, k, su, n) dept_map_init(m, k, su, n) +#define ldt_lock(m, sl, t, n, i) \ + do { \ + if (n) \ + dept_ecxt_enter_nokeep(m); \ + else if (t) \ + dept_ecxt_enter(m, LDT_EVT_L, i, "trylock", "unlock", sl);\ + else { \ + dept_wait(m, LDT_EVT_L, i, "lock", sl); \ + dept_ecxt_enter(m, LDT_EVT_L, i, "lock", "unlock", sl);\ + } \ + } while (0) + +#define ldt_rlock(m, sl, t, n, i, q) \ + do { \ + if (n) \ + dept_ecxt_enter_nokeep(m); \ + else if (t) \ + dept_ecxt_enter(m, LDT_EVT_R, i, "read_trylock", "read_unlock", sl);\ + else { \ + dept_wait(m, q ? LDT_EVT_RW : LDT_EVT_W, i, "read_lock", sl);\ + dept_ecxt_enter(m, LDT_EVT_R, i, "read_lock", "read_unlock", sl);\ + } \ + } while (0) + +#define ldt_wlock(m, sl, t, n, i) \ + do { \ + if (n) \ + dept_ecxt_enter_nokeep(m); \ + else if (t) \ + dept_ecxt_enter(m, LDT_EVT_W, i, "write_trylock", "write_unlock", sl);\ + else { \ + dept_wait(m, LDT_EVT_RW, i, "write_lock", sl); \ + dept_ecxt_enter(m, LDT_EVT_W, i, "write_lock", "write_unlock", sl);\ + } \ + } while (0) + +#define ldt_unlock(m, i) dept_ecxt_exit(m, LDT_EVT_ALL, i) + +#define ldt_downgrade(m, i) \ + do { \ + if (dept_ecxt_holding(m, LDT_EVT_W)) \ + dept_map_ecxt_modify(m, LDT_EVT_W, NULL, LDT_EVT_R, i, "downgrade", "read_unlock", -1);\ + } while (0) + +#define ldt_set_class(m, n, k, sl, i) dept_map_ecxt_modify(m, LDT_EVT_ALL, k, 0UL, i, "lock_set_class", "(any)unlock", sl) +#else /* !CONFIG_DEPT */ +#define ldt_init(m, k, su, n) do { (void)(k); } while (0) +#define ldt_lock(m, sl, t, n, i) do { } while (0) +#define ldt_rlock(m, sl, t, n, i, q) do { } while (0) +#define ldt_wlock(m, sl, t, n, i) do { } while (0) +#define ldt_unlock(m, i) do { } while (0) +#define ldt_downgrade(m, i) do { } while (0) +#define ldt_set_class(m, n, k, sl, i) do { } while (0) +#endif +#endif /* __LINUX_DEPT_LDT_H */ -- 2.17.1