Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935603AbcJ0NuM (ORCPT ); Thu, 27 Oct 2016 09:50:12 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:56764 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754325AbcJ0Nsb (ORCPT ); Thu, 27 Oct 2016 09:48:31 -0400 From: Arnd Bergmann To: David Herrmann Cc: Peter Zijlstra , linux-kernel , Andy Lutomirski , Jiri Kosina , Greg KH , Hannes Reinecke , Steven Rostedt , Tom Gundersen , Josh Triplett , Linus Torvalds , Andrew Morton Subject: Re: [RFC v1 04/14] bus1: util - fixed list utility library Date: Thu, 27 Oct 2016 14:56:31 +0200 Message-ID: <3334796.z7DWQtPDNS@wuerfel> User-Agent: KMail/5.1.3 (Linux/4.4.0-34-generic; KDE/5.18.0; x86_64; ; ) In-Reply-To: References: <20161026191810.12275-1-dh.herrmann@gmail.com> <20161027123726.GD3175@twins.programming.kicks-ass.net> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Provags-ID: V03:K0:P6KkYlYVTAh2BPc1+0oidE/jRUAVjcxWBcHwhMy1FWbn1EcUGd2 UpjnxNTzYfMnihYtP9fSHjuGUXISw8U/9OnB1eXKVboAAzaOb/j5LYkA9X19vUfrmdEtRE3 a/+KHzs5vU26BqoY/9Sew3Gk0iQtW25XBiXK6oYgtUO/wNMvW2faVBi9LbbZWxQwrkn/QCn KSfrTBHycm37PfYlz4ouQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:8LYo45vaasE=:/+kF24Vx7C9WZETLJXBsLG /KP1s9qcBGzaNK6VGLkyfR2dJwWmwDSHoNAbqs7LqHeSiJZJm14dGQs8Cm0f7wDoO4BP1px87 unqhcHf5a2S/iwgaILCRZQL7UYFQZ/E5tModiDAfyWPXKMxxgcCNfwX12YzI3jHCqT8M20wL/ 8z8KDtctlMNpaZK/W04lZoF89BQOMfvfQEUECS4QRopGK44BToDo8S7FmxnIIY4uoMVN23Bdi FIHv8WjiIFqovMJUDMmRyGWavv9OhyiIafgmGSS0THunLuUUSo1gDHnwUHXobarSiOFcrV4oN PlpdIlM5/5ouJM41GZaGCD8TgtWNs9eFQeNA5AxkWGNBA1UQ43B94zzYbbrDG7QtiZrCGPPTx MzrkF7bYAfLDRBKqlmlVC9TJNb24KkDDGCYD3X22yN98fJgbAfh8Vcr0QTEbYYWYd6q/OD//r trgiNotmQ9ehKVG2LXMNl2gYgrfTJS1Sefd5aeqLHn/r3MPSQXNa3sa6O74y5K+B1kt9fa5o5 bIFfQ7UHXLF1pWS2RwLv7jZRa7ex9wE9M2bdkWktZbyjrTCyeb2JlSlheMCPoxdeY8cpNtNcE LHQAvCyvN+jqrW0IJvb9YJ5KRQxjXX4PxVgFJPpbPD4f9dR7p+Fmqyn4suhrYiQlcNGGshdeF Y2YsxALsQfFdE1aSmfXAY75/7K0JKu2Wg9EACx6a7bC+lao5QRU6On/94ENHnZnabtyHc1Xpv yerIUAUlIZi+vlB3 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1121 Lines: 33 On Thursday, October 27, 2016 2:48:46 PM CEST David Herrmann wrote: > On Thu, Oct 27, 2016 at 2:37 PM, Peter Zijlstra wrote: > > On Wed, Oct 26, 2016 at 09:18:00PM +0200, David Herrmann wrote: > >> + e = kmalloc_array(sizeof(*e), BUS1_FLIST_BATCH + 1, gfp); > > > >> +#define BUS1_FLIST_BATCH (1024) > > > >> +struct bus1_flist { > >> + union { > >> + struct bus1_flist *next; > >> + void *ptr; > >> + }; > >> +}; > > > > So that's an allocation of 8*(1024+1), or slightly more than 2 pages. > > > > kmalloc will round up to the next power of two, so you'll end up with an > > allocation of 16*1024, wasting a whopping 8184 bytes per such allocation > > in slack space. > > > > Please consider using 1023 or something for your batch size, 511 would > > get you to exactly 1 page which would be even better. > > Thanks for the hint! 511 looks like the obvious choice. Maybe even > (PAGE_SIZE / sizeof(long) - 1). I will put a comment next to the > definition. > > PAGE_SIZE can be up to 64KB though, so that might lead wasting a lot of memory. Arnd