Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2332245ybl; Thu, 29 Aug 2019 06:55:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqyXHGD0tk+IlLSNWYm8UtXn766ktryDFvDm1MT3lalrVdyJysmLSyyEe7eJUqQMXCx2nuz5 X-Received: by 2002:a17:90a:ff04:: with SMTP id ce4mr10041548pjb.77.1567086927577; Thu, 29 Aug 2019 06:55:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567086927; cv=none; d=google.com; s=arc-20160816; b=yCexJg7+grA8wXsSFxLSCMk3i8kwv86K3shE/bkpKWrJ2t2Ma+OeuH4ZgZm3hi2lPw 0M2WMtvxaZIvN1sLjKfJa3br50wxYmrfRGulnqTpwnQTHdti0LYWBKQEkJAtv0MYdbnY ON/lc9+U1D7KjMckCeP3tZQSZ4E4RcjKkA72Cng5IOAW7wPFRIVQk0SVCsj920x4wmZI pABiPBALxNuYLKeHqM3Kw2wlfd7hKd5bndwacOzhTiBiNDJal82i2E9QJx2XjfdWHiLT VUAGM05HFgOlBMk4D1LZ4UgsBlrb+YMUP17stNedIENx9HUhM0Sre80dTN7JUTB+VRsd zYgQ== 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-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Pf/db+szbYm7dJzEjw6KZt3csHMZhr4jO5xT4UCnNZE=; b=pPLqRTf3uq95/33WxKklAi3Y5eeBZnw8xEadz6mHqwCy1V9tVMb65CVywk3R4XURrp EOlr2FCJFjVy5ZHD5k8lZf1IuLGShRquzGEZxsNJ1LUhgQzIXkk9/eNDqVJOQngIDMbp x9Eg3JebciS4QgmEBYTIneVWqKszWgUmSwK6cQJTjm6uh6DAsOFLtw1xxWuxaHPFTc2x GAzh5Hy3kLBX+4Y3JpklXoYiFf8sPBc6hk4jOzS3kY0//6nC6jRVeziJ4wWG16JaA4zl +L+3bstdnLM0EzAu+QsbkU6AkdvsbrCvYx3fL+EAGTelEWK3HpjTVn2L5CD13X6whYVk VGPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=RCqHCdBf; 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 v142si2607104pfc.67.2019.08.29.06.55.11; Thu, 29 Aug 2019 06:55:27 -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=pass header.i=@joelfernandes.org header.s=google header.b=RCqHCdBf; 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 S1727736AbfH2NyC (ORCPT + 99 others); Thu, 29 Aug 2019 09:54:02 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:38152 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726973AbfH2NyB (ORCPT ); Thu, 29 Aug 2019 09:54:01 -0400 Received: by mail-pf1-f194.google.com with SMTP id o70so2103961pfg.5 for ; Thu, 29 Aug 2019 06:54:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Pf/db+szbYm7dJzEjw6KZt3csHMZhr4jO5xT4UCnNZE=; b=RCqHCdBfnJpfcZnScGd1muttY38RJgoi9gHDa1Omn5PBRnmwnAT2EHr/oXc5auS4dS gxUK6n3qvAeAhkUb7pFLyw3asgmek8WpG0tsknS4dq/VTEJGR3Yl3NqOeXzdxDX2okk/ fdyoiaYasK1GrF5x8jDqMzGOuiRQfCvnGNndc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Pf/db+szbYm7dJzEjw6KZt3csHMZhr4jO5xT4UCnNZE=; b=A9iNg/0Ius8KEGJgtRM5YEiwx+w7FnvAwBVWCv5lvQB38YcAtnR+oE1bTCEb1i8toL Xy/OIssS2iEFaJgaCIZ1kExhfmBGQQFwnsrfNva5a8iZ4A4cIqQe3hvQmd/mT54GU9qv 9ZbcndwEJA5tt0AzUTsnzZj2HBwEUhaW9CeGVbsyuH/DA8xMX2w1WZNjqoAJmpf016Dz C8rbWUyeoO3QyKX+RZQuc78FmhgSuQgFCW/JiQ8O8wPJJRgJkjINmB+/V1A4TcfaVQWX ucNqLssW4MUZtQRyLtL1dw+DnEdhpWtONO/uIDq89V9UTdukBKhjN4qozbZ5+YolphqS E1aQ== X-Gm-Message-State: APjAAAW9F1U+8bpDwKm2gvqF2ty3qcXXsNkVTkeN9Y/SxUvjlj3eeQ/B KfZDBPYkV7eJyo4d+nV/h9BQCw== X-Received: by 2002:a63:f401:: with SMTP id g1mr8784816pgi.314.1567086840883; Thu, 29 Aug 2019 06:54:00 -0700 (PDT) Received: from localhost ([2620:15c:6:12:9c46:e0da:efbf:69cc]) by smtp.gmail.com with ESMTPSA id 185sm4229503pfd.125.2019.08.29.06.53.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2019 06:54:00 -0700 (PDT) Date: Thu, 29 Aug 2019 09:53:59 -0400 From: Joel Fernandes To: Greg KH Cc: Peikan Tsai , arve@android.com, tkjos@android.com, maco@android.com, christian@brauner.io, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] binder: Use kmem_cache for binder_thread Message-ID: <20190829135359.GB63638@google.com> References: <20190829054953.GA18328@mark-All-Series> <20190829064229.GA30423@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190829064229.GA30423@kroah.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 29, 2019 at 08:42:29AM +0200, Greg KH wrote: > On Thu, Aug 29, 2019 at 01:49:53PM +0800, Peikan Tsai wrote: [snip] > > The allocated size for each binder_thread is 512 bytes by kzalloc. > > Because the size of binder_thread is fixed and it's only 304 bytes. > > It will save 208 bytes per binder_thread when use create a kmem_cache > > for the binder_thread. > > Are you _sure_ it really will save that much memory? You want to do > allocations based on a nice alignment for lots of good reasons, > especially for something that needs quick accesses. Alignment can be done for slab allocations, kmem_cache_create() takes an align argument. I am not sure what the default alignment of objects is though (probably no default alignment). What is an optimal alignment in your view? > Did you test your change on a system that relies on binder and find any > speed improvement or decrease, and any actual memory savings? > > If so, can you post your results? That's certainly worth it and I thought of asking for the same, but spoke too soon! Independent note: In general I find the internal fragmentation with large kmalloc()s troubling in the kernel :-(. Say you have a 5000 objects of 512 allocation, each 300 bytes. 212 * 5000 is around 1MB. Which is arguably not neglible on a small memory system, right? thanks, - Joel