[PATCH 10/17] KVM: monolithic: x86: use the external functions instead of kvm_x86_ops

2019-09-20 Thread Andrea Arcangeli
Now that the new methods are plugged in and they are functional use them instead of invoking the pointer to functions through kvm_x86_ops. Signed-off-by: Andrea Arcangeli --- arch/x86/include/asm/kvm_host.h | 10 +- arch/x86/kvm/cpuid.c| 22 +-- arch/x86/kvm/hyperv.c

[PATCH 01/17] x86: spec_ctrl: fix SPEC_CTRL initialization after kexec

2019-09-20 Thread Andrea Arcangeli
y and unexpectedly leave bit 2 set in SPEC_CTRL. Signed-off-by: Andrea Arcangeli --- arch/x86/include/asm/msr-index.h | 2 ++ arch/x86/kernel/cpu/bugs.c | 20 +++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/as

[PATCH 12/17] KVM: monolithic: remove exports from KVM common code

2019-09-20 Thread Andrea Arcangeli
e. Previous export was in arch/x86/kvm/kvm-intel.ko WARNING: arch/x86/kvm/kvm-amd: 'kvm_page_track_unregister_notifier' exported twice. Previous export was in arch/x86/kvm/kvm-intel.ko a Signed-off-by: Andrea Arcangeli --- virt/kvm/eventfd.c | 1 - virt/kvm/kvm_main.c | 65 ---

[PATCH 06/17] KVM: monolithic: x86: enable the kvm_pmu_ops external functions

2019-09-20 Thread Andrea Arcangeli
Plug in the new external functions and their extern declarations in the respective kernel modules (kvm-intel and kvm-amd). Signed-off-by: Andrea Arcangeli --- arch/x86/kvm/pmu.h | 2 ++ arch/x86/kvm/pmu_amd.c | 2 ++ arch/x86/kvm/vmx/pmu_intel.c | 2 ++ 3 files changed, 6

[PATCH 04/17] KVM: monolithic: x86: convert the kvm_pmu_ops methods to external functions

2019-09-20 Thread Andrea Arcangeli
This replaces all kvm_pmu_ops pointer to functions with regular external functions that don't require indirect calls. Signed-off-by: Andrea Arcangeli --- arch/x86/kvm/pmu_amd_ops.c | 68 arch/x86/kvm/pmu_ops.h | 22 +++ arch/x86/kv

[PATCH 15/17] KVM: retpolines: x86: eliminate retpoline from vmx.c exit handlers

2019-09-20 Thread Andrea Arcangeli
It's enough to check the exit value and issue a direct call to avoid the retpoline for all the common vmexit reasons. Signed-off-by: Andrea Arcangeli --- arch/x86/kvm/vmx/vmx.c | 24 ++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/vmx/vm

[PATCH 16/17] KVM: retpolines: x86: eliminate retpoline from svm.c exit handlers

2019-09-20 Thread Andrea Arcangeli
64+89 entry_SYSCALL_64_after_hwframe+68 ]: 499845 @total: 1780243 SVM has no TSC based programmable preemption timer so it is invoking ktime_get() frequently. Signed-off-by: Andrea Arcangeli --- arch/x86/kvm/svm.c | 14 ++ 1 file changed, 14 insertions(+) diff --git a/arch/x86/kvm/svm.c b

[PATCH 07/17] KVM: monolithic: x86: adjust the section prefixes

2019-09-20 Thread Andrea Arcangeli
Adjusts the section prefixes of some KVM common code function because with the monolithic methods the section checker can now do a more accurate analysis at build time and this allows to build without CONFIG_SECTION_MISMATCH_WARN_ONLY=n. Signed-off-by: Andrea Arcangeli --- arch/x86/kvm/svm.c

Re: [PATCH RFC] tools/memory-model: Fix data race detection for unordered store and load

2019-09-17 Thread Andrea Parri
on-multicopy-atomic systems, as the WWC pattern demonstrates. > > This patch changes the LKMM to accept either a wr-vis or a reverse > rw-xbstar link as a proof of non-concurrency. > > Signed-off-by: Alan Stern Acked-by: Andrea

Re: [patch for-5.3 0/4] revert immediate fallback to remote hugepages

2019-09-04 Thread Andrea Arcangeli
On Wed, Sep 04, 2019 at 12:54:15PM -0700, David Rientjes wrote: > Two commits: > > commit a8282608c88e08b1782141026eab61204c1e533f > Author: Andrea Arcangeli > Date: Tue Aug 13 15:37:53 2019 -0700 > > Revert "mm, thp: restore node-local hugepag

Re: numlist_push() barriers Re: [RFC PATCH v4 1/9] printk-rb: add a new printk ringbuffer implementation

2019-08-26 Thread Andrea Parri
2e8e51c2129d33ddf5e4c76a49 > > > > N.B. This analysis generally depends on the assumption that every marked > > access (e.g., the cmpxchg_release() called out above and the READ_ONCE() > > heading the address dependencies) are _single-copy atomic, an assumption > > wh

Re: numlist_push() barriers Re: [RFC PATCH v4 1/9] printk-rb: add a new printk ringbuffer implementation

2019-08-26 Thread Andrea Parri
Sorry for top posting, but I forgot to mention: as you might have noticed, my @amarulasolutions address is not active anymore; FWIW, you should still be able to reach me at this @gmail address. Thanks, Andrea On Mon, Aug 26, 2019 at 10:34:36AM +0200, Andrea Parri wrote

Re: numlist_push() barriers Re: [RFC PATCH v4 1/9] printk-rb: add a new printk ringbuffer implementation

