[<prev] [next>] [day] [month] [year] [list]
Message-ID: <dc9fad3577551d34ead36c0f7340a573086c0cab.camel@linux.ibm.com>
Date: Mon, 23 Sep 2019 16:40:39 -0300
From: Leonardo Bras <leonardo@...ux.ibm.com>
To: John Hubbard <jhubbard@...dia.com>, linuxppc-dev@...ts.ozlabs.org,
linux-kernel@...r.kernel.org, Linux-MM <linux-mm@...ck.org>
Cc: Arnd Bergmann <arnd@...db.de>,
Richard Fontana <rfontana@...hat.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
YueHaibing <yuehaibing@...wei.com>,
Nicholas Piggin <npiggin@...il.com>,
Mike Rapoport <rppt@...ux.ibm.com>,
Keith Busch <keith.busch@...el.com>,
Jason Gunthorpe <jgg@...pe.ca>,
Paul Mackerras <paulus@...ba.org>,
"Aneesh Kumar K.V" <aneesh.kumar@...ux.ibm.com>,
Allison Randal <allison@...utok.net>,
Mahesh Salgaonkar <mahesh@...ux.vnet.ibm.com>,
Ganesh Goudar <ganeshgr@...ux.ibm.com>,
Thomas Gleixner <tglx@...utronix.de>,
Ira Weiny <ira.weiny@...el.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Dan Williams <dan.j.williams@...el.com>
Subject: Re: [PATCH v2 11/11] powerpc/mm/book3s64/pgtable: Uses counting
method to skip serializing
On Mon, 2019-09-23 at 11:14 -0700, John Hubbard wrote:
> On 9/23/19 10:25 AM, Leonardo Bras wrote:
> [...]
> That part is all fine, but there are no run-time memory barriers in the
> atomic_inc() and atomic_dec() additions, which means that this is not
> safe, because memory operations on CPU 1 can be reordered. It's safe
> as shown *if* there are memory barriers to keep the order as shown:
>
> CPU 0 CPU 1
> ------ --------------
> atomic_inc(val) (no run-time memory barrier!)
> pmd_clear(pte)
> if (val)
> run_on_all_cpus(): IPI
> local_irq_disable() (also not a mem barrier)
>
> READ(pte)
> if(pte)
> walk page tables
>
> local_irq_enable() (still not a barrier)
> atomic_dec(val)
>
> free(pte)
>
> thanks,
This is serialize:
void serialize_against_pte_lookup(struct mm_struct *mm)
{
smp_mb();
if (running_lockless_pgtbl_walk(mm))
smp_call_function_many(mm_cpumask(mm), do_nothing,
NULL, 1);
}
That would mean:
CPU 0 CPU 1
------ --------------
atomic_inc(val)
pmd_clear(pte)
smp_mb()
if (val)
run_on_all_cpus(): IPI
local_irq_disable()
READ(pte)
if(pte)
walk page tables
local_irq_enable() (still not a barrier)
atomic_dec(val)
By https://www.kernel.org/doc/Documentation/memory-barriers.txt :
'If you need all the CPUs to see a given store at the same time, use
smp_mb().'
Is it not enough?
Do you suggest adding 'smp_mb()' after atomic_{inc,dec} ?
Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)
Powered by blists - more mailing lists