Received: by 10.213.65.68 with SMTP id h4csp508729imn; Wed, 28 Mar 2018 07:43:17 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+IRsXq8yEjlHrQ+38C0SUkSC1pc4fWYDu1cFS3u0Ob17b1PiUt6YrH5swL3ZoOfuGZd+Ck X-Received: by 10.101.73.74 with SMTP id q10mr2804957pgs.323.1522248197802; Wed, 28 Mar 2018 07:43:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522248197; cv=none; d=google.com; s=arc-20160816; b=TLriC31Mpx9t6hpqYpU0DA32wPC3KPyRVPdvQSA8fqVmxlXpLmpT2Ftxnhf0mWFPod 436Z1XU5oAgZEY0fBqARwmVNp2Wpe5I8VtiseWpGL4/G85F0tXPWA4wH/d1ba3Vo3JF9 bheG1N2eIJ/wydQIAsQoOFg4+oUEkPLFiRo62KIjkFAwOjSyEVrUsEaqjFKDPchN1ZUp TQ//skKuDzP+1wAeNn0S0EqWDHWwPiLH2jaKcP+hwynUawu4LHGI02txqKpu7v0NEDf0 4CpaSW6Efo3OrwDumZKm40sQ0UEgX9JFe1inzvzTl2cdl3likIbqpb/6thTq9kQ0O1SH CPkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature:arc-authentication-results; bh=4HjWtoVu1vu7dGPIRIs2JsD6GNq014KnSc1S9W9GVhA=; b=gf3s/C9vLYmB6M3pDfKWEoVjrT7Ayr57hPhMCfi0bz+NzRXZElNy6OrX25CgbM56KD gSLm42GK/4yXoGfOB6MO8JW7Jd+/1YftpaZ8PpDWlYPLUHMOftTWDzj3mgmG+CzNJ9x1 a9TvsSRCTPTSVz5vHH1ReiaWfh+mPtioAlWy2l1+zqk7roXNuGOYw6E+TUvJrD2lUof/ VP8HSFg+FlxsvlJnp8tO5unkbOBmo6JIBToJxbXsLnJjZB+4LUU2LbwCaKJRU9CCvlia ywHrOVgHIwSH3Gim3cuuup1l3i3Kv2qmOUZA+J3qhkXt1H9seRxjDhb9jQ4uSc1TdJH7 Gn1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@CAVIUMNETWORKS.onmicrosoft.com header.s=selector1-cavium-com header.b=eHk/cGKQ; 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 l8si2533050pgr.187.2018.03.28.07.43.02; Wed, 28 Mar 2018 07:43:17 -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; dkim=pass header.i=@CAVIUMNETWORKS.onmicrosoft.com header.s=selector1-cavium-com header.b=eHk/cGKQ; 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 S1753098AbeC1OmC (ORCPT + 99 others); Wed, 28 Mar 2018 10:42:02 -0400 Received: from mail-sn1nam02on0059.outbound.protection.outlook.com ([104.47.36.59]:6692 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752572AbeC1Ol6 (ORCPT ); Wed, 28 Mar 2018 10:41:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=4HjWtoVu1vu7dGPIRIs2JsD6GNq014KnSc1S9W9GVhA=; b=eHk/cGKQeUi0bKmt2tcI2hr9UACSYPB3q5jIOI3dyEw3QdzE/uwQ8qO8HhAcA6Q7ZqvZwhyte3y88Z6hlkc0rKHe+18pTfqAtJUHrZ/zN+uQfwTVmYiKpzCHqq7bU39SiFS+tsamJDMMpHStzPfVQv/ArSM02XeoTzniPFi3Fec= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Yuri.Norov@cavium.com; Received: from localhost (171.101.210.188) by BN6PR07MB2897.namprd07.prod.outlook.com (10.173.28.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.631.10; Wed, 28 Mar 2018 14:41:54 +0000 Date: Wed, 28 Mar 2018 17:41:40 +0300 From: Yury Norov To: "Paul E. McKenney" Cc: Chris Metcalf , Christopher Lameter , Russell King - ARM Linux , Mark Rutland , Steven Rostedt , Mathieu Desnoyers , Catalin Marinas , Will Deacon , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, kvm-ppc@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, luto@kernel.org Subject: Re: [PATCH 2/2] smp: introduce kick_active_cpus_sync() Message-ID: <20180328144140.g4qwtciikffaescu@yury-thinkpad> References: <20180325175004.28162-1-ynorov@caviumnetworks.com> <20180325175004.28162-3-ynorov@caviumnetworks.com> <20180325192328.GI3675@linux.vnet.ibm.com> <20180325201154.icdcyl4nw2jootqq@yury-thinkpad> <20180326124555.GJ3675@linux.vnet.ibm.com> <20180328133605.u7pftfxpn3jbqire@yury-thinkpad> <20180328135617.GQ3675@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180328135617.GQ3675@linux.vnet.ibm.com> User-Agent: NeoMutt/20170609 (1.8.3) X-Originating-IP: [171.101.210.188] X-ClientProxiedBy: HE1PR0102CA0029.eurprd01.prod.exchangelabs.com (10.170.250.42) To BN6PR07MB2897.namprd07.prod.outlook.com (10.173.28.143) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: df9753b7-a473-4cf2-4708-08d594ba0d57 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(5600026)(4604075)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020);SRVR:BN6PR07MB2897; X-Microsoft-Exchange-Diagnostics: 1;BN6PR07MB2897;3:gqfbHMIAKM4ZvJeFIh7Z4A0Vv80xz2tnsiKTdzZ6EZgfcMe23ZZqzgJTHhOMUW5b/uHxzFyExQtO1YJ0X8pumSXp6Dyzrz4hrE4LrgRBvZQlvyuCOSKqaN3bGyEREZ90d0qnagkZO2UYiaijdsnbTNBBzZC8ULjKLr20AtmJrnIW+fP2a2b0d9iGYf+HbEV+ZgDgUTf9v0XZU5NZEkKp8vk9fL8EgcrdHTHoJSnkUJETN2ERncghkFKKgJ0TjIl/;25:lgXqjAAIlr0n3Xyel99U7Q0VCNy9ApcYJt1tUui5tqEz7loPrzyWMgDdJuj1274iI+75XmJC37VAcPRK9PFa2YF4k6BpjQFAAx9Etd5OKVjEKYRHGgu8UaXl7zPur2bEK7hbQNFi8gIjIiQUmp4otoSl6SNzHSWg7QOhdTBqDXH/XpYpNyVKfisDSNAKISlXGr80rIPf/pcpkLYucyEQcjUQcjaLkM+vyLrJPlGlXbfO2SXqqMhNtbxPZ9CwhnH9iNEGX4VX9XbvO2QZ+APTfC9nkRyE8pUA2lnRHC/kZMVz3H46yKOnMJn8iFFUZkCghJBsTE5nLUqiTilEdscoNA==;31:g3FcGnwJcdOa2dZ9QfqsnOlpAq6bsQK77uPtM6Voglf5x+52cAdr7gXtvdpFCPLSVAttFvZLHrjCXt4mOgj4XanxNLSFjQUjPlw/qExzM1L4HUyps39p8X45jIT3WdUBX7aglZ/gULoLRQ3E2W1f5jNim8wll2BkGzAaDRK/9McjxBtVBM+08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VS: X-Exchange-Antispam-Report-Test: UriScan:(788757137089); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3231221)(944501327)(52105095)(10201501046)(93006095)(3002001)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(20161123562045)(20161123564045)(6072148)(201708071742011);SRVR:BN6PR07MB2897;BCL:0;PCL:0;RULEID:;SRVR:BN6PR07MB2897; X-Forefront-PRVS: 06259BA5A2 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6069001)(7916004)(366004)(39860400002)(346002)(39380400002)(376002)(396003)(189003)(199004)(52314003)(55236004)(6246003)(26005)(478600001)(6486002)(6666003)(33896004)(66066001)(2906002)(97736004)(54906003)(93886005)(186003)(42882007)(16526019)(47776003)(3846002)(386003)(6496006)(53936002)(52116002)(9686003)(6306002)(76176011)(6916009)(76506005)(59450400001)(316002)(6116002)(16586007)(23726003)(1076002)(50466002)(58126008)(81156014)(4326008)(229853002)(33716001)(305945005)(68736007)(8676002)(956004)(106356001)(486005)(446003)(7416002)(81166006)(8936002)(486005)(105586002)(7736002)(476003)(25786009)(5660300001)(11346002)(72206003);DIR:OUT;SFP:1101;SCL:1;SRVR:BN6PR07MB2897;H:localhost;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BN6PR07MB2897;23:GGkB9HSdN26DYOPDZ98TU/ZRei635yjtT3guM1Ndj?= =?us-ascii?Q?/wCk8O3k8ADjkR1mEQ4QbBUli0AM7+wwivjxXqmABEECFgS7atpAdUTfVmNc?= =?us-ascii?Q?ZhNGn1zA30P0RXRfGoTCdgMOJZoifP5L7esdg6eVGV5R4GOdH6Kp2u7nxpW9?= =?us-ascii?Q?4YWoOfUl8mEyLkxX6h2YC40G/AZ9XtL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kghzTfz/a1T8NZgs/onG18zjMG1wMnLv6YBIIzJRwUXEJ6LdOjZBZCX8dvk1K7ZkbGhDzl7xhpp/FSmI1/YIw8Kmbat551HLfblMv9prrC5J4dls1EL/BG6iYKp4Jnzw==;5:KVTgu6Qamje86TZN5/6dTI+N9skJIpG+73TyZHvyFHWVVcsuX4WnY1ss/eLytrly6x6L47/sfhuh3g8eXgasKWP+OFU5R3wH/HUZYCoWM7EjemN/ux3OiJE2lSQ6mq7e1Wi8f1HFQvoTQb9TQbDpaZcKd1tZRhZMqfOh6WIP4oE=;24:VWp7oZzE3hR6PbXyLJYblx790fGyIY/eGgGmwo0DMq5VqFDkGLtGCXwxDLkKWUEhvfapfMThOGu+3pngc8edRjBUBIxmpl+YVvTucLWxhRU= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BN6PR07MB2897;7:Hr4LGBjAhhujeAi6dZinsG8wIzfzhQR2bzHg6yRZ/7khtvJgr8qnVhZnaGsBxKfaCyLQSMrMJkaLNRiCRhn/Z4VK2/nm0TF64ZnHoZncE1Fkk/6nnlZeNHpQV8dEiAoByIWgkDPJHBbEu2ZjZ8/RHlYyToRtQ0rOLzyO0lnAGPVhswUk2xAepNvtMxr0QuI/VhCTMjMXvPZt8iwZlBDjwGlnojbtzqboCqPaDTmbMimsRPT9305PNBbbuDjCwEJs X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Mar 2018 14:41:54.2367 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: df9753b7-a473-4cf2-4708-08d594ba0d57 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR07MB2897 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 28, 2018 at 06:56:17AM -0700, Paul E. McKenney wrote: > On Wed, Mar 28, 2018 at 04:36:05PM +0300, Yury Norov wrote: > > On Mon, Mar 26, 2018 at 05:45:55AM -0700, Paul E. McKenney wrote: > > > On Sun, Mar 25, 2018 at 11:11:54PM +0300, Yury Norov wrote: > > > > On Sun, Mar 25, 2018 at 12:23:28PM -0700, Paul E. McKenney wrote: > > > > > On Sun, Mar 25, 2018 at 08:50:04PM +0300, Yury Norov wrote: > > > > > > kick_all_cpus_sync() forces all CPUs to sync caches by sending broadcast IPI. > > > > > > If CPU is in extended quiescent state (idle task or nohz_full userspace), this > > > > > > work may be done at the exit of this state. Delaying synchronization helps to > > > > > > save power if CPU is in idle state and decrease latency for real-time tasks. > > > > > > > > > > > > This patch introduces kick_active_cpus_sync() and uses it in mm/slab and arm64 > > > > > > code to delay syncronization. > > > > > > > > > > > > For task isolation (https://lkml.org/lkml/2017/11/3/589), IPI to the CPU running > > > > > > isolated task would be fatal, as it breaks isolation. The approach with delaying > > > > > > of synchronization work helps to maintain isolated state. > > > > > > > > > > > > I've tested it with test from task isolation series on ThunderX2 for more than > > > > > > 10 hours (10k giga-ticks) without breaking isolation. > > > > > > > > > > > > Signed-off-by: Yury Norov > > > > > > --- > > > > > > arch/arm64/kernel/insn.c | 2 +- > > > > > > include/linux/smp.h | 2 ++ > > > > > > kernel/smp.c | 24 ++++++++++++++++++++++++ > > > > > > mm/slab.c | 2 +- > > > > > > 4 files changed, 28 insertions(+), 2 deletions(-) > > > > > > > > > > > > diff --git a/arch/arm64/kernel/insn.c b/arch/arm64/kernel/insn.c > > > > > > index 2718a77da165..9d7c492e920e 100644 > > > > > > --- a/arch/arm64/kernel/insn.c > > > > > > +++ b/arch/arm64/kernel/insn.c > > > > > > @@ -291,7 +291,7 @@ int __kprobes aarch64_insn_patch_text(void *addrs[], u32 insns[], int cnt) > > > > > > * synchronization. > > > > > > */ > > > > > > ret = aarch64_insn_patch_text_nosync(addrs[0], insns[0]); > > > > > > - kick_all_cpus_sync(); > > > > > > + kick_active_cpus_sync(); > > > > > > return ret; > > > > > > } > > > > > > } > > > > > > diff --git a/include/linux/smp.h b/include/linux/smp.h > > > > > > index 9fb239e12b82..27215e22240d 100644 > > > > > > --- a/include/linux/smp.h > > > > > > +++ b/include/linux/smp.h > > > > > > @@ -105,6 +105,7 @@ int smp_call_function_any(const struct cpumask *mask, > > > > > > smp_call_func_t func, void *info, int wait); > > > > > > > > > > > > void kick_all_cpus_sync(void); > > > > > > +void kick_active_cpus_sync(void); > > > > > > void wake_up_all_idle_cpus(void); > > > > > > > > > > > > /* > > > > > > @@ -161,6 +162,7 @@ smp_call_function_any(const struct cpumask *mask, smp_call_func_t func, > > > > > > } > > > > > > > > > > > > static inline void kick_all_cpus_sync(void) { } > > > > > > +static inline void kick_active_cpus_sync(void) { } > > > > > > static inline void wake_up_all_idle_cpus(void) { } > > > > > > > > > > > > #ifdef CONFIG_UP_LATE_INIT > > > > > > diff --git a/kernel/smp.c b/kernel/smp.c > > > > > > index 084c8b3a2681..0358d6673850 100644 > > > > > > --- a/kernel/smp.c > > > > > > +++ b/kernel/smp.c > > > > > > @@ -724,6 +724,30 @@ void kick_all_cpus_sync(void) > > > > > > } > > > > > > EXPORT_SYMBOL_GPL(kick_all_cpus_sync); > > > > > > > > > > > > +/** > > > > > > + * kick_active_cpus_sync - Force CPUs that are not in extended > > > > > > + * quiescent state (idle or nohz_full userspace) sync by sending > > > > > > + * IPI. Extended quiescent state CPUs will sync at the exit of > > > > > > + * that state. > > > > > > + */ > > > > > > +void kick_active_cpus_sync(void) > > > > > > +{ > > > > > > + int cpu; > > > > > > + struct cpumask kernel_cpus; > > > > > > + > > > > > > + smp_mb(); > > > > > > + > > > > > > + cpumask_clear(&kernel_cpus); > > > > > > + preempt_disable(); > > > > > > + for_each_online_cpu(cpu) { > > > > > > + if (!rcu_eqs_special_set(cpu)) > > > > > > > > > > If we get here, the CPU is not in a quiescent state, so we therefore > > > > > must IPI it, correct? > > > > > > > > > > But don't you also need to define rcu_eqs_special_exit() so that RCU > > > > > can invoke it when it next leaves its quiescent state? Or are you able > > > > > to ignore the CPU in that case? (If you are able to ignore the CPU in > > > > > that case, I could give you a lower-cost function to get your job done.) > > > > > > > > > > Thanx, Paul > > > > > > > > What's actually needed for synchronization is issuing memory barrier on target > > > > CPUs before we start executing kernel code. > > > > > > > > smp_mb() is implicitly called in smp_call_function*() path for it. In > > > > rcu_eqs_special_set() -> rcu_dynticks_eqs_exit() path, smp_mb__after_atomic() > > > > is called just before rcu_eqs_special_exit(). > > > > > > > > So I think, rcu_eqs_special_exit() may be left untouched. Empty > > > > rcu_eqs_special_exit() in new RCU path corresponds empty do_nothing() in old > > > > IPI path. > > > > > > > > Or my understanding of smp_mb__after_atomic() is wrong? By default, > > > > smp_mb__after_atomic() is just alias to smp_mb(). But some > > > > architectures define it differently. x86, for example, aliases it to > > > > just barrier() with a comment: "Atomic operations are already > > > > serializing on x86". > > > > > > > > I was initially thinking that it's also fine to leave > > > > rcu_eqs_special_exit() empty in this case, but now I'm not sure... > > > > > > > > Anyway, answering to your question, we shouldn't ignore quiescent > > > > CPUs, and rcu_eqs_special_set() path is really needed as it issues > > > > memory barrier on them. > > > > > > An alternative approach would be for me to make something like this > > > and export it: > > > > > > bool rcu_cpu_in_eqs(int cpu) > > > { > > > struct rcu_dynticks *rdtp = &per_cpu(rcu_dynticks, cpu); > > > int snap; > > > > > > smp_mb(); /* Obtain consistent snapshot, pairs with update. */ > > > snap = READ_ONCE(&rdtp->dynticks); > > > smp_mb(); /* See above. */ > > > return !(snap & RCU_DYNTICK_CTRL_CTR); > > > } > > > > > > Then you could replace your use of rcu_cpu_in_eqs() above with > > > > Did you mean replace rcu_eqs_special_set()? > > Yes, apologies for my confusion, and good show figuring it out. ;-) > > > > the new rcu_cpu_in_eqs(). This would avoid the RMW atomic, and, more > > > important, the unnecessary write to ->dynticks. > > > > > > Or am I missing something? > > > > > > Thanx, Paul > > > > This will not work because EQS CPUs will not be charged to call > > smp_mb() on exit of EQS. > > Actually, CPUs are guaranteed to do a value-returning atomic increment > of ->dynticks on EQS exit, which implies smp_mb() both before and after > that atomic increment. > > > Lets sync our understanding of IPI and RCU mechanisms. > > > > Traditional IPI scheme looks like this: > > > > CPU1: CPU2: > > touch shared resource(); /* running any code */ > > smp_mb(); > > smp_call_function(); ---> handle_IPI() > > EQS exit here, so implied > smp_mb() on both sides of the > ->dynticks increment. > > > { > > /* Make resource visible */ > > smp_mb(); > > do_nothing(); > > } > > > > And new RCU scheme for eqs CPUs looks like this: > > > > CPU1: CPU2: > > touch shared resource(); /* Running EQS */ > > smp_mb(); > > > > if (RCU_DYNTICK_CTRL_CTR) > > set(RCU_DYNTICK_CTRL_MASK); /* Still in EQS */ > > > > /* And later */ > > rcu_dynticks_eqs_exit() > > { > > if (RCU_DYNTICK_CTRL_MASK) { > > /* Make resource visible */ > > smp_mb(); > > rcu_eqs_special_exit(); > > } > > } > > > > Is it correct? > > You are missing the atomic_add_return() that is already in > rcu_dynticks_eqs_exit(), and this value-returning atomic operation again > implies smp_mb() both before and after. So you should be covered without > needing to worry about RCU_DYNTICK_CTRL_MASK. > > Or am I missing something subtle here? Ah, now I understand, thank you. I'll collect other comments for more, and submit v2 with this change. Yury