2019-08-26 Thread Andrea Parri
ds from bD. > > +* > > +* Relies on: > > +* > > +* RELEASE from bD to bE > > +*matching > > +* ADDRESS DEP. from bB to bC->aA > > +*/ > > + WRITE_ONCE(n->seq, seq + 1); > > Do we really need WRITE_ONCE() here? > It is the same problem as with setting n->next_id above. Same considerations as above would apply here. Andrea

Re: comments style: Re: [RFC PATCH v4 1/9] printk-rb: add a new printk ringbuffer implementation

2019-08-23 Thread Andrea Parri
of course specific to the given context: the language, the memory model, etc. ) IOW, I'd say that that wheel _and a common denominator here can be represented by the notion of "litmus test". I'm not suggesting to reinvent this wheel of course; my point was more along the lines of "let's use the wheel, it'll be helpful..." ;-) Andrea

Re: comments style: Re: [RFC PATCH v4 1/9] printk-rb: add a new printk ringbuffer implementation

2019-08-22 Thread Andrea Parri
tness. Is this the case? >From what I've read so far, it _should be relatively straighforward to write down a litmus test from any such comment (and give this to the LKMM simulator). > > In each case, it should follow some "widely" used format. > We should not invent

Re: [PATCH] userfaultfd_release: always remove uffd flags and clear vm_userfaultfd_ctx

2019-08-20 Thread Andrea Arcangeli
changed, 13 insertions(+), 12 deletions(-) Reviewed-by: Andrea Arcangeli Thanks, Andrea

[tip:perf/urgent] kprobes: Fix potential deadlock in kprobe_optimizer()

2019-08-19 Thread tip-bot for Andrea Righi
Commit-ID: f1c6ece23729257fb46562ff9224cf5f61b818da Gitweb: https://git.kernel.org/tip/f1c6ece23729257fb46562ff9224cf5f61b818da Author: Andrea Righi AuthorDate: Mon, 12 Aug 2019 20:43:02 +0200 Committer: Ingo Molnar CommitDate: Mon, 19 Aug 2019 12:22:19 +0200 kprobes: Fix potential

[PATCH] kprobes: fix potential deadlock in kprobe_optimizer()

2019-08-12 Thread Andrea Righi
t*' That immediately triggers the lockdep splat. Fix by acquiring text_mutex before module_mutex in kprobe_optimizer(). Fixes: d5b844a2cf50 ("ftrace/x86: Remove possible deadlock between register_kprobe() and ftrace_run_update_code()") Signed-off-by: Andrea Righi --- kernel/kp

[PATCH v3] bcache: fix deadlock in bcache_allocator

2019-08-07 Thread Andrea Righi
Moreover, make sure to wake up the garbage collector thread when bch_prio_write() is failing to allocate buckets. BugLink: https://bugs.launchpad.net/bugs/1784665 BugLink: https://bugs.launchpad.net/bugs/1796292 Signed-off-by: Andrea Righi --- Changes in v3: - prevent buckets leak in bch_prio_write(

Re: [PATCH v2] bcache: fix deadlock in bcache_allocator

2019-08-07 Thread Andrea Righi
On Tue, Aug 06, 2019 at 07:36:48PM +0200, Andrea Righi wrote: > On Tue, Aug 06, 2019 at 11:18:01AM +0200, Andrea Righi wrote: > > bcache_allocator() can call the following: > > > > bch_allocator_thread() > > -> bch_prio_write() > > -> bch_bucket_

Re: [PATCH v2] bcache: fix deadlock in bcache_allocator

2019-08-06 Thread Andrea Righi
On Tue, Aug 06, 2019 at 11:18:01AM +0200, Andrea Righi wrote: > bcache_allocator() can call the following: > > bch_allocator_thread() > -> bch_prio_write() > -> bch_bucket_alloc() > -> wait on &ca->set->bucket_wait > > But the wake up ev

[PATCH v2] bcache: fix deadlock in bcache_allocator

2019-08-06 Thread Andrea Righi
Moreover, make sure to wake up the garbage collector thread when bch_prio_write() is failing to allocate buckets. BugLink: https://bugs.launchpad.net/bugs/1784665 BugLink: https://bugs.launchpad.net/bugs/1796292 Signed-off-by: Andrea Righi --- Changes in v2: - prevent retry_invalidate busy loop

Re: [PATCH] bcache: fix deadlock in bcache_allocator()

2019-08-06 Thread Andrea Righi
On Wed, Jul 10, 2019 at 05:46:56PM +0200, Andrea Righi wrote: > On Wed, Jul 10, 2019 at 11:11:37PM +0800, Coly Li wrote: > > On 2019/7/10 5:31 下午, Andrea Righi wrote: > > > bcache_allocator() can call the following: > > > > > > bch_allocato

Re: [PATCH] MAINTAINERS: Update e-mail address for Andrea Parri

2019-08-05 Thread Andrea Parri
On Mon, Aug 05, 2019 at 08:23:38AM -0700, James Bottomley wrote: > On Mon, 2019-08-05 at 17:15 +0200, Andrea Parri wrote: > > > Why don't you also add an entry in .mailmap as Will did in commit > > > c584b1202f2d ("MAINTAINERS: Update my email address to use

Re: [PATCH] MAINTAINERS: Update e-mail address for Andrea Parri

2019-08-05 Thread Andrea Parri
ded/desired). Thanks, Andrea

[PATCH] MAINTAINERS: Update e-mail address for Andrea Parri

2019-08-05 Thread Andrea Parri
My @amarulasolutions.com address stopped working this July, so update to my @gmail.com address where you'll still be able to reach me. Signed-off-by: Andrea Parri Cc: Alan Stern Cc: Will Deacon Cc: Peter Zijlstra Cc: Boqun Feng Cc: Nicholas Piggin Cc: David Howells Cc: Jade Alglav

