From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753458AbcCGSmq (ORCPT ); Mon, 7 Mar 2016 13:42:46 -0500 Received: from shards.monkeyblade.net ([149.20.54.216]:52749 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753013AbcCGSmh (ORCPT ); Mon, 7 Mar 2016 13:42:37 -0500 Date: Mon, 07 Mar 2016 13:42:33 -0500 (EST) Message-Id: <20160307.134233.201526978853409580.davem@davemloft.net> To: dhowells@redhat.com Cc: linux-afs@lists.infradead.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 01/11] rxrpc: Add a common object cache From: David Miller In-Reply-To: <20160307143806.18567.30020.stgit@warthog.procyon.org.uk> References: <20160307143759.18567.8234.stgit@warthog.procyon.org.uk> <20160307143806.18567.30020.stgit@warthog.procyon.org.uk> X-Mailer: Mew version 6.6 on Emacs 24.5 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Mon, 07 Mar 2016 10:42:37 -0800 (PST) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: David Howells Date: Mon, 07 Mar 2016 14:38:06 +0000 > Add a common object cache implementation for RxRPC. This will be used to > cache objects of various types (calls, connections, local and remote > endpoint records). Each object that would be cached must contain an > obj_node struct for the cache to use. The object's usage count and link > pointers are here, plus other internal metadata. > > Each object cache consists of a primary hash to which all objects of that > type must be added and a secondary hash to which objects may also be added > and removed a single time. Objects are automatically removed from both > hashes when they expire. > > Objects start off life with a usage count of 2 - one for the cache and one > for the caller. When an object's usage count is reduced to 1, it sits in > the cache until its expiry time is reached, at which point the cache > attempts to reduce the count to 0 and, if successful, clean it up. An > object with a usage count of 1 in the cache can be looked up and have its > usage count increased, thereby stopping the expiry process. > > Objects are looked up, unlinked and destroyed under RCU-safe conditions. > > A garbage collector cycles through all the hash buckets in the primary hash > and compares the expiry times of the usage-count-1 objects to the current > time, removing any that have expired. This is kicked by a single timer for > the whole cache rather than having a timer per object. > > Signed-off-by: David Howells I know you put a lot of time and effort into this, but I want to strongly recommend against a garbage collected hash table for anything whatsoever. Especially if the given objects are in some way created/destroyed/etc. by operations triggerable remotely. This can be DoS'd quite trivially, and that's why we have removed the ipv4 routing cache which did the same.