From patchwork Mon Jul 3 09:47:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Byungchul Park X-Patchwork-Id: 13299818 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 793B8EB64DC for ; Mon, 3 Jul 2023 09:49:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C88AF8E00A3; Mon, 3 Jul 2023 05:49:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C37C88E007C; Mon, 3 Jul 2023 05:49:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A62C48E00A3; Mon, 3 Jul 2023 05:49:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 9893E8E007C for ; Mon, 3 Jul 2023 05:49:46 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 1E218160906 for ; Mon, 3 Jul 2023 09:49:46 +0000 (UTC) X-FDA: 80969828772.09.6DECFB3 Received: from invmail4.hynix.com (exvmail4.skhynix.com [166.125.252.92]) by imf24.hostedemail.com (Postfix) with ESMTP id 2E2E418000D for ; Mon, 3 Jul 2023 09:49:43 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=none; spf=pass (imf24.hostedemail.com: domain of byungchul@sk.com designates 166.125.252.92 as permitted sender) smtp.mailfrom=byungchul@sk.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688377784; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=wYwglYqfeifxk6lW+gBTi4yrQI/O7ARWxzTDfqjUyi8=; b=6yOrxOsLIEsjeqynd/uYb5mbsyvT/RzBKBYYhEPU4NzueYS70VPltcjgPie0az2rF8eOOK oq3/QenpTMQhHWycLt4xdvarmenM1q0MAYONoVUzbvkxXQ2A6CoTWiOXDb6H0+BsQLw3sD w/98istJQ2o0qiqfWQPJDIXMerfY3BE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688377784; a=rsa-sha256; cv=none; b=KUpm+FzQg3slpiXYowI/z2b0GWlDcp0xitZvESUBzy243hQkv+f8GzHISMzAk5SLOi1t7/ NZkvcxCpfOSs+FtfVmdDqArOmyLXbkXtoAq1UIVtBTDJS6u1ILb2Z8Pxk1YQx8QzAOXXGg pj0t5TVx501p9f3GiUKZy1vhFVTJfWo= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=none; spf=pass (imf24.hostedemail.com: domain of byungchul@sk.com designates 166.125.252.92 as permitted sender) smtp.mailfrom=byungchul@sk.com; dmarc=none X-AuditID: a67dfc5b-d85ff70000001748-16-64a299b26989 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, viro@zeniv.linux.org.uk, 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 v10 rebased on v6.4 04/25] dept: Add lock dependency tracker APIs Date: Mon, 3 Jul 2023 18:47:31 +0900 Message-Id: <20230703094752.79269-5-byungchul@sk.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230703094752.79269-1-byungchul@sk.com> References: <20230703094752.79269-1-byungchul@sk.com> X-Brightmail-Tracker: H4sIAAAAAAAAAzWSe0xTZxjG933n2krNsQM502SaxlswU9jQvC7TkJi5E2cTdYlGiXHVcwKN UEihINvIKlTFC0xNALlEobraAAqcYsYmdRUmiAToRqNgapWLG8RyCa4VBN0KxH/e/PI8T568 fzwsoW6klrF6Q7pkNOiSNLSSVI6GWT+RS6xitKV2FVw8Hw2Bf/NIKK+tocF9qxpBTcMJDCP3 v4LHQT+Cmc5uAooL3Qgq+58S0NDqQ+C059DQM7QYPIFxGtoLz9GQe62Whj9fzmLwFl3CUC1r oeOCFYNr+h8SikdoKCvOxaEzjGHaVsWAzbwaBuylDMz2x0C77xEFzifroeSKl4YmZzsJrY0D GHp+K6fBV/MfBR2tD0hwX8yn4OaYlYaXQRsBtsA4A3+5KjDUWUJFp169o6At34Xh1PV6DJ6+ Owju5j3HINc8oqEl4MfgkAsJeHPjPoKBglEGTp6fZqDsRAGCcyeLSOh+20aBxbsJZqbK6bjP hRb/OCFYHJmCM1hBCg+t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DlpRXD2dAEFT34+pMHcFwMT30vxqliheWSU FMx1RwTXWBklPKrghdvFLxjBfK+XEcqkVKHOGSFUNg4TQvkXPy1IVdlYkL7kM4Llg5cQPra3 M0Jr4QQlvPbaic1z4mXLNaJOmybql8btlSWaA9cdGgpLv+w2IiOqVlhQCMtz0fzLxgI6yJhb yPf0jJNBDuXm8XW5bwN7GUtyZ6byzk9tOBjM5LbwWfeDJZaluHDeYfyLci6Gl4w7/ynn8tXX 3X81Idwy/s13KwqyIlDpK+rH55CsDE2pQqHalLRktVYXE2k4kJiRok2PTDiYLKHAyzhOTOY1 oG9d65oQxyLlNHnPsXKNglanGTKSmxDPkspQuWngokYh16gzjor6g3v0qTrR0IRms5QyTL5+ h7hXwe1XHxYPiOIhUf8/JdiQWUa01RW1ulS1afriwvqG2043O0f27Piz2p/ZldHeW/mOnCvS Mut8q27S2Jl+bP7Xys9Y77HdNaqidtGLfNsTTL7VhTtGh1QXLb64BFuBJWnrhuTupKTd7e1h kWERSeH7btp7J351rqmKt0xdMTaDu+/L7lmbsK8ornhlbXyDJnPbgi1KypCoVkWQeoP6D0Di ZREuAwAA X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 2E2E418000D X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: ih7znd7f4d7uh5jpo4a5u7bfaarqtz5h X-HE-Tag: 1688377783-979450 X-HE-Meta: U2FsdGVkX1/T4vafBESuzyrlTsJPmp04Kpnw12N+5LM9N7133Dg+deBey4aX1AYtHYBVnkXLZ64CTJC78P5gT7FWRsdJ1QsVI0ogsVzXcZt5Z1kqhv/1peyy+jcIIY4YHnBqa42uZxyfabpKa9rBythuFXlsDXZjkUnHKsTkTREDhzIWWUkM90cerFLvlDoJrDUC3Vy/ZTVatUc4isz7GxxFQanYqgQUvHNLrYGZYjZNtQ9adyXRP+vk4GnDF2kkTpaoFXcvavQeqOt/0D2sj47dPXtES0O93Z6GhDK7fRIR3IZKt2Wc4fqe7D+i4pJ0FdxmqXiEjPk4+Pwz10141u7t88VF8cJFmoO1CahLzJs+DI+6Q40mSqBybHy6rZOQtzfKxERkxlDVRU+8FQLhUWXW68ygjZtrRkYInLDFVaaRUioao5wk3XFAqTmBMPQJd+h4Qc6CJ1gOykMiQTmXAL6LU/iIR6B7cv3oSJVuydhPK+eMjaA0YKPAIfx4yxPTdcOzm8vu/jYsmytLJkWJckl7nHts0/5RnvS9jHMJERwBxc2dBtwMnKAelJZmA755CvtRjZfDhQb/E8i0Bgq/x+qt0YyWgQ6vpo6oyW+4PEIqq3aqAQy7gtnjwuWr6qmtSSd9ykMbDs8ta0QU8PxeAzyr7oipJmkgYnzL+BXHy/NkWwGhqZi+pTho3ftgVDKkKJP6CSJYVWpBsC4S9OipAb8hieA0d/LRSTsto2zomxoSszRqjTZaVmVgMaGbdFqv4/fqVptzW476D/4NltNUuroDq+6n+AmSok1LBDF690rCTBYZd/4M4ynQ05wyf6k194i+TzCXX/C7f8tD966oVkPMS3zoc4Oi9xjG46zMm/0uB7gsqVbquDisj7aFZHS9Y9uM0NL1q5q162Fyov7zqScJtTV+/nBctXvsQirZFRMF4MkccJ40Mm8+kA8wu3ksitq+zbwGGcS3xIYwH6E A7HSrY0U 1hB4j1fwtGNPHUdNgVMzn2XBIpAGOempOQyeK8E/MW1B+CgP9HhEMeMN1+NX597UxqIxBPBIhWWBawBSkrCRbl1O1jQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 */