Re: [PATCH 1/4] locking/rwsem: Add missing ACQUIRE to read_slowpath exit when queue is empty

2019-07-19 Thread Andrea Parri
/* Provide lock ACQUIRE */ > + smp_acquire__after_ctrl_dep(); Does this also make the lock RCtso? Or maybe RCtso was already guaranteed (and I'm failing to see why)? Thanks, Andrea

Re: [PATCH] bcache: fix deadlock in bcache_allocator()

2019-07-10 Thread Andrea Righi
On Wed, Jul 10, 2019 at 11:11:37PM +0800, Coly Li wrote: > On 2019/7/10 5:31 下午, Andrea Righi wrote: > > bcache_allocator() can call the following: > > > > bch_allocator_thread() > > -> bch_prio_write() > > -> bch_bucket_alloc() > >

[PATCH] bcache: fix deadlock in bcache_allocator()

2019-07-10 Thread Andrea Righi
er waits on itself. Moreover, make sure to wake up the garbage collector thread when bch_prio_write() is failing to allocate buckets. BugLink: https://bugs.launchpad.net/bugs/1784665 Signed-off-by: Andrea Righi --- drivers/md/bcache/alloc.c | 6 +- drivers/md/bcache/bcache.h | 2

Re: [RFC PATCH v2 1/2] printk-rb: add a new printk ringbuffer implementation

2019-06-30 Thread Andrea Parri
On Sun, Jun 30, 2019 at 04:03:34AM +0200, John Ogness wrote: > On 2019-06-29, Andrea Parri wrote: > >> /** > >> * add_descr_list() - Add a descriptor to the descriptor list. > >> * > >> * @e: An entry that has already reserved data. > >> * &g

[PATCH] tools/memory-model: Update the informal documentation

2019-06-29 Thread Andrea Parri
. Signed-off-by: Andrea Parri Cc: Alan Stern Cc: Will Deacon Cc: Peter Zijlstra Cc: Boqun Feng Cc: Nicholas Piggin Cc: David Howells Cc: Jade Alglave Cc: Luc Maranget Cc: "Paul E. McKenney" Cc: Akira Yokosawa Cc: Daniel Lustig --- tools/memory-model/Documentation/explanatio

Re: [RFC PATCH v2 1/2] printk-rb: add a new printk ringbuffer implementation

2019-06-29 Thread Andrea Parri
o the iterating reader in the pairing >* MB6-read context. >* >* Note: Before this store, the value of @next of the >* previously newest descriptor is EOL. >*/ Same as above but for MB6-read and the acce

Re: [RFC] Deadlock via recursive wakeup via RCU with threadirqs

2019-06-29 Thread Andrea Parri
On Sat, Jun 29, 2019 at 12:15:15PM -0700, Paul E. McKenney wrote: > On Sat, Jun 29, 2019 at 08:09:10PM +0200, Andrea Parri wrote: > > On Sat, Jun 29, 2019 at 09:55:33AM -0700, Paul E. McKenney wrote: > > > On Sat, Jun 29, 2019 at 05:12:36PM +0200, Andrea Parri wrote

Re: [RFC] Deadlock via recursive wakeup via RCU with threadirqs

2019-06-29 Thread Andrea Parri
be (more) paranoid? ..." should have been "IPIs are serializing" (so all a different "order"...) Andrea

Re: [RFC] Deadlock via recursive wakeup via RCU with threadirqs

2019-06-29 Thread Andrea Parri
On Sat, Jun 29, 2019 at 09:55:33AM -0700, Paul E. McKenney wrote: > On Sat, Jun 29, 2019 at 05:12:36PM +0200, Andrea Parri wrote: > > Hi Steve, > > > > > As Paul stated, interrupts are synchronization points. Archs can only > > > play games with ordering when deal

Re: [RFC] Deadlock via recursive wakeup via RCU with threadirqs

2019-06-29 Thread Andrea Parri
t the stores are > done in that order as the interrupt sees it. Hopefully I'm not derailing the conversation too much with my questions ... but I was wondering if we had any documentation (or inline comments) elaborating on this "interrupts are synchronization points"? Thanks, Andrea

Re: [PATCH RFC v2] Convert struct pid count to refcount_t

2019-06-29 Thread Andrea Parri
, it's quite possible that I'm missing something subtle here; said this, ;-) the patch does look good to me: FWIW, Reviewed-by: Andrea Parri Thanks, Andrea > > --- > Changed to RFC to get any feedback on the memory ordering. > > > include/linux/pid.h | 5 +++-

Re: [PATCH] mm/gup: continue VM_FAULT_RETRY processing event for pre-faults

2019-06-22 Thread Andrea Arcangeli
ter if network or disk with userfaultfd or just pagecache readpage on filebacked kernel faults) and only a minor fault is required to obtain the page. But it is better to defer that second minor fault to the point where "pages" already become != NULL, so we end up calling __get_user_pages 2 times instead of 3 times. Thanks, Andrea

Re: [RFC PATCH v2 1/2] printk-rb: add a new printk ringbuffer implementation

2019-06-21 Thread Andrea Parri
= cmpxchg(addr, old, new); (and it will complain loudly without that "loc_var = " part...); this is something that could be improved, or at least it seems this way... A similar consideration holds for all the value-returning primitives. Thanks, Andrea

Re: [PATCH 3/3] tools: memory-model: Improve data-race detection

