Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965882AbcJ0OU6 (ORCPT ); Thu, 27 Oct 2016 10:20:58 -0400 Received: from merlin.infradead.org ([205.233.59.134]:42954 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935925AbcJ0OUx (ORCPT ); Thu, 27 Oct 2016 10:20:53 -0400 Date: Thu, 27 Oct 2016 14:37:26 +0200 From: Peter Zijlstra To: David Herrmann Cc: linux-kernel@vger.kernel.org, Andy Lutomirski , Jiri Kosina , Greg KH , Hannes Reinecke , Steven Rostedt , Arnd Bergmann , Tom Gundersen , Josh Triplett , Linus Torvalds , Andrew Morton Subject: Re: [RFC v1 04/14] bus1: util - fixed list utility library Message-ID: <20161027123726.GD3175@twins.programming.kicks-ass.net> References: <20161026191810.12275-1-dh.herrmann@gmail.com> <20161026191810.12275-5-dh.herrmann@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20161026191810.12275-5-dh.herrmann@gmail.com> User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 618 Lines: 20 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.