Received: by 2002:a05:7412:3290:b0:fa:6e18:a558 with SMTP id ev16csp241300rdb; Thu, 25 Jan 2024 13:56:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IGSn2RWASxrNkFw+lsnt0DCHYHuuEhf9T9oFj3OWGp+CQyz/ZiTtnvWqfsVwuoq3LCgWsFx X-Received: by 2002:aa7:d3d2:0:b0:559:bdf5:82b5 with SMTP id o18-20020aa7d3d2000000b00559bdf582b5mr143197edr.72.1706219793732; Thu, 25 Jan 2024 13:56:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706219793; cv=pass; d=google.com; s=arc-20160816; b=oshqHIvhZ/P0qYUZhqbWqcaL139eVCnueYQSui8G8N+mN/L3UtTYUehe4em+YyyaPb vJUuGs/tYG6kUol68MK1Zu57P72rE0q+PlAjLPM+Dxiow1d25qLUtJMVc4dFu27+mloB gDhwNEBsDwodZnhcbhQffsFAkNxpPuD2FhBxzCbMexPiq06E4toipn5CbyUTaQuGajWc +56mqXkCjrqSwOZPHAGPWKmpPu+UIEl/oE64I7mpANhO5UkyhUMJFvZ5bA6QxgIajdrv pVuOaYZlfAkWweX2kU+NeMuEn64djBjGacKiXiDPsS3BBmdLp13XqthzQRbasyGxCJEk l11w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=f6m+zu3oNEJHiwD8qfoMPQzECOUmp8yU0Qm9W6z7sE4=; fh=IQE7hsTnUb19I7x7JQRLJcuTlVCyoQwHRF2INfJ6HpU=; b=MTFUQ+UU89/LI66EOA4CravZMLZ/OV95GgPpFctVo3+tD6ckqEEq1imCSPkF+ZguvA TW8h0XEvfSwLPVj+r74t/fSXmgZ83HkjGohUflnI4C5J7ZX+gD3PwjyC0AMqiZlhcYyq R80OAJUZgs9JyBgnvRjfkVZIffzw8GOOcAr6fQhPT/QJa0BJMbl04NlasnvrJW3YNMbv XMMoz6QttrygQaRwEcd+SoXFEYM1HCRMZSGDlzn1y9A4fdJfV2snJVC60ZLWwRUsHg8T WAesOGKaPR6WjKk5gw5L76o7fU0D4KouhA2PnoSvPVHpmg/HS1rnqGQI1X9LJ5zD972J QGLg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=QcXiMWJZ; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-39332-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-39332-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id q17-20020a056402249100b0055c992af827si2951275eda.291.2024.01.25.13.56.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 13:56:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-39332-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=QcXiMWJZ; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-39332-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-39332-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id B9EB21F232C2 for ; Thu, 25 Jan 2024 21:47:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8236313B784; Thu, 25 Jan 2024 21:47:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="QcXiMWJZ" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9703C13A272 for ; Thu, 25 Jan 2024 21:47:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706219245; cv=none; b=CvXCx29PfCxRgo2Dcgw3hxs/FAN9bS+KkyXvZiC6pQoF0LgfTlm4Sk7xdIzPvOx5iWoEeA7Q/NWhyuN1DoJeiMlzhl+XuZXLwJMKDPuLTTwNWVG7+vXZ1uvA+7hA3Ibj/n5NGCLx4ly4rJdk3AJ3Mm8KIhxroyino9dTyTpkshM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706219245; c=relaxed/simple; bh=NcaE8S5NwQHT5Tq0RlWwGiOlHY6ORi1hFNchO5th4hc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type:Content-Disposition; b=DIr1Yr/NwgC+J/XyPUrHlTxICYnKSwjPuExQKPwPq9+3lDNTa+QweihaTVgsAKnqYE6LoXH2CKPxT0nX6DAXSist5f8AJDbF6WxXspV8TxDJgby78nE2iirFMGwjT52QHZrjDzSTC+qOgE4+rSc+bYgEdkv7uCQGHFFFN2kfDXk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=QcXiMWJZ; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706219241; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=f6m+zu3oNEJHiwD8qfoMPQzECOUmp8yU0Qm9W6z7sE4=; b=QcXiMWJZu+AGOKu6W5kpKqtiYsQCS5z+HAq2DRQ99WAvlJLcuUtk66UTd8OQM/C+I3TWlL YYXNOW43HPAX8hTqweQYUVVitA5vvg4TY5ERKnKqjTNrhUr78U6FyaOxiHP4tGnIluNqeQ e9UUtxC0X3sccvJRgCIGTJ1RhmKis9Q= Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-553-sDAaEQhtPkOmeEQU79Up1Q-1; Thu, 25 Jan 2024 16:47:20 -0500 X-MC-Unique: sDAaEQhtPkOmeEQU79Up1Q-1 Received: by mail-pg1-f198.google.com with SMTP id 41be03b00d2f7-5cfda2f4716so2452475a12.3 for ; Thu, 25 Jan 2024 13:47:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706219239; x=1706824039; h=content-transfer-encoding:content-disposition:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=f6m+zu3oNEJHiwD8qfoMPQzECOUmp8yU0Qm9W6z7sE4=; b=xQn3+8V1UpN/YHnpCf5kj57zqimGZY1cRuQ4vAQCxMxnEmfTpS7WPwMsB2FBYntvwG HlRAsVuT1K0QcXGe15sEc5jTBH0cdmXgzYSLb88PQueToTmlmyAaJBHUXWIeqrU7StSQ AVQr00zyAIl/u549wS5d4djSKQpbks+XeUV4oMtuVG/ynPWnSJe2qJ5cPnclPv/ywujI piIdUP9jnRxwcm6akxyZpfg7a/wQNC9KM57oNW59AzZ1tsr55AlBaI8sDPUkuyaf2jio GfubikiQsA3ZAzOTvo0pL7i3qQMEIn12uceY5nxNxy67quaFpNtSnqpLVAGkGjMsrdKf +l6g== X-Gm-Message-State: AOJu0YzFoypPQI9QYtaWKcQOTsozg1bHPHTfOPmseHKssORyFaJ/VxJ4 K4qQc2p4JSIKVU1vnlY9OfilhiuUFM1e83yXM5WxCE5k2IcN33excHFNCnQPyX/YYfM6fJMOB3J p250Ec8MOkmx89nnLaXCll+3s/sXosZgcBbsUNDGhpM0yEOdUmd79GF069tYupw== X-Received: by 2002:a17:902:c942:b0:1d7:8cd6:63d with SMTP id i2-20020a170902c94200b001d78cd6063dmr428542pla.106.1706219238867; Thu, 25 Jan 2024 13:47:18 -0800 (PST) X-Received: by 2002:a17:902:c942:b0:1d7:8cd6:63d with SMTP id i2-20020a170902c94200b001d78cd6063dmr428530pla.106.1706219238486; Thu, 25 Jan 2024 13:47:18 -0800 (PST) Received: from localhost.localdomain ([2804:1b3:a803:96a5:ba81:becc:80f3:6a79]) by smtp.gmail.com with ESMTPSA id mm14-20020a1709030a0e00b001d7222d8caasm10460079plb.50.2024.01.25.13.47.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 13:47:17 -0800 (PST) From: Leonardo Bras To: Tejun Heo Cc: Leonardo Bras , 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 Date: Thu, 25 Jan 2024 18:46:33 -0300 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: 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 Content-Transfer-Encoding: 8bit On Thu, Jan 25, 2024 at 08:38:25AM -1000, Tejun Heo wrote: > 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. It looks like a good idea to me. It's basicaly (2) with "keep the timer in this cpu if it's not isolated", which seems the right thing to do. Thanks! Leo > > -- > tejun >