2019-06-21 Thread Andrea Parri
vis > relations). > > With these changes, the LKMM gives the desired result for Herbert's > litmus test and other related ones. > > Signed-off-by: Alan Stern > Reported-by: Herbert Xu For the entire series: Acked-by: Andrea Parri Two nits, but up to Paul A

Re: [RFC PATCH v2 1/2] printk-rb: add a new printk ringbuffer implementation

2019-06-19 Thread Andrea Parri
illustrated in the examples pointed out above. I'd suggest to _not be stingy with memory barriers explanations: this eases/makes it possible the review itself as well as future changes or fixes to the implementation. FWIW (and as anticipated time ago in a private email), when I see code like this I tend to look elsewhere... ;-/ Thanks, Andrea

[PATCH 1/1] coredump: fix race condition between collapse_huge_page() and core dumping

2019-06-07 Thread Andrea Arcangeli
tate backporting, but in my view it's more a bug in the coredump code that will eventually have to be rewritten to stop invoking page faults without the mmap_sem for reading. So the long term plan is still to drop all mmget_still_valid(). Cc: Fixes: ba76149f47d8 ("thp: khugepaged") Re

Re: [tip:locking/core] Documentation/atomic_t.txt: Clarify pure non-rmw usage

2019-06-06 Thread Andrea Parri
On Thu, Jun 06, 2019 at 11:04:39AM +0200, Peter Zijlstra wrote: > On Thu, Jun 06, 2019 at 10:44:21AM +0200, Andrea Parri wrote: > > On Mon, Jun 03, 2019 at 06:46:54AM -0700, tip-bot for Peter Zijlstra wrote: > > > Commit-ID: fff9b6c7d26943a8eb32b58364b7ec6b9369746a > > &g

Re: [tip:locking/core] Documentation/atomic_t.txt: Clarify pure non-rmw usage

2019-06-06 Thread Andrea Parri
Cc: Thomas Gleixner > Link: > https://lkml.kernel.org/r/20190524115231.gn2...@hirez.programming.kicks-ass.net > Signed-off-by: Ingo Molnar I'd appreciate if you could Cc: me in future changes to this doc. (as currently suggested by get_maintainer.pl). This is particularly annoying when you spend time

Re: rcu_read_lock lost its compiler barrier

