Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6378537rwb; Tue, 22 Nov 2022 12:29:41 -0800 (PST) X-Google-Smtp-Source: AA0mqf5EVFQp5I/kvu5cYyABjzWjkNOLj5zsmtQt5Aw2tzpufOR39ls32fFUIqQcq7XDBCAgcNpN X-Received: by 2002:a17:902:d58d:b0:188:d6e1:b82b with SMTP id k13-20020a170902d58d00b00188d6e1b82bmr5630933plh.146.1669148981153; Tue, 22 Nov 2022 12:29:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669148981; cv=none; d=google.com; s=arc-20160816; b=kbe/zBobElbvVitOWQQSqOsgaL4VfWz01DSeB1cg7Em7DOD3zJXqVgYQPGZbwe2pcw hlW9sCo/Yb+VRHRSKJu2fvUl/yTA7npFg2CxYgfybkifui8zMPDJ+1+TtURuYuBsFZTC kLBa/n9dAV2Ux3nMCTQQ6SkykmT7oBxAKGSiJMEpEg50KJmyVbu5GYIfu3SGBeAT0YIf lcKg2vJjSFDBXwdLCORs04C7FELDoOIhdnyUhv7H/4PGZa3uQieP0bCpHyQw7Im62VLn P4g7VnT4cOImbCdRmxKpUVGG+EoZ1cNIw5gtqBdgWKX/Nkpi8fN1J4/pC/EWmrIFkVEq 7p+w== 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:sender:dkim-signature; bh=p4u4OXrLVlO99xYsRoKZMfZRyTXMaPRYGMBVHkWDPkM=; b=XK5gUApxlZrS4ixFJVYIq646FPjo+Gz6I0E+7uuY87CP2qUQywDRENWxe7EjK8ff5t NAjVRR565SREWcI2lovumnQt5hsROHU4ho3IWjPiGukQN/QSm/lKzu6CYl/I4IkleMoG X22vVPPZvXYLzNAL20vx7Cl9LXJsRpUbnOBmvD61aCiHYVxG9szTeaDbtpetnx42qKI2 kpjBMx86mNVctn0KZjZrg0U+4J4/03wuSoElUq8PEwiP+JY8i9PvxJmVmF0TGzDdrMo5 fagmqISEMRV3naoOPlnrSyxREJ+jLQdwFvq8NFbJrCjDVRb8iEeTn3usNxXRaTZOrAtJ fAAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=oiwM53og; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e8-20020a636908000000b00477b10def88si1227631pgc.696.2022.11.22.12.29.30; Tue, 22 Nov 2022 12:29:41 -0800 (PST) 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=@gmail.com header.s=20210112 header.b=oiwM53og; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234552AbiKVUYB (ORCPT + 90 others); Tue, 22 Nov 2022 15:24:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234872AbiKVUXq (ORCPT ); Tue, 22 Nov 2022 15:23:46 -0500 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6C83167FB for ; Tue, 22 Nov 2022 12:23:39 -0800 (PST) Received: by mail-pl1-x62f.google.com with SMTP id jn7so12885612plb.13 for ; Tue, 22 Nov 2022 12:23:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:from:to:cc:subject:date:message-id :reply-to; bh=p4u4OXrLVlO99xYsRoKZMfZRyTXMaPRYGMBVHkWDPkM=; b=oiwM53ogJ2puZg4oizPgE12GVOLkIoaFbBa4mg7Y/L1vrXQ/bbl5GjiyuKMwDSei5b S8onGp+gN6sPJW+3DFEXy5Ip7mOd7xqZcc725OTs0jMhYRjayBkmG83dNVpilt912xW8 WxNXRo98unrU3lDoL7n/eQed+4zn2Qn6qVFhYvqFihX8JXf+m0GiOftcanPq1e5g1ZpL Dw+pz/8W9pHkowcIjhEo2iM2raWscvfmAMWzY0Qzl4wdA6IvW3Q4B/FTPbQYnvfy80YX Yey+OIsW1ILS4UtiowCMNgYuYe2e9JBV3f4tuOXn3y0wQEklKfIqm4/u9gMqxs2kuQOI xlPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=p4u4OXrLVlO99xYsRoKZMfZRyTXMaPRYGMBVHkWDPkM=; b=y138xGXj6A84/Wd79/q1ztQhXA85einnBPYyR2AP9q2PsslTkS2RYEgJ44bj0o7m39 KJtMwGx5YNv83y1AR7ffxriNt0T4IbZYV2yL1Ku14T7nKlLgpaMNhK4ZzMylBQe5VBVC sxWclOSg/JBQPqfJQy5Yt3Y2p+CzEV37c9l172uBQx/EcJV6eTjGMUykSaPL7JN+0ttU LB0VG8oEwirkYupWoF4IxcwXbToULxAImTp740BKjCzb6mFAhi6VK71tCe+b1zAOycpr EYpYZR8fNg8s+PU8iwyLvMh3qriIAkWFo3fL70+ugWCZlmHGl/VrgEiRyjsuH/i/o6Js LsIw== X-Gm-Message-State: ANoB5plGm6eVIaM3/GQ1SQw6g/gULLcgotgowGjhW4FeQiyCUZPEacuy MWT45MmBwKaU7IqUItaL4pQ= X-Received: by 2002:a17:902:ec01:b0:186:878e:3b0d with SMTP id l1-20020a170902ec0100b00186878e3b0dmr5522521pld.149.1669148619084; Tue, 22 Nov 2022 12:23:39 -0800 (PST) Received: from localhost ([2620:10d:c090:400::5:bb3]) by smtp.gmail.com with ESMTPSA id f4-20020a170902e98400b00188c5f0f9e9sm12316383plb.199.2022.11.22.12.23.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Nov 2022 12:23:38 -0800 (PST) Sender: Tejun Heo Date: Tue, 22 Nov 2022 10:23:37 -1000 From: Tejun Heo To: Valentin Schneider Cc: linux-kernel@vger.kernel.org, Lai Jiangshan , Peter Zijlstra , Frederic Weisbecker , Juri Lelli , Phil Auld , Marcelo Tosatti Subject: Re: [PATCH v5 4/5] workqueue: Convert the idle_timer to a timer + work_struct Message-ID: References: <20221122192937.2386494-1-vschneid@redhat.com> <20221122192937.2386494-5-vschneid@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221122192937.2386494-5-vschneid@redhat.com> X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no 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 Hello, On Tue, Nov 22, 2022 at 07:29:36PM +0000, Valentin Schneider wrote: > @@ -2039,12 +2060,48 @@ static void idle_worker_timeout(struct timer_list *t) > worker = list_entry(pool->idle_list.prev, struct worker, entry); > expires = worker->last_active + IDLE_WORKER_TIMEOUT; > > + /* All remaining entries will be younger than this */ > if (time_before(jiffies, expires)) { > - mod_timer(&pool->idle_timer, expires); > + if (!cull_cnt) > + mod_timer(&pool->idle_timer, expires); > break; > } > > + /* > + * Mark the idle worker ripe for culling. > + * If a preempted idle worker gets to run before the idle cull > + * handles it, it will just pop itself out of that list and > + * continue as normal. > + */ > + list_move(&worker->entry, &pool->idle_cull_list); > + } > + raw_spin_unlock_irq(&pool->lock); > + > + if (cull_cnt) > + queue_work(system_unbound_wq, &pool->idle_cull_work); > +} So, you mentioned this explicitly in the cover letter but I think I'd prefer if the timer were simpler and all logic were in the work item. It just needs to pick at the first worker and compare the expiration once, right? If that bothers you, we can make workers keep track of the oldest idle's timestamp in, say, wq->first_idle_at as the workers go idle and busy and then the timer can simply look at the value and decide to schedule the work item or not. Thanks. -- tejun