Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp9390550rwr; Thu, 11 May 2023 14:21:14 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ71vsslZzsEGnb/RMAERQcqB/Q9ivHFFt52YcR0TPEq7UpuXal+W2DG0PxhjkrrJqVAGl/M X-Received: by 2002:a05:6a20:3947:b0:102:2de7:ee36 with SMTP id r7-20020a056a20394700b001022de7ee36mr10212088pzg.36.1683840074459; Thu, 11 May 2023 14:21:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683840074; cv=none; d=google.com; s=arc-20160816; b=SKCkDM1U/b3p1vvMpIVyw0Q6wiAhDA0QmONpbdnMyp+eVrH0Ov8rT+N7ATIQB9YyVj UaT4Lm7pW5rvqW5sXcAxKTYeK9s5/A6tetw631FgAbY+HlVxuKr6H9a0ta8D8FaYT3ld 1r6q9vp0AzNOU03jDIRj6TSupqoTJdceiHQ7hRg1gGr68lH6o+LIHovOVywWwKF7sdnQ lZR8Wj+zCHPJMzxBxytxuZ7DPvHVDJVj9jNthL7WHBo7AH9VrkWPVe7jWlD8FftyuWdo xbN4uSBrtlo4Vk0JgsVXt5fS26hYb5DQDnRtPu1b67jK5QabakZuUVcRcF8YMuM5F1zv GY6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=BcmV9Aw2E0H6l6GyxDS0g0rL3d0GJwBvc39g/nl/58c=; b=oD/y4Yd6efmJUH1diR1SOFWpW9NnP8ZNURQOEtE1P2LFXcl/NIsfHw/zY0wuRYzm1J JKaSwvJG+xD/bD8klifqkyT6ITMMC8Ws44ThW0AS1nzJFMSg8gRJG5ijFeYV0GCNGwcc /4sTgl6WbZrn82T2GyCUS2amZizS5y10ijQEXhtFZ3LRfth+ZbJ99mi9yPO4BdjuVFzQ wqMpfo6Q/X7X0zqsSs/fKbp+VjoHqsI4CGIHeWmCkbJmT4RXtv/Lil7a0fXL3gh+XCCi 7JwTJhvWK5nbSK5mgYut+gChzzfDLWpLaS49VAjHTCl5OWxfuPoeRq3GsDF2ADkm9v0Q 8tVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=uxbICcvL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j5-20020a637a45000000b005186bbfb286si7975675pgn.308.2023.05.11.14.21.02; Thu, 11 May 2023 14:21:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=uxbICcvL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238811AbjEKVLq (ORCPT + 99 others); Thu, 11 May 2023 17:11:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238084AbjEKVLp (ORCPT ); Thu, 11 May 2023 17:11:45 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD41C10F6 for ; Thu, 11 May 2023 14:11:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=BcmV9Aw2E0H6l6GyxDS0g0rL3d0GJwBvc39g/nl/58c=; b=uxbICcvLBrJHxoL/FLgrkrwOWi jLHAS4MTmzPC4W+Q3Y79tGBdTOJWs01AOfriARjJ+/08ZeYlzqUdKQwDVK83EO/ZZolPApI6Qz15Y IUNghPRpJwbbDbdDD5y6aGPRgVCLdJpg7tLZGXMxsKF5hh9so8UAY0jWo2e1JVTG7AuCVAdZINCDe x2EuRklcEsXP+XJyMj66H4B8AedI3sz5/4CSaiUQiyWDTOm0EseFeLdYcL7JL8kwYll11NiufhC0d SPs88Z+dxP/1pIWrExh8fFq+6FXszev2tQtX1/eCzdbGKBusEnccVdcqXDf+nqLOEGwfQsmIziAFc 66/FPR0g==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1pxDZX-00HZrK-DF; Thu, 11 May 2023 21:11:35 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 595DF300023; Thu, 11 May 2023 23:11:34 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 417CB2C7C5BEB; Thu, 11 May 2023 23:11:34 +0200 (CEST) Date: Thu, 11 May 2023 23:11:34 +0200 From: Peter Zijlstra To: Tejun Heo Cc: jiangshanlai@gmail.com, torvalds@linux-foundation.org, linux-kernel@vger.kernel.org, kernel-team@meta.com Subject: Re: [PATCH 7/7] workqueue: Track and monitor per-workqueue CPU time usage Message-ID: <20230511211134.GG2296992@hirez.programming.kicks-ass.net> References: <20230511181931.869812-1-tj@kernel.org> <20230511181931.869812-8-tj@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230511181931.869812-8-tj@kernel.org> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 11, 2023 at 08:19:31AM -1000, Tejun Heo wrote: > Now that wq_worker_tick() is there, we can easily track the rough CPU time > consumption of each workqueue by charging the whole tick whenever a tick > hits an active workqueue. While not super accurate, it provides reasonable > visibility into the workqueues that consume a lot of CPU cycles. > wq_monitor.py is updated to report the per-workqueue CPU times. I'm utterly failing to read that dragon thing (or possibly snake, but I can typically sorta make out what it intends to do). However, while you don't have preempt-out, you still have sched-out through wq_worker_sleeping(), so you should be able to compute the time spend on the workqueue by past worker runs -- fully accurate. Then you only need to add the time since sched-in of any current worker and you have a complete picture of time spend on the workqueue, no approximation needed. Or am I completely missing the point?