Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3126254imm; Sun, 29 Jul 2018 10:52:22 -0700 (PDT) X-Google-Smtp-Source: AAOMgpevvU5fdTmvO9SirPBiP6H83Y0iF7llXBQO+oJb7fMKnrYDyz1Q0l7NMzSPsGwqOitnPxGI X-Received: by 2002:a62:c699:: with SMTP id x25-v6mr15016400pfk.16.1532886742704; Sun, 29 Jul 2018 10:52:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532886742; cv=none; d=google.com; s=arc-20160816; b=fGAQoWKTVniW/JwcG/iS2r4I/sk+rgQnD5GSIcJ42tpOMBoG4++Z8tyoYuRLoI9eCc FaYhrH5n94cS2tj4aYOwSBG7HNHCtMRBQ7s+XlJAI6QiS+GdWbUYid4Od14aUt8KkLJP 2rs/LZDYZJ8EahdVJId9CRXiCmYinVWjSojq8MqfTeQQahedFp4R9YGvufItkEvtg0tM 1rWnlKBKZal3q8ZF8elNzLs0r4swwd6VOSa6ufcRwTTIJb9pAnTH2tsDqimMkGUkCLKF ISfPYzcywyu15GcYps52W4v9IW7+1Y/9Wcb0GC8ogeWDBX5EInlc65uv6YG7kn8zYZrC rdMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to:date :cc:to:from:subject:message-id:arc-authentication-results; bh=Bx/bENtII4HfKQkQk/6TvGszZ+kO5DgZFK3F7cKYzAw=; b=pKff5p4jH3GoDe01PNwYNAiBX0GAU/uvQbbtXL8NFiWOahHacFXD/BXThT75XW7z4z SyzHkiCs6Ne5zN7wzMlCmlcomcUACvE/nhQo+6R9Ywun4HYZIHKjUQ872GuQvu4pwUOn pJeMqIYiY8XKzAzqpWIU9k4GaHSV4UbgW38sYii6vHO5+zSgpc/zbe0edy4IH4xFtaeU ubKfa6nVeIogAWlC67wBPxvigKRip9vfKetnkkTlFCXm8qIarCIrTsXRZvdAhRLwCZGj Kg2+0R61FgttuxY4UhHAzF4UeqDPHydOsIVZyh1TzoFyUD5rsRJQAMTYGnA3DlKkbCzQ WZvA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y126-v6si8598160pgb.23.2018.07.29.10.52.06; Sun, 29 Jul 2018 10:52:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726776AbeG2TWa (ORCPT + 99 others); Sun, 29 Jul 2018 15:22:30 -0400 Received: from shelob.surriel.com ([96.67.55.147]:48080 "EHLO shelob.surriel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726417AbeG2TW3 (ORCPT ); Sun, 29 Jul 2018 15:22:29 -0400 Received: from imladris.surriel.com ([96.67.55.152]) by shelob.surriel.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1fjpqc-0000qv-1L; Sun, 29 Jul 2018 13:51:14 -0400 Message-ID: <1532886673.28585.24.camel@surriel.com> Subject: Re: [PATCH 03/10] smp,cpumask: introduce on_each_cpu_cond_mask From: Rik van Riel To: Andy Lutomirski , Paolo Bonzini Cc: Andy Lutomirski , LKML , kernel-team , Peter Zijlstra , X86 ML , Vitaly Kuznetsov , Ingo Molnar , Mike Galbraith , Dave Hansen , will.daecon@arm.com, Catalin Marinas , Benjamin Herrenschmidt Date: Sun, 29 Jul 2018 13:51:13 -0400 In-Reply-To: References: <20180728215357.3249-1-riel@surriel.com> <20180728215357.3249-4-riel@surriel.com> <1532865634.28585.2.camel@surriel.com> Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-HPwDAnWcn0Bwl+Uxv4cO" X-Mailer: Evolution 3.26.6 (3.26.6-1.fc27) Mime-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-HPwDAnWcn0Bwl+Uxv4cO Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sun, 2018-07-29 at 08:36 -0700, Andy Lutomirski wrote: > On Jul 29, 2018, at 5:00 AM, Rik van Riel wrote: >=20 > > On Sat, 2018-07-28 at 19:57 -0700, Andy Lutomirski wrote: > > > On Sat, Jul 28, 2018 at 2:53 PM, Rik van Riel > > > wrote: > > > > Introduce a variant of on_each_cpu_cond that iterates only over > > > > the > > > > CPUs in a cpumask, in order to avoid making callbacks for every > > > > single > > > > CPU in the system when we only need to test a subset. > > > Nice. > > > Although, if you want to be really fancy, you could optimize this > > > (or > > > add a variant) that does the callback on the local CPU in > > > parallel > > > with the remote ones. That would give a small boost to TLB > > > flushes. > >=20 > > The test_func callbacks are not run remotely, but on > > the local CPU, before deciding who to send callbacks > > to. > >=20 > > The actual IPIs are sent in parallel, if the cpumask > > allocation succeeds (it always should in many kernel > > configurations, and almost always in the rest). > >=20 >=20 > What I meant is that on_each_cpu_mask does: >=20 > smp_call_function_many(mask, func, info, wait); > if (cpumask_test_cpu(cpu, mask)) { > unsigned long flags; > local_irq_save(flags); func(info); > local_irq_restore(flags); > } >=20 > So it IPIs all the remote CPUs in parallel, then waits, then does the > local work. In principle, the local flush could be done after > triggering the IPIs but before they all finish. Grepping around the code, I found a few examples where the calling code appears to expect that smp_call_function_many also calls "func" on the local CPU. For example, kvm_emulate_wbinvd_noskip has this: if (kvm_x86_ops->has_wbinvd_exit()) { int cpu =3D get_cpu(); cpumask_set_cpu(cpu, vcpu->arch.wbinvd_dirty_mask); smp_call_function_many(vcpu->arch.wbinvd_dirty_mask, wbinvd_ipi, NULL, 1); put_cpu(); cpumask_clear(vcpu->arch.wbinvd_dirty_mask); } else wbinvd(); This seems to result in systems with ->has_wbinvd_exit only calling wbinvd_ipi on OTHER CPUs, and not on the CPU where the guest exited with wbinvd? This seems unintended. I guess looking into on_each_cpu_mask might be a little higher priority than waiting until the next Outreachy season :) --=20 All Rights Reversed. --=-HPwDAnWcn0Bwl+Uxv4cO Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEEKR73pCCtJ5Xj3yADznnekoTE3oMFAltd/pEACgkQznnekoTE 3oOwfQf/TiWhO4KCwv6tIrnlpxmqskv2tdP7pubr67Xz1dTXbumj9jb9u27Kh+z+ /PQjTIoOMV5m97VH1bSl9OPOS5me+bfRbV4KYnbIngfu4m1vwOKQfUklr9TUXRpF AWSNo3uSyIKFxyuuhSSHmzpuOxB1AVtlYGAgPVJHPWY7RPx96jPmCX/E7MBF/zCH hqznTxO5ulLzCT87EstfO8om1oOH1lKXHOOkRH9S6Hcluyi/sgTF2eqjChO8zDVR CLqYrRgo4rLC6jrymYsQXiG/mB2LtfbRDimWAkXwFj17sSZ2BGNdRlJlnKVvmUOw uKY18EpC8acOgRjJtFVdGXGUMyA5/w== =1zI0 -----END PGP SIGNATURE----- --=-HPwDAnWcn0Bwl+Uxv4cO--