Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp1091206rwn; Thu, 8 Sep 2022 13:18:18 -0700 (PDT) X-Google-Smtp-Source: AA6agR6XYvD2dlvGzDZdxXgjzJvgQVhoydbHr70GzLQdclhuAmpdVUpUTDtjo6PEjViQShP/7/sB X-Received: by 2002:a17:902:e887:b0:16e:ef31:416b with SMTP id w7-20020a170902e88700b0016eef31416bmr10556870plg.51.1662668297835; Thu, 08 Sep 2022 13:18:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662668297; cv=none; d=google.com; s=arc-20160816; b=P75YyRXuxKU81TY5e9HCaB7baFPnkj+O0prDmd3fi8Yj37tpBU3sy4acDVin5+bkyR BOHiuBN+VQOzIo/BcJOcADu/MmLpps5XRWWB45JJV2svh4Y8Yk7OE/VxVbxZ4rxkbfdD cX+yvaAXFNuFvT2PbKShqs3kWTUoIqKYNn3CU6lAn0HFuOAhh+QPBDQc9MHfTfVIC9yZ +k+vewPA2UZPoiP4ur7C6aYi98zv2eCb5zx5k4AZNtiP4y4yB2S8NU3soA7tvscyjmoJ ypibJe+SRQKzMdtQSSBLgc1G5UdTNjwCkfC/X8N/nF+lJiO4N71AI4Lc0D1Qn1Wxvjwk Hoow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:date:user-agent:message-id :dkim-signature; bh=zYQznb7UCgAsj1nSAP7Hka8AefENrite35msFZDyBWs=; b=D63co1jafWDvMtlmDZSF6OfzenJ3Eo+ZIv/W7kS/hkCwfCHXCesKjrrFYfc+ojikIW YzD8PTs0N12IixgmfW3wRDOikaK4NQv7ZOhkXinPLUKxNidw9F/ZYBKoAvb5Uz60Y9rg sQ4IwGjQANSCaE3aUHXmQ5oWHQO5K1SzF1NWPlVcmdmeAuGTurzQ5Ddew/AiXAvdAcHg TTlYfmLN2rdHA/YorgPOwlAivOfuqMOh/5s9P6ib8JcTumc5Zt+XOKJD1Uxcs3wPKJy9 QCmefhURid0ssPBMbXqoSZYixaKvq1ePwYJ/TjdogYIOr61Dg3beqOMDHUFrazuTYmyu fiag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="eW7UBO/v"; 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 b16-20020a170902d51000b00176b28d9acesi13154122plg.137.2022.09.08.13.18.02; Thu, 08 Sep 2022 13:18:17 -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="eW7UBO/v"; 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 S229871AbiIHT5q (ORCPT + 99 others); Thu, 8 Sep 2022 15:57:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229633AbiIHT53 (ORCPT ); Thu, 8 Sep 2022 15:57:29 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3945FDBB9 for ; Thu, 8 Sep 2022 12:57:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1662667043; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc; bh=zYQznb7UCgAsj1nSAP7Hka8AefENrite35msFZDyBWs=; b=eW7UBO/voCe5SvN2hS/ANPTgCZtZ7qA7hgbQulmLRoWPVKIIfNh6T8c5JKllY6ClSzvtJS A/sthbrHd/Lb/4sumooexL9tR+ztguGfAhXos4aAEK0L/67gekDUqHxo9IPSDQ4Td4mT3O F2vPdaNvSz08V+l2w/HNzvssC9aZ9sg= 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-563-8fX44FGMPyu1Ii8SboH5_w-1; Thu, 08 Sep 2022 15:57:19 -0400 X-MC-Unique: 8fX44FGMPyu1Ii8SboH5_w-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8A64B803520; Thu, 8 Sep 2022 19:57:18 +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 3E4E32166B26; Thu, 8 Sep 2022 19:57:18 +0000 (UTC) Received: by fuller.cnet (Postfix, from userid 1000) id 1FECC415CD52; Thu, 8 Sep 2022 16:54:07 -0300 (-03) Message-ID: <20220908192859.546633738@redhat.com> User-Agent: quilt/0.66 Date: Thu, 08 Sep 2022 16:28:59 -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 Subject: [RFC PATCH 0/7] cpu isolation: infra to block interference to select CPUs X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 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 There are a number of codepaths in the kernel that interrupt code execution in remote CPUs. A subset of such codepaths are triggered from userspace and can therefore return errors. Introduce a cpumask named "block interference", writable from userspace. This cpumask (and associated helpers) can be used by code that executes code on remote CPUs to optionally return an error. Note: the word "interference" has been chosen since "interruption" is often confused with "device interrupt". To protect readers VS writers of this cpumask, a per-CPU read-write semaphore is used. This is acceptable since the codepaths which trigger such interferences are not (or should not be) hot. What is proposed is to incrementally modify code that can return errors in two ways: 1) Introduction of fail variants of the functions that generate code execution on remote CPUs. This way the modified code should look like: block_interf_read_lock(); ret = smp_call_func_single_fail() / stop_machine_fail() / ... block_interf_read_unlock(); This is grep friendly (so one can search for smp_call_function_* variants) and re-uses code. 2) Usage of block interference CPU mask helpers. For certain users of smp_call_func_*, stop_machine_* functions it is natural to check for block interference CPUs before calling the functions for remote code execution. For example if its not desirable to perform error handling at smp_call_func_* time, or if performing the error handling requires unjustified complexity. Then: block_interf_read_lock(); if target cpumask intersects with block interference cpumask { block_interf_read_unlock(); return error } ... ret = smp_call_function_single / stop_machine() / ... ... block_interf_read_unlock(); Regarding housekeeping flags, it is usually the case that initialization might require code execution on interference blocked CPUs (for example MTRR initialization, resctrlfs initialization, MSR writes, ...). Therefore tagging the CPUs after system initialization is necessary, which is not possible with current housekeeping flags infrastructure. This patchset converts clockevent and clocksource unbind, perf_event_open system call, and /proc/mtrr writes, but there are several more users to convert (eg: MSR reads/writes, resctrlfs, etc). Sending this as an RFC to know whether folks think this is the right direction.