Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932234AbbDMLjI (ORCPT ); Mon, 13 Apr 2015 07:39:08 -0400 Received: from mail-oi0-f49.google.com ([209.85.218.49]:34562 "EHLO mail-oi0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753794AbbDMLjF (ORCPT ); Mon, 13 Apr 2015 07:39:05 -0400 MIME-Version: 1.0 In-Reply-To: <20150328104712.GA4016@linux.vnet.ibm.com> References: <55113D0A.2030302@gmail.com> <20150325143018.GZ5718@linux.vnet.ibm.com> <5512CDC4.10203@gmail.com> <20150328104210.GB28980@linux.vnet.ibm.com> <20150328104712.GA4016@linux.vnet.ibm.com> Date: Mon, 13 Apr 2015 13:39:04 +0200 Message-ID: Subject: Re: [PATCH 1/3] rculist: Fix list_entry_rcu to read ptr with rcu_dereference_raw From: Patrick Marlier To: Paul McKenney Cc: linux-kernel@vger.kernel.org, Josh Triplett Content-Type: multipart/mixed; boundary=001a113497faab688a0513998f46 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 7902 Lines: 152 --001a113497faab688a0513998f46 Content-Type: text/plain; charset=UTF-8 Strange I don't get any conflict. Maybe due to my email client so I attached the patches to this email. Thanks, -- Patrick On Sat, Mar 28, 2015 at 11:47 AM, Paul E. McKenney wrote: > On Sat, Mar 28, 2015 at 03:42:10AM -0700, Paul E. McKenney wrote: >> On Wed, Mar 25, 2015 at 04:01:24PM +0100, Patrick Marlier wrote: >> > On 03/25/2015 03:30 PM, Paul E. McKenney wrote: >> > >On Tue, Mar 24, 2015 at 11:31:38AM +0100, Patrick Marlier wrote: >> > >>Change to read effectively ptr with rcu_dereference_raw and not the >> > >>__ptr variable on the stack. >> > >> >> > >>Signed-off-by: Patrick Marlier >> > >Avoiding an extra load could be worthwhile in a number of situations, >> > >agreed. >> > Not only a load. It adds a store and a load on the stack and I think >> > this creates a dependency in the processor pipeline. >> > >> > >However, won't this change cause sparse to complain if invoked on a >> > >non-RCU-protected pointer? The ability to use list-RCU API >> > >members on both RCU and non-RCU pointers was one of the points >> > >of the previous commit, right? >> > Probably we can put back the cast but I am not familiar enough with >> > the RCU API. >> > >> > Also, the problem here is that you probably want ACCESS_ONCE to >> > happen on the content of 'ptr' and not on the stack variable >> > '__ptr'. >> > >> > (you have to follow this chain: rcu_dereference_raw -> >> > rcu_dereference_check -> __rcu_dereference_check -> >> > lockless_dereference -> ACCESS_ONCE) >> > >> > #define lockless_dereference(p) \ >> > ({ \ >> > typeof(p) _________p1 = ACCESS_ONCE(p); \ >> > smp_read_barrier_depends(); /* Dependency order vs. p above. */ \ >> > (_________p1); \ >> > }) >> > >> > #define __ACCESS_ONCE(x) ({ \ >> > __maybe_unused typeof(x) __var = (__force typeof(x)) 0; \ >> > (volatile typeof(x) *)&(x); }) >> > #define ACCESS_ONCE(x) (*__ACCESS_ONCE(x)) >> > >> > Note that ACCESS_ONCE is doing "&" on x. >> > >> > IMHO, I would prefer saving some useless instructions for better >> > performance rather than giving too much flexibility on the API (also >> > pretty sure the cast can be still done). >> >> OK, what I am going to do is to apply your patches for testing purposes. >> If there are no complaints, they will likely go into v4.3 or thereabouts. > > Except that I hit conflicts. Could you please rebase to rcu/dev at > git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git? > > Thanx, Paul > --001a113497faab688a0513998f46 Content-Type: text/x-patch; charset=US-ASCII; name="0001-rculist-Fix-list_entry_rcu-to-read-ptr-with-rcu_dere.patch" Content-Disposition: attachment; filename="0001-rculist-Fix-list_entry_rcu-to-read-ptr-with-rcu_dere.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_i8ft3x1e0 RnJvbSA4YWM4MThkNDE4MDY4MTA1NjIzZTQzYmJkMjg5ZDk1NTNjMTgyZTZjIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBQYXRyaWNrIE1hcmxpZXIgPHBhdHJpY2subWFybGllckBnb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KnB0cikg X19yY3UgX19mb3JjZSAqKXB0cjsgXAotCWNvbnRhaW5lcl9vZigodHlwZW9mKHB0cikpcmN1X2Rl cmVmZXJlbmNlX3JhdyhfX3B0ciksIHR5cGUsIG1lbWJlcik7IFwKLX0pCisJY29udGFpbmVyX29m KCh0eXBlb2YocHRyKSlyY3VfZGVyZWZlcmVuY2VfcmF3KHB0ciksIHR5cGUsIG1lbWJlcikKIAog LyoqCiAgKiBXaGVyZSBhcmUgbGlzdF9lbXB0eV9yY3UoKSBhbmQgbGlzdF9maXJzdF9lbnRyeV9y Y3UoKT8KLS0gCjIuMS4wCgo= --001a113497faab688a0513998f46 Content-Type: text/x-patch; charset=US-ASCII; name="0002-netfilter-fix-list_entry_rcu-usage.patch" Content-Disposition: attachment; filename="0002-netfilter-fix-list_entry_rcu-usage.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_i8ft3x1o1 RnJvbSAzYWI1ZjM0MjkzOWY3NjhiNjkzNzA4YmQzMmVmM2YzNTBhZjNiNWE2IE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBQYXRyaWNrIE1hcmxpZXIgPHBhdHJpY2subWFybGllckBnbWFp bC5jb20+CkRhdGU6IFR1ZSwgMjQgTWFyIDIwMTUgMTE6MjE6MDUgKzAxMDAKU3ViamVjdDogW1BB VENIIDIvM10gbmV0ZmlsdGVyOiBmaXggbGlzdF9lbnRyeV9yY3UgdXNhZ2UuCgpTaWduZWQtb2Zm LWJ5OiBQYXRyaWNrIE1hcmxpZXIgPHBhdHJpY2subWFybGllckBnbWFpbC5jb20+Ci0tLQogbmV0 L25ldGZpbHRlci9jb3JlLmMgfCAyICstCiAxIGZpbGUgY2hhbmdlZCwgMSBpbnNlcnRpb24oKyks IDEgZGVsZXRpb24oLSkKCmRpZmYgLS1naXQgYS9uZXQvbmV0ZmlsdGVyL2NvcmUuYyBiL25ldC9u ZXRmaWx0ZXIvY29yZS5jCmluZGV4IGZlYTllZjUuLjA1YmQzMTEgMTAwNjQ0Ci0tLSBhL25ldC9u ZXRmaWx0ZXIvY29yZS5jCisrKyBiL25ldC9uZXRmaWx0ZXIvY29yZS5jCkBAIC0xNzQsNyArMTc0 LDcgQEAgaW50IG5mX2hvb2tfc2xvdyh1X2ludDhfdCBwZiwgdW5zaWduZWQgaW50IGhvb2ssIHN0 cnVjdCBza19idWZmICpza2IsCiAJLyogV2UgbWF5IGFscmVhZHkgaGF2ZSB0aGlzLCBidXQgcmVh ZC1sb2NrcyBuZXN0IGFueXdheSAqLwogCXJjdV9yZWFkX2xvY2soKTsKIAotCWVsZW0gPSBsaXN0 X2VudHJ5X3JjdSgmbmZfaG9va3NbcGZdW2hvb2tdLCBzdHJ1Y3QgbmZfaG9va19vcHMsIGxpc3Qp OworCWVsZW0gPSBsaXN0X2VudHJ5X3JjdShuZl9ob29rc1twZl1baG9va10ubmV4dCwgc3RydWN0 IG5mX2hvb2tfb3BzLCBsaXN0KTsKIG5leHRfaG9vazoKIAl2ZXJkaWN0ID0gbmZfaXRlcmF0ZSgm bmZfaG9va3NbcGZdW2hvb2tdLCBza2IsIGhvb2ssIGluZGV2LAogCQkJICAgICBvdXRkZXYsICZl bGVtLCBva2ZuLCBob29rX3RocmVzaCk7Ci0tIAoyLjEuMAoK --001a113497faab688a0513998f46 Content-Type: text/x-patch; charset=US-ASCII; name="0003-md-bitmap-fix-list_entry_rcu-usage.patch" Content-Disposition: attachment; filename="0003-md-bitmap-fix-list_entry_rcu-usage.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_i8ft3x1q2 RnJvbSA4NGYwNDI4ZTJjOTE3MjY5MmFiYTcyNzYzNmE2NDNlZmI2OTk0NzUyIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBQYXRyaWNrIE1hcmxpZXIgPHBhdHJpY2subWFybGllckBnbWFp bC5jb20+CkRhdGU6IFR1ZSwgMjQgTWFyIDIwMTUgMTE6MjI6MTAgKzAxMDAKU3ViamVjdDogW1BB VENIIDMvM10gbWQvYml0bWFwOiBmaXggbGlzdF9lbnRyeV9yY3UgdXNhZ2UuCgpTaWduZWQtb2Zm LWJ5OiBQYXRyaWNrIE1hcmxpZXIgPHBhdHJpY2subWFybGllckBnbWFpbC5jb20+Ci0tLQogZHJp dmVycy9tZC9iaXRtYXAuYyB8IDIgKy0KIDEgZmlsZSBjaGFuZ2VkLCAxIGluc2VydGlvbigrKSwg MSBkZWxldGlvbigtKQoKZGlmZiAtLWdpdCBhL2RyaXZlcnMvbWQvYml0bWFwLmMgYi9kcml2ZXJz L21kL2JpdG1hcC5jCmluZGV4IDNhNTc2NzkuLmVkMDBlNDYgMTAwNjQ0Ci0tLSBhL2RyaXZlcnMv bWQvYml0bWFwLmMKKysrIGIvZHJpdmVycy9tZC9iaXRtYXAuYwpAQCAtMTgxLDcgKzE4MSw3IEBA IHN0YXRpYyBzdHJ1Y3QgbWRfcmRldiAqbmV4dF9hY3RpdmVfcmRldihzdHJ1Y3QgbWRfcmRldiAq cmRldiwgc3RydWN0IG1kZGV2ICptZGRlCiAJcmN1X3JlYWRfbG9jaygpOwogCWlmIChyZGV2ID09 IE5VTEwpCiAJCS8qIHN0YXJ0IGF0IHRoZSBiZWdpbm5pbmcgKi8KLQkJcmRldiA9IGxpc3RfZW50 cnlfcmN1KCZtZGRldi0+ZGlza3MsIHN0cnVjdCBtZF9yZGV2LCBzYW1lX3NldCk7CisJCXJkZXYg PSBsaXN0X2VudHJ5X3JjdShtZGRldi0+ZGlza3MubmV4dCwgc3RydWN0IG1kX3JkZXYsIHNhbWVf c2V0KTsKIAllbHNlIHsKIAkJLyogcmVsZWFzZSB0aGUgcHJldmlvdXMgcmRldiBhbmQgc3RhcnQg ZnJvbSB0aGVyZS4gKi8KIAkJcmRldl9kZWNfcGVuZGluZyhyZGV2LCBtZGRldik7Ci0tIAoyLjEu MAoK --001a113497faab688a0513998f46-- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/