From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751319AbeADXrC (ORCPT + 1 other); Thu, 4 Jan 2018 18:47:02 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:56804 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751108AbeADXrB (ORCPT ); Thu, 4 Jan 2018 18:47:01 -0500 Date: Thu, 4 Jan 2018 15:47:32 -0800 From: "Paul E. McKenney" To: Matthew Wilcox Cc: Rao Shoaib , Boqun Feng , linux-kernel@vger.kernel.org, brouer@redhat.com, linux-mm@kvack.org Subject: Re: [PATCH 1/2] Move kfree_call_rcu() to slab_common.c Reply-To: paulmck@linux.vnet.ibm.com References: <1514923898-2495-1-git-send-email-rao.shoaib@oracle.com> <20180102222341.GB20405@bombadil.infradead.org> <3be609d4-800e-a89e-f885-7e0f5d288862@oracle.com> <20180104013807.GA31392@tardis> <64ca3929-4044-9393-a6ca-70c0a2589a35@oracle.com> <20180104214658.GA20740@bombadil.infradead.org> <3e4ea0b9-686f-7e36-d80c-8577401517e2@oracle.com> <20180104231307.GA794@bombadil.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180104231307.GA794@bombadil.infradead.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-GCONF: 00 x-cbid: 18010423-0040-0000-0000-000003DB9361 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008319; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000244; SDB=6.00970332; UDB=6.00491431; IPR=6.00750303; BA=6.00005765; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00018878; XFM=3.00000015; UTC=2018-01-04 23:46:58 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18010423-0041-0000-0000-000007D0E864 Message-Id: <20180104234732.GM9671@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-01-04_11:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1801040323 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On Thu, Jan 04, 2018 at 03:13:07PM -0800, Matthew Wilcox wrote: > On Thu, Jan 04, 2018 at 02:18:50PM -0800, Rao Shoaib wrote: > > > > > > +#define kfree_rcu(ptr, rcu_head_name) \ > > > > > > +    do { \ > > > > > > +        typeof(ptr) __ptr = ptr;    \ > > > > > > +        unsigned long __off = offsetof(typeof(*(__ptr)), \ > > > > > > +                              rcu_head_name); \ > > > > > > +        struct rcu_head *__rptr = (void *)__ptr + __off; \ > > > > > > +        __kfree_rcu(__rptr, __off); \ > > > > > > +    } while (0) > > > > > why do you want to open code this? > > > But why are you changing this macro at all? If it was to avoid the > > > double-mention of "ptr", then you haven't done that. > > I have -- I do not get the error because ptr is being assigned only one. If > > you have a better way than let me know and I will be happy to make the > > change. > > But look at the original: > > #define kfree_rcu(ptr, rcu_head) \ > __kfree_rcu(&((ptr)->rcu_head), offsetof(typeof(*(ptr)), rcu_head)) > ^^^ ^^^ > > versus your version: > > +#define kfree_rcu(ptr, rcu_head_name) \ > +    do { \ > +        typeof(ptr) __ptr = ptr;    \ > ^^^ ^^^ > +        unsigned long __off = offsetof(typeof(*(__ptr)), \ > +                              rcu_head_name); \ > +        struct rcu_head *__rptr = (void *)__ptr + __off; \ > +        __kfree_rcu(__rptr, __off); \ > +    } while (0) > > I don't see the difference. I was under the impression that typeof did not actually evaluate its argument, but rather only returned its type. And there are a few macros with this pattern in mainline. Or am I confused about what typeof does? Thanx, Paul