Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp565638rdb; Thu, 18 Jan 2024 11:34:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IEDzR0eE5oaB7gE+m0RZ739N1KaCaAgd8shJE9dXO2UatZSGl5D4wW5UQuA5Fpn8RrhevRH X-Received: by 2002:a17:90a:d303:b0:28d:6230:c1a2 with SMTP id p3-20020a17090ad30300b0028d6230c1a2mr1211285pju.50.1705606442030; Thu, 18 Jan 2024 11:34:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705606442; cv=pass; d=google.com; s=arc-20160816; b=dmj0qRgetDKNze86sC+xbwrhHacWkpMYPf1am2l5SogbIoz2goAafJpuVn/y30jPz1 ZuI4CMbaE/LCaNP6lmV/pqb1EzTKYaCH9qM45uuAboHfeF+hCEMsFI4rCbLAPDlCM3/4 RrL2t5ifUYi2pwm83w7sS9NLNjlW4k24YFsopq4iiEFWw8t+dUzr6909/0XxaU+aVGNg KALWsTNZm/zauGI/GQ0aWUP9aLmqpybm00kF/4+ZQETUMfJIrER0J2EqQzKR03RZB5UY I929wEJBWGHz5EIEoSArgI+uIIP6EBvEMb4ZQ3tJiLzKVF1z3ZTq200Os/9kjFA8FdbB iFWw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=2Eimo1bLVuQLA4eG0D77yPQYKlmdquXBMxi8UiFbf2o=; fh=UzUr7NLI6EtgkIIdxM8ao3bqJIkxrpV6HNDE83TgN0M=; b=azkAvVoqPv8MeY9fzApfEbuKmxmk63yggdYajQNMGjn3U8NF3Q3J+Sw+BXR184V7iv rR4qbZgKmgdHlvxSwB3hzgdTuQG3v8h6lxF5WGPYeZO0pkoCfsv1A6TCBebBkUx2aPYX F1qwNjqHcqoQR9wklOl+JHVFijmHpGMWISyy8kCTTq5y7QCgIthWc2Pes7xckXN2QQuR 5LBI4SE2V4Gdbcf5osv4SXDygs4NRiZW/4spxKsng7Jkl4H3Kni3E4p/JPOY6NE+3Goc Q7+WeNhabSbqztCnuyC2XZKTq9OKAMiGKGFR7vp1To9i1MEWX/euzKxfgkQtiy4Zlj+w uAHA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=xrWtmYjx; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-30519-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30519-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id y23-20020a17090a16d700b0028ddcd93732si1951063pje.22.2024.01.18.11.34.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jan 2024 11:34:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-30519-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=xrWtmYjx; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-30519-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30519-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id A0E8D2896D9 for ; Thu, 18 Jan 2024 19:34:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C563B2E41C; Thu, 18 Jan 2024 19:33:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="xrWtmYjx" Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 26E0D2E403 for ; Thu, 18 Jan 2024 19:33:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705606435; cv=none; b=kEmevcfGX8v9V8jCooXWeIYjN45y4q/kPu0iB9bfjQLLFjLzDGpB3vteCZOz5XpQnaEfNpV5LH9a+WmUGrq1tw7wbu5LMDgrvAeXzIkpN+JrhUuY6nqZHmY0jlHvVHx+OdoTcIC62VthKc+1guxuxValthRDGSpTFPZToSZOq/Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705606435; c=relaxed/simple; bh=r7q6DvUCmOsKy6+NbzdyWEddN1onz2OiEikraaSBQa8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=EYzUC/BRxBgB97ua8QTVz9SteoThjLHF+COyuPmI8bZc8AKbYZNMZRqjfgckRa5jT68ccfqMBDfauIgLa+Yo7usSn9urVMkpsaD3lNLRmyOO5j0PhSUDXyhhJ36cppw0yKCl1epQO9iSviRgMcTuT5vtM0QUO+8yr4RITgMkrQM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=xrWtmYjx; arc=none smtp.client-ip=209.85.214.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-1d711d7a940so6531095ad.1 for ; Thu, 18 Jan 2024 11:33:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1705606432; x=1706211232; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=2Eimo1bLVuQLA4eG0D77yPQYKlmdquXBMxi8UiFbf2o=; b=xrWtmYjxlRDgwio8cVAuZuud2MlU+7JhxUcN0Ti5h8hRFE1KRppD3jfPWJnGwPRhtf qZrPkU+/9K78O1UN1eHMjLSyN5y/2ismXyRnfXodrHXErTA5pmO1KpFbNs8V0DNc3Wn1 I1x0tSB/oT/yjTWZwOa3CJHZgPFZt5rHs5qJEUHoqvsar/asz3Bdq/PRA5t9QND0PDpd 7/6P9OCVoyfwyxOc+/Y4xGHfVROp24UNV8SkhBefa8ax4gfEIvSywlMYpyMRP2Z/Jexp R0l3VQQpruMTpyBxInjz66O0I6YA62hw+X37kmeRNp28Snil3A/PzGF7tLLaTbRWXy6+ l83g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705606432; x=1706211232; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=2Eimo1bLVuQLA4eG0D77yPQYKlmdquXBMxi8UiFbf2o=; b=OW5xKBP7riMA+7NG1oWH8Qn5mrwoTGgK5c6mieSJofSn4pZ781AhuvhjcWWghiRxNJ RffeaQEARXGKAYSfohIvFFsTNOLXfJuHM08Zxd9n1SeFzcf6Yg5PTXnh0coVjyvbNzr3 ypeXgPtX7deRZqS61bEIVfUi8BUGrYhkt2/xHxCMw62G/vfQ6NWCPER3KLl2snnu56kl dGFfXr5SnVr9kSPkLXJDKMxCDXPwaA0rIgha7GjKhfxH088jyDpEztrkU7nyX/W+eoYY nEbH69d6b+pKex92HaIyLbXXxUlylPI8UlRUhWrSmmuh580Jf0HYwHT+bjnRV9WKQVw5 WCMA== X-Gm-Message-State: AOJu0Yz+ysUFFL1ZEsOLPQrkKl8AKyzWX70AwpGV6OVzW/50baB7HYFG GWQPy5mXMi7uBVndNukbOGHKB+H/SzC6+ghjwEBbGztF5gXRm1dtWxMejAJEiA== X-Received: by 2002:a17:902:dacc:b0:1d4:69a5:edbb with SMTP id q12-20020a170902dacc00b001d469a5edbbmr1528056plx.48.1705606432321; Thu, 18 Jan 2024 11:33:52 -0800 (PST) Received: from google.com (77.62.105.34.bc.googleusercontent.com. [34.105.62.77]) by smtp.gmail.com with ESMTPSA id ee6-20020a17090afc4600b002868abc0e6dsm2261384pjb.11.2024.01.18.11.33.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jan 2024 11:33:51 -0800 (PST) Date: Thu, 18 Jan 2024 19:33:48 +0000 From: Carlos Llamas To: Greg Kroah-Hartman , Arve =?iso-8859-1?B?SGr4bm5lduVn?= , Todd Kjos , Martijn Coenen , Joel Fernandes , Christian Brauner , Suren Baghdasaryan , Sherry Yang Cc: linux-kernel@vger.kernel.org, kernel-team@android.com, stable@vger.kernel.org Subject: Re: [PATCH v2 05/28] binder: fix unused alloc->free_async_space Message-ID: References: <20231201172212.1813387-1-cmllamas@google.com> <20231201172212.1813387-6-cmllamas@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231201172212.1813387-6-cmllamas@google.com> On Fri, Dec 01, 2023 at 05:21:34PM +0000, Carlos Llamas wrote: > Each transaction is associated with a 'struct binder_buffer' that stores > the metadata about its buffer area. Since commit 74310e06be4d ("android: > binder: Move buffer out of area shared with user space") this struct is > no longer embedded within the buffer itself but is instead allocated on > the heap to prevent userspace access to this driver-exclusive info. > > Unfortunately, the space of this struct is still being accounted for in > the total buffer size calculation, specifically for async transactions. > This results in an additional 104 bytes added to every async buffer > request, and this area is never used. > > This wasted space can be substantial. If we consider the maximum mmap > buffer space of SZ_4M, the driver will reserve half of it for async > transactions, or 0x200000. This area should, in theory, accommodate up > to 262,144 buffers of the minimum 8-byte size. However, after adding > the extra 'sizeof(struct binder_buffer)', the total number of buffers > drops to only 18,724, which is a sad 7.14% of the actual capacity. > > This patch fixes the buffer size calculation to enable the utilization > of the entire async buffer space. This is expected to reduce the number > of -ENOSPC errors that are seen on the field. > > Fixes: 74310e06be4d ("android: binder: Move buffer out of area shared with user space") > Signed-off-by: Carlos Llamas > --- Sorry, I forgot to Cc: stable@vger.kernel.org. -- Carlos Llamas