2019-06-06 Thread Andrea Parri
On Mon, Jun 03, 2019 at 10:46:40AM +0800, Herbert Xu wrote: > The case we were discussing is from net/ipv4/inet_fragment.c from > the net-next tree: BTW, thank you for keeping me and other people who intervened in that discussion in Cc:... Andrea > > void fqdir_exit(struct

Re: rcu_read_lock lost its compiler barrier

2019-06-06 Thread Andrea Parri
code and the informal doc will have settled in such direction). It seems worth stressing the fact that _neither_ of these changes will prevent the test below from being racy, considered the two accesses to "a" happen concurrently / without synchronization. Thanks, Andrea C xu-2 {

Re: [PATCH] ptrace: restore smp_rmb() in __ptrace_may_access()

2019-05-30 Thread Andrea Parri
acquire__after_ctrl_dep() is for cases in which you would > otherwise need a full memory barrier - smp_mb() - and you want to be > able to reduce it to a read barrier. It is supposed to be used when you want an ACQUIRE but you only have a control dependency (so you "augment the dependency" with this barrier). FWIW, I do agree on the "dark magic"..., and I'd strongly recommend to not use this barrier (or, at least, to use it with high suspicion). Andrea

Re: [PATCH 00/18] locking/atomic: atomic64 type cleanup

2019-05-28 Thread Andrea Parri
On Tue, May 28, 2019 at 12:47:19PM +0200, Peter Zijlstra wrote: > On Sat, May 25, 2019 at 12:43:40AM +0200, Andrea Parri wrote: > > > --- > > > Subject: Documentation/atomic_t.txt: Clarify pure non-rmw usage > > > > > > Clarify that pure non-RMW u

Re: [PATCH -mm] mm, swap: Simplify total_swapcache_pages() with get_swap_device()

2019-05-27 Thread Andrea Parri
/linux-mmots.git/commit/?id=87efc56527b92a59d15c5d4e4b05f875b276a59a Thanks, Andrea

[PATCH v2] rcu: Don't return a value from rcu_assign_pointer()

2019-05-27 Thread Andrea Parri
ps://lkml.kernel.org/r/20190523135013.gl28...@linux.ibm.com Signed-off-by: Andrea Parri Cc: "Paul E. McKenney" Cc: Josh Triplett Cc: Steven Rostedt Cc: Mathieu Desnoyers Cc: Lai Jiangshan Cc: Joel Fernandes Cc: r...@vger.kernel.org Cc: Peter Zijlstra Cc: Will Deacon Cc: Mark R

Re: [PATCH 00/18] locking/atomic: atomic64 type cleanup

2019-05-24 Thread Andrea Parri
counterargument (not so theoretic, just look around in the kernel!) is: we all 'forget' to use READ_ONCE() and WRITE_ONCE(), it should be difficult or more difficult to forget to use atomic_read() and atomic_set()... IAC, I wouldn't call any of them 'wrong'. Andrea >

Re: [PATCH 2/2] Revert "mm, thp: restore node-local hugepage allocations"

2019-05-24 Thread Andrea Arcangeli
vior for compaction+reclaim interleaving if only the whole system would be out of memory in all nodes (and it isn't). The false positive result from the automated testing (where swapping overall performance decreased because fariness increased) wasn't anybody's fault and so the revert at the end of the merge window was a safe approach. So we can try again to fix it now. Thanks! Andrea

Re: [PATCH] rcu: Prevent evaluation of rcu_assign_pointer()

2019-05-24 Thread Andrea Parri
On Fri, May 24, 2019 at 12:45:09PM -0400, Joel Fernandes wrote: > On Fri, May 24, 2019 at 12:36:37PM +0200, Andrea Parri wrote: > > Quoting Paul [1]: > > > > "Given that a quick (and perhaps error-prone) search of the uses > > of rcu_assign_pointer() in v5.1

Re: [PATCH] rcu: Prevent evaluation of rcu_assign_pointer()

2019-05-24 Thread Andrea Parri
On Fri, May 24, 2019 at 06:29:11AM -0700, Paul E. McKenney wrote: > On Fri, May 24, 2019 at 12:36:37PM +0200, Andrea Parri wrote: > > Quoting Paul [1]: > > > > "Given that a quick (and perhaps error-prone) search of the uses > > of rcu_assign_pointer() in v5.1

Re: [PATCH 1/2] vmw_vmci: Clean up uses of atomic*_set()

2019-05-24 Thread Andrea Parri
for the confirmation, Greg. I'll drop mine. At this time, it's not clear to me where Peter's patch will be applied, and where/whether I should rebase 2/2 (if there is interested in that): Please let me know. Thanks, Andrea

Re: [PATCH 1/2] vmw_vmci: Clean up uses of atomic*_set()

2019-05-24 Thread Andrea Parri
On Fri, May 24, 2019 at 12:39:34PM +0200, Peter Zijlstra wrote: > On Fri, May 24, 2019 at 12:35:35PM +0200, Andrea Parri wrote: > > The primitive vmci_q_set_pointer() relies on atomic*_set() being of > > type 'void', but this is a non-portable implementation detail. &

Re: [PATCH 2/2] compiler: Prevent evaluation of WRITE_ONCE()

2019-05-24 Thread Andrea Parri
assign_pointer() patch. > > ... since we do want the WRITE_ONCE() itself to be evaluated. > > On Fri, May 24, 2019 at 12:35:36PM +0200, Andrea Parri wrote: > > Now that there's no single use of the value of WRITE_ONCE(), change > > the implementation to eliminate it. >

[PATCH] rcu: Prevent evaluation of rcu_assign_pointer()

2019-05-24 Thread Andrea Parri
://lkml.kernel.org/r/20190523135013.gl28...@linux.ibm.com Signed-off-by: Andrea Parri Cc: "Paul E. McKenney" Cc: Josh Triplett Cc: Steven Rostedt Cc: Mathieu Desnoyers Cc: Lai Jiangshan Cc: Joel Fernandes Cc: r...@vger.kernel.org Cc: Peter Zijlstra Cc: Will Deacon Cc: Mark Rutland

[PATCH 1/2] vmw_vmci: Clean up uses of atomic*_set()

2019-05-24 Thread Andrea Parri
The primitive vmci_q_set_pointer() relies on atomic*_set() being of type 'void', but this is a non-portable implementation detail. Reported-by: Mark Rutland Signed-off-by: Andrea Parri Cc: Arnd Bergmann Cc: Greg Kroah-Hartman Cc: Jorgen Hansen Cc: Peter Zijlstra Cc: Will Deacon

[PATCH 0/2] Prevent evaluation of WRITE_ONCE()

2019-05-24 Thread Andrea Parri
o to WRITE_ONCE() (which is currently evaluated). Mark suggested to clean up all non-portable users of atomic*_set(), and to prevent WRITE_ONCE() from being evaluated [2]; this resulted in this first attempt/patchset based on Mark's atomics/type-cleanup branch [3]. Cheers Andrea

[PATCH 2/2] compiler: Prevent evaluation of WRITE_ONCE()

2019-05-24 Thread Andrea Parri
Now that there's no single use of the value of WRITE_ONCE(), change the implementation to eliminate it. Suggested-by: Mark Rutland Signed-off-by: Andrea Parri Cc: Arnd Bergmann Cc: Greg Kroah-Hartman Cc: Jorgen Hansen Cc: Peter Zijlstra Cc: Will Deacon Cc: Mark Rutland Cc: &q

Re: [RFC PATCH] rcu: Make 'rcu_assign_pointer(p, v)' of type 'typeof(p)'

2019-05-23 Thread Andrea Parri
st one user that needs to be cleaned up > first (relying on non-portable implementation detaisl of atomic*_set()), > but I suspect rcu_assign_pointer() isn't used as much as a building > block for low-level macros. Thanks for the confirmation, Mark. I can look at the WRITE_ONCE() issues (user and implementation); it will probably be a separate patchset... Thanks, Andrea

Re: [RFC PATCH] rcu: Make 'rcu_assign_pointer(p, v)' of type 'typeof(p)'

2019-05-23 Thread Andrea Parri
eliminate the return value. Thanks for the confirmation, Paul; I'll prepare the new patch shortly... Andrea

[RFC PATCH] rcu: Make 'rcu_assign_pointer(p, v)' of type 'typeof(p)'

2019-05-23 Thread Andrea Parri
nter(*y, x); can currently result in the compiler warning warning: assignment to ‘int *’ from ‘uintptr_t’ {aka ‘long unsigned int’} makes pointer from integer without a cast [-Wint-conversion] Cast the uintptr_t value to a typeof(p) value. Signed-off-by: Andrea Parri Cc: "Paul E. McKe

Re: [PATCH 00/18] locking/atomic: atomic64 type cleanup

2019-05-23 Thread Andrea Parri
ctures implementing arch_atomic_* will have both of these functions > returning void. Currently that's x86 and arm64, but (time permitting) I intend > to migrate other architectures, so I guess we'll have to fix the above up as > required. > > I think it's best to avoid the construct above. Thank you for the clarification, Mark. I agree with you that it'd be better to avoid such constructs. (FWIW, it is not currently possible to use them in litmus tests for the LKMM...) Thanks, Andrea

Re: [PATCH 00/18] locking/atomic: atomic64 type cleanup

2019-05-23 Thread Andrea Parri
y in the implementation of atomic64_set() or if this would also need to be fixed /addressed (say in a different patchset)? Thanks, Andrea

[PATCH 4/4] ceph: fix improper use of smp_mb__before_atomic()

2019-05-20 Thread Andrea Parri
y" Reported-by: Peter Zijlstra Signed-off-by: Andrea Parri Cc: "Yan, Zheng" Cc: Sage Weil Cc: Ilya Dryomov Cc: ceph-de...@vger.kernel.org Cc: "Paul E. McKenney" Cc: Peter Zijlstra --- fs/ceph/super.h | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff -

[PATCH 2/4] bio: fix improper use of smp_mb__before_atomic()

2019-05-20 Thread Andrea Parri
d-by: "Paul E. McKenney" Reported-by: Peter Zijlstra Signed-off-by: Andrea Parri Reviewed-by: Ming Lei Cc: Jens Axboe Cc: Ming Lei Cc: linux-bl...@vger.kernel.org Cc: "Paul E. McKenney" Cc: Peter Zijlstra --- include/linux/bio.h | 2 +- 1 file changed, 1 insertion(+), 1

[PATCH 1/4] drm/msm: Fix improper uses of smp_mb__{before,after}_atomic()

2019-05-20 Thread Andrea Parri
aul E. McKenney" Reported-by: Peter Zijlstra Signed-off-by: Andrea Parri Cc: Rob Clark Cc: Sean Paul Cc: David Airlie Cc: Daniel Vetter Cc: Jordan Crouse Cc: linux-arm-...@vger.kernel.org Cc: dri-de...@lists.freedesktop.org Cc: freedr...@lists.freedesktop.org Cc: "Paul E. McKe

[PATCH 0/4] Fix improper uses of smp_mb__{before,after}_atomic()

2019-05-20 Thread Andrea Parri
://lkml.kernel.org/r/20190430164404.GA2874@andrea Cheers Andrea Cc: Rob Clark Cc: Sean Paul Cc: David Airlie Cc: Daniel Vetter Cc: Jordan Crouse Cc: Jens Axboe Cc: Omar Sandoval Cc: Ming Lei Cc: "Yan, Zheng" Cc: Sage Weil Cc: Ilya Dryomov Cc: "Paul E. McKenney" Cc: Pet

Re: [PATCH 5/5] IB/hfi1: Fix improper uses of smp_mb__before_atomic()

2019-05-14 Thread Andrea Parri
On Tue, May 14, 2019 at 08:32:52AM -0400, Dennis Dalessandro wrote: > On 5/9/2019 5:12 PM, Andrea Parri wrote: > >On Tue, Apr 30, 2019 at 01:16:57AM +0200, Andrea Parri wrote: > >>Hi Mike, > >> > >>>>This barrier only applies to the read-modify-write op

Re: [PATCH 4/5] ceph: fix improper use of smp_mb__before_atomic()

2019-05-13 Thread Andrea Parri
ordered with following atomic64_set. > > > >Thanks for the suggestion, Yan. > > > >To be clear: would you like me to integrate your comment and resend? > >any other suggestions? > > > > Yes, please Will do: I'll let the merge window close and send v2 on top of -rc1. Thanks, Andrea

Re: Question about sched_setaffinity()

2019-05-11 Thread Andrea Parri
e the issue. > > Thank you! May I add your Tested-by? Please feel free to do so. But it may be worth to squash "the commits" (and adjust the changelogs accordingly). And you might want to remove some of those debug checks/prints? Andrea

Re: Linux Testing Microconference at LPC

2019-05-11 Thread Andrea Parri
to Linux Kernel" project [1] and (for the "dynamic analysis" side) the efforts to revive the Kernel Thread sanitizer [2]. I should also mention the efforts to add (support for) "unmarked" accesses and to formalize the notion of "data race" in the memory consistency mo

Re: Question about sched_setaffinity()

2019-05-11 Thread Andrea Parri
is down!!! Peter (echoing Paul): Thank you for pointing that shuffler out! Andrea

Re: Question about sched_setaffinity()

2019-05-09 Thread Andrea Parri
eter Zijlstra kindly volunteered over IRC to look at this more closely > tomorrow (well, today, his time). It is quite strange, though! ;-) Sounds good! ;-) Thanx, Andrea

