Received: by 10.213.65.68 with SMTP id h4csp477027imn; Wed, 4 Apr 2018 01:41:29 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/5E2nfwekmG+dNQkQIf/tWr/yO8VFcR2zx47oh6sNDkzDewqB/OiAIJMcbHfjYTBTjwPQf X-Received: by 10.99.52.11 with SMTP id b11mr11118218pga.377.1522831289126; Wed, 04 Apr 2018 01:41:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522831289; cv=none; d=google.com; s=arc-20160816; b=PvHhOkgjAzsFRs3/IYeu/iX5GD90TSya/ofZop5yJJFVSPER3ka+ZCj9Ps3odqYuW3 wt227oRWZoTGUyh4+5rBGWUnmmJTN+zOzMRz6IjHQnGLC5CNH6Qe+CWiNxAuwxSBPZJ5 iPKJPaEedpXFlGSBSP+qnmNOEVfiag7gfwAlTFyka0dVDw4VLhonR10Y4ZfZMs3Z/UVv ERulH9tnjrdJtzVdSNXBAOlXiMJOvX5NiVWrRIFYM9QC8y6nBXberBqjZe2JlfgRupwA VStahdTddkHTLdSuUgnPZsYT5muZgPAYWQmMEjnEnq4MVgRQTMMiEbGuEf7oCMCOhfFV 77TA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:from:subject:dkim-signature :arc-authentication-results; bh=PyZq6SrzcL7w+2akbALT7A0Fuit8jLX1NgbpL6tIiBI=; b=zXCg+5dqPDXCGm+rLPwOFby+nQr+wolJOLiMnOLrNbk6V/bLMHExlsGvQwvW8r2nKw oW/vRJS1TRJwNwp/6vszlkNzp806Q2sPqXEIkSEyehctBX9nc9zz1gFgH/R4QxNYQd5u AyfRrIbb+VbbtO3dVFUi7GiOBELilNPhotaH64IlKXdTou88L7rkD8Hnk/lCz2w6Ur9k nONlmg0Szc654Bf3ODeN1VjQ7tt73LDy56vOhLM0OXLYErj4pWvW7ePwd8teiN+paIqH NfwSQofnF7UpARMvodj075Fq3fA1NA0fU3SGDUOO+kkW9BNAc2ec94SYRUh34D291LyM m6sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=JZOT+jft; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 142si3336315pgg.29.2018.04.04.01.41.15; Wed, 04 Apr 2018 01:41:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=JZOT+jft; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751428AbeDDIjf (ORCPT + 99 others); Wed, 4 Apr 2018 04:39:35 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:53750 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751274AbeDDIjd (ORCPT ); Wed, 4 Apr 2018 04:39:33 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w348G2fq138563; Wed, 4 Apr 2018 08:39:11 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : references : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2017-10-26; bh=PyZq6SrzcL7w+2akbALT7A0Fuit8jLX1NgbpL6tIiBI=; b=JZOT+jftVqFFWHB7aUjZ4FAo9x/QfQOsYdDyzUM1PmwW5a5TKY01PrVVo4fai5C9JAEP /kWDrtOI5HkUvdYzDOGzYwyzyCgjpmU6GLeMhSMTDaHg7lVWy7HWFQjhmz2n3DKEbNC4 sh5vBcesfbpaC5Cx3Sv48eeIvYmIHsQNbu/xeOGjzoqJ/UJqIehEd8Cm5PlOTU5vuY7g o3XqHh+coNWZtlWhc9E4iH/DY2mKyd9IbQHIluoCxlKVDuTt9JvtSZSq5yT+fdFzqS1G t/NMQa9mAhy82DopRyweWNIf8gN02IOMratm8ioMcrx7AOOvkhGfBxJdZxI3i3bWX/Ji lA== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2120.oracle.com with ESMTP id 2h4u20053a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 04 Apr 2018 08:39:10 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w348d9NB016651 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 4 Apr 2018 08:39:09 GMT Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w348d8kc016586; Wed, 4 Apr 2018 08:39:08 GMT Received: from [192.168.1.34] (/67.188.214.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 04 Apr 2018 01:39:08 -0700 Subject: Re: [PATCH 2/2] kfree_rcu() should use kfree_bulk() interface From: Rao Shoaib To: Matthew Wilcox Cc: linux-kernel@vger.kernel.org, paulmck@linux.vnet.ibm.com, joe@perches.com, brouer@redhat.com, linux-mm@kvack.org References: <1522776173-7190-1-git-send-email-rao.shoaib@oracle.com> <1522776173-7190-3-git-send-email-rao.shoaib@oracle.com> <20180403205822.GB30145@bombadil.infradead.org> <20180404022347.GA17512@bombadil.infradead.org> <954a9ea2-5202-4ee3-1fa2-21acf8d07cdb@oracle.com> Message-ID: Date: Wed, 4 Apr 2018 01:39:07 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <954a9ea2-5202-4ee3-1fa2-21acf8d07cdb@oracle.com> 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=8852 signatures=668697 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 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-1804040086 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/04/2018 12:16 AM, Rao Shoaib wrote: > > > On 04/03/2018 07:23 PM, Matthew Wilcox wrote: >> On Tue, Apr 03, 2018 at 05:55:55PM -0700, Rao Shoaib wrote: >>> On 04/03/2018 01:58 PM, Matthew Wilcox wrote: >>>> I think you might be better off with an IDR.  The IDR can always >>>> contain one entry, so there's no need for this 'rbf_list_head' or >>>> __rcu_bulk_schedule_list.  The IDR contains its first 64 entries in >>>> an array (if that array can be allocated), so it's compatible with the >>>> kfree_bulk() interface. >>>> >>> I have just familiarized myself with what IDR is by reading your >>> article. If >>> I am incorrect please correct me. >>> >>> The list and head you have pointed are only used  if the container >>> can not >>> be allocated. That could happen with IDR as well. Note that the >>> containers >>> are allocated at boot time and are re-used. >> No, it can't happen with the IDR.  The IDR can always contain one entry >> without allocating anything.  If you fail to allocate the second entry, >> just free the first entry. >> >>> IDR seems to have some overhead, such as I have to specifically add the >>> pointer and free the ID, plus radix tree maintenance. >> ... what?  Adding a pointer is simply idr_alloc(), and you get back an >> integer telling you which index it has.  Your data structure has its >> own set of overhead. > The only overhead is a pointer that points to the head and an int to > keep count. If I use idr, I would have to allocate an struct idr which > is much larger. idr_alloc()/idr_destroy() operations are much more > costly than updating two pointers. As the pointers are stored in > slots/nodes corresponding to the id, I would  have to retrieve the > pointers by calling idr_remove() to pass them to be freed, the > slots/nodes would constantly be allocated and freed. > > IDR is a very useful interface for allocating/managing ID's but I > really do not see the justification for using it over here, perhaps > you can elaborate more on the benefits and also on how I can just pass > the array to be freed. > > Shoaib > I may have mis-understood your comment. You are probably suggesting that I use IDR instead of allocating following containers. + struct rcu_bulk_free_container *rbf_container; + struct rcu_bulk_free_container *rbf_cached_container; IDR uses radix_tree_node which allocates following two arrays. since I do not need any ID's why not just use the radix_tree_node directly, but I do not need a radix tree either, so why not just use an array. That is what I am doing. void __rcu      *slots[RADIX_TREE_MAP_SIZE]; unsigned long   tags[RADIX_TREE_MAX_TAGS][RADIX_TREE_TAG_LONGS]; ==> Not needed As far as allocation failure is concerned, the allocation has to be done at run time. If the allocation of a container can fail, so can the allocation of radix_tree_node as it also requires memory. I really do not see any advantages of using IDR. The structure I have is much simpler and does exactly what I need. Shoaib