Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752678AbdLURcD (ORCPT ); Thu, 21 Dec 2017 12:32:03 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:46993 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752944AbdLURb4 (ORCPT ); Thu, 21 Dec 2017 12:31:56 -0500 Subject: Re: [PATCH] Move kfree_call_rcu() to slab_common.c To: Matthew Wilcox Cc: linux-kernel@vger.kernel.org, paulmck@linux.vnet.ibm.com, brouer@redhat.com, linux-mm@kvack.org References: <1513844387-2668-1-git-send-email-rao.shoaib@oracle.com> <20171221123630.GB22405@bombadil.infradead.org> From: Rao Shoaib Message-ID: <44044955-1ef9-1d1e-5311-d8edc006b812@oracle.com> Date: Thu, 21 Dec 2017 09:31:23 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <20171221123630.GB22405@bombadil.infradead.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8752 signatures=668651 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1712210238 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2579 Lines: 74 On 12/21/2017 04:36 AM, Matthew Wilcox wrote: > On Thu, Dec 21, 2017 at 12:19:47AM -0800, rao.shoaib@oracle.com wrote: >> This patch moves kfree_call_rcu() and related macros out of rcu code. A new >> function __call_rcu_lazy() is created for calling __call_rcu() with the lazy >> flag. > Something you probably didn't know ... there are two RCU implementations > in the kernel; Tree and Tiny. It looks like you've only added > __call_rcu_lazy() to Tree and you'll also need to add it to Tiny. I left it out on purpose because the call in tiny is a little different rcutiny.h: static inline void kfree_call_rcu(struct rcu_head *head,                   void (*func)(struct rcu_head *rcu)) {     call_rcu(head, func); } tree.c: void kfree_call_rcu(struct rcu_head *head,             void (*func)(struct rcu_head *rcu)) {     __call_rcu(head, func, rcu_state_p, -1, 1); } EXPORT_SYMBOL_GPL(kfree_call_rcu); If we want the code to be exactly same I can create a lazy version for tiny as well. However,  I don not know where to move kfree_call_rcu() from it's current home in rcutiny.h though. Any thoughts ? > >> Also moving macros generated following checkpatch noise. I do not know >> how to silence checkpatch as there is nothing wrong. >> >> CHECK: Macro argument reuse 'offset' - possible side-effects? >> #91: FILE: include/linux/slab.h:348: >> +#define __kfree_rcu(head, offset) \ >> + do { \ >> + BUILD_BUG_ON(!__is_kfree_rcu_offset(offset)); \ >> + kfree_call_rcu(head, (rcu_callback_t)(unsigned long)(offset)); \ >> + } while (0) > What checkpatch is warning you about here is that somebody might call > > __kfree_rcu(p, a++); > > and this would expand into > > do { \ > BUILD_BUG_ON(!__is_kfree_rcu_offset(a++)); \ > kfree_call_rcu(p, (rcu_callback_t)(unsigned long)(a++)); \ > } while (0) > > which would increment 'a' twice, and cause pain and suffering. > > That's pretty unlikely usage of __kfree_rcu(), but I suppose it's not > impossible. We have various hacks to get around this kind of thing; > for example I might do this as:: > > #define __kfree_rcu(head, offset) \ > do { \ > unsigned long __o = offset; > BUILD_BUG_ON(!__is_kfree_rcu_offset(__o)); \ > kfree_call_rcu(head, (rcu_callback_t)(unsigned long)(__o)); \ > } while (0) > > Now offset is only evaluated once per invocation of the macro. The other > two warnings are the same problem. > Thanks. I was not sure if I was required to fix the noise or based on inspection the noise could be ignored. I will make the change and resubmit. Shoaib