From patchwork Wed Feb 21 09:49:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Byungchul Park X-Patchwork-Id: 13565290 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 8F498C48BF6 for ; Wed, 21 Feb 2024 09:50:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6C1CF6B008C; Wed, 21 Feb 2024 04:50:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 559466B0092; Wed, 21 Feb 2024 04:50:00 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 336A46B0095; Wed, 21 Feb 2024 04:50:00 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 181A06B008C for ; Wed, 21 Feb 2024 04:50:00 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id E41ED120189 for ; Wed, 21 Feb 2024 09:49:59 +0000 (UTC) X-FDA: 81815339718.02.3EBBE0B Received: from invmail4.hynix.com (exvmail4.skhynix.com [166.125.252.92]) by imf27.hostedemail.com (Postfix) with ESMTP id 0AB0640018 for ; Wed, 21 Feb 2024 09:49:57 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf27.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=1708508998; 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=0Bphe8yoMuGLh9s0WEaR0ZpIp2nXoxSS114lmIVP6GxnfQfafbT5Lm85F6qxIbhFOmzXg0 IMPzWSx+d2eH7aUSanfWwFRhbuJ5P2FS39AB43hQ+tk0uj2NKutbtXRpco2SAta7QZlUYn X6CqlW5hrfleZaXN8xhMQyGPS6UDuJ0= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf27.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=1708508998; a=rsa-sha256; cv=none; b=INJjnCmvnI5+Pf5Q8ZcviSr+bAsK50hCHxZmpB+CRGicu50UEyLMVNIAi0UO0p/kaXHKtY /RFwa+ubZzkkCdUvyPtNNW7/f9xHUFj6vTaumC3oznH360FOcDash8g5Zk6rHi4VAEMsbx /iWfGgnUx0tP85DFwF/KXSFS3p1AidM= X-AuditID: a67dfc5b-d85ff70000001748-48-65d5c739e041 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 v12 12/27] dept: Distinguish each work from another Date: Wed, 21 Feb 2024 18:49:18 +0900 Message-Id: <20240221094933.36348-13-byungchul@sk.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240221094933.36348-1-byungchul@sk.com> References: <20240221094933.36348-1-byungchul@sk.com> X-Brightmail-Tracker: H4sIAAAAAAAAAzWSW0yTZxjHfd/v2I6az4L6TWM0TZxRAuoA84xsi4eLvbtYYmK8GRejjk+p cpCiHEwWUaqyIgxYEAfEcFhqgTqwRQWkWDGCqIV2VDkjoE47wBLWdquwQ6vZzZNf/v/8f1cP TynbmXW8Ju2EpE1Tp6hYOS2fD6uNiu99Iu0YKsVQenEH+LwFNFQ3m1hw/NKEwNR6BoP7/hcw 5J9DsGQfoKCi3IGgdnqCgtaeSQRW41kWBl+sBJfPw0JfeSEL+fXNLDhnlzGMXyrD0GT+Ch6V 1GGwBV7RUOFmoaoiHwfPawwBQyMHhrzNMGOs5GB5eif0TT5lwDoaCT9dGWeh09pHQ0/bDIbB jmoWJk3/MvCo5wENjtIiBq69qWNh1m+gwODzcPCrrQZDiy4oOv/HPwz0FtkwnP/5OgbXyG0E XQVTGMympyzc881hsJjLKXh79T6CmeJ5Ds5dDHBQdaYYQeG5SzQM/N3LgG48Dpb+qmZ3x5N7 cx6K6CzZxOq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qtExiUGTNxmL3zEoE59SsNyZdnaNAlpCJISb5KQMevRhKShvxg7mcutdOfr5+w4HxS 2Rm+elpP8C35HP8kZ5jmk2oGaF5vjOHLCj34gqpxjM/7biV5Y9Elijd+19K8+qsJ47+1t9N8 07U5gn9vysICVx4VbQ8RwmWxgtx7R5AoNKfLgk5/XhTXX3kFV6G7rBoxDMf6ch+mnNTIgaHY tVx//wxuZxfWlSvTfCTVSMTg7AVHrnCyjbIPi9jd3KBKS9uZYN252YpU3N4Rs5u5ya7Fds2x q7jiB7X/Og42fVc3QdrZmfXjerse4WlIpEcLipCLLDI2QioL9/NShIUqI2VxXsFREUZkexnD 2fn0SjTVs68OsQySLBSHPjYJzqQ0VqGMqEMcg0tcxMQZmxKHSJXxgjzquDwmXFDUoRUMIVkq 3n9YCHJmT0qjhTBBOC3I/68Y47BchTIeBWd0H5kclb1oLW3bEljhL1buGR9ep3+77Lb/2HFJ svcuh4LZBbLRIl1B/OD6JcdCtgSZW/I9HeVrNmrWZ7/K9VZZPvhoyoN/HZS47n1+o8Vt0K34 gtot8YCnV9wJz6hV25Sn7ufNa31zDqVpzwWsximXSknbzZR4devY75i3ZJWEUIRKfTxwuUL6 FwSUBtwuAwAA X-CFilter-Loop: Reflected X-Rspam-User: X-Stat-Signature: bcpydza9f46b74tu8xtfr73r58nucicf X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 0AB0640018 X-HE-Tag: 1708508997-601813 X-HE-Meta: U2FsdGVkX18bsF4M3bG/5/5LWZF/zoBSVMMB1QzjPKbDPFVVK7A7Ep6qYkNA4egoRbeK04LgCUY+mEuQsVgwZLWwUfhPoQzaB0YuDYWw02nelkva6oLEbpBXJV065VkxcvaeM9SVWIsc4Y6+GlW0YIbBpYWrNbIE7GblQFtqWXBjxFAPFhsNXoZpncSB0OAseA8iVs8QFwQS+BJsLQCMUBLEhnwVS08nN8It1VI1ViPGtZB0YkxzDhUksh3g7LqmIrLvDagWkACejJRTya/GG2iObxR3fw2Md+g8mfXTBzrrxXewJjhlzlS5x7uYx5quy/uLwQ7XfIUGWJ6wky08GteGZZDuA1S8gjEoWBb56vJjhUa/x0sv5T9vvxs94NeeByxGqkt4I6AOiBc3MSnnqHki5nvJamjgMdJXP+AqN/2c5ULsezHEHc07fCcgYbcBWr8okT3eh3rB/ynQYVhtFV+x9pIB48eoxWNePn8WacXYIqq32fliZWnmU8HFcta5Wm3IST9SaXaVI3mjDGiSYbH36U7V3i9EpO4JAOiOXJicYhP2z7xYHUxQv7BoOvkIRzx+DvarxhVmpQk//AOUTjH9xu3eJLplt8zLi2NnyBabS5h+9T14GiJqh50BrVYqt6esP75Chw/ksDzvX9We3PvWYaZC3s/SeWNL5sQKiH0xGVxzwDHmJW78TeRt3yIUYKZOUfsRXMJ95XcNbchDxHeC+eptrZSyjAyffw5d6ocusxMj31uXPs9tvw2MzXOlcjJ+mEW1pL66k6HZSH03loO1gUKeTpvCsfKHAHAMK+U6prPTjBK6oIRjom6z9xTM3uyW6TYXvFwb6oRF6xcIlO2JO0gUL6ZRGq1FUG0PD52/CzVGMbPmhJCZFFpxIW+vJgtCMrc5/Gkes3zP6AgIjh2cWMiXkEkFgErp5FYaCt0kVPashxW58SCGQ9LXObI4jM1t3eCo+byn+qv3iL6 0n7F1rm6 O5+42/Uz0qX1b3cfF8nKBuZ2bs7V8K3tYTyjCRHBfGa9vpcuUWxwVys7jEk1UxneCmGR0 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);