From patchwork Mon Jun 26 11:56:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Byungchul Park X-Patchwork-Id: 13292764 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 98294EB64D7 for ; Mon, 26 Jun 2023 11:58:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D0EC18D0006; Mon, 26 Jun 2023 07:58:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C98EF8D0005; Mon, 26 Jun 2023 07:58:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B11908D0006; Mon, 26 Jun 2023 07:58:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id A1DC08D0005 for ; Mon, 26 Jun 2023 07:58:43 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 423D1120139 for ; Mon, 26 Jun 2023 11:58:43 +0000 (UTC) X-FDA: 80944752126.09.3B47481 Received: from invmail4.hynix.com (exvmail4.hynix.com [166.125.252.92]) by imf06.hostedemail.com (Postfix) with ESMTP id 44D0D18001E for ; Mon, 26 Jun 2023 11:58:40 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=none; spf=pass (imf06.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=1687780721; 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=nzq1iQorpnCm1CnU3kQrvmy2yZbWgR2lNyJeWAt+yA7RXCFl8mOBvZ1HnDojhU9B1ADxkg ove3PljMzGSyu2QfuXsazOBFzgpIMaeOAYauhPb5Ems7Rk1plYLyk9W0KeUq/sKTIxgcNZ ZbBGUjtlHa/FFQG11CrghE4qnI9q+vk= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687780721; a=rsa-sha256; cv=none; b=V2ycqZaWLB5Qodpjz7ke7qXu1eOd64FKKX/2fmHuD5MGSwn8ag6zL6t6od2TLUsTQfM1Nr dYsLP2Goj3/keJxPEttZ39jE2cxWY+Vbu08EywXTkdrc6SOEtfmDyL0xKwOQnLsdDU6RjR Dd6qOjiGhBYhxSIrCKNYOlR22IsOH+A= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=none; spf=pass (imf06.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-c8-64997d6b8990 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, paolo.valente@linaro.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 04/25] dept: Add lock dependency tracker APIs Date: Mon, 26 Jun 2023 20:56:39 +0900 Message-Id: <20230626115700.13873-5-byungchul@sk.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230626115700.13873-1-byungchul@sk.com> References: <20230626115700.13873-1-byungchul@sk.com> X-Brightmail-Tracker: H4sIAAAAAAAAAzWSa0xTZxjHfc/lPaeV6knH5IhGXRMz1MDQeHkSL9Ho4vtFY+JijM5oZ89G BYppFcFoUqGaWsABykVLTC1aCcVbYRsCdRUEQSaXSSpKS4R4oUolQYsieCkYvzz5Jf//88vz 4eFp5b9sNK/VHZD0OnWSCssZeTDCHpt49Kwm3uKPg7zseAi9NTNQcq0CQ8dVJ4KKqmMUBBo3 wsORQQRj99tpKCroQHChz09DVVMvAndZBoYHT6dBV2gIQ0tBFobM0msYOl+NU+ArzKfA6doE rbl2CjyjLxgoCmCwFmVS4TFAwaijnAOHcT70l53jYLxvMbT0ellwP14EZ8/7MNS5Wxhoqu6n 4EFNCYbeis8stDY1M9CRl8PCldd2DK9GHDQ4QkMc/O+xUXDdFBa9HHdTcOLNJxbu5njCdPEG BV2PahHcMj+hwFXhxdAQGqSg0lVAw4fLjQj6TwU5OJ49yoH12CkEWccLGWj/eJcFk28ZjL0v wWt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BSwLsNg+Gdv8oAY12Ewk/r3UiGDnzkYETReMMXMw9g+D0iTIK+n9102D0JsDEjwq8Ya3Q PjpGCsbGw4IjUEUJ9y28cOfCECMY7z1nhCr7IaGxNkaoafURQvUXPy3Y605hwf6llBEKPw4S gtfTioVPDx8yQk/5BLV9/i7ZWrWUpsmStEuT9spSjMHvDryLyL7qNCADqlcUohCW51byBUOV 5BRjbjH/9On4NIdxC/nG4jd0IZKxJFczk3/b08FMFUpuI//C0z7NFBfNP/DcpgoRy8q5BL7I t+6fM4qvb3BOe0K4VXxLnwVNsSJ4kudtw2eRrArNqENhmoysdFGTlhCnS03RZ2iy4/ZlpttR cDjWnMmSZvTNvbkNcSxSzZLHLyhXK2gxS6dPb0M8S6rC5OE/zGqFXC3qj0jazD3aQ2mSrg3N ZSlVhHzrTmmvgtsvHpRSJemApP3fEmxIpAFVz98t9eXnWsUdSeETWXm2RGPH0dW3O22Lw719 s/p9XatD7yqPR/UpyYJHYTGfx+40+5dnig5F2ewVI5c3HTM3aCO2JSVWph81FUV9b1L2l5qu 17gPm0K66UDn7Dnu0NSc0eRywznqdbZjy/rE6N7SQOR+vMj3xrWxR/9yXuxlvYrSpYjLYkit TvwLwSrfujQDAAA= X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 44D0D18001E X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 7kurdbrbfpatxjh6b8escdjtu5z443gj X-HE-Tag: 1687780720-531135 X-HE-Meta: U2FsdGVkX1/HaLR7rQjS38o1hDI9QJRL6XcTpe7QFA2bbk1pNpIt+Zfq1wv/FOSDjkgcu5jVTydaQ2cl2DoKrxyD4S7Pu9wQjVc435mmPPSQ3f1zxG81A4GYr3ZEcd9srZlV5DJQNZLEmQk7hW5RjR/hPobuBvBMveLHo0dOBFz1yq6uAinwPSZaZ75Y0ogqqvljp1yM7Q4/h2wXoun5cWRlFwJC077vITR1+9sspo+/njIJPyEyio7LZRU9Vyc7NorIuzXjq9hLmzL9MNWav/Z284R3t9RXkl6Mndc0/JK+gznAwJFbSw6aY88mPWKXpo4TAaS5yQ3UWNDOKYEa6l++45aiY5z96NfTDVYPBGoUSZYHHKAbbuWD1kiUUk9Zn2MetWecA11E1dvUlswxMgeKRUw24vPYwGTTDs4BMxIswXYM7U3b29Qsp4HVqkSklEkfpy/xkVwwvmYVVnHd6df25keaqUVMwfEfn25Js4gXQx+tUxISGac6b6n15+IfU2JxvBK9vbiB8j1l2t/9XDZ2EgMmNcEsUA5vNBxnIzSIuZpC4/k3Ax/4sknwtaneOvmDdPuRV5RLJAZ68J94SQLgHVATiHKRs2RHHIAtS/V9RTKl5Rrxh+mO6ne+mmmoJGjgsfny6XsEP3nuPDSzx9K6UYWeQ3IuItOQz7Iy9ZOHUlQFnD0/B1v9/FQiIaRwjFMAb3bFq4YmqLu3YUsZhoUfEmu9lbOwKya+vCHPS9pV/cMqdSrW9HyT5M0wZBGq+sMU2dsfzV6uB1i5Yj98kjGkvr/SKUN0yU1xH8RFLIL78qhL0mKh205wkCCi1A8AauIm7KIojJS9fZ3oy1IPsuAZ3s5jp+cHKCUbYhFTYurW9YoHYCpBasEoC57SGSAKUA+0oglYC96Wz9pwDzUX6XW4lqozLB4fH6r0+JrtGkX6e3zrrU429xxCZ/fVlnvwQGm/6z3Y8s+jsn/yrLV Vva2HKWR EwPthAHKqnwikt83W2Sx6JRo8qGZqyPRsIlLLRSEN6JBzCfAjiO5eLA69Y3TyGDhDLrleWlbETd7xg/rpYzQnSUgs2w== 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 */