From patchwork Mon Jan 9 03:33:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Byungchul Park X-Patchwork-Id: 13092885 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 4D1ACC54EBD for ; Mon, 9 Jan 2023 03:33:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 775DA8E0005; Sun, 8 Jan 2023 22:33:57 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7042E900005; Sun, 8 Jan 2023 22:33:57 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3F13B8E0005; Sun, 8 Jan 2023 22:33:57 -0500 (EST) 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 29F3A8E0001 for ; Sun, 8 Jan 2023 22:33:57 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 028D11205E6 for ; Mon, 9 Jan 2023 03:33:56 +0000 (UTC) X-FDA: 80333841714.13.A08AD95 Received: from lgeamrelo11.lge.com (lgeamrelo11.lge.com [156.147.23.51]) by imf21.hostedemail.com (Postfix) with ESMTP id 0D8651C0009 for ; Mon, 9 Jan 2023 03:33:54 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf21.hostedemail.com: domain of byungchul.park@lge.com designates 156.147.23.51 as permitted sender) smtp.mailfrom=byungchul.park@lge.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673235235; a=rsa-sha256; cv=none; b=0njt5jeAYAeFZSuB2jF+1mEKHaX9+edwlDdqGXgmof36MMQJPz/6ll2ewEgN0ozB8W7yh3 RJnQxrG/plMu9j1hI/E9hxp/v0TAXaZxKQ0L/R80Mc8j7CoodxxQpBDx1Xl0W4RF4zLHLp /r9fOO+4A4+zVdbcF3CypojpRqk5Yyo= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf21.hostedemail.com: domain of byungchul.park@lge.com designates 156.147.23.51 as permitted sender) smtp.mailfrom=byungchul.park@lge.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1673235235; 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=L3ppAkq5rLruG+8SPhkPAnZpB7FRHrfSMFk57i7jnGM=; b=riWOEjfVZzPVdbuzd8LXCaEFEU35w/EnInOoeuMtUtm0DG60tmjJrXdWOTsieDPF9tog// FLzM802xlrFLoki81mz8ZSF2o7qNt84A72xIA74c1uLpfafwzW5btsTpR7OyVt8eSBtDnm LsvHq7FZXM4Xkwc31maO+ubHmo9XURk= Received: from unknown (HELO lgemrelse6q.lge.com) (156.147.1.121) by 156.147.23.51 with ESMTP; 9 Jan 2023 12:33:53 +0900 X-Original-SENDERIP: 156.147.1.121 X-Original-MAILFROM: byungchul.park@lge.com Received: from unknown (HELO localhost.localdomain) (10.177.244.38) by 156.147.1.121 with ESMTP; 9 Jan 2023 12:33:53 +0900 X-Original-SENDERIP: 10.177.244.38 X-Original-MAILFROM: byungchul.park@lge.com From: Byungchul Park To: linux-kernel@vger.kernel.org Cc: 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 Subject: [PATCH RFC v7 13/23] dept: Distinguish each work from another Date: Mon, 9 Jan 2023 12:33:41 +0900 Message-Id: <1673235231-30302-14-git-send-email-byungchul.park@lge.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1673235231-30302-1-git-send-email-byungchul.park@lge.com> References: <1673235231-30302-1-git-send-email-byungchul.park@lge.com> X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 0D8651C0009 X-Stat-Signature: torpqw1jkexd9jkipyxgtg3xo9e9g4pg X-HE-Tag: 1673235234-874082 X-HE-Meta: U2FsdGVkX1876T391YtzRtv+XhXSPEXfcaS2bdbmA6vR7/uibVF+psFWKsYnNw9rYA/TyCsCLPwl2VFGRmPmaemZZRyovsB86H8VCvUzx7AfLWvKEVp0pKNhgua2VtgHs+CY9o0ii7LsnvhDp8JvbpQqhmZWInYDx5Ox4ajb3bjb9yT4sYYXdT8Ka0nFGu67TwMwx3u1PFEDeBl7lgO3sQJ+SVp5M/kKguJlg7C8CdmfjnaVIQk0Je9Sg5Hd+XZn6KUd3RGEFCoybrnTDkdtntAq6W0/CehlJkgDJBAVSRQg/ROCHuTKfw5Pa153xyQVxB0rsdRvF+c4KZ7FCrvl1qgym0jWOLFZRBHfGuR5Vr0ms6rK5tfG//7hN5wHr40XDgu3oYi4an6Rc77EGOoQIkd19UQGbvcL15EeOPeiZ3JaSGctvOzrWANtqDgbHRFfdNJ02FQK5nxMLF7PUooL18um3ELvuOenQ1q2hzxzjOUUUIxf25ORqTBgofPKnlctNhhJSiFHqeTkl8mYwUXxtdd/Sz9msjmIFM8FABZkcsvjrSEr1PyrcV0VDSshQRrHXxfCBKTLJMJeELNmR7ltu9Wd3E8CAiLAsIKsZNBYCFPTINAqcB7TmgVAaAutI5FYFCXG3PlbIKHcqusN8A9jZS5DzrlilYSSqaG1SVhkaqtRjGIYrZRr0rIo3RMrGxHfGnbJ/HHJ2ckjIyp/wdpq+noxCdUEaJOKXef3MLyJU5lB8Vpeyi+ggfWrjWoZTxIyjxRwml3Mpi3qB2YaVTA1AEx/3WYiujgx4au9anKTOlq74mFkplc+xWMDe+n3lKTybNDLDkV30t0zRjQEQtR4gA== 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 777c837..625c645 100644 --- a/include/linux/dept.h +++ b/include/linux/dept.h @@ -515,6 +515,7 @@ struct dept_task { 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) { @@ -565,6 +566,7 @@ static inline void dept_ecxt_enter_nokeep(struct dept_map *m) #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 e98617b..2f215c2 100644 --- a/kernel/dependency/dept.c +++ b/kernel/dependency/dept.c @@ -1954,6 +1954,16 @@ void dept_hardirqs_off(unsigned long ip) } EXPORT_SYMBOL_GPL(dept_hardirqs_off); +/* + * 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 07895de..69c4f46 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -51,6 +51,7 @@ #include #include #include +#include #include "workqueue_internal.h" @@ -2199,6 +2200,8 @@ static void process_one_work(struct worker *worker, struct work_struct *work) 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);