Re: Question about sched_setaffinity()

2019-05-09 Thread Andrea Parri
On Thu, May 09, 2019 at 11:40:25PM +0200, Andrea Parri wrote: > On Thu, May 09, 2019 at 10:36:54AM -0700, Paul E. McKenney wrote: > > On Tue, May 07, 2019 at 03:16:13PM -0700, Paul E. McKenney wrote: > > > On Wed, May 01, 2019 at 01:27:13PM -0700, Paul E. McKenney wrote: >

Re: Question about sched_setaffinity()

2019-05-09 Thread Andrea Parri
Except > > that this rcutorture scenario doesn't offline anything, and I don't see > > any CPU-hotplug removal messages. So I added another trace_printk() to > > print out cpu_online_mask. This gets me the following: > > > > [ 31.565605] 0) | /* On unexpected CPU 0, expected 1!!! */ > > [ 31.565605] 0) | /* Online CPUs: 0-7 */ > > > > So we didn't make it to CPU 1 despite its being online. I placed the > > console log here: > > > > http://www2.rdrop.com/~paulmck/submission/console.tpkol.log.gz > > > > Thoughts? And I can finally see/reproduce it!! Frankly, no idea how this is happening (I have been staring at these traces/functions for hours/days now... ;-/ ) Adding some "sched" folks in Cc: hopefully, they can shed some light about this. And yes, my only suggestion/approach would be to keep bisecting this code with printk*..., 'fun' ;-/ Andrea

