From patchwork Mon Aug 21 03:46:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Byungchul Park X-Patchwork-Id: 13359066 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 B24B0EE4996 for ; Mon, 21 Aug 2023 03:50:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 901D194000F; Sun, 20 Aug 2023 23:49:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 88F99940010; Sun, 20 Aug 2023 23:49:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5CBF094000F; Sun, 20 Aug 2023 23:49:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 4AB5394000C for ; Sun, 20 Aug 2023 23:49:55 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 2D7791A012E for ; Mon, 21 Aug 2023 03:49:55 +0000 (UTC) X-FDA: 81146733150.20.5D40D0C Received: from invmail4.hynix.com (exvmail4.hynix.com [166.125.252.92]) by imf05.hostedemail.com (Postfix) with ESMTP id 6477D100002 for ; Mon, 21 Aug 2023 03:49:53 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf05.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=1692589793; 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=B0TNvH4/grahfflbZTO38DOoEo9g4B+0IkW8HFlPE8cOLdr/dq/w5A6nfItTE+lbF8aqlF 3fQ28yLW+pnojcugmi+9dsQ3C9+iOjKd9OxYbu7nM0HkRarf/kKfaBvw2lgC7Cji2DCD5J yOjGDiIq1QLw+oBQ9FpAOkWPFxi08hQ= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf05.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=1692589793; a=rsa-sha256; cv=none; b=Rc+5tangrKWQvFyTRBSK0630fktZgmbm9PgBpBN+Tqh0ApRHL2v9TeggZT8Q6NmapYVYkx mccrYggoNst5X2RnGyTJMIz+YpvxnxMu5F56yQOTJ4XnhYlFrcWb4P/jREPWYI68zdE4b9 48NJClwkmhPNfp76jLtwXPxHl35P5V8= X-AuditID: a67dfc5b-d6dff70000001748-bb-64e2ded5b546 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: [RESEND PATCH v10 13/25] dept: Distinguish each work from another Date: Mon, 21 Aug 2023 12:46:25 +0900 Message-Id: <20230821034637.34630-14-byungchul@sk.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230821034637.34630-1-byungchul@sk.com> References: <20230821034637.34630-1-byungchul@sk.com> X-Brightmail-Tracker: H4sIAAAAAAAAAzWSbUxTZxTHfZ77VirdrkXdHWyZa6oY3RCMmpPhFvaJGze3Je7D4jRa7XVU gWpBFCIbCDIQS4AM2ISYUknXQDfwFhRBCC8KAhMqVEQDlXZG5J3BWuVFthbjl5Nfzv9/fp+O hJDXUYESTWy8oItVRStoKSmd9C/9uN/hUofWZrKQdykU3P9mklBSaaHB9mcFAkt1KobRO5Hw 0DOBYPFeDwFFBTYEpc4hAqrbHAgazOdp6Hv6Ftjd0zR0FGTTkHa1kob740sYBgvzMVSIe6Er 14ihaX6EhKJRGoqL0rB3PMcwbypnwJSyEVzmywwsOcOgw9FPQcPjrfDblUEabjV0kNBW68LQ V1dCg8PyHwVdbXdJsOXpKfhjykjDuMdEgMk9zUBvkwFDVbpXlDG3TEG7vglDRtk1DPZH9Qga M4cxiJZ+GlrdExisYgEBC7/fQeDKmWTgwqV5BopTcxBkXygkoedVOwXpgzth8WUJHfEJ3zox TfDp1jN8g8dA8p1Gjr95eYjh0x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5WUS8DYjUcIXOc+M3A6Y5SBy4nnEKSfvkBC66/HFCR3q2D8ZwG9fo3QMDhE CMlVxwXbSCEpPC3mhTuXehghufYVIxRKx4Sq0qXCNesAFoq+eShBKkulBelbDiOkfbZj4UtL CyM8yR8nhT57Ht42f69srUaM1MWKhpWhETJthcVOHHX7mLqq5yYgiUtD3izPBfNPK8fJKaa5 xfyLF6PEFPtyC/mqzPdUGpKxBHd2Bl/qfkZPBT5cGP/wwfPpB5JbxLcmjqEplnOreKe7Df+T LuDLK+umRd6Te+ne3ekbBafivzrfkVlIVoi8ypCvTh8bpdZFqlYYj2jj9DrTioPRURKa7Iw5 fiK7Bn3v2FyPOBYpZ8oj5rs0Ckoda4yLqkc8Syh95f4/nBqFXKOOOyEaovcbjkWKxnrkz5JK P3nYbjFCwR1Sx4hHRPGoaPifYtZ7XgKK35lqDNMWXY2pcERbw1XNczaEttSaAiXbrhv3vbT+ S2T5+1rbf3RaV38I7T+ZsjLg/MbtQ1alaZbjys5l1316Vg8fTMqKCdrb9zp6q3xsj76hxBTu Ffx2x57+JeschpAD5l3DmeaS2Tl+8Y1vfoW48zdZeg6nn2IH3B7DclET4n9TSRq16qClhMGo /gv9mtivLwMAAA== X-CFilter-Loop: Reflected X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 6477D100002 X-Stat-Signature: bo8gz3wbqeaq11bgu93k67jear89dngs X-HE-Tag: 1692589793-637423 X-HE-Meta: U2FsdGVkX1/Hg+YD5yMlG5TZMWl+PXKg2AOBWsGLzThbuvKC18+h4ej9IuwxV4rNNpmVwsWSpSMIq2DGx7XsK6+FfsFPm0eidkrHpbqhpT4JiAilsBFRs6rMmjM1N/Bv7uO5ofJO7Ot8zvjEoeCulzjYEf9iriGzD0e0+EKI3SgTS+MwoM/PJIdjwuF5hV+cD08XGnQt/zcjO0T1wW+tYMoKqF504iOXTUDVcyaNVYsNEBOmZ1e9IBQTNi2RslJ7GgpD9riExcurZjwS8mQv6VpMm45f9WmTmPAac4agITrxA2sBbV47GpUxPpOX7HTkVnb7Nmx1wv9GmABZHFgqPObrME1euvBRwkxa6T7HigFRRTkezW8WbWFCTsfXPLXBsu7YOnoHlI8/cQnT+/eeQ3Sbo5HeBV/AbFS+xWLQB/+zfGrfJQZQiKtkWxgBMSieHt37jWMmukjU+ODPR32SFBM+QtI5+KC+9xWZRgNZc9UOuWJhznHkYiSQet2M007LRPIPmb7Vg48NPhmnEK8tA/ww5CjJ8+8yA05gL1n2nnEtQNyjwN6EdGUoDbamTQ+IqmM8blH6Ap6norVSVhSlAfDQV3O/RFz8fBnwOdoDcHCyBfGyIfwEA69NUC7GEcdFelEM7tZZySzyS2nRWzeUnjPjOLTAf/ak3Uel9DEMRb0zTMOQh7qNXRFXnklFKwFgtdRucB8J1k08Tn3APlrk1j2uuHBsTReZQREbykNDvmHmTUeau2NNYlEByCcFd+VlU6Ousq/I+QnMmim/Bw7+Mw/dmpsC43heyDVDnJ9TGCxIvJ5SJvK/M3p7TCOIfQ1+nHiCE4A+uz2yaDGk7K0NRr+Mlc4NrZNvYQkSDKbeES+ecwV94YDIOLpWQvlxBw4IcfudhBbr50EKym/jSBV1TUXge9fFchXmKIEqdbmJ5vQPSsgapbFn/o12eIadmCiqzJIo2O7LFpWTmqnfqIt AjsPqzni +r3hUj7tO/H7H8Sa2kO55e5ORnalEOxpkqGWxWduL3OZPDzQBWA9tWrmEzA== 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);