From patchwork Wed Jan 24 11:59:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Byungchul Park X-Patchwork-Id: 13529080 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 077A2C46CD2 for ; Wed, 24 Jan 2024 12:00:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 13C9C6B0093; Wed, 24 Jan 2024 07:00:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0EC7A6B0072; Wed, 24 Jan 2024 07:00:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DBB708D0008; Wed, 24 Jan 2024 07:00:03 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id CCE718D0007 for ; Wed, 24 Jan 2024 07:00:03 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id A56174037D for ; Wed, 24 Jan 2024 12:00:03 +0000 (UTC) X-FDA: 81714061086.27.08CAD75 Received: from invmail4.hynix.com (exvmail4.hynix.com [166.125.252.92]) by imf27.hostedemail.com (Postfix) with ESMTP id BC45240003 for ; Wed, 24 Jan 2024 12:00:01 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=none; spf=pass (imf27.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=1706097602; 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=dR3Pzjy2Jj23hEAEpr6NYX9tDj+7L5au6v0rSi3RxIY=; b=iX+RcLc9WfxTbE7c4E/tLkRCxvx1nL6Ph9gMT4C7Ne+NvICYk5uK54v5K93prujBASKW4j m9xp/hgPeRXx9ybhfcGSgojw0lKDn0HRgR+YVUvJ+OSUoAIkOAqNVsjf1ZmOUvvG6bma37 GLYOPh+w12/2mQz3gFXZ9GMBjsk68v8= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=none; spf=pass (imf27.hostedemail.com: domain of byungchul@sk.com designates 166.125.252.92 as permitted sender) smtp.mailfrom=byungchul@sk.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706097602; a=rsa-sha256; cv=none; b=vgHFHyxsFCk46L7nj4H13DrbCAfaRmkYQ8/FxNuaHp4bwzO2CLT8Cu5gMjYqKHJ2r4AzGt hQ93hjUD3y6rDSlIk5UvI7qNtm9JrHwMmDvLNuZgfJLhPXJnDwrsNyL/IG+yMzr9jmP7fj 01WzrGjzf/0dIEdUBeMQ+PR8RzJouSY= X-AuditID: a67dfc5b-d85ff70000001748-05-65b0fbb6d9f7 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 v11 12/26] dept: Distinguish each work from another Date: Wed, 24 Jan 2024 20:59:23 +0900 Message-Id: <20240124115938.80132-13-byungchul@sk.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240124115938.80132-1-byungchul@sk.com> References: <20240124115938.80132-1-byungchul@sk.com> X-Brightmail-Tracker: H4sIAAAAAAAAAzWSbUxTZxTH9zz3tR1drhfjrvQDpsaZsCAw1JywZWKm8ZpFojGLm5poM26k ESqWyovJEhgVEYSKDlFEw4t2pdSCBQ0OqgiCggOqdloJbyUMRAoYtjarMDde4peTX/7nn9/5 cliCv0uFsBqtXtJp1YkqWk7Kp4Iqwu/M1UmRb3vXQNHZSPD9nUtCWa2VBqetBoG1IQvDRPsO eOn3Ipjr7iWgpNiJoMIzQEBDxyACh/lnGp6PfgIu3wwNncX5NGRX1dLwdHIeQ//F8xhq7Lvg yblKDC2BcRJKJmi4UpKNF8ZrDAGThQFT5joYMZcyMO+Jgs7BFxQ4+j6Hy9f6aWh2dJLQ0TiC 4flvZTQMWv+j4EnHYxKcRQUU3JyupGHSbyLA5Jth4FlLOYY6w4Io56/3FDwqaMGQc/0WBter JgT3cocx2K0vaGjzeTHU24sJePdrO4KRwikGTp0NMHAlqxBB/qmLJPT++4gCQ/8mmPunjI6N Edu8M4R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ed5wj6rgwzkHLZy0DemSsILqVcJ6Hl1wsKkntCYMyTT68LExqGHISQ bD4m1LkLSeGVgRce5L5jhOQn3YxQKCUI5pIgofhxPxaKvrsoQTJdpAXpeyYjpA7bsDBitTLC yxtjpPDRlo23+YfLVh8Uo9WJomb5mgOyyNw2B4ob8D3eWZtO6FApl4p8WJ5bxeubb9NTTHOB fGenl5hiP24hb077TKUiGUtw56fzJd+a/z75cut572AvTkUsS3IBfK87eKqWc6F8qSGD+udc wJdVWf56fCb7ipxucooVXAj/3pTOXEWyQjTNhPzUsYkxKnV0yDJtVGRSrPr4sogjMRKa3Izx 9HhGLXK2b6xHHIuUM+TrTJWiglIlapNi6hHPEko/eefcu6JCflCVdELUHNmvSYgWtfVoPksq 58g37RIPKLjDqngxShTjRM3/K2Z95ulQ+LUBa4H/jkdOs2QY0EbJ2rqe7UUTszZvn50Zag8s yJl1dqXFP2frsO3U7pR9o0l+XWG9Vq/kXHm6xRq03TfOEkD2w77S2eHunYoIp2f508TaT2vN 96vbJceGE4sO9Xo6UuL0oYf2hHboKs7DYPrDw57Fo0cD7eRJT17xaJduQklqI1XBQYRGq/oD klMBFy8DAAA= X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: BC45240003 X-Rspam-User: X-Stat-Signature: o8sotkwzd8xj47tz65e5f9z5znch946m X-Rspamd-Server: rspam01 X-HE-Tag: 1706097601-118602 X-HE-Meta: U2FsdGVkX19Uj6RxEbS9gpIRZvI1u5lZQRgugm3ztUW1LvTDTkv5VKBANq6qd1bfDhGW4pCiirGIHe/rzwKClSAkKuSFSmImBTPLKuCz8ihEWwKpNrMBX4MAEvpNwkRkylr7yNjKyqFBo4Oerhi49gbKDVotG49+Wx113UDP58Qte+tXKIISHKAfe3/HaNfnZc/vc1YoankvJXblTYxw1cvRlHgRqMNv6RARWBKyPPKTBWWNc+Sn8ldFJs9dYcuEeuBqcAExBjq3qGLL/tBRZrwIFgA+VyFUvGw4cP2+71AH0fDkLVgjiK6/P6SKuyjYSTk4B6c2knuM6QrjO9WtmoAwLSlxhJrDZ+UUU1EeAY3nIJvb5jb3o8/Tv8edMAIUxSFjWSX0P/LrPwvGE3m+VkJdYcwpU7C28CMnZBymJRP/GxFj4v4COsDaMMI1tziQKrqU/nleC3gGkgBFFyGjoKPtZj5yYg9w7EEj0VX0Vyq3ZqOTfWqyPHDXByS6WA2rCpqRHdLxLN85BjxInK2zUG6nr9cPxevN5E9L64LRAG3YDzd3Tfg4e/+rurC1QA6XT4xPa4wVPs+ZSzpS6QzXB+Z/FnKPj1u5+jDnktXQOQxGkM0vpvLkWMxqaegot1PYu76C0rFYSdNh4qYQa3vMjB3AVA395zf9UXnpqoR9Wo5kgtVu14bPmCxQdr2O40AZ0p8NESJEsKs3I98UstNKHU7+bjRCo4I6DZFsxuq+7HM30+wUBfKB01tG3Sm9nhVuplgjenS6/eRuVkCAvH2E3VOp8/b3VI7sRrTjDm4eAoCdrDpacGFjRlg6EDnSG1mfztH0NCKB1GalHr6dZg2VqepgRpU09PhtML61Sxrgfr98VegH6BOTvL8NlrxuU/yhlRb5t/22krB912veZpWeO6ypYRS4HhsnAN1qUWGiPz6CM6Ddjrnkv3A1zCHKxthsACET3GtNipZhlVX4EMO 19isphm+ 7XJoQBWNqL5sPUmsr/Gwl+Bwwmc9X6VKX5bbAdYn61qXpjnx6+FOse6TQ2RlNxEwwr+i5 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: List-Subscribe: List-Unsubscribe: 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 4e359f76ac3c..319a5b43df89 100644 --- a/include/linux/dept.h +++ b/include/linux/dept.h @@ -509,6 +509,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) { @@ -559,6 +560,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 9aba9eb22760..a8e693fd590f 100644 --- a/kernel/dependency/dept.c +++ b/kernel/dependency/dept.c @@ -1933,6 +1933,16 @@ void noinstr dept_hardirqs_off(void) dept_task()->hardirqs_enabled = false; } +/* + * 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 noinstr dept_kernel_enter(void) { struct dept_task *dt = dept_task(); diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 2989b57e154a..4452864b918b 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -53,6 +53,7 @@ #include #include #include +#include #include "workqueue_internal.h" @@ -2549,6 +2550,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);