Re: [PATCH 5/5] IB/hfi1: Fix improper uses of smp_mb__before_atomic()

2019-05-09 Thread Andrea Parri
On Tue, Apr 30, 2019 at 01:16:57AM +0200, Andrea Parri wrote: > Hi Mike, > > > >This barrier only applies to the read-modify-write operations; in > > >particular, it does not apply to the atomic_read() primitive. > > > > > >Replace the barrier with an smp

Re: [PATCH 4/5] ceph: fix improper use of smp_mb__before_atomic()

2019-05-09 Thread Andrea Parri
On Tue, Apr 30, 2019 at 05:08:43PM +0800, Yan, Zheng wrote: > On Tue, Apr 30, 2019 at 4:26 PM Peter Zijlstra wrote: > > > > On Mon, Apr 29, 2019 at 10:15:00PM +0200, Andrea Parri wrote: > > > This barrier only applies to the read-modify-write operations; in > > >

Re: [PATCH v2] Documentation: atomic_t.txt: Explain ordering provided by smp_mb__{before,after}_atomic()

2019-05-06 Thread Andrea Parri
s. > > This improves the text to make the actual ordering implications clear, > and also to explain how these barriers differ from a RELEASE or > ACQUIRE ordering. > > Signed-off-by: Alan Stern > CC: Peter Zijlstra I understand that this does indeed better describe the inte

[PATCH 2/2] Revert "mm, thp: restore node-local hugepage allocations"

2019-05-03 Thread Andrea Arcangeli
in feature for guest mode is worth it, to swap "DN 4k | DN+1 THP" with "DN+1 THP | DN 4k" at every NUMA distance crossing. Signed-off-by: Andrea Arcangeli --- include/linux/mempolicy.h | 2 ++ mm/huge_memory.c | 42 --- mm/mempol

[PATCH 0/2] reapply: relax __GFP_THISNODE for MADV_HUGEPAGE mappings

2019-05-03 Thread Andrea Arcangeli
rther. The silver lining is that this extra time allowed to think more at this issue and also plan for a future direction to improve things further in terms of THP NUMA locality. Thank you, Andrea Andrea Arcangeli (2): Revert "Revert "mm, thp: consolidate THP gfp handling into alloc_hug

[PATCH 1/2] Revert "Revert "mm, thp: consolidate THP gfp handling into alloc_hugepage_direct_gfpmask""

2019-05-03 Thread Andrea Arcangeli
This reverts commit 356ff8a9a78fb35d6482584d260c3754dcbdf669. Signed-off-by: Andrea Arcangeli --- include/linux/gfp.h | 12 mm/huge_memory.c| 27 ++- mm/mempolicy.c | 32 +++- mm/shmem.c | 2 +- 4 files changed

Re: [PATCH 0/5] Fix improper uses of smp_mb__{before,after}_atomic()

2019-04-30 Thread Andrea Parri
On Tue, Apr 30, 2019 at 10:34:09AM +0200, Peter Zijlstra wrote: > On Mon, Apr 29, 2019 at 10:14:56PM +0200, Andrea Parri wrote: > > Hello! > > > > A relatively common misuse of these barriers is to apply these to > > operations which are not read-modify-write operati

Re: [PATCH 5/5] IB/hfi1: Fix improper uses of smp_mb__before_atomic()

2019-04-29 Thread Andrea Parri
nto. > > See: > > [PATCH for-next 6/9] IB/rdmavt: Add new completion inline > > We will take a look at this one as well. Thank you for the reference and for looking into this, Andrea

[PATCH 5/5] IB/hfi1: Fix improper uses of smp_mb__before_atomic()

2019-04-29 Thread Andrea Parri
y: "Paul E. McKenney" Reported-by: Peter Zijlstra Signed-off-by: Andrea Parri Cc: Dennis Dalessandro Cc: Mike Marciniszyn Cc: Doug Ledford Cc: Jason Gunthorpe Cc: linux-r...@vger.kernel.org --- drivers/infiniband/sw/rdmavt/qp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deleti

[PATCH 4/5] ceph: fix improper use of smp_mb__before_atomic()

2019-04-29 Thread Andrea Parri
y" Reported-by: Peter Zijlstra Signed-off-by: Andrea Parri Cc: "Yan, Zheng" Cc: Sage Weil Cc: Ilya Dryomov Cc: ceph-de...@vger.kernel.org --- fs/ceph/super.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ceph/super.h b/fs/ceph/super.h index 16c03188578ea.

[PATCH 0/5] Fix improper uses of smp_mb__{before,after}_atomic()

2019-04-29 Thread Andrea Parri
}_atomic() barriers with full memory barriers. Applies on 5.1-rc7. Thanks, Andrea Cc: "Paul E. McKenney" Cc: Peter Zijlstra Cc: Rob Clark Cc: Sean Paul Cc: David Airlie Cc: Daniel Vetter Cc: Jordan Crouse Cc: Jens Axboe Cc: Omar Sandoval Cc: "Yan, Zheng" Cc: Sage We

Re: [PATCH] Documentation: atomic_t.txt: Explain ordering provided by smp_mb__{before,after}_atomic()

