From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753980AbcKIS6S (ORCPT ); Wed, 9 Nov 2016 13:58:18 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:58520 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751802AbcKIS6R (ORCPT ); Wed, 9 Nov 2016 13:58:17 -0500 Date: Wed, 9 Nov 2016 10:58:10 -0800 From: "Paul E. McKenney" To: Tetsuo Handa Cc: josh@joshtriplett.org, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, jiangshanlai@gmail.com, linux-kernel@vger.kernel.org Subject: Re: [srcu] Can we suppress sparse warning? Reply-To: paulmck@linux.vnet.ibm.com References: <201611092036.DAJ05243.HOOMQSVOJFFLtF@I-love.SAKURA.ne.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201611092036.DAJ05243.HOOMQSVOJFFLtF@I-love.SAKURA.ne.jp> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16110918-0016-0000-0000-000005225B0D X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006049; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000189; SDB=6.00778727; UDB=6.00375098; IPR=6.00556083; BA=6.00004866; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00013275; XFM=3.00000011; UTC=2016-11-09 18:58:13 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16110918-0017-0000-0000-000034822884 Message-Id: <20161109185810.GM4127@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-11-09_08:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1609300000 definitions=main-1611090348 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 09, 2016 at 08:36:31PM +0900, Tetsuo Handa wrote: > Hello. > > When I build > > ---------- test/test.c ---------- > #include > > static int __init test_init(void) > { > DEFINE_SRCU(srcu); > int idx = srcu_read_lock(&srcu); > void *ptr = srcu_dereference(ptr, &srcu); I am really confused by the above line of code... > srcu_read_unlock(&srcu, idx); > return -EINVAL; > } > > module_init(test_init); > MODULE_LICENSE("GPL"); > ---------- test/test.c ---------- > > with C=1 option, I get > > test/test.c:7:21: error: incompatible types in comparison expression (different address spaces) > > warning from > > --- a/include/linux/rcupdate.h > +++ b/include/linux/rcupdate.h > @@ -605,7 +605,7 @@ static inline void rcu_preempt_sleep_check(void) > /* Dependency order vs. p above. */ \ > typeof(*p) *________p1 = (typeof(*p) *__force)lockless_dereference(p); \ > RCU_LOCKDEP_WARN(!(c), "suspicious rcu_dereference_check() usage"); \ > - rcu_dereference_sparse(p, space); \ > + rcu_dereference_sparse(p, space); /** this line **/ \ > ((typeof(*p) __force __kernel *)(________p1)); \ > }) > #define __rcu_dereference_protected(p, c, space) \ > > . > > I want to use srcu_dereference() at > https://lists.01.org/pipermail/kbuild-all/2016-October/026587.html . > Can we have srcu version of 995f1405610bd844 ("rcu: Suppress sparse > warnings for rcu_dereference_raw()") ? Notwithstanding my confusion about what your self-referential srcu_dereference() is intended to achieve, what happens if you change the "void *ptr = srcu_dereference(ptr, &srcu);" to add __rcu? void __rcu *ptr = srcu_dereference(ptr, &srcu); Or, more to the point: void __rcu *gptr; void *lptr = srcu_dereference(ptr, &srcu); Thanx, Paul