Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp4017894rdg; Wed, 18 Oct 2023 12:20:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHkgMg4khPW3alXwMzemg+hvdlRV0O1hL9LMIVcrxz/wRggCN8xrOl5ZfoDcz8PZFRlbEiq X-Received: by 2002:a17:90b:2dd1:b0:27d:10ab:2329 with SMTP id sk17-20020a17090b2dd100b0027d10ab2329mr95833pjb.14.1697656801128; Wed, 18 Oct 2023 12:20:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697656801; cv=none; d=google.com; s=arc-20160816; b=bazzGgPsKCw82BqRjJcMDLOEbrBuDMMtkj/JNg5uEhw/hRI9lQDnMTenkD062pVcg0 Cx3lZziP7EwIUOudDZGBsFH4LlK5KyqlOquMtTCg4jmTBUapFNWfruURDTu+iPwk97fd G+LEBWvkLWErmroicl58rkqFc/PJ59CpPJw6mDLlBTXDIrGs7LqTSIVB2xM15CyhdlhO qMvD/3Aht6yxOeyfijmghnxcuCrFyKVei8q3le1XZXmmD39DEQ5TfbsAnAQW0bTojVAB 2KMtTRnGFDjSEYDuNhsVCQyrErk1N6BM6fSMg4NdPZduUKASRvVROEVs5TIregyZLwbU rmHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=O8mqtxJn0RIu5PIvWrBwIFU/c+8fQEb8PdmiMLhcCVo=; fh=qHj29L2A5mwzu/PF4m4XcxAWuokRE3PlYhTqb6/cyNs=; b=s9t1MB7JOG7Ga9fo+IiAtvT8f+sjNa7Aj7JSwRM9HYY3wFt0WxMxYHCspt5iFuZG6e tCx+jkZI/OhtjCD0o3VPnJiMCUVC9GBxcHFo/CIp/ZgWjvu+c8Y+VHjhjVus4gtYrVdM vb5HD8874L870E6aMKR+1Xx7yC0f3Q8bhnKSVCXB05oJYTW0RwEgp0bPYYdUWOzcvBqT xochkbCeFfQ1D29SIaiI+UVNegWqu4LXjS/uoE/hIkS7S1sBeZRRPHbrvdBZGwhQpGEs T1MIQIvjV3qTFvK7wDUMCD5El89c5q1TH4LR5QeCiqqB8C93xIDth0qDDE1WCuOYm4Up WQgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=E7Bm3HI6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id lb7-20020a17090b4a4700b00276945c92c1si525027pjb.36.2023.10.18.12.20.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 12:20:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=E7Bm3HI6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id ECC9081143E8; Wed, 18 Oct 2023 12:19:56 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230421AbjJRTTp (ORCPT + 99 others); Wed, 18 Oct 2023 15:19:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230491AbjJRTTo (ORCPT ); Wed, 18 Oct 2023 15:19:44 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A65D211C for ; Wed, 18 Oct 2023 12:19:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697656741; 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=O8mqtxJn0RIu5PIvWrBwIFU/c+8fQEb8PdmiMLhcCVo=; b=E7Bm3HI6X9LhlRFGtr4BRkLM+qkeF2CKmyQXXgNtwrpISHFJzHRgYgsuMObvmnHiNVec8d YgpcnxLEDSe5SOf967m9hMdiQudF5YeZDsDsJRCbHOltd7LntoeOg1jmz46JTBxi6E7Tn5 z4z88hYZYpMvStdpXKuHClEX4sv83qw= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-193-6TOr_ffSO6qAkdIxLaQMiQ-1; Wed, 18 Oct 2023 15:18:55 -0400 X-MC-Unique: 6TOr_ffSO6qAkdIxLaQMiQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C722A857D0C; Wed, 18 Oct 2023 19:18:53 +0000 (UTC) Received: from [10.22.17.22] (unknown [10.22.17.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1651C1121319; Wed, 18 Oct 2023 19:18:53 +0000 (UTC) Message-ID: Date: Wed, 18 Oct 2023 15:18:52 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.14.0 Subject: Re: [PATCH-cgroup 1/4] workqueue: Add workqueue_unbound_exclude_cpumask() to exclude CPUs from wq_unbound_cpumask Content-Language: en-US From: Waiman Long To: Tejun Heo Cc: Zefan Li , Johannes Weiner , Jonathan Corbet , Lai Jiangshan , Shuah Khan , cgroups@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org References: <20231013181122.3518610-1-longman@redhat.com> <20231013181122.3518610-2-longman@redhat.com> <4e9cc6e3-7582-64af-76d7-6f9f72779146@redhat.com> In-Reply-To: <4e9cc6e3-7582-64af-76d7-6f9f72779146@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 X-Spam-Status: No, score=-4.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 18 Oct 2023 12:19:57 -0700 (PDT) On 10/18/23 09:41, Waiman Long wrote: > On 10/18/23 05:24, Tejun Heo wrote: >> Hello, >> >> On Fri, Oct 13, 2023 at 02:11:19PM -0400, Waiman Long wrote: >>> When the "isolcpus" boot command line option is used to add a set >>> of isolated CPUs, those CPUs will be excluded automatically from >>> wq_unbound_cpumask to avoid running work functions from unbound >>> workqueues. >>> >>> Recently cpuset has been extended to allow the creation of partitions >>> of isolated CPUs dynamically. To make it closer to the "isolcpus" >>> in functionality, the CPUs in those isolated cpuset partitions >>> should be >>> excluded from wq_unbound_cpumask as well. This can be done currently by >>> explicitly writing to the workqueue's cpumask sysfs file after creating >>> the isolated partitions. However, this process can be error prone. >>> Ideally, the cpuset code should be allowed to request the workqueue >>> code >>> to exclude those isolated CPUs from wq_unbound_cpumask so that this >>> operation can be done automatically and the isolated CPUs will be >>> returned >>> back to wq_unbound_cpumask after the destructions of the isolated >>> cpuset partitions. >>> >>> This patch adds a new workqueue_unbound_exclude_cpumask() to enable >>> that. This new function will exclude the specified isolated CPUs >>> from wq_unbound_cpumask. To be able to restore those isolated CPUs >>> back after the destruction of isolated cpuset partitions, a new >>> wq_user_unbound_cpumask is added to store the user provided unbound >>> cpumask either from the boot command line options or from writing to >>> the cpumask sysfs file. This new cpumask provides the basis for CPU >>> exclusion. >> The behaviors around wq_unbound_cpumask is getting pretty inconsistent: >> >> 1. Housekeeping excludes isolated CPUs on boot but allows user to >> override >>     it to include isolated CPUs afterwards. >> >> 2. If an unbound wq's cpumask doesn't have any intersection with >>     wq_unbound_cpumask we ignore the per-wq cpumask and falls back to >>     wq_unbound_cpumask. >> >> 3. You're adding a masking layer on top with exclude which fails to >> set if >>     the intersection is empty. >> >> Can we do the followings for consistency? >> >> 1. User's requested_unbound_cpumask is stored separately (as in this >> patch). >> >> 2. The effect wq_unbound_cpumask is determined by >> requested_unbound_cpumask >>     & housekeeping_cpumask & cpuset_allowed_cpumask. The operation order >>     matters. When an & operation yields an cpumask, the cpumask from the >>     previous step is the effective one. > Sure. I will do that. I have a second thought after taking a further look at that. First of all, cpuset_allowed_mask isn't relevant here and the mask can certainly contain offline CPUs. So cpu_possible_mask is the proper fallback. With the current patch, wq_user_unbound_cpumask is set up initially as  (HK_TYPE_WQ ∩ HK_TYPE_DOMAIN) house keeping mask and rewritten by any subsequent write to workqueue/cpumask sysfs file. So using wq_user_unbound_cpumask has the implied precedence of user-sysfs written mask, command line isolcpus or nohz_full option mask and cpu_possible_mask. I think just fall back to wq_user_unbound_cpumask if the operation fails should be enough. Cheers, Longman