From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christian Borntraeger Subject: Re: [PATCH v2 22/32] s390: define __smp_xxx Date: Tue, 5 Jan 2016 16:39:37 +0100 Message-ID: <568BE3B9.8020901@de.ibm.com> References: <1451572003-2440-1-git-send-email-mst@redhat.com> <1451572003-2440-23-git-send-email-mst@redhat.com> <20160104134525.GA6344@twins.programming.kicks-ass.net> <20160104221323-mutt-send-email-mst@redhat.com> <20160105091319.59ddefc7@mschwide> <20160105105335-mutt-send-email-mst@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20160105105335-mutt-send-email-mst-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> Sender: linux-metag-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: "Michael S. Tsirkin" , Martin Schwidefsky Cc: Peter Zijlstra , linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Arnd Bergmann , linux-arch-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Andrew Cooper , virtualization-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org, Stefano Stabellini , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , David Miller , linux-ia64-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org, linux-s390-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, sparclinux-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, linux-metag-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-mips-6z/3iImG2C8G8FEW9MqTrA@public.gmane.org, x86-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org, user-mode-linux-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org, adi-buildroot-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org, linux-sh-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-xtensa-PjhNF2WwrV/0Sa2dR60CXw@public.gmane.org, xen-devel-GuqFBffKawtpuQazS67q72D2FQJk+8+b@public.gmane.org, Heiko Carstens , Ingo Molnar List-Id: linux-arch.vger.kernel.org On 01/05/2016 10:30 AM, Michael S. Tsirkin wrote: > > arch/s390/kernel/vdso.c: smp_mb(); > > Looking at > Author: Christian Borntraeger > Date: Fri Sep 11 16:23:06 2015 +0200 > > s390/vdso: use correct memory barrier > > By definition smp_wmb only orders writes against writes. (Finish all > previous writes, and do not start any future write). To protect the > vdso init code against early reads on other CPUs, let's use a full > smp_mb at the end of vdso init. As right now smp_wmb is implemented > as full serialization, this needs no stable backport, but this change > will be necessary if we reimplement smp_wmb. > > ok from hypervisor point of view, but it's also strange: > 1. why isn't this paired with another mb somewhere? > this seems to violate barrier pairing rules. > 2. how does smp_mb protect against early reads on other CPUs? > It normally does not: it orders reads from this CPU versus writes > from same CPU. But init code does not appear to read anything. > Maybe this is some s390 specific trick? > > I could not figure out the above commit. It was probably me misreading the code. I change a wmb into a full mb here since I was changing the defintion of wmb to a compiler barrier. I tried to fixup all users of wmb that really pair with other code. I assumed that there must be some reader (as there was a wmb before) but I could not figure out which. So I just played safe here. But it probably can be removed. > arch/s390/kvm/kvm-s390.c: smp_mb(); This can go. If you have a patch, I can carry that via the kvms390 tree, or I will spin a new patch with you as suggested-by. Christian From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from e06smtp11.uk.ibm.com ([195.75.94.107]:36558 "EHLO e06smtp11.uk.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751603AbcAEPjw (ORCPT ); Tue, 5 Jan 2016 10:39:52 -0500 Received: from localhost by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 5 Jan 2016 15:39:50 -0000 Subject: Re: [PATCH v2 22/32] s390: define __smp_xxx References: <1451572003-2440-1-git-send-email-mst@redhat.com> <1451572003-2440-23-git-send-email-mst@redhat.com> <20160104134525.GA6344@twins.programming.kicks-ass.net> <20160104221323-mutt-send-email-mst@redhat.com> <20160105091319.59ddefc7@mschwide> <20160105105335-mutt-send-email-mst@redhat.com> From: Christian Borntraeger Message-ID: <568BE3B9.8020901@de.ibm.com> Date: Tue, 5 Jan 2016 16:39:37 +0100 MIME-Version: 1.0 In-Reply-To: <20160105105335-mutt-send-email-mst@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-arch-owner@vger.kernel.org List-ID: To: "Michael S. Tsirkin" , Martin Schwidefsky Cc: Peter Zijlstra , linux-kernel@vger.kernel.org, Arnd Bergmann , linux-arch@vger.kernel.org, Andrew Cooper , virtualization@lists.linux-foundation.org, Stefano Stabellini , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , David Miller , linux-ia64@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, sparclinux@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-metag@vger.kernel.org, linux-mips@linux-mips.org, x86@kernel.org, user-mode-linux-devel@lists.sourceforge.net, adi-buildroot-devel@lists.sourceforge.net, linux-sh@vger.kernel.org, linux-xtensa@linux-xtensa.org, xen-devel@lists.xenproject.org, Heiko Carstens , Ingo Molnar , Davidlohr Bueso , Andrey Konovalov Message-ID: <20160105153937.cYGhqmYLP831RuHELb4pUaSvkPsaCfD6rBZd2e4s6v8@z> On 01/05/2016 10:30 AM, Michael S. Tsirkin wrote: > > arch/s390/kernel/vdso.c: smp_mb(); > > Looking at > Author: Christian Borntraeger > Date: Fri Sep 11 16:23:06 2015 +0200 > > s390/vdso: use correct memory barrier > > By definition smp_wmb only orders writes against writes. (Finish all > previous writes, and do not start any future write). To protect the > vdso init code against early reads on other CPUs, let's use a full > smp_mb at the end of vdso init. As right now smp_wmb is implemented > as full serialization, this needs no stable backport, but this change > will be necessary if we reimplement smp_wmb. > > ok from hypervisor point of view, but it's also strange: > 1. why isn't this paired with another mb somewhere? > this seems to violate barrier pairing rules. > 2. how does smp_mb protect against early reads on other CPUs? > It normally does not: it orders reads from this CPU versus writes > from same CPU. But init code does not appear to read anything. > Maybe this is some s390 specific trick? > > I could not figure out the above commit. It was probably me misreading the code. I change a wmb into a full mb here since I was changing the defintion of wmb to a compiler barrier. I tried to fixup all users of wmb that really pair with other code. I assumed that there must be some reader (as there was a wmb before) but I could not figure out which. So I just played safe here. But it probably can be removed. > arch/s390/kvm/kvm-s390.c: smp_mb(); This can go. If you have a patch, I can carry that via the kvms390 tree, or I will spin a new patch with you as suggested-by. Christian