From patchwork Mon Jul 3 09:47:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Byungchul Park X-Patchwork-Id: 13299827 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 988A7C05051 for ; Mon, 3 Jul 2023 09:50:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 257998E00AF; Mon, 3 Jul 2023 05:49:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 13B588E00AD; Mon, 3 Jul 2023 05:49:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E87D18E00AE; Mon, 3 Jul 2023 05:49:53 -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 D791F8E00AB for ; Mon, 3 Jul 2023 05:49:53 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 8014E140855 for ; Mon, 3 Jul 2023 09:49:53 +0000 (UTC) X-FDA: 80969829066.03.2CBB4B4 Received: from invmail4.hynix.com (exvmail4.skhynix.com [166.125.252.92]) by imf18.hostedemail.com (Postfix) with ESMTP id 6D2901C0022 for ; Mon, 3 Jul 2023 09:49:51 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf18.hostedemail.com: domain of byungchul@sk.com designates 166.125.252.92 as permitted sender) smtp.mailfrom=byungchul@sk.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688377791; 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=3eye6OD1X+HoXy1nXbL8uijgw0gPjqU66lxZMfKwMZU=; b=bD7B1d4GGwd2eBYc8QTVMXW8e/f7eoW+vFkuXDe2bwf6MBx9N3Erg7i90CMjKzoRw9uuwc JJYkT/Dnf5BQNl9npc30GS7WCiOuJPp3r3b7AXuiAMiPiibKKb/44Ri0kjgWeZeAnH61xi uxiN4U2X4D6bpeAXbLlL1SBam/heeSk= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf18.hostedemail.com: domain of byungchul@sk.com designates 166.125.252.92 as permitted sender) smtp.mailfrom=byungchul@sk.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688377791; a=rsa-sha256; cv=none; b=zFYK1SnXWp02TRlHh1zLO58ja7OY4QX1YADqHt7F86GQsvrckcZqcutTNwL1d+ZuXnLtDk pYODt+o5Coc9zM82Q102aBEqhCZzi+d5fo/+MJFOfprtHnnvu8LnR7tAVQBEX+41bahTEI HQfBZs0duqgKbRJrmlP+is8rQvx0Kyo= X-AuditID: a67dfc5b-d85ff70000001748-a6-64a299b3d23d 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 13/25] dept: Distinguish each work from another Date: Mon, 3 Jul 2023 18:47:40 +0900 Message-Id: <20230703094752.79269-14-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: H4sIAAAAAAAAAzXSbUxTZxQHcJ/n3vvcS6XmpmK8ajKXJsbMF9T5dlzmy/yyu8QtTdgHM0xm Y6/S2CIpiKCS4aji0EvQiIiWScF0DXSAt8QgUkUYICJYtUoltZGKYkMRxyyBwWTUzS8nv5xz 8s/5cDhKc51ZyBlTMyRLqt6kJSpaNRxvX+kurTCsDjckwpnTqyH67iQNtloXAW9NNQJX/TEM 4bavoXcsgmCy+z4FJcVeBPb+ZxTUtwcReJw/E3g0MAd80RECncWnCORV1hJ4MDSFIXD+LIZq 5VvoKqrA0DwxSENJmMClkjw8U15jmHBUseDIXQIh50UWpvrXQGfwCQOevuVQ+muAQJOnk4b2 hhCGR402AkHXNANd7Xdo8J6RGfj9TQWBoTEHBY7oCAsPm8sx1Flngk789Z6BDrkZw4krVzH4 nt5AcPPkcwyK6wmB1mgEg1sppuDv39oQhAqHWTh+eoKFS8cKEZw6fp6G+/90MGANrIfJcRvZ 9oXYGhmhRKv7kO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gJuJou1HQib+fInzDXxInPxw/wDat4GwC5C0NfFydkE6th/NtVriZoNrI1Ls2cetMQIttA0i3NZkQP7kT09gSB4nsMXHUm9N/nnBBrAsfHqLRTtfddKSdnvrk/wh3UsaETj5aekOlTnfn3FFWiqKeYGrF/LeZHCn0Kemi9n2/LO+ZBKzVOCUQyP2o3xlCfbZvHDkmbxMUuN8vyF4jQH5bPhUgh5x2b0Bx7ZEV19GUgQVI0L7jCFm9SVUYrKOZkVHW7iY8Cc2pJWg/DHUIRs8VssisAg/WaPlbiOIzwlvDyJEGTS0vBxvYikuPrWRwHSSeaZcZfMV6VldWhcsejhTnA3/XSTTM9fKuZUAVeBQhkyjJJcxTxSOXrKY2vrBhYFb9zh6oRf5F2xVjlI7qBuB3vl3BGhZco/jxV1j45JVqlqiVeEEsVTGOkfBAdE6AqTgx9Va+MS5/ngEb8SrwfHOF3+zFyeZqsAp0qv6RSxM4Buyk6SnsJDtt4mFcc+PbqNbMt1j/k5m+7w8xUgZtynAGauNsMLpxV+2f4dD0MDXZq+7yDD/gdkJZr8ixTPezGvvOhV3nS/h9h6DTwvAV1S0/Jkbm44Jav7KhrXHpxy+v866lowGYwivgpVZdDu65ktXYG2/hHz3qgg1/sid7trIdcZrEj3pNofNul0XpXpgc5uGmol78lmRd V8ILumnt JM4/jGrv+KPZoOpN+qvcYlE/q+/3kDKWcEXVfHty9Bgo5qlkOOEFiJgilvmdwdrLj8JeX 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: Workqueue already provides concurrency control. By that, any wait in a work doesn't prevents events in other works with the control enabled. Thus, each work would better be considered a different context. So let Dept assign a different context id to each work. Signed-off-by: Byungchul Park --- include/linux/dept.h | 2 ++ kernel/dependency/dept.c | 10 ++++++++++ kernel/workqueue.c | 3 +++ 3 files changed, 15 insertions(+) diff --git a/include/linux/dept.h b/include/linux/dept.h index f62c7b6f42c6..d9ca9dd50219 100644 --- a/include/linux/dept.h +++ b/include/linux/dept.h @@ -515,6 +515,7 @@ extern void dept_ecxt_exit(struct dept_map *m, unsigned long e_f, unsigned long extern void dept_sched_enter(void); extern void dept_sched_exit(void); extern void dept_kernel_enter(void); +extern void dept_work_enter(void); static inline void dept_ecxt_enter_nokeep(struct dept_map *m) { @@ -567,6 +568,7 @@ struct dept_task { }; #define dept_sched_enter() do { } while (0) #define dept_sched_exit() do { } while (0) #define dept_kernel_enter() do { } while (0) +#define dept_work_enter() do { } while (0) #define dept_ecxt_enter_nokeep(m) do { } while (0) #define dept_key_init(k) do { (void)(k); } while (0) #define dept_key_destroy(k) do { (void)(k); } while (0) diff --git a/kernel/dependency/dept.c b/kernel/dependency/dept.c index 4165cacf4ebb..6cf17f206b78 100644 --- a/kernel/dependency/dept.c +++ b/kernel/dependency/dept.c @@ -1977,6 +1977,16 @@ void dept_hardirqs_off_ip(unsigned long ip) } EXPORT_SYMBOL_GPL(dept_hardirqs_off_ip); +/* + * Assign a different context id to each work. + */ +void dept_work_enter(void) +{ + struct dept_task *dt = dept_task(); + + dt->cxt_id[DEPT_CXT_PROCESS] += 1UL << DEPT_CXTS_NR; +} + void dept_kernel_enter(void) { struct dept_task *dt = dept_task(); diff --git a/kernel/workqueue.c b/kernel/workqueue.c index c913e333cce8..fa23d876a8b5 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -52,6 +52,7 @@ #include #include #include +#include #include "workqueue_internal.h" @@ -2318,6 +2319,8 @@ __acquires(&pool->lock) lockdep_copy_map(&lockdep_map, &work->lockdep_map); #endif + dept_work_enter(); + /* ensure we're on the correct CPU */ WARN_ON_ONCE(!(pool->flags & POOL_DISASSOCIATED) && raw_smp_processor_id() != pool->cpu);