From patchwork Tue Feb 6 18:49:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 197611 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1754380dyb; Tue, 6 Feb 2024 11:03:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IGDl5iS4lLhU87VFH5IJOmcDq6TiPhzib22AutL1UQC5zJCZ1u0DQ1OcwQMK6g+bNmePi49 X-Received: by 2002:a05:622a:648:b0:42c:333:d89b with SMTP id a8-20020a05622a064800b0042c0333d89bmr4703213qtb.2.1707246212089; Tue, 06 Feb 2024 11:03:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707246212; cv=pass; d=google.com; s=arc-20160816; b=RNAcRz1goNKcUr+GGCNpCp190LGSA8WQBcz4Yl0NP1imEyDPq8SQ924QfAmhO+RSwl 3TIPPWrAc+Y/RBMBOB5+LQ6MAaekEKIXG6gqOFaIrSi7G8M7J/N9XyDXHSwlxcZ+f5WJ 7YUTp1rgbE63+vCwN3lgifsHB6oYWSVa+IhUNFz+8lVPVOxt0FIJU50fR3XKd2gxJYmk QtxPgnX4BAJxraHUt3xx8PTgOLRWg8Qp9I3YoImX4Ozyb/tFy0U2SI0A+Z82R/leuz0X QbOeRVRDhSIXV+zKk/VPSeDUZe+48nv/hsAYU1JfAs++U1GJIMo0Ksr8SS1PazdJIWGk h4tg== 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=J50CvXczHSwA/BrhgFcQolBldvwwnU8vOyQFXDiy4d8=; b=Ne8gteBi3LtwUywo+xsW+QuMCz6i1q+XtaRIOluCztN7sqbmn1jxiQfJvy1yymm7Pg Z+zAx1RGZRT117eLvl18bMKPhM2dMf6EX+R8Yay6gj0Bh/M2p3wapLn4Q4aOCTfCQAvt ZA+IYVqM1O4T5Yx/q2vuuVmOFGILMXqkwfeX8gHvz3FIo7Zzqqdgxg8FQ3XDBHzPc0Cd qOB3cdatFeOU3PLZ3fQr4MrL/26UcwOfVn9bcFCqSdCw7SZQgNtqr/aywWyoVbRsCgWe XWvDb7QcwLDGFO0zRMdHpVB06vIPGH6r7kBSOp+u79uu/VBQO1noGVt8tfVNIu+YCLvp EOIA==; 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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55525-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Forwarded-Encrypted: i=1; AJvYcCXj73HjZ0ij+eRV9Dj04fiBYvxGjnFIejHRwzEsX0WdyA4at3jCeb/QrTCp8IuJqaV7Ad9Wq9up5J1Hl6pZAkF7i1VjsA== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id w7-20020a05622a134700b0042c30fc6ac5si2962390qtk.222.2024.02.06.11.03.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 11:03:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55525-ouuuleilei=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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55525-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 8CEFE1C257F5 for ; Tue, 6 Feb 2024 19:03:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1C7721C694; Tue, 6 Feb 2024 19:00:41 +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 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790177403937182560 X-GMAIL-MSGID: 1790177403937182560 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) {