From patchwork Mon Jun 26 11:56:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Byungchul Park X-Patchwork-Id: 13292774 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 43573EB64DC for ; Mon, 26 Jun 2023 11:59:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 389BD8D000D; Mon, 26 Jun 2023 07:58:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 176528D000F; Mon, 26 Jun 2023 07:58:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EBAAF8D0005; Mon, 26 Jun 2023 07:58:50 -0400 (EDT) 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 D314A8D000D for ; Mon, 26 Jun 2023 07:58:50 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 9F4668056F for ; Mon, 26 Jun 2023 11:58:50 +0000 (UTC) X-FDA: 80944752420.06.F6B7929 Received: from invmail4.hynix.com (exvmail4.hynix.com [166.125.252.92]) by imf22.hostedemail.com (Postfix) with ESMTP id A06C3C000D for ; Mon, 26 Jun 2023 11:58:48 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=none; spf=pass (imf22.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=1687780729; 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=BvXEQ5ZQ3IP/vpby1IXgyMQtGEDB2fYF+BHL7ncNroo=; b=OvoUT0HA/LC5S3U3eS3k3vgc3ti8VFHgNz7Lri0RPdIiW0z6Q8KkUAcX83aDUP6OPUoBA+ 4P0EBiI8nVLl2EFu8NN8dmFzE5owwQO/8YevCm9Cs+abrv0tC+bRYUZCMphQKur1Owtbln MVNPabOtm6slGeT96Kt0KirQedI906s= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=none; spf=pass (imf22.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=1687780729; a=rsa-sha256; cv=none; b=P62SE6a9ToV1hByjTSCEWpoKm6Q9CdHAU1HxES6lAqvsGRm446VgeHpL7R+5yj/ooAcG3V w9iZuN99a1mpMrd6hGduJpnqwhWCZUQgYex8zYkze16nB8a0KWmeMQ42PSTJg5WBHk01ZO 1EnWQNdMMfHd6WqnCwFqD0e45AtubGs= X-AuditID: a67dfc5b-d85ff70000001748-6b-64997d6ca482 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, 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, max.byungchul.park@gmail.com, boqun.feng@gmail.com, longman@redhat.com, hdanton@sina.com, her0gyugyu@gmail.com Subject: [PATCH v10 13/25] dept: Distinguish each work from another Date: Mon, 26 Jun 2023 20:56:48 +0900 Message-Id: <20230626115700.13873-14-byungchul@sk.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230626115700.13873-1-byungchul@sk.com> References: <20230626115700.13873-1-byungchul@sk.com> X-Brightmail-Tracker: H4sIAAAAAAAAAzXSe0xTdxQHcH/38bu3lZKb+rqiUVNDzPCFBuXojBpN9P7hazOaBTelsXej kSJpAUFDgloXaYUIUguCSymuNlBBCyGolADy9EUdhAEWBOILBUmYrSAIK6j/nHxyzsn3/HNY Ul5FB7HqmDhRG6OMVmApJR0KyF+tSc5RhU6dhoxLoeD9eJGCvBIHBndxEQJH2VkCBup3w7++ QQTjT1pIMJvcCPL7ukkoa+hB4LKfw9D6MhDavMMYmk1GDOcLSjA8ez9BgOdqJgFFzr3w6LKV gOqxNxSYBzDkms8T/vKWgDFbIQO2lGDot19jYKJvHTT3tNPg6loJOX95MFS6miloqOgnoPVe HoYexxQNjxqaKHBnpNFw64MVw3ufjQSbd5iBf6otBNzW+4PeTbgI+PO/SRoa06r9unGHgLbO +wiqLvYS4HS0Y3jgHSSg1Gki4fPNegT96UMMXLg0xkDu2XQExgtXKWj50kiD3rMBxkfz8PYf hQeDw6SgLz0luHwWSnho5YW717oZ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6hF4Mns5OHJymIPcw5kIThzJZuDxWCMLJncYjHzN w6tWkrqefpqYKvYR51ABQ+7ZRHLzfDtHTNUvOFLgSCQVRQtIYVUXRS4OeFniKD6OiWPgNEcy elsp4m6rwqTv0SOONJ0bYTbPiuJXamSd1ijr/wnfxUeXu77j+MGpSZbcy2wK+k/IQP4KUVgq Dry7SY8bC/PEZ8+GJxwgzBUrzO/ZDMQraKFwktjZdJcbL6YKq8X6obMTZoRg8W6jiRm3Ulgm Ztqu4l+jc8SSspqJIX9ffvuBDY1bJYSJqe5afArxBcivGAVo44yxklYXttgQE50cp01avHtv rAP5Psd+cDTrBhpsWV+LBAVST1aGzD6nUbGS0ZAcW4tEBa0OUAZ+tWpUSo2UvF/W792pT9TJ hlo0Q8Gopykjtsm7VMIeKUGOkeV4Wf+7pRT+QSnILPfihUmfjvW1bEiIGcv55vXmbEoM3LP2 0Fjj1k/lgV+uT34ZXD0z8clSV8n8sukR4d7wo+mh0sczUV+K3vBRkZ0kqN38Jz9pvpQanNXm xxxoT00e88uPWMPHTzN0xSy3zltXuSNs5M6WtdvFJZv+2GbUddvv+M8pNEYNWpgLf0d61Iwh WgpdQOsN0k8Tj+VLNQMAAA== X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: A06C3C000D X-Rspam-User: X-Stat-Signature: ttqoqjxixfisdj6cxbioit744aex876j X-Rspamd-Server: rspam01 X-HE-Tag: 1687780728-994797 X-HE-Meta: U2FsdGVkX19LyuaoDsY7pRmTw1roLI9e5woPLCGIuxe1CYV8NDhwdgBvk2qY+A2OMub70F2fzJbLbKqFoTfCeHMIdKq189o35g4FNGH9gRVl+YbVvBJLtfi5rfO2AfYSLNjk9EyZiFVHFboYkXAEnvd+545q/elzTaYgZK/T+CyG55jm+zi9HzFwhruEXwmsbeIdX8fe358O3o3cafnH92XWLZd9iCyGKhcKbBm7eh3xkmToIzpO2g8r+nrukwmTeInLHO/RAsqKuXlmCcNtjMa10/F+HJPqKk4MBz/PyuFb/VG3s69QPI3HaUdl+w/IS9ORSPODNWbmxtDqht3mU4DiQQmAsdvc4W9dPAc4R1L3EFaU9xhfvnTDgHwQVs20qvExPAJvt3n7Nd/ICyVCu4plTSGbU+UirIbDEu9ESfHbkWhSNRsA95KNsWDID2rNTchFsdtAV3lYKUPDwIFoWT3Fwx7FfD1zXE2bq1ku+/M/UzsmpLwRzRhFUkAtNgO0UVO4C84jxSJvglX6erhVib01dE4SrbR7fmsUbXbaEM5ADFGkvlSBcVu1ce5urvy8vCDP3TZ5vjNZUj3SqMH1zLhJ+wEe1YhpFHz/hzUSszxuNlut9LgGm35KDkCxqDlpeAlikLanenje2P0E3S+bHKK/6llHxQiwQhsep1pupaLMvuqk/alEhMji6wfBo4MaVB50pstCHtaOieLqbkUCG73qzlsyh8JJNccKh7wh+P8RJ6yrjqzMUZTBKxv7U9mMiGy3mOrPn5rmTVXE9eFAtni6eQRqXHf8TpaRDmFfjwWtDltwtJ2OSYnnAFbewuPH4SB1gthUhRQtMfFrbGgj7xyFw8cO7m13mj/IJsuAGnmk0bgCbA8T/l61tdOx5VFP3cVsrFHK84q5Qf6CKmFB/8AJLaNK08LlC/eMTUDBkdSDp0QUEiZ44LDljbGuAg33VekrxCxcnE8w06P0vh3 HWshg8HI nOfJO7QElsTYsal1bR70G0U0l3kOqE9tywBHL2wN+kwY5CepAsi+Q/6Ni+7dM25474i16 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 07895deca271..69c4f464d017 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 @@ __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);