Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp498102ioo; Thu, 26 May 2022 08:09:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy/wQnZufXsI10Px8w2OyQhmF72o93GSyuti/P73AD/+qRgqIdGGLtoo6lyL3u9RdRtn+Qo X-Received: by 2002:a05:6402:1d51:b0:41f:cf6c:35a5 with SMTP id dz17-20020a0564021d5100b0041fcf6c35a5mr40675377edb.25.1653577787691; Thu, 26 May 2022 08:09:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653577787; cv=none; d=google.com; s=arc-20160816; b=IfskTQRayakUwbuM79eB8nHrKeH+cQWwtGOKU3LJI1aBTWRJfvMgZDlKjBa4/Ef/i9 CFAuzvfLG3MNZPojmH7FHUkjZ/s0EjJHU/QFeXX2TiG6w5/PQ2JBACYKWwyKZHfXvCH8 I+1QbtFZ2q0kVWB5NIUvxeam0WZ9YckYblYTToPHzA+NjuI+ii7nJAgZr1rLWs61Sv1E 77FyNcF2cJXKSQXJ9rgkv3sh08UQ+Bx0Ce/De+mLm2yVv/3+FFbLHD/ERCgXVIqVDh7J FW/NsB1V8ZkDWyojC7nMGotZAbsr7CqgdE1iMdcEvzuRYs77CvJH/+z5hJ2mRMe/X0zv a1SQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=qiDvNRmB6KjtSCgRXwxptmQtUbQS+zDvhCmU6cvGOFI=; b=jtdVkWIZWuF4/63Plbv5jUJsFtIsh4TlTAl6WvAgPryTFQVarFiMYu+RLYM4lYXrzU KUQoZ4Ju54qYXOgBTrnoQ9TaGjVPg6lIYQlallVyBZ4QBil/QNhHCVO4nU4Dry/FtVcO q8bfe/9ZPR9tIXiS21MbKu0Q7rwfwR9B9FZPZg+p3y/So4EKZUlL9d2sF7voV3lelGl6 6jpsWHAwmQ6Lp8ndjjf8a1NgL5OGunSVstX/dD2qLxSwtXBFhIJZt+YtgWLfvO7Tva6c AFPfHc9eyFkpM+eQHP34W+pk3s0c5lNBacGLIfziEhICuOtDzGeyI7JUzv7nUxfk5FP5 xHuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Z8awa+Mb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b19-20020a056402279300b0042b2dc4bf5dsi2214649ede.66.2022.05.26.08.09.19; Thu, 26 May 2022 08:09:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Z8awa+Mb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345395AbiEYWLY (ORCPT + 99 others); Wed, 25 May 2022 18:11:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345347AbiEYWLO (ORCPT ); Wed, 25 May 2022 18:11:14 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E75B513CEC; Wed, 25 May 2022 15:11:12 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 708C961AD8; Wed, 25 May 2022 22:11:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 14C9DC34119; Wed, 25 May 2022 22:11:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1653516671; bh=3zniIbPdy7+9dNP1xUFhfBA0uM9hAlLVYqm9/0P36DE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z8awa+Mbgjc4sfpESzBF+k72TBoJ7yG8rlly8BaIhqNwqCWJo7o3y2eFhWB/l0oa/ Tx9HTmfhNaH8d0u3VIhejG1rh+HTjQoCl1sxu8p01i1l1CqQ/I7ed0yfpF1oYnfFbi WYR8VsejPW7OgHmrYM2C8Qv1wSQg6lYsJb2iTz0s8qsaHKM1vhwd41ipcYjV8i9K+e EQV5HAP3JHE5qGcLYvVPHawJ4dUWU1B7VvMbCTcx4aj0sA86BqyH6BkFEVMnyO5R8o lQOG8ZIbKnqb1yW6wrf27ZJ7engpEfr1QDykVVdZX25aSp9zlokvqbB75qWZE1OF04 k3q6HHEXq4MUQ== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , Tejun Heo , Peter Zijlstra , "Paul E . McKenney" , Paul Gortmaker , Johannes Weiner , Marcelo Tosatti , Phil Auld , Zefan Li , Waiman Long , Daniel Bristot de Oliveira , Nicolas Saenz Julienne , rcu@vger.kernel.org Subject: [PATCH 3/4] sched/isolation: Infrastructure to support rcu nocb cpumask changes Date: Thu, 26 May 2022 00:10:54 +0200 Message-Id: <20220525221055.1152307-4-frederic@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220525221055.1152307-1-frederic@kernel.org> References: <20220525221055.1152307-1-frederic@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Provide a minimal infrastructure to change the housekeeping cpumasks. For now only RCU NOCB cpumask is handled. Signed-off-by: Frederic Weisbecker Cc: Zefan Li Cc: Tejun Heo Cc: Johannes Weiner Cc: Paul E. McKenney Cc: Phil Auld Cc: Nicolas Saenz Julienne Cc: Marcelo Tosatti Cc: Paul Gortmaker Cc: Waiman Long Cc: Daniel Bristot de Oliveira Cc: Peter Zijlstra --- include/linux/sched/isolation.h | 13 +++++++++++ kernel/sched/isolation.c | 38 +++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/include/linux/sched/isolation.h b/include/linux/sched/isolation.h index 8c15abd67aed..c6d0e3f83a20 100644 --- a/include/linux/sched/isolation.h +++ b/include/linux/sched/isolation.h @@ -25,6 +25,8 @@ extern const struct cpumask *housekeeping_cpumask(enum hk_type type); extern bool housekeeping_enabled(enum hk_type type); extern void housekeeping_affine(struct task_struct *t, enum hk_type type); extern bool housekeeping_test_cpu(int cpu, enum hk_type type); +extern int housekeeping_cpumask_set(struct cpumask *cpumask, enum hk_type type); +extern int housekeeping_cpumask_clear(struct cpumask *cpumask, enum hk_type type); extern void __init housekeeping_init(void); #else @@ -46,6 +48,17 @@ static inline bool housekeeping_enabled(enum hk_type type) static inline void housekeeping_affine(struct task_struct *t, enum hk_type type) { } + +static inline int housekeeping_cpumask_set(struct cpumask *cpumask, enum hk_type type) +{ + return -EINVAL; +} + +static inline int housekeeping_cpumask_clear(struct cpumask *cpumask, enum hk_type type) +{ + return -EINVAL; +} + static inline void housekeeping_init(void) { } #endif /* CONFIG_CPU_ISOLATION */ diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c index 373d42c707bc..ab4aba795c01 100644 --- a/kernel/sched/isolation.c +++ b/kernel/sched/isolation.c @@ -79,6 +79,44 @@ bool housekeeping_test_cpu(int cpu, enum hk_type type) } EXPORT_SYMBOL_GPL(housekeeping_test_cpu); +static int housekeeping_cpumask_update(struct cpumask *cpumask, + enum hk_type type, bool on) +{ + int err; + + switch (type) { + case HK_TYPE_RCU: + err = rcu_nocb_cpumask_update(cpumask, on); + break; + default: + err = -EINVAL; + } + + if (err >= 0) { + if (on) { + cpumask_or(housekeeping.cpumasks[type], + housekeeping.cpumasks[type], + cpumask); + } else { + cpumask_andnot(housekeeping.cpumasks[type], + housekeeping.cpumasks[type], + cpumask); + } + } + + return err; +} + +int housekeeping_cpumask_set(struct cpumask *cpumask, enum hk_type type) +{ + return housekeeping_cpumask_update(cpumask, type, true); +} + +int housekeeping_cpumask_clear(struct cpumask *cpumask, enum hk_type type) +{ + return housekeeping_cpumask_update(cpumask, type, false); +} + void __init housekeeping_init(void) { enum hk_type type; -- 2.25.1