Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp3237155rdb; Tue, 6 Feb 2024 11:02:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IHezsnnhf5g6/CAMM7dn3x16N4IA0NwaODmC7ACp5DIEA8WHraIu88A3trs5Vsmnh6h6ejf X-Received: by 2002:a05:622a:215:b0:42a:6ea9:f2df with SMTP id b21-20020a05622a021500b0042a6ea9f2dfmr4096052qtx.49.1707246163564; Tue, 06 Feb 2024 11:02:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707246163; cv=pass; d=google.com; s=arc-20160816; b=ijOxMckl44KuBtQtwzt0SR0CXVdnNyIY5X4ZrAwgexBRWWoUfeHrnKgOqR1/1ZWF+E 9to6BvhsXyDX42qm9iC+oojBga7U2msCxm7Sl5IvU+BY4LjB6Y2PpP/SAEmBjLd4XSF1 +jhAPDKMkWwRsB0Dw3QLp6wdl3quMSkt8KeXcHn49jBdvect6rKImDuarTuzhUrWyobe ey8peerOIhsfBfIzFuzCr68IkZ9PFkeQRvq0b3tVXmbpeDcSoDYqiiQ0W8oQnnsI68bf EQtJgZ9witZff3bWiyhU2QnPmqI3Da9nB5wHeRruyfL6G4b2i438KD54xTWcsNy28TSZ al2w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:subject:cc:to:from:date:user-agent:message-id :dkim-signature; bh=9S9tPpZAmseeiLZUrI+pVU9cbhqwZZw6DOXomnrNeHc=; fh=8Ui3WkrlGagdM5rbeGORZp8md+n0q4zV1a+swv7AYts=; b=bxm913vb0vYSi0mcthoVSLRTyE0hc6klZdhJU5TYaHreV+7dXbCBBk9lOuDDxLhkuK quTKrCofhIrkcxFoKpF1v/MLDQoYH0Zw2Vy51mKiNmbbkc5TEtnLP91cjNJX6goVOpSc e36521s2FYqtZgaha/KPYLIpRisk5eE3FewcsCpNqp35mVMFgi4fA4j2lXbfG1K1FElP aVPWmYMdEUC+4UlR1wkY3jT65EZuF6+HCjSjsR0iAY1LsaMXaHQ1VodoAijuVelCGSgd jv1kWpuAMAN+q+4z1tamAJZTKTLgZ7KeSj/m8ONelNM+6BKs7q+/8A0gv6B6ieW1rc+2 6+DA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=E5z81I8E; 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-55525-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55525-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Forwarded-Encrypted: i=1; AJvYcCU84pGt4y8wRr6BuTm7P54TYOY9UJ8w+FX/FhO9j4jw63AGi2VEGwfzLNsUekQ3FeUU/68SnJHBiA8xfMKW3uBFX+19V0M9w+KvTFhJ4w== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id i15-20020ac85c0f000000b0042c2e933c51si3010721qti.486.2024.02.06.11.02.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 11:02:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55525-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=E5z81I8E; 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-55525-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55525-linux.lists.archive=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 77B2A1C25C82 for ; Tue, 6 Feb 2024 19:02:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E5EA31B7F0; Tue, 6 Feb 2024 19:00:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="E5z81I8E" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 91CD913FE2 for ; Tue, 6 Feb 2024 19:00:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707246036; cv=none; b=XQVEHOkFRK1L1eniXHnYIOQ6EJjoHhsaTia7xBQpxBIRoCyEdIFoXW7+3uZ974xk/noDtUiO3eK5Jn/8DKo6FhCDu9QyFWXEaH7wZlX84hSlkYVbaxzdBESnw2eYQcwLVY2W7RJ1P0T+ipliPt137DXQsQC5ZZ50VpbUhT5gh5c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707246036; c=relaxed/simple; bh=xMRGD+douvn1GyniumMUnx87zYhBacweAJuDukjwzso=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=mRNnYJctI6/Ht2p2hZc6vuiMloRVt7uvEdbTAyiqhvBPEsfpU5SMgL1womFV1j1H6RFf7OhfwE2q4sGsI2skN6XDFnyepCpoU3gTtZnDzA/gkraNIwo/GY7Qb2v1GgL/9xR+7oDzgN7L5H7BSRTZXI2EtgYEYKn+rFlTWTtHFx4= 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=E5z81I8E; arc=none smtp.client-ip=170.10.129.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=1707246031; 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=9S9tPpZAmseeiLZUrI+pVU9cbhqwZZw6DOXomnrNeHc=; b=E5z81I8EhMgvdkS3ckqz3BXP+LPGEuQVydiN1DmqKE9GgyNDHuYjGlz+5otWb7KMq+Yfzr C/Fd6+qCnN0YpR/iGfGLVXqDh4OWSgR+pDXcJCczbjow7uekZN9TvteqIqOQvYqmYMuN87 gG5ULneluL3Mk8dmO05F1SzURDgml+c= 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-489-uBtq7ULgOpq9Vlkm0gw09g-1; Tue, 06 Feb 2024 14:00:26 -0500 X-MC-Unique: uBtq7ULgOpq9Vlkm0gw09g-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (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 58E6F8489A6; Tue, 6 Feb 2024 19:00:25 +0000 (UTC) Received: from tpad.localdomain (unknown [10.96.133.4]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1B6BA1103A; Tue, 6 Feb 2024 19:00:25 +0000 (UTC) Received: by tpad.localdomain (Postfix, from userid 1000) id 21F57401E1133; Tue, 6 Feb 2024 15:58:07 -0300 (-03) Message-ID: <20240206185709.902281455@redhat.com> User-Agent: quilt/0.67 Date: Tue, 06 Feb 2024 15:49:14 -0300 From: Marcelo Tosatti To: linux-kernel@vger.kernel.org Cc: Daniel Bristot de Oliveira , Juri Lelli , Valentin Schneider , Frederic Weisbecker , Leonardo Bras , Peter Zijlstra , Thomas Gleixner , Marcelo Tosatti Subject: [patch 03/12] Introduce _fail variants of stop_machine functions References: <20240206184911.248214633@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 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-isolation/include/linux/stop_machine.h =================================================================== --- linux-isolation.orig/include/linux/stop_machine.h +++ linux-isolation/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-isolation/kernel/stop_machine.c =================================================================== --- linux-isolation.orig/kernel/stop_machine.c +++ linux-isolation/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) {