Received: by 2002:a05:7412:3290:b0:fa:6e18:a558 with SMTP id ev16csp145682rdb; Thu, 25 Jan 2024 10:38:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IEWpZu10Gzi3VAQS7HVH5LBxDWlVbxNlSDf2NzzgZO6/sln+8ppO6hnSSI7akmFw//b9JIZ X-Received: by 2002:a05:6808:189a:b0:3bd:bff9:7156 with SMTP id bi26-20020a056808189a00b003bdbff97156mr222289oib.20.1706207916539; Thu, 25 Jan 2024 10:38:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706207916; cv=pass; d=google.com; s=arc-20160816; b=T2Lt3w4OkXbKHYPjdEwrO3bqQanX4prJ+T5bRrsr0V21rj/+fVWIZOqTkD54lXo91s IgcwK2u9pIyAvojKlIHDYW5T52nEbbDUmx1Rd2oMLMqvhP0ThmJOohlj9StPUlOrJXsv RMV8I9OnMvmWvdvfyRYRriqDDaPGyF729DUrUJDN3VKiEcrIjm52GdDaP5Gk06Iwwavt yTFTTWbFLLW3K71srkiT9KVNSafeEbn91tDsCed6IWi7CthufrlK/zBYyFkBzVMC+buN xSXsER8l6uwFr32B3QdU9t6XPU4h2r79/2/MK7jDAB6XZe2M6ywXVhbqWq44XOaPMCrT Np+w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:sender:dkim-signature; bh=TjpbnjVkJNaYuycPPkK9d7AUEFZBY5VnjgqUS9zaxEA=; fh=zhu1C8umPZjGXufbaC6GMdJqphOqjDhRtkNu5UNgLiY=; b=o74TDF54qD1Kgh2ed2spmITmuN01Ku8SZUYeiRhWMObj0TaH67k7sbDHZy07T9vyJX 7sTyyn5SD1+Uaz4BCqro7X5sZGXIvOudHMzXF037KAY/bRD6P3zmXsGzjaztrunF/u5F Zqz5yFXtaGky+hCVoOdLda/s+YsUPSavdzhdB2nn4J5sSlQdLnrrjMhnoeDGC7VcJYTB MEDZCweTSyN5+7WKP/78can1pCGDD6VKzQhmKrJyO3p2E0TA5ej3kXSzFgz2J27DohlV zbkOCjGFjPmmQNsO9bPijXw5Sv4K0CUaSIl9VBsjcwT5+WV8qtgXwKPBSCQ/9tVjs2la 3nzQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="M8fT/wIt"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-39134-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-39134-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id z6-20020ae9f446000000b00783a96b5ee9si7006888qkl.92.2024.01.25.10.38.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 10:38:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-39134-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="M8fT/wIt"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-39134-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-39134-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id D4B551C22806 for ; Thu, 25 Jan 2024 18:38:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D129022093; Thu, 25 Jan 2024 18:38:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="M8fT/wIt" Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8BC2B10A12 for ; Thu, 25 Jan 2024 18:38:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706207909; cv=none; b=fGJ3n3LE0sgR4SQQP04WnHNns24HSl2NVCLEnOiw+DFKImo7eIvyX5IMRSR9CfvoWDXRKFcVFYZGyrm1pERkT29mWZKCyUgWuTbLzG28ph2nWF6m7RyBUPu7c4z+A59TzhUohW0nWTYPYpbdlqhlt+nNeCU0kjQhgecKcUfRrJE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706207909; c=relaxed/simple; bh=cZx+YNVP7ZTa30LGqSaWbg8X8fXKuev5Uk2WGNJ5Y4g=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=hA1SgrmOr1YLWZ5dY2HfXCxMqmf+YzLYqR0XGZfNRvUWL7Kdut4z639hhdYA1dmKf+GAfVHVcTD1T23tFEbqn3PnlMVLi1rwBoXTCwAE2Ai6lSo4JkN8qT2aF+WpkgB95YGOxqz0IaIB8XbMoqoqkEgfVRCQO6SL6hKQEFYEQa4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=M8fT/wIt; arc=none smtp.client-ip=209.85.214.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-1d88e775d91so7059215ad.2 for ; Thu, 25 Jan 2024 10:38:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706207907; x=1706812707; darn=vger.kernel.org; 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=TjpbnjVkJNaYuycPPkK9d7AUEFZBY5VnjgqUS9zaxEA=; b=M8fT/wIte5Tu4UuwTJdTh4It3NPDMN3BSY31FuLaii5w571zfhCch/TdWqjnWkpmsg SwbDvGcht+okrrzBuaqDgE2b0Y1tK69FjjsRhtEQC0JAzqdnWgH3yApNgu3yDneG/HhK oz/KSliA0uhEJdvZxO4tYAU8Goqz67aPulO9IUNvMJf5B1Kvtk4fWiFcfwvSSLw4BCDb emE2K8anNkjOg7TPfPRI2DQkQQjck0uNDSd2udQ/AxVlDYjlEk55qPXHiF0DjL2ZN8V5 XzYCDFAy7sD9chrVKTDPKrTHNnk3tqEX65G7S4eD9pGHq0sYJFTNtcw6wt/dJsme//8C Csdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706207907; x=1706812707; 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=TjpbnjVkJNaYuycPPkK9d7AUEFZBY5VnjgqUS9zaxEA=; b=aVjhhmGxw3rXpf8+sXBjey7d0KnaqftKVSTuzn9CB1bpw04QwKQc/9RI0FOnUyqgRo pzF+s2HAr92pm40ynrdil5dRjqgufb+YTEcJXEfwA0y/UBsqn5RyhZ+LmU2zgnAdyCTf y9uggAfsKjTpSoZUxoOmH2dOBHlTskX9cCSHtBIIATcGUMvNw9u1/2BdQALotwQOHhZS bwrNGAGo0nrgksUKTFLdXPSrfYHVJUyBF/YEN/HLtbJbyxJF5ErrRtw7XLB0SPjxf8eh ZOtFx9I/w9kUqwmn8RQ387MSpTAIsFg+DwuchOLgx2qMbh9iD3QOtnkRD6lwGuYaJuHr QFeg== X-Gm-Message-State: AOJu0YxLgp6DWPwaIVCOtZDtAvP2ZHJTTnZpchrfuOwEdpDsbnuHFRCm hQ4z+zGDI2Q8q8qbPyPOBrr45/uE4fc918+A+MHUWt5KrKH6H6SUv8P5yOcS X-Received: by 2002:a17:902:fc8d:b0:1d7:1948:6f2e with SMTP id mf13-20020a170902fc8d00b001d719486f2emr132480plb.80.1706207906637; Thu, 25 Jan 2024 10:38:26 -0800 (PST) Received: from localhost (dhcp-141-239-144-21.hawaiiantel.net. [141.239.144.21]) by smtp.gmail.com with ESMTPSA id jh10-20020a170903328a00b001d6ea47ce68sm12386895plb.52.2024.01.25.10.38.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 10:38:26 -0800 (PST) Sender: Tejun Heo Date: Thu, 25 Jan 2024 08:38:25 -1000 From: Tejun Heo To: Leonardo Bras Cc: Lai Jiangshan , Marcelo Tosatti , linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH v1 1/1] wq: Avoid using isolated cpus' timers on unbounded queue_delayed_work Message-ID: References: <20240124082938.2527697-2-leobras@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Hello, On Wed, Jan 24, 2024 at 10:45:50PM -0300, Leonardo Bras wrote: > That's a good suggestion, but looking at workqueue_init_early() I see that, > in short: > wq_unbound_cpumask = cpu_possible_mask & > housekeeping_cpumask(HK_TYPE_WQ) & > housekeeping_cpumask(HK_TYPE_DOMAIN) & > wq_cmdline_cpumask > > So wq_unbound_cpumask relates to domain and workqueue cpu isolation. > > In our case, we are using this to choose in which cpu is the timer we want > to use, so it makes sense to use timer-related cpu isolation, instead. - In the proposed code, when cpu == WORK_CPU_UNBOUND, it's always setting cpu to housekeeping_any_cpu(HK_TYPE_TIMER). This may unnecessarily move the timer and task away from local CPU. Preferring the local CPU would likely make sense. - If HK_TYPE_TIMER and workqueue masks may not agree, setting dwork->cpu to the one returned from HK_TYPE_TIMER is likely problematic. That would force __queue_work() to use that CPU instead of picking one from wq_unbound_cpumask. > As of today, your suggestion would work the same, as the only way to enable > WQ cpu isolation is to use nohz_full, which also enables TIMER cpu > isolation. But since that can change in the future, for any reason, I would > suggest that we stick to using the HK_TYPE_TIMER cpumask. > > I can now notice that this can end up introducing an issue: possibly > running on a workqueue on a cpu outside of a valid wq_cmdline_cpumask. Yeap. > I would suggest fixing this in a couple ways: > 1 - We introduce a new cpumask which is basically > housekeeping_cpumask(HK_TYPE_DOMAIN) & wq_cmdline_cpumask, allowing us > to keep the timer interrupt in the same cpu as the scheduled function, > 2- We use the resulting cpu only to pick the right timer. > > What are your thouhts on that? How about something like the following instead? - If current CPU is in HK_TYPE_TIMER, pick that CPU. - If not, pick a CPU from HK_TYPE_TIMER. - Do add_timer_on() on the selected CPU but leave dwork->cpu as WORK_CPU_UNBOUND and leave that part to __queue_work(). Thanks. -- tejun