Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp1092465rwn; Thu, 8 Sep 2022 13:19:44 -0700 (PDT) X-Google-Smtp-Source: AA6agR4/lJOQRIAUfBNlzdGI0JnsH3a0WMnot7weK42AP9uvODseQoyZKDjy5Ss7kSzNY6E6pnFm X-Received: by 2002:a17:90b:3e86:b0:1f5:2b4f:7460 with SMTP id rj6-20020a17090b3e8600b001f52b4f7460mr5915408pjb.97.1662668384563; Thu, 08 Sep 2022 13:19:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662668384; cv=none; d=google.com; s=arc-20160816; b=LqDq6GtTpfGKpw1dMVOOOCj3OALIuvbDfF18V0Rl4ZBtCHj7l/0zTsU3pznwgfuXKF 37OpIPfYF3ANAQRa2CMJZ5nVkBE8mzVk7aAdEy8zIKsSHH/pFA/8okNXgh5KSqLKScN8 i984kAbkIt6GqKqb/MDWYKQYaLpdNo/2iiPuZltNqkPSi2CRaGWV8ZcCBlQRbVwpqnoZ ANvJ4RSqJ67C9yLKk/SVDWxOnZWxtTW9p/LUX8cVCnC6LkdswPGvYF2kJ+y/qi1VMqdH 2/c9vOyHP3Mbzi9EB8qyl5dQgFxp/6pxwdYnVyNdh4FjnVbhFCu7N9u+YAqClInx23rJ vcuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:subject:cc:to:from:date :user-agent:message-id:dkim-signature; bh=BV5ynmETQj//VSEXh0fAfYZTasPgvMiaUOPYWaeZfe8=; b=xhPtaP4DqUaT6Q4E8fvydcOdF7j144ymwWYc663sPp8U36Sb/4iQs7T64FRy53PmcA uyhQk/bnv+nEb48R0siwd/C/UPLIreZjDjmMPaIr1DMVAN6drHeqoX0dTnHTEVb0IuH0 am65Bx40nABtCYvy2emEKsun4QVWSNU8nItpswxDqy1fMcRqyDvhJda9hepXUr6CxDTE uBlRtjKsejPyLcxvPw979ObtEsp8wbJkPfudMhKB6TBzUAamDgFh9yQs6ihWPas2sIHi PBqtDCPaxdTYiSSINMMh6saWLBjfOaUx01gTxuQvX8Cth8K+lZslcfmGo9zBaqmiVJ3N G4mA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IxIYD+a6; 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=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z25-20020a631919000000b0042bca297653si2769987pgl.207.2022.09.08.13.19.32; Thu, 08 Sep 2022 13:19:44 -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=@redhat.com header.s=mimecast20190719 header.b=IxIYD+a6; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229550AbiIHT5U (ORCPT + 99 others); Thu, 8 Sep 2022 15:57:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229451AbiIHT5T (ORCPT ); Thu, 8 Sep 2022 15:57:19 -0400 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 AED03A50D4 for ; Thu, 8 Sep 2022 12:57:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1662667037; 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: references:references; bh=BV5ynmETQj//VSEXh0fAfYZTasPgvMiaUOPYWaeZfe8=; b=IxIYD+a6OeNXzu5ZKuXRHPgSH238iRqTxUpp9fZtmNkGpyOmhm7bNoKAVkCw21P54Z/ayN jOT1SuCCC2Cnbp8kyGj/CYGiPZfzfYn/S0ZlepWrKguCF1aXvZG4rtJBp7czi4AX0E3+aR 6835wstLEyn2LyPv59il7/hPv5UnrW0= 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-554-vW0eyKDYPEa9FwmV1xQMqQ-1; Thu, 08 Sep 2022 15:57:16 -0400 X-MC-Unique: vW0eyKDYPEa9FwmV1xQMqQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 76DD785A596; Thu, 8 Sep 2022 19:57:16 +0000 (UTC) Received: from fuller.cnet (ovpn-112-2.gru2.redhat.com [10.97.112.2]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 44C7D2026D4C; Thu, 8 Sep 2022 19:57:16 +0000 (UTC) Received: by fuller.cnet (Postfix, from userid 1000) id 24234415CD7D; Thu, 8 Sep 2022 16:54:07 -0300 (-03) Message-ID: <20220908195111.760134219@redhat.com> User-Agent: quilt/0.66 Date: Thu, 08 Sep 2022 16:29:02 -0300 From: Marcelo Tosatti To: linux-kernel@vger.kernel.org Cc: Frederic Weisbecker , Juri Lelli , Daniel Bristot de Oliveira , Prasad Pandit , Valentin Schneider , Yair Podemsky , Thomas Gleixner , Marcelo Tosatti Subject: [RFC PATCH 3/7] introduce _fail variants of stop_machine functions References: <20220908192859.546633738@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE,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 Introduce stop_machine_fail and stop_machine_cpuslocked_fail, which check if any online CPU in the system is tagged as a block interference CPU. If so, returns an error. Signed-off-by: Marcelo Tosatti Index: linux-2.6/include/linux/stop_machine.h =================================================================== --- linux-2.6.orig/include/linux/stop_machine.h +++ linux-2.6/include/linux/stop_machine.h @@ -113,6 +113,9 @@ static inline void print_stop_info(const */ int stop_machine(cpu_stop_fn_t fn, void *data, const struct cpumask *cpus); + +int stop_machine_fail(cpu_stop_fn_t fn, void *data, const struct cpumask *cpus); + /** * stop_machine_cpuslocked: freeze the machine on all CPUs and run this function * @fn: the function to run @@ -124,6 +127,9 @@ int stop_machine(cpu_stop_fn_t fn, void */ int stop_machine_cpuslocked(cpu_stop_fn_t fn, void *data, const struct cpumask *cpus); + +int stop_machine_cpuslocked_fail(cpu_stop_fn_t fn, void *data, const struct cpumask *cpus); + /** * stop_core_cpuslocked: - stop all threads on just one core * @cpu: any cpu in the targeted core Index: linux-2.6/kernel/stop_machine.c =================================================================== --- linux-2.6.orig/kernel/stop_machine.c +++ linux-2.6/kernel/stop_machine.c @@ -22,6 +22,7 @@ #include #include #include +#include /* * Structure to determine completion condition and record errors. May @@ -619,6 +620,17 @@ int stop_machine_cpuslocked(cpu_stop_fn_ return stop_cpus(cpu_online_mask, multi_cpu_stop, &msdata); } +int stop_machine_cpuslocked_fail(cpu_stop_fn_t fn, void *data, + const struct cpumask *cpus) +{ + block_interf_assert_held(); + + if (cpumask_intersects(block_interf_cpumask, cpu_online_mask)) + return -EPERM; + + return stop_machine_cpuslocked(fn, data, cpus); +} + int stop_machine(cpu_stop_fn_t fn, void *data, const struct cpumask *cpus) { int ret; @@ -631,6 +643,19 @@ int stop_machine(cpu_stop_fn_t fn, void } EXPORT_SYMBOL_GPL(stop_machine); +int stop_machine_fail(cpu_stop_fn_t fn, void *data, const struct cpumask *cpus) +{ + int ret; + + /* No CPUs can come up or down during this. */ + cpus_read_lock(); + ret = stop_machine_cpuslocked_fail(fn, data, cpus); + cpus_read_unlock(); + return ret; +} +EXPORT_SYMBOL_GPL(stop_machine_fail); + + #ifdef CONFIG_SCHED_SMT int stop_core_cpuslocked(unsigned int cpu, cpu_stop_fn_t fn, void *data) {