Received: by 10.213.65.68 with SMTP id h4csp225805imn; Tue, 3 Apr 2018 19:26:41 -0700 (PDT) X-Google-Smtp-Source: AIpwx49tj8Jip5Ar7Md50gUsVVplPP6HKcrEKpQhFdKcnQaCpJ9l8Yh0eO/7adgG6JhNjyNKocf3 X-Received: by 2002:a17:902:144:: with SMTP id 62-v6mr16872430plb.202.1522808801622; Tue, 03 Apr 2018 19:26:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522808801; cv=none; d=google.com; s=arc-20160816; b=Wxe4tFx3bAcfNg5vGOZzTBdX0DW3oWVQXEWKdiICQk86a8K3BnUDEjmypQjFQfeA7v 5/smvvIQC4sez80svZRDpbi08mMmGDhRb8zUn8cKUUZLOKZaQ/QgP8W+/4clPJGVFfjx b5ttWRzsrou+tTqmDECSorOkj5k5D2Z98rW+pP5I4AeFFeLvR93VrqmRDBdCdoSApQh+ K2BmePxoRz2Zcj3Z+msJwvAnEnAp7lTyMZxqDYAJwRkOBJ9Ho4P9TnDqD9zaM5hlGYG4 krzXnv3r1nGmgkbuJ596AiU+8etfmzOIf/hEJPC6i90OYnqkOzCAjlFKCLBJwCAEPdhk Qz7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=+qOc2VDh6K4CWFDRI3t2Gr9lZSoMhTE5yKFWzSKp+2I=; b=aeWI/5GXb++6WZoE1pfhYk8UGbuBQdWQfHBj1jv+v/SlyzOi2Z418YbYZNqogwAwk3 pKsYihIIHgQLLCNtxs99Mpvdw98N5i1PAjfUVwiNxHw7WcMVtgZGNNnY4cVbi0/MKEg9 Aqm8emaLzhcPXz7hzd4RdQPD4GYi8F2A6WFBtuq1NO6w8QPTg99V5Arkl0VlCPb6nKKi rL2aGg+/NFXiUsCZWGq1vZlOSPTI5N/2449Op+iW4L91jDSZEl+fIrTWZwQ6usuXf9lW Y7cRIzBbbTKneRiQOZHCrz5Han74Lhee1W8cLqGpR8w2OX3A0geQI6PaBlaS5UFa/4mQ 2CyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@infradead.org header.s=bombadil.20170209 header.b=EWMUqz4V; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j3si2853141pga.364.2018.04.03.19.26.27; Tue, 03 Apr 2018 19:26:41 -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=neutral (body hash did not verify) header.i=@infradead.org header.s=bombadil.20170209 header.b=EWMUqz4V; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755447AbeDDCYz (ORCPT + 99 others); Tue, 3 Apr 2018 22:24:55 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:41746 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754687AbeDDCXs (ORCPT ); Tue, 3 Apr 2018 22:23:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Transfer-Encoding :Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=mo/cgyJyhd7KoEY7+zwZSDEqaRScUohjHfDDKUkDxL0=; b=EWMUqz4Vjv0ik5dlnjcMgSfg9u vuxvFUJRhMJqg2mhrXH2eQjqKcgsskpaP9DlBmB2e8whxiZxm/Fki3C0e7g6GQBpymGhJoq9PycMp 9DqcBBdIFTc2lk8Qaaxk5C06VBsryc2GrjaZzYaCOa3923pW/MymVza7J9kDCq1zFDswmxdrqmqte TjiZ3rCIuWs2pmpquo3bM76ZeMpH9I07BAoKg9DpRLbgXDXgI+q/TZAJOj4LxIjPmYkQox+BP0+qz QinqTw++SEAneHAcHi9ZoRKYB3oBeS0OvdNVNd5PSLK/cTEolLdtGbHNSdZCAD9d0nth+C21BYcQX nhsK8rWA==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1f3Y5T-0003cu-BJ; Wed, 04 Apr 2018 02:23:47 +0000 Date: Tue, 3 Apr 2018 19:23:47 -0700 From: Matthew Wilcox To: Rao Shoaib Cc: linux-kernel@vger.kernel.org, paulmck@linux.vnet.ibm.com, joe@perches.com, brouer@redhat.com, linux-mm@kvack.org Subject: Re: [PATCH 2/2] kfree_rcu() should use kfree_bulk() interface Message-ID: <20180404022347.GA17512@bombadil.infradead.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> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. IDR has a bulk-free option (idr_destroy()), but it doesn't have a get-bulk function yet. I think that's a relatively straightforward function to add ... /* * Return: number of elements pointed to by 'ptrs'. */ int idr_get_bulk(struct idr *idr, void __rcu ***ptrs, u32 *start) { struct radix_tree_iter iter; void __rcu **slot; unsigned long base = idr->idr_base; unsigned long id = *start; id = (id < base) ? 0 : id - base; slot = radix_tree_iter_find(&idr->idr_rt, &iter, id); if (!slot) return 0; *start = iter.index + base; *ptrs = slot; return iter.next_index - iter.index; } (completely untested, but you get the idea. For your case, it's just going to return a pointer to the first slot). > The change would also require retesting. So I would like to keep the current > design. That's not how review works.