Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751218AbdGaGDP (ORCPT ); Mon, 31 Jul 2017 02:03:15 -0400 Received: from mail-wr0-f182.google.com ([209.85.128.182]:37250 "EHLO mail-wr0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750927AbdGaGDO (ORCPT ); Mon, 31 Jul 2017 02:03:14 -0400 Subject: Re: Udpated sys_membarrier() speedup patch, FYI To: Mathieu Desnoyers , "Paul E. McKenney" Cc: maged michael , Andrew Hunter , gromer , linux-kernel , Peter Zijlstra References: <20170727181250.GA20183@linux.vnet.ibm.com> <5c8c6946-ce3a-6183-76a2-027823a9948a@scylladb.com> <20170727194322.GL3730@linux.vnet.ibm.com> <5fe39d32-5fc1-3a59-23fc-9bdb1d90edf9@scylladb.com> <20170727203706.GO3730@linux.vnet.ibm.com> <1035920775.29109.1501189118277.JavaMail.zimbra@efficios.com> <1546253326.29115.1501189344518.JavaMail.zimbra@efficios.com> From: Avi Kivity Organization: ScyllaDB Message-ID: Date: Mon, 31 Jul 2017 09:03:09 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <1546253326.29115.1501189344518.JavaMail.zimbra@efficios.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1473 Lines: 42 On 07/28/2017 12:02 AM, Mathieu Desnoyers wrote: > ----- On Jul 27, 2017, at 4:58 PM, Mathieu Desnoyers mathieu.desnoyers@efficios.com wrote: > >> ----- On Jul 27, 2017, at 4:37 PM, Paul E. McKenney paulmck@linux.vnet.ibm.com >> wrote: >> >>> On Thu, Jul 27, 2017 at 11:04:13PM +0300, Avi Kivity wrote: > [...] >>>>> + >>>>> + this_cpu = raw_smp_processor_id(); >>>>> + for_each_online_cpu(cpu) { >>>>> + struct task_struct *p; >>>>> + >>>>> + if (cpu == this_cpu) >>>>> + continue; >>>>> + rcu_read_lock(); >>>>> + p = task_rcu_dereference(&cpu_rq(cpu)->curr); >>>>> + if (p && p->mm == current->mm) >>>>> + __cpumask_set_cpu(cpu, tmpmask); >>>> This gets you some false positives, if the CPU idled then mm will >>>> not have changed. >>> Good point! The battery-powered embedded guys would probably prefer >>> we not needlessly IPI idle CPUs. We cannot rely on RCU's dyntick-idle >>> state in nohz_full cases. Not sure if is_idle_task() can be used >>> safely, given things like play_idle(). >> Would changing the check in this loop to: >> >> if (p && !is_idle_task(p) && p->mm == current->mm) { >> >> work for you ? > Avi, is there an optimization that allows current->mm to be non-null > when the idle task is scheduled that I am missing ? > > I would have expected current->mm to be always NULL for idle > tasks. > > I remembered that current->mm does not change when switching to a kernel task, but my Kernlish is very rusty, or maybe it has changed.