2019-04-27 Thread Andrea Parri
specifies > > the barriers only apply to RmW ops and both _set() and _read() are > > specified to not be a RmW. > > Agreed. The "Ditto" covers my atomic_set() consternation. ;-) I was working on some of these before the Easter break [1, 2]: the plan was to continue next week

Re: [PATCH 3/3] tools: memory-model: Add data-race detection

2019-04-26 Thread Andrea Parri
t; facility. The basic design has been explained in various emails, and > a separate documentation patch will be submitted later. > > This work is based on an earlier formulation of data races for the > LKMM by Andrea Parri. > > Signed-off-by: Alan Stern For the entire series, Reviewed-by: Andrea Parri Thanks, Andrea

Re: Adding plain accesses and detecting data races in the LKMM

2019-04-19 Thread Andrea Parri
ich are free to reorder the atomic_dec() with the READ_ONCE() execute a full memory barrier in smp_mb__before_atomic() ... This assumption currently holds, AFAICT, but yes: it may well become "non-portable"! ... ;-) Andrea

Re: Adding plain accesses and detecting data races in the LKMM

2019-04-18 Thread Andrea Parri
hese boil down to: https://elixir.bootlin.com/linux/v5.1-rc5/source/arch/x86/include/asm/atomic.h#L95 https://elixir.bootlin.com/linux/v5.1-rc5/source/arch/x86/include/asm/barrier.h#L84 Andrea

Re: Adding plain accesses and detecting data races in the LKMM

2019-04-18 Thread Andrea Parri
CE(*y, 1); when CONFIG_WEAK_ORDERING=y, CONFIG_WEAK_REORDERING_BEYOND_LLSC=n. Do these observations make sense to you? Thoughts? Andrea

[PATCH] kernfs: fix barrier usage in __kernfs_new_node()

2019-04-16 Thread Andrea Parri
smp_mb__before_atomic() can not be applied to atomic_set(). Remove the barrier and rely on RELEASE synchronization. Fixes: ba16b2846a8c6 ("kernfs: add an API to get kernfs node from inode number") Cc: sta...@vger.kernel.org Signed-off-by: Andrea Parri --- fs/kernfs/dir.c | 5 ++-

Re: Adding plain accesses and detecting data races in the LKMM

2019-04-13 Thread Andrea Parri
On Tue, Apr 09, 2019 at 08:01:32AM -0700, Paul E. McKenney wrote: > On Tue, Apr 09, 2019 at 03:36:18AM +0200, Andrea Parri wrote: > > > > The formula was more along the line of "do not assume either of these > > > > cases to hold; use barrier() is y

Re: Adding plain accesses and detecting data races in the LKMM

2019-04-08 Thread Andrea Parri
is equivalent to: smp_mb__before_atomic(); atomic_fetch_add_relaxed(); smp_mb__after_atomic(); [...] 2) Some implementations of the _relaxed() variants do not provide any compiler barrier currently. Andrea

Re: Adding plain accesses and detecting data races in the LKMM

2019-04-07 Thread Andrea Parri
So consider the following test: > > > > C non-transitive-wmb-2 > > > > { > > x=0x0001; > > } > > > > P0(int *x, int *y) > > { > > *x = 1; > > smp_store_release(y, 1); > > } > > > > P1(int *x, int *y, int *z) > > { > > int r1; > > > > r1 = smp_load_acquire(y); > > if (r1) { > > *x = 2; > > smp_wmb(); > > WRITE_ONCE(*z, 1); > > } > > } > > > > P2(int *x, int *z) > > { > > int r3; > > int r4 = 0; > > > > r3 = READ_ONCE(*z); > > if (r3) { > > smp_rmb(); > > r4 = READ_ONCE(*x); /* E */ > > } > > } > > > > exists (2:r3=1 /\ 2:r4=2) > > > > The proposed model says that this is race-free. Now suppose that the > > compiler mapped the two plain writes above as follows: > > > > *x = 1; --> A:write 0x0001 at x > > B:write 0x at (x + 2) > > > > *x = 2; --> C:write 0x0002 at x > > if ((D:read of 2 bytes at (x + 2)) != 0x) > > write 0x at (x + 2) > > > > and consider the execution where 1:r1=1 and 2:r3=1. We know that A and > > B propagate to P1 before C and D execute (release/acquire) and that C > > propagates to P2 before E executes (wmb/rmb). But what guarantees that > > B, say, propagates to P2 before E executes? AFAICT, nothing prevent P2 > > from reading the value 0x00010002 for x, that is, from reading the least > > significant bits from P1's "write 0x0002 at x" and the most significant > > bits from the initial write. However, the proposed model doesn't report > > the corresponding execution/state. > > Ah, that is indeed an excellent example! I had not considered > mixed-size accesses generated by the compiler. > > So perhaps it would be better to get rid of the whole notion of super > and major writes, and declare that non-transitive-wmb is racy in all > its variants. This makes sense to me. Andrea

Re: Adding plain accesses and detecting data races in the LKMM

2019-04-05 Thread Andrea Parri
; As mentioned earlier, ww-vis is contained in ww-xb and wr-vis is > > > contained in wr-xb. It turns out that the LKMM can almost prove that > > > the ij-xb relations are transitive, in the following sense. If W is a > > > write and R is a read, then: > > > &

Re: [PATCH tip/core/rcu 08/21] tools/memory-model: Add support for synchronize_srcu_expedited()

2019-04-02 Thread Andrea Parri
om the series do not apply to "tip/core/rcu" (from the Subject), but this seems straightforward enough: Acked-by: Andrea Parri Andrea > > // Atomic > atomic_read(X) READ_ONCE(*X) > -- > 2.17.1 >

<    1   2   3   4   5   6   7   8   9   10   >