Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp2672210pxb; Mon, 11 Jan 2021 16:45:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJw0jvlAf/rMDHgI4fxGyPQWRjhHy6iFUVYr0SsjSl/jYb+wxSr/qDFuPR2ZeQKpJ3NdSXaA X-Received: by 2002:aa7:d916:: with SMTP id a22mr1390966edr.122.1610412340035; Mon, 11 Jan 2021 16:45:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610412340; cv=none; d=google.com; s=arc-20160816; b=v1b6H5/lIGo6MHblQJVoZElwSBgoDoB6Q4qHApjgrkTOqTLVQAKV0tf5ssbHZr6h4l LmMFW6P7TlZI8rARIRCQZxdtjZyCiN4kT0OLvL6jNWv/+QPiwr4iCywq26lUSES0EkSn pOUfMqfHlkIH04MzZFas2U3o3HOPP/oB760WaiJ2OV/TCrfsVvMVOoAvolO4aseOQKyG 5l6mS1iizS3Wpfu8bCj8Uv+2Vvy/7qTUqOuor3WsQgxE3AeSUc7qoPQd9q5OEWIlw81S 60ie8V0RJkku/T8+FztCbPuBrTGI08yECpD70gFuzYDLMKSPpQWmoex49WXTvGFtzIUY YkzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=g4g9UvuZqb5QuTQUvrUt+AOzG9Bnn6t7VISrZi5p4os=; b=D6sZUEm/NVCY1qMH7fsVCcr1EowbwRmN9nHJwdjQluI3U7uLSeg/WXhFGDhPzNCT79 KjIM++6uooCbCfjrHZ3CC28qnfjOixsH1ZE9KwX4b4kLYlKDUMtNWp9eN+69fvacuFHX mgHfZE/DVEjVIjlyykDcgt3WQJ2WDXHQT45cyXh0X5j6j+SQAGibGKCtZWaRU7ERN0R/ XVJxXxtNJJhqqbs7j9CZkDoW+7DhSTiUZv0j/87+wJc0L/G8HiVCIiIhl4LMPI43bDw2 LyHMqSHJSr2hofEAGanjIOEXu645GUJnQi7bqrlQcnWR75QML7prfNXBTUkFw4M1+jb/ p9JQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=aGl27pIw; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j26si543109eds.457.2021.01.11.16.45.16; Mon, 11 Jan 2021 16:45:40 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=aGl27pIw; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728873AbhAKNB4 (ORCPT + 99 others); Mon, 11 Jan 2021 08:01:56 -0500 Received: from mail.kernel.org ([198.145.29.99]:48856 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728285AbhAKNBa (ORCPT ); Mon, 11 Jan 2021 08:01:30 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id E87CE22795; Mon, 11 Jan 2021 13:00:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1610370027; bh=rwD9k7bQQnO3THoOxfPHyhYKcGlat+o94zX7/ZLDhFU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aGl27pIwm9/PVjI4xeCO6npNkvYwXq1/cWFcNZWtmMYIEkCh45xXEefj+Alk1AMJi hgOAXpJ06pPpBm108gXEii14+5JdPR4cpyg0h2d7nnyux8AyQhRMm52zpjVVP5xY45 ZuhS99b6dF+VHlLGezBq2Y/M9wtI3WDaiq1iOQrQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yunfeng Ye , Lai Jiangshan , Tejun Heo , Sasha Levin Subject: [PATCH 4.4 02/38] workqueue: Kick a worker based on the actual activation of delayed works Date: Mon, 11 Jan 2021 14:00:34 +0100 Message-Id: <20210111130032.588245581@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210111130032.469630231@linuxfoundation.org> References: <20210111130032.469630231@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yunfeng Ye [ Upstream commit 01341fbd0d8d4e717fc1231cdffe00343088ce0b ] 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 Reviewed-by: Lai Jiangshan Signed-off-by: Tejun Heo Signed-off-by: Sasha Levin --- kernel/workqueue.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 3fb2d45c0b42f..6b293804cd734 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -3361,17 +3361,24 @@ 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. In realtime scenarios, always kicking a + * worker will cause interference on the isolated cpu cores, so + * let's kick iff work items were activated. */ - wake_up_worker(pwq->pool); + if (kick) + wake_up_worker(pwq->pool); } else { pwq->max_active = 0; } -- 2.27.0