Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp224816pxb; Wed, 18 Nov 2020 22:26:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJx8ypcgL38+7JN7g6uBkrWXaO567P0w+sFbRJz0j4MOoUzJECOhM+Kb5C/UI147mhoz0oV+ X-Received: by 2002:aa7:de01:: with SMTP id h1mr28878372edv.269.1605767177938; Wed, 18 Nov 2020 22:26:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605767177; cv=none; d=google.com; s=arc-20160816; b=c8CYCiKhbrNLSCosA7uOdrOzLux13O32uzVH9xGwO9HNXrVkZ/iPrrHqD6OFu49xps R8KZESSnIquDwUV4O7R86/cqbr1P5A6FDEE0QI+dpMbYxYHcl4zqORQiMknKewsvNr1T CUaz0mHyeLrfOLPYMiMkb6eB1vj5W4fngYXxnxXYt1Ddy0AOe+KV0MhqpP+mwoRUJ0/t n1BLxfZIc1/s4fD4k1W0JfukXSQ/he+rxNcy6gGkfDaz5MJUojnfQ1yKaMITxPag0A0n w+pdvzYc09zEwbxqZKRyOTh71zcCkO8HQeeHo1pGE0jBEantArZ+xe/GBtp08FwAt3FR do6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :mime-version:user-agent:date:message-id:subject:from:cc:to; bh=Wui6VCoro/aZxCZuw6VHnHA5Fl//IUSeXl789+ScsLk=; b=KPpFqhv4wvbDxFop4F+nG4y6PtFkK08Rq/piSnxiBH0jWi2jk6pyyOMwrkMlxGSp4s z17CLgitfS6zZmfUrjdRHkNp+c0qq+2Tj4Cj2RCs0L+yxa/5T1yxOmZV7p2feeUncoV8 i6gde0vqzKnuelz7kck+XUWR2FIs0p5dCE9L9C92hYj1BbAokHzu5rxoO7jShkpQu7vd DMbup3Mw5nDTS6IFeZxg4foHIe0NRR1Qrm383CAr/EkRmbW9PcVkFxpCHB5cSneYSXtp 9qn9jBB8MLM3nvbCMSP/84iIOr3hiiEwsmS7E3ONfRpefTIOEvrDFivMbBF4P7JxazQ0 dgfQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id go10si225265ejc.656.2020.11.18.22.25.54; Wed, 18 Nov 2020 22:26:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726497AbgKSGVi (ORCPT + 99 others); Thu, 19 Nov 2020 01:21:38 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:7557 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725816AbgKSGVi (ORCPT ); Thu, 19 Nov 2020 01:21:38 -0500 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4Cc8hD2jrkzhcmG; Thu, 19 Nov 2020 14:21:16 +0800 (CST) Received: from [10.174.176.199] (10.174.176.199) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.487.0; Thu, 19 Nov 2020 14:21:26 +0800 To: , , CC: Shiyuan Hu , Hewenliang From: Yunfeng Ye Subject: [PATCH v2] workqueue: Kick a worker based on the actual activation of delayed works Message-ID: <3837a2ee-f3d5-2732-7d15-7e9616319f05@huawei.com> Date: Thu, 19 Nov 2020 14:21:25 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.176.199] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In realtime scenario, We do not want to have interference on the isolated cpu cores. but when invoking alloc_workqueue() for percpu wq on the housekeeping cpu, it kick a kworker on the isolated cpu. alloc_workqueue pwq_adjust_max_active wake_up_worker The comment in pwq_adjust_max_active() said: "Need to kick a worker after thawed or an unbound wq's max_active is bumped" So it is unnecessary to kick a kworker for percpu's wq when invoking alloc_workqueue(). this patch only kick a worker based on the actual activation of delayed works. Signed-off-by: Yunfeng Ye --- kernel/workqueue.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index c41c3c17b86a..b3c9d6ef7c69 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -3725,17 +3725,25 @@ static void pwq_adjust_max_active(struct pool_workqueue *pwq) * is updated and visible. */ if (!freezable || !workqueue_freezing) { + bool kick = false; + pwq->max_active = wq->saved_max_active; while (!list_empty(&pwq->delayed_works) && - pwq->nr_active < pwq->max_active) + pwq->nr_active < pwq->max_active) { pwq_activate_first_delayed(pwq); + kick = true; + } /* * Need to kick a worker after thawed or an unbound wq's - * max_active is bumped. It's a slow path. Do it always. + * max_active is bumped. But in realtime scenario, kick a + * worker always will have interference on the isolated + * cpu cores. So do it only based on the actual activation + * of delayed works. */ - wake_up_worker(pwq->pool); + if (kick) + wake_up_worker(pwq->pool); } else { pwq->max_active = 0; } -- 2.18.4