From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5886AC48BE5 for ; Wed, 16 Jun 2021 10:29:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 33C9861245 for ; Wed, 16 Jun 2021 10:29:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232358AbhFPKbP (ORCPT ); Wed, 16 Jun 2021 06:31:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:47692 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232048AbhFPKbO (ORCPT ); Wed, 16 Jun 2021 06:31:14 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 96F4A60FE6; Wed, 16 Jun 2021 10:29:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1623839349; bh=Z0UNEV6qSxs/ADJyTpVCdlAObn8GbfeoX2RCiE/Gv2g=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=oU+OxzvxmmwL10TJBoqn1VVSEX0vaisVNjzKh5YrHI/qu7atXiSVG2AiIEv+OBUUf LRln0CqIsVc9mG+0PRKLeFPWJNYCJHYLIpgCJ7yjXfMXA1YJS7sJE+KL1/xOxnKZz4 7q9sCPTngsDTlrnaNSWWIPQsoYs6m5vksC11lVIg= Date: Wed, 16 Jun 2021 12:29:06 +0200 From: Greg Kroah-Hartman To: David Laight Cc: 'Amit Klein' , "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" , Eric Dumazet , Willy Tarreau , "David S. Miller" , Sasha Levin Subject: Re: [PATCH 5.4 175/244] inet: use bigger hash table for IP ID generation Message-ID: References: <20210512144743.039977287@linuxfoundation.org> <20210512144748.600206118@linuxfoundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org On Wed, Jun 16, 2021 at 10:19:15AM +0000, David Laight wrote: > From: Amit Klein > > Sent: 16 June 2021 10:17 > ... > > -#define IP_IDENTS_SZ 2048u > > - > > +/* Hash tables of size 2048..262144 depending on RAM size. > > + * Each bucket uses 8 bytes. > > + */ > > +static u32 ip_idents_mask __read_mostly; > ... > > + /* For modern hosts, this will use 2 MB of memory */ > > + idents_hash = alloc_large_system_hash("IP idents", > > + sizeof(*ip_idents) + sizeof(*ip_tstamps), > > + 0, > > + 16, /* one bucket per 64 KB */ > > + HASH_ZERO, > > + NULL, > > + &ip_idents_mask, > > + 2048, > > + 256*1024); > > + > > Can someone explain why this is a good idea for a 'normal' system? > > Why should my desktop system 'waste' 2MB of memory on a massive > hash table that I don't need. > It might be needed by systems than handle massive numbers > of concurrent connections - but that isn't 'most systems'. > > Surely it would be better to detect when the number of entries > is comparable to the table size and then resize the table. Patches always gladly accepted.