From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755165AbbBUBv6 (ORCPT ); Fri, 20 Feb 2015 20:51:58 -0500 Received: from mail-ig0-f173.google.com ([209.85.213.173]:60167 "EHLO mail-ig0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754696AbbBUBv5 (ORCPT ); Fri, 20 Feb 2015 20:51:57 -0500 MIME-Version: 1.0 In-Reply-To: References: <20150220133756.GA30528@gmail.com> Date: Fri, 20 Feb 2015 17:51:56 -0800 X-Google-Sender-Auth: NQ4yHHInXaRGwDnndLAp8GRmTYo Message-ID: Subject: Re: [GIT PULL] locking fixes From: Linus Torvalds To: Ingo Molnar , Christian Borntraeger Cc: Linux Kernel Mailing List , Peter Zijlstra , Thomas Gleixner , Andrew Morton Content-Type: multipart/mixed; boundary=001a11c3d13afd878f050f8f69bf Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --001a11c3d13afd878f050f8f69bf Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable So here's my try at fixing READ_ONCE() so that it is happy with 'const' sou= rces. It is entirely untested. Comments/testing? Christian, I guess I could just have forced a cast instead of the union. I'd like you to take a look at this, because right now it's holding up me pulling from Ingo. And Ingo, I think you need to add some kind of test for "horrible new warnings". I think your pull request *worked*, but the tens of lines of new warnings it generates is unacceptable, and will just cause me to undo the pull if I notice in time (like I did this time). Linus On Fri, Feb 20, 2015 at 4:03 PM, Linus Torvalds wrote: > How does this work for you at all? > > On Fri, Feb 20, 2015 at 5:37 AM, Ingo Molnar wrote: >> diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c >> index 94f643484300..e354cc6446ab 100644 >> --- a/arch/x86/kernel/kvm.c >> +++ b/arch/x86/kernel/kvm.c >> @@ -803,8 +808,8 @@ static void kvm_unlock_kick(struct arch_spinlock *lo= ck, __ticket_t ticket) >> add_stats(RELEASED_SLOW, 1); >> for_each_cpu(cpu, &waiting_cpus) { >> const struct kvm_lock_waiting *w =3D &per_cpu(klock_wait= ing, cpu); >> - if (ACCESS_ONCE(w->lock) =3D=3D lock && >> - ACCESS_ONCE(w->want) =3D=3D ticket) { >> + if (READ_ONCE(w->lock) =3D=3D lock && >> + READ_ONCE(w->want) =3D=3D ticket) { >> add_stats(RELEASED_SLOW_KICKED, 1); >> kvm_kick_cpu(cpu); >> break; > > I get horrible compile warnings from this, because of how 'w' is a > pointer to a 'const' structure, which then causes things like > > include/linux/compiler.h:262:39: warning: passing argument 1 of > =E2=80=98__read_once_size=E2=80=99 discards =E2=80=98const=E2=80=99 quali= fier from pointer target type > ({ typeof(x) __val; __read_once_size(&x, &__val, sizeof(__val)); __= val; }) > > which is fairly hard to avoid (looks like it might need a union) > > Linus --001a11c3d13afd878f050f8f69bf Content-Type: text/plain; charset=US-ASCII; name="patch.diff" Content-Disposition: attachment; filename="patch.diff" Content-Transfer-Encoding: base64 X-Attachment-Id: f_i6ecmg320 Y29tbWl0IDFjYjIwNTgxYjBhMzI2NzNmYTNkMDU2ODI5Y2E4OWRiNGZhMGRlMDkKQXV0aG9yOiBM aW51cyBUb3J2YWxkcyA8dG9ydmFsZHNAbGludXgtZm91bmRhdGlvbi5vcmc+CkRhdGU6ICAgRnJp IEZlYiAyMCAxNTo0NjozMSAyMDE1IC0wODAwCgogICAga2VybmVsOiBtYWtlIFJFQURfT05DRSgp IHZhbGlkIG9uIGNvbnN0IHBvaW50ZXJzCiAgICAKICAgIFRoZXJlIGlzIGNlcnRhaW5seSBub3Ro aW5nIHdyb25nIHdpdGggdXNpbmcgUkVBRF9PTkNFKCkgb24gYSBjb25zdAogICAgcG9pbnRlciwg YnV0IHRoZSBoZWxwZXIgZnVuY3Rpb24gX19yZWFkX29uY2Vfc2l6ZSgpIHdvdWxkIGNhdXNlIHdh cm5pbmdzCiAgICBiZWNhdXNlIGl0IHdvdWxkIGRyb3AgdGh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