From patchwork Thu Feb 29 02:14:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Waiman Long X-Patchwork-Id: 208165 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp129882dyb; Wed, 28 Feb 2024 18:15:41 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWqgGe/oS82k8pPhrd3yUR0Jv+GTrXTdM5aopXeDNGIX0KdxrtNTPDRkOGxwEaplD9tak/TtUE5NpOlZLC9EPhArrfu1w== X-Google-Smtp-Source: AGHT+IETD6Ae/+kUpULvpi3/xUfA1+PFishXeatOyMfwE/oVa26vJ5KqRtbwZvWLSgEg7jri5t4W X-Received: by 2002:a17:90a:b889:b0:29b:299:6f8b with SMTP id o9-20020a17090ab88900b0029b02996f8bmr994767pjr.27.1709172941687; Wed, 28 Feb 2024 18:15:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709172941; cv=pass; d=google.com; s=arc-20160816; b=Ud+SXBOuX+SkHB+TvLP8Py5P5bIvq7oCbdAaXJ2p10duhTV2GAx44wOmR+e2M0j4EF 04l37COfHknlFB73Zt7Logkk/GT7SuzRDlX6c82adNDkyvCthzOAZaMA0Fyt65JzTjyX AsjRTxC9UzbY99iAd2Fz2o0zkjWkxnw6YxVuLypd432b93/KsvmWZh4qUHVFHS11/B8P yATHKf7u8Pdq4HuZ46qo+CZfVBrAAjPcEVvX/zmxVcijk6HBLbNR1HfXsqOKXcBcdpgO tKKiXpOXy6A4Kddo67iI/bZGEdYlThtUYYIZ5ujty9BvjrgsR2OmNfJVl6taR9ASev8w pR7A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=/XKfDwEYq77yh2Tx7xxyUZeYeDXKbwbjelgL1h1OpUk=; fh=Ieh26qMz7ii+wAfD3rSAC/AGrlk2wkd+lASkLp3ZwYY=; b=I0TQ9I+Ig8fgNZ12rW5ULmQYSFTQ0r9bfELZCyOG6CtLa2Khgsvn4BxGuFOtl/VtNT 3jWvgKW2rS9/sa+ghXAE/yyWCVTRgf38afhnnNjTlAy1cIqXv4M9Om0Uw2NguvvbofOi JLkNIcQ9Bt9XwTf005YY9uQDtBIopW+0MRV/EtrfPkOfByL7RtH0iWeslmPpi8wcDCwR 6weKf4862wjdLstoKtcDnUAUc58hlvxCqyRVONMRoCbjE/kzHjkhRrpQ4GU1w1jGGOya MdSqgy2zCURskK3t+EWK8/gP+VXurcTSths5hNx0xevXE3KZMSklX/Kc7oYxxQujB4iV 1G6A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=iCMWisb7; 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-86037-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86037-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id e63-20020a17090a6fc500b00296416a8f10si2490781pjk.112.2024.02.28.18.15.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 18:15:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-86037-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=iCMWisb7; 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-86037-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86037-ouuuleilei=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 78B792889B4 for ; Thu, 29 Feb 2024 02:15:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6AD4B38384; Thu, 29 Feb 2024 02:15:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="iCMWisb7" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 CDCB536AFF for ; Thu, 29 Feb 2024 02:14:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709172901; cv=none; b=cNVUIHJZ1OWavto36r5/pODRS7+3aHSTrlztUbI6TmJlQ3PtfkRWvBT8y+RLDvEpKN2AvprT1iMVrZOBPbdhy6qRrIo2ku46cNuMK7tUPmIo9jMAmBvfsX52cpWS/KZ1z12j+yXICEhBX4MFZh8CXqanR42QcYiGVY5nCSx5z1w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709172901; c=relaxed/simple; bh=sakExV8Zhp5Sh/q1+gBQuscarUS25o1Em4K3tkAC4hY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=uiwa4v5PoZ9gg6b9+1iKDu1urNRutxQTCMbPYZVAMZ20aDsOr6Eo6042FW3XD1thQjPpFN2gZAZiZCdBJ0lsxi3W2VfI4Z7/LW/E2+S7qNvtoMPnr5cVQIs2FRpAZWlXNlwwaYUl5r9Xj81Ubgf81vhkYz0erT5PUWrKJzuV7GM= 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=iCMWisb7; arc=none smtp.client-ip=170.10.133.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=1709172898; 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: in-reply-to:in-reply-to:references:references; bh=/XKfDwEYq77yh2Tx7xxyUZeYeDXKbwbjelgL1h1OpUk=; b=iCMWisb7YdMJFW1meLGylIuuQDACZaR+KNXB233LUevdoF3ej/6KaWAOUgjH3sp0vQB/p3 HA1rZC6UWl1bhN30G9ozPbw+t1jqGvaDO4y6B5TEZVSEacz9BV1sh7nJqMYqfqzjW1dIPw 7QQ2wmrvW0vfbuUbIjsYouK2ce2bFN4= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-658-hYHPAaMkPg2jcoflFBPneA-1; Wed, 28 Feb 2024 21:14:54 -0500 X-MC-Unique: hYHPAaMkPg2jcoflFBPneA-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 E47AA85A588; Thu, 29 Feb 2024 02:14:53 +0000 (UTC) Received: from llong.com (unknown [10.22.9.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5AE30492BFA; Thu, 29 Feb 2024 02:14:52 +0000 (UTC) From: Waiman Long To: Zefan Li , Tejun Heo , Johannes Weiner , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , Frederic Weisbecker Cc: linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, Cestmir Kalina , Costa Shulyupin , Waiman Long Subject: [PATCH 2/2] cgroup/cpuset: Exclude isolated CPUs from housekeeping CPU masks Date: Wed, 28 Feb 2024 21:14:14 -0500 Message-Id: <20240229021414.508972-3-longman@redhat.com> In-Reply-To: <20240229021414.508972-1-longman@redhat.com> References: <20240229021414.508972-1-longman@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792197726645116429 X-GMAIL-MSGID: 1792197726645116429 Call the newly introduced housekeeping_exlude_isolcpus() function to exclude isolated CPUs from the selected housekeeping CPU masks. This is in addition to the exclusion of isolated CPUs from the workqueue unbound CPU mask. Right now only HK_TYPE_TIMER and HK_TYPE_RCU CPU masks are updated, but more may be added in the future when appropriate. Signed-off-by: Waiman Long --- kernel/cgroup/cpuset.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index ba36c073304a..d2541af71c22 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -214,6 +214,11 @@ static cpumask_var_t isolated_cpus; /* List of remote partition root children */ static struct list_head remote_children; +/* + * The set of housekeeping flags to be updated for CPU isolation + */ +#define HOUSEKEEPING_FLAGS (BIT(HK_TYPE_TIMER) | BIT(HK_TYPE_RCU)) + /* * Partition root states: * @@ -1505,7 +1510,15 @@ static bool partition_xcpus_del(int old_prs, struct cpuset *parent, return isolcpus_updated; } -static void update_unbound_workqueue_cpumask(bool isolcpus_updated) +/** + * update_isolation_cpumasks - Update external isolation CPU masks + * @isolcpus_updated - @true if isolation CPU masks update needed + * + * The following external CPU masks will be updated if necessary: + * - workqueue unbound cpumask + * - housekeeping cpumasks + */ +static void update_isolation_cpumasks(bool isolcpus_updated) { int ret; @@ -1515,7 +1528,10 @@ static void update_unbound_workqueue_cpumask(bool isolcpus_updated) return; ret = workqueue_unbound_exclude_cpumask(isolated_cpus); - WARN_ON_ONCE(ret < 0); + if (WARN_ON_ONCE(ret < 0)) + return; + ret = housekeeping_exlude_isolcpus(isolated_cpus, HOUSEKEEPING_FLAGS); + WARN_ON_ONCE((ret < 0) && (ret != -EOPNOTSUPP)); } /** @@ -1609,7 +1625,7 @@ static int remote_partition_enable(struct cpuset *cs, int new_prs, parent->child_ecpus_count--; } spin_unlock_irq(&callback_lock); - update_unbound_workqueue_cpumask(isolcpus_updated); + update_isolation_cpumasks(isolcpus_updated); /* * Proprogate changes in top_cpuset's effective_cpus down the hierarchy. @@ -1645,7 +1661,7 @@ static void remote_partition_disable(struct cpuset *cs, struct tmpmasks *tmp) cs->prs_err = PERR_INVCPUS; reset_partition_data(cs); spin_unlock_irq(&callback_lock); - update_unbound_workqueue_cpumask(isolcpus_updated); + update_isolation_cpumasks(isolcpus_updated); /* * Proprogate changes in top_cpuset's effective_cpus down the hierarchy. @@ -1697,7 +1713,7 @@ static void remote_cpus_update(struct cpuset *cs, struct cpumask *newmask, if (deleting) isolcpus_updated += partition_xcpus_del(prs, NULL, tmp->delmask); spin_unlock_irq(&callback_lock); - update_unbound_workqueue_cpumask(isolcpus_updated); + update_isolation_cpumasks(isolcpus_updated); /* * Proprogate changes in top_cpuset's effective_cpus down the hierarchy. @@ -2067,7 +2083,7 @@ static int update_parent_effective_cpumask(struct cpuset *cs, int cmd, WARN_ON_ONCE(parent->nr_subparts < 0); } spin_unlock_irq(&callback_lock); - update_unbound_workqueue_cpumask(isolcpus_updated); + update_isolation_cpumasks(isolcpus_updated); if ((old_prs != new_prs) && (cmd == partcmd_update)) update_partition_exclusive(cs, new_prs); @@ -3131,7 +3147,7 @@ static int update_prstate(struct cpuset *cs, int new_prs) else if (new_xcpus_state) partition_xcpus_newstate(old_prs, new_prs, cs->effective_xcpus); spin_unlock_irq(&callback_lock); - update_unbound_workqueue_cpumask(new_xcpus_state); + update_isolation_cpumasks(new_xcpus_state); /* Force update if switching back to member */ update_cpumasks_hier(cs, &tmpmask, !new_prs ? HIER_CHECKALL : 0);