Received: by 2002:a05:7412:b101:b0:e2:908c:2ebd with SMTP id az1csp3027707rdb; Wed, 15 Nov 2023 19:35:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IGiHOKvcIWTt73p0SZnBQN+b9RTj93+9rikZ0WCEs4py2dcXD9xvsPFgWEoBDze4q5JI2gU X-Received: by 2002:a05:6a20:a105:b0:187:72e7:6d9b with SMTP id q5-20020a056a20a10500b0018772e76d9bmr3594293pzk.57.1700105748482; Wed, 15 Nov 2023 19:35:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700105748; cv=none; d=google.com; s=arc-20160816; b=B2wfnsCxXrdy1hJj1ZJYxww+cVflgDOdewkvqhuSMonAwKrWYPMajM6CKZMcEQcZyK D4wSu6bW1eo/8lOomL6zcbPdtjGL7dcSp738znFqWAzfkShwv9ilAKBrpgzr1a/TRbNW Zb6jc8AeUrsUUCPi8XInQnN1FSy5feWMH3utZDXsasMIR1Gfuf39UP6rzYOpzx6OYCuz IuSqmBhQmV9hoJgw6+xO53RwRqz+1Kw+9vBXF0e/9x0K6nBmtNf6i49fEsICyv6Sy98y kpbRsER8t0GDR8pD4K0+6zxYGDniTycyrlKJJQIZT+BqSh3S44IEENdimYoax/GqrLDD NXeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=Fh6sr5djueJxvg69Qt1Q1YfFiPMkWzsCiD40QbSJilw=; fh=bNpy/TkeoCLOfJdH8gD+DRrlc5TtbiBfs9F9HtSKd4A=; b=b7RtkfeLfahVsJZI09suufz80t3omxsTl6rZ8V2y6lt9mlGgs3fAcH0zpU2KUd4bje sec0GtCZxsu6VI5p9acPDjlW3i+Hz4myeAwsqgQIiEx5A7cJDxmsedfclqGfFxrTXafD Caki+xjm/uBdBYZu8X0JhUn4oh9gZ841z4HgGokVZFIjIm1JcS1ngiFLm6QrAcEF3a0a oA47ONzDVszkHLZ3wC/eslSMls6Q1dU8t3rtAdCyZlNjBxSL2O7q5+tJklN/7aWnfjhk bf/xn4eLSlsnIOqCM288HDkdN11REE+ww/s6gHSnzM1dqgPXnytS7nlXPxtLUQfZeOvB KMpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=MlPaDj9t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id j1-20020a170902c3c100b001c4749ee72csi10532987plj.503.2023.11.15.19.35.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 19:35:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=MlPaDj9t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id AFE1080209DF; Wed, 15 Nov 2023 19:34:59 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344782AbjKPDen (ORCPT + 99 others); Wed, 15 Nov 2023 22:34:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235663AbjKPDem (ORCPT ); Wed, 15 Nov 2023 22:34:42 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5FA019B for ; Wed, 15 Nov 2023 19:34:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700105677; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=Fh6sr5djueJxvg69Qt1Q1YfFiPMkWzsCiD40QbSJilw=; b=MlPaDj9t9Q3VpepCYrQEERlS/QrIwmwF80slh0jRG/fdWkjhuXs+Kqn43IfCXalWssLPgj F6tZI0CCT+zhyt4RuVc5NWZ/iG2ywSrSm8PTf3wfKY9ZCEIt01KUZ8f2SewcTbZIARFVI7 8Gh9G61VAuuJazS1T/f4dQx3yM56C0U= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-508-LVbmSX7jPZ2g5WfQ6uex4g-1; Wed, 15 Nov 2023 22:34:34 -0500 X-MC-Unique: LVbmSX7jPZ2g5WfQ6uex4g-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 061C91C04344; Thu, 16 Nov 2023 03:34:34 +0000 (UTC) Received: from llong.com (unknown [10.22.8.169]) by smtp.corp.redhat.com (Postfix) with ESMTP id 241AF492BFD; Thu, 16 Nov 2023 03:34:33 +0000 (UTC) From: Waiman Long To: Tejun Heo , Zefan Li , Johannes Weiner , Jonathan Corbet , Lai Jiangshan , Shuah Khan Cc: cgroups@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Peter Hunt , Frederic Weisbecker , Waiman Long Subject: [PATCH v4 0/5] cgroup/cpuset: Improve CPU isolation in isolated partitions Date: Wed, 15 Nov 2023 22:34:00 -0500 Message-Id: <20231116033405.185166-1-longman@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 X-Spam-Status: No, score=-1.0 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.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 (lipwig.vger.email [0.0.0.0]); Wed, 15 Nov 2023 19:34:59 -0800 (PST) v4: - Update patch 1 to move apply_wqattrs_lock() and apply_wqattrs_unlock() down into CONFIG_SYSFS block to avoid compilation warnings. v3: - Break out a separate patch to make workqueue_set_unbound_cpumask() static and move it down to the CONFIG_SYSFS section. - Remove the "__DEBUG__." prefix and the CFTYPE_DEBUG flag from the new root only cpuset.cpus.isolated control files and update the test accordingly. v2: - Add 2 read-only workqueue sysfs files to expose the user requested cpumask as well as the isolated CPUs to be excluded from wq_unbound_cpumask. - Ensure that caller of the new workqueue_unbound_exclude_cpumask() hold cpus_read_lock. - Update the cpuset code to make sure the cpus_read_lock is held whenever workqueue_unbound_exclude_cpumask() may be called. Isolated cpuset partition can currently be created to contain an exclusive set of CPUs not used in other cgroups and with load balancing disabled to reduce interference from the scheduler. The main purpose of this isolated partition type is to dynamically emulate what can be done via the "isolcpus" boot command line option, specifically the default domain flag. One effect of the "isolcpus" option is to remove the isolated CPUs from the cpumasks of unbound workqueues since running work functions in an isolated CPU can be a major source of interference. Changing the unbound workqueue cpumasks can be done at run time by writing an appropriate cpumask without the isolated CPUs to /sys/devices/virtual/workqueue/cpumask. So one can set up an isolated cpuset partition and then write to the cpumask sysfs file to achieve similar level of CPU isolation. However, this manual process can be error prone. This patch series implements automatic exclusion of isolated CPUs from unbound workqueue cpumasks when an isolated cpuset partition is created and then adds those CPUs back when the isolated partition is destroyed. There are also other places in the kernel that look at the HK_FLAG_DOMAIN cpumask or other HK_FLAG_* cpumasks and exclude the isolated CPUs from certain actions to further reduce interference. CPUs in an isolated cpuset partition will not be able to avoid those interferences yet. That may change in the future as the need arises. Waiman Long (5): workqueue: Make workqueue_set_unbound_cpumask() static workqueue: Add workqueue_unbound_exclude_cpumask() to exclude CPUs from wq_unbound_cpumask selftests/cgroup: Minor code cleanup and reorganization of test_cpuset_prs.sh cgroup/cpuset: Keep track of CPUs in isolated partitions cgroup/cpuset: Take isolated CPUs out of workqueue unbound cpumask Documentation/admin-guide/cgroup-v2.rst | 10 +- include/linux/workqueue.h | 2 +- kernel/cgroup/cpuset.c | 286 +++++++++++++----- kernel/workqueue.c | 165 +++++++--- .../selftests/cgroup/test_cpuset_prs.sh | 216 ++++++++----- 5 files changed, 475 insertions(+), 204 deletions(-) -- 2.39.3