Received: by 10.213.65.68 with SMTP id h4csp1661750imn; Mon, 26 Mar 2018 11:58:58 -0700 (PDT) X-Google-Smtp-Source: AG47ELtV3GdOH4j1CxjeH9weToNq9I8o8jPZffBkJimmfAo6wVfuup5atDXpg5uTlmfVO6B3MwSZ X-Received: by 10.98.61.80 with SMTP id k77mr27929745pfa.2.1522090738329; Mon, 26 Mar 2018 11:58:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522090738; cv=none; d=google.com; s=arc-20160816; b=VAU63n+9GpxQmwoUDd/9cMMzBvflKVl6jkS0kjqXF2dz0dNgpSMrF+CQ8jvgcC2jtI bpM0NwPHIfQ6XZ4bSP85HrE3479z3gsAuh/gZUm+aTsiMf0uq69Q2DQVhF8/SKDWVmLA C6Xp3m2D4rGmjFWAjTgx8bieNcD6SLa21Q2w9xKO3C88Yab5yInNIBZCR7qEpEvnSJas lHiBEkANcl+dS0pCjGiVfJd8WM5ht1ZsHj+gteSm9ka2pnW0h/BnXOLcBKY4pjhNEGRM otqVGZs/jUcNx+k6epFWcwGfzDky+mWUWZkOxTHxGqm5p/eP3sB/00ruQ3z+eIrPkGq4 lUHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dmarc-filter:arc-authentication-results; bh=b7ev5YtrVtql7KuniqoD+PFdOWAEM1i6s46EjptTqCg=; b=nVBeMXlHO3MaUvb/UVQ0jmaSHIPJ/WZZc/b7GdO1rVHcDc9y5BJUKZvGIVDPr77FkZ Esbdc7BIR6tyfTZSNcu2Be8kzwObEU8PzyDbUJtRchlDFAo5x48v9XJSX0ncwySNdTo0 MYt0qX//IY0qqY9NcehCsvbT3ePu+sIh3V2HDcZtEusEGgCYQCB1O1LR3mFWuB1WxSK/ s4GrX2lsoSn3RvLs1/W9y1xoyzoJzoKAHD6AEMJ4YFu4tyAn+IYObg0YUWFt+Lk5Vkre lNzt4JBlLDWVDmR9PjCjJwBJ7qI+pWJQmMNLilczb7n2LUIpOiDPG1It4jNI2J/bnCw6 HdWw== 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 r20si11933443pfk.125.2018.03.26.11.58.42; Mon, 26 Mar 2018 11:58:58 -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 S1752699AbeCZS5l (ORCPT + 99 others); Mon, 26 Mar 2018 14:57:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:51276 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750983AbeCZS5j (ORCPT ); Mon, 26 Mar 2018 14:57:39 -0400 Received: from gandalf.local.home (cpe-172-100-180-131.stny.res.rr.com [172.100.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 693672177B; Mon, 26 Mar 2018 18:57:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 693672177B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=goodmis.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=rostedt@goodmis.org Date: Mon, 26 Mar 2018 14:57:35 -0400 From: Steven Rostedt To: Andrea Parri Cc: Yury Norov , "Paul E. McKenney" , Chris Metcalf , Christopher Lameter , Russell King - ARM Linux , Mark Rutland , 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 Subject: Re: [PATCH 2/2] smp: introduce kick_active_cpus_sync() Message-ID: <20180326145735.57ba306b@gandalf.local.home> In-Reply-To: <20180326085313.GA4016@andrea> References: <20180325175004.28162-1-ynorov@caviumnetworks.com> <20180325175004.28162-3-ynorov@caviumnetworks.com> <20180326085313.GA4016@andrea> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 26 Mar 2018 10:53:13 +0200 Andrea Parri wrote: > > --- 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(); > > (A general remark only:) > > checkpatch.pl should have warned about the fact that this barrier is > missing an accompanying comment (which accesses are being "ordered", > what is the pairing barrier, etc.). He could have simply copied the comment above the smp_mb() for kick_all_cpus_sync(): /* Make sure the change is visible before we kick the cpus */ The kick itself is pretty much a synchronization primitive. That is, you make some changes and then you need all CPUs to see it, and you call: kick_active_cpus_synch(), which is the barrier to make sure you previous changes are seen on all CPUS before you proceed further. Note, the matching barrier is implicit in the IPI itself. -- Steve > > Moreover if, as your reply above suggested, your patch is relying on > "implicit barriers" (something I would not recommend) then even more > so you should comment on these requirements. > > This could: (a) force you to reason about the memory ordering stuff, > (b) easy the task of reviewing and adopting your patch, (c) easy the > task of preserving those requirements (as implementations changes). > > Andrea > > > > + > > + cpumask_clear(&kernel_cpus); > > + preempt_disable(); > > + for_each_online_cpu(cpu) { > > + if (!rcu_eqs_special_set(cpu)) > > + cpumask_set_cpu(cpu, &kernel_cpus); > > + } > > + smp_call_function_many(&kernel_cpus, do_nothing, NULL, 1); > > + preempt_enable(); > > +} > > +EXPORT_SYMBOL_GPL(kick_active_cpus_sync); > > + > > /** > > * wake_up_all_idle_cpus - break all cpus out of idle > > * wake_up_all_idle_cpus try to break all cpus which is in idle state even > > diff --git a/mm/slab.c b/mm/slab.c > > index 324446621b3e..678d5dbd6f46 100644 > > --- a/mm/slab.c > > +++ b/mm/slab.c > > @@ -3856,7 +3856,7 @@ static int __do_tune_cpucache(struct kmem_cache *cachep, int limit, > > * cpus, so skip the IPIs. > > */ > > if (prev) > > - kick_all_cpus_sync(); > > + kick_active_cpus_sync(); > > > > check_irq_on(); > > cachep->batchcount = batchcount; > > -- > > 2.14.1 > >