Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp1145535rdb; Fri, 19 Jan 2024 09:27:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IFYYjYsyHp1WjuID3A5fnrg66V4YNb9kdiL8DzKXFfnXcqQcDs4yjiN1d5363c9MENwIoBx X-Received: by 2002:a17:902:8e8a:b0:1d5:121f:2be5 with SMTP id bg10-20020a1709028e8a00b001d5121f2be5mr225708plb.2.1705685251160; Fri, 19 Jan 2024 09:27:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705685251; cv=pass; d=google.com; s=arc-20160816; b=jRrnH9XVeRVWIy+lkcXJZJWprHGB4t5iLmVun0Cai5N+C5QTxWai6onWnEZjHkD4Is K+d360xFTl1+tAbhxWEIUhO9HP9JT/Tusuz4XHioBcrKKg6EttVdikjBt3hVjvM162gd IOh6Hp0k0ntJncVn1fG97MLnxSrorYC2H5AcQL0xEoDLm60shW61cS9eVxdoR05+o8vS UvMxDqFsK41S/rdXMsDwdUDSrlU1OYZTSZn2Zk3kvjr+ivHeOYoOVao4H00hIk0kpODk 2epD6+WwUUZ+xjezQIWt1eL7XOQaZP8c3Bxz7FGvTxNauGIUJNu/rAY7bsbXDiSEMeN6 VonQ== 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=n7a9skkOJDoeDAzXAlrhaoQRm2nSLoLLiCg9+PzsFlc=; fh=9VpuXEkrjRPOAOVhHdIOMc5Ai5mpgSDvBEUlQqQm1jc=; b=07fnJ55kqRYrT4kpUatVtjRfzvWH6mlTpmWFEFp0J8ltbJVXuXdq+cv7ZAZMwF/Hpu U45xwjrlzI6LFJ2MpH29ZJCdYt48KRkkVPS2orxOt/f3aGrPQBto1x3aLBrFPiGafIFS cw+SYX5F06LsB78bBz4eyY2t7woGFnbJFfGBfrpqVpcY9pos8qjmqeBawrqk18+vGQ0s ahnp8ZAeFz2CAwIpXPy9gd83mEqy1yMoIRaicHByPFbP03+Vn/cEMdX0LWiYEemv/2kF j5pwselQ8xE3r7pHnH/rxMZSCOUSy1G0IYFsIlz9OQBH6yV8O22ZQM7o4n8gLPEPdkhx dkDQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=quGWsSGd; 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-31422-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-31422-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. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id x12-20020a170902a38c00b001d499d617aesi3633967pla.235.2024.01.19.09.27.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jan 2024 09:27:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-31422-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=quGWsSGd; 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-31422-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-31422-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 3F86028767E for ; Fri, 19 Jan 2024 17:27:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6155455E66; Fri, 19 Jan 2024 17:27:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="quGWsSGd" Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) (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 4EC5D55E50 for ; Fri, 19 Jan 2024 17:27:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705685244; cv=none; b=Ii8zpL/Feevpr/iTqpTf6YusTJoSIuKJJ7yLLpLw9wQhTXpRX5vgTvk9DOem9uCO0Py/WchtbSj5gZesX5eIiNDcEr567U60+IR/jHQixr8FvIywJaSR8AhHnjfsl7J+w4V8YHoMi5WlHoFiKItTN4vQ8jNiMuQCoFEDusT88o8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705685244; c=relaxed/simple; bh=hQAkoZXDTSlJOPauCujJoN2NrBGM5OoV2NNA7O0qjTM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Cs2zQ+LpPE0GxmzVLX5EKjnL1xJBz+XSndfOCAZWY1Zxx90d34q1qMM0XeBmbcZlM9go7eP7EJVdPEYPpHjNN18NwEIvKdrqbyaJuL5ffkG+b67muYGkv0EPB4H9+4iUW1GZV6nSUCU8g0mNfYI0oQwqkcBOhtRtpCgQ4kQiV/s= 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=quGWsSGd; arc=none smtp.client-ip=209.85.210.176 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-pf1-f176.google.com with SMTP id d2e1a72fcca58-6db599d5cb8so1009937b3a.0 for ; Fri, 19 Jan 2024 09:27:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1705685242; x=1706290042; 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=n7a9skkOJDoeDAzXAlrhaoQRm2nSLoLLiCg9+PzsFlc=; b=quGWsSGdOEtcTU9ih2drDjVvCefQO4cs7BSRcO4Es0flrcpXliW1PexXT+RbsXAYEF p2Epbf3X7YseqN8BVVE9nWp55HO44LKdPh1UnVrk72dvv9JHoCxPm7PwahZLLKvbEQMl 186aMJYA/K2dhm8KXAe3K2m3BuPATWBn5eC0mLCqVVGNLGFeCpqMxpeiyJGbHoG41CqS u8j2fGGL4z1RBR2KqICyfEBKy2jN6jzbPDsjjJsxUfKinWrY5vfLE6pmn3JIlCa9awjN A5qlk/LUfiMO89gmfIeAKxFw84J/DsLteTI5jJFc6nZUn+T7seFtUGzYtXTWXp1l2TQ9 DyKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705685242; x=1706290042; 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=n7a9skkOJDoeDAzXAlrhaoQRm2nSLoLLiCg9+PzsFlc=; b=f4oAFUxztifT0KFS3W3yWGf7pO2YrhQOZPEvAhWZaLbNZNAarWcwEqCVo0ofpqmjgm p/+N4d5mC9mFoIPPQbLFwxNTp+SmBV9mj3c78SI4p/bNFqp35fOpvfTTu+TPWfQ9Aq60 gJxa0UEk2HP9o7we0KLoy9Xq2yqvi8VCZt2dJlGSdZ3GURzT426Cw0mSFTkoSb0yAcKo okIU5hCrHZtFutzs3vbXZnZTw56pp9SuqP0EYJMGCy+TbVco+JQ5VKdEJ6/prY4VIxnh 1BG2nBKug4wZZYq4QT/rvr9aqj3O93NlWYwZVpwsaQJZgardp8XVuAzWKICpxJvfjPBA J3NA== X-Gm-Message-State: AOJu0YzYTdyLVLcVBQTkUppy3MOT8UwcKYaAcKTOx+zEuUuaCHdlIV6Y ej2Nqs93Lqw6umptEF9SIdY3JYC/KS+x0+nT8ZZXzYG2NX3cDb+HPF5+80tKsw== X-Received: by 2002:a05:6a20:e123:b0:19a:e66e:b155 with SMTP id kr35-20020a056a20e12300b0019ae66eb155mr155863pzb.74.1705685242498; Fri, 19 Jan 2024 09:27:22 -0800 (PST) Received: from google.com (77.62.105.34.bc.googleusercontent.com. [34.105.62.77]) by smtp.gmail.com with ESMTPSA id i124-20020a62c182000000b006dadc436071sm5574807pfg.36.2024.01.19.09.27.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jan 2024 09:27:22 -0800 (PST) Date: Fri, 19 Jan 2024 17:27:18 +0000 From: Carlos Llamas To: Greg Kroah-Hartman Cc: Arve =?iso-8859-1?B?SGr4bm5lduVn?= , Todd Kjos , Martijn Coenen , Joel Fernandes , Christian Brauner , Suren Baghdasaryan , Sherry Yang , 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> <2024011955-quotation-zone-7f20@gregkh> 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: <2024011955-quotation-zone-7f20@gregkh> On Fri, Jan 19, 2024 at 06:49:00AM +0100, Greg Kroah-Hartman wrote: > On Thu, Jan 18, 2024 at 07:33:48PM +0000, Carlos Llamas wrote: > > 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. > > > > > This is not the correct way to submit patches for inclusion in the > stable kernel tree. Please read: > https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html > for how to do this properly. > > Oops, here is the complete info: Commit ID: c6d05e0762ab276102246d24affd1e116a46aa0c Subject: "binder: fix unused alloc->free_async_space" Reason: Fixes an incorrect calculation of available space. Versions: v4.19+ Note this patch will also have trivial conflicts in v4.19 and v5.4 kernels as commit 261e7818f06e is missing there. Please let me know and I can send the corresponding patches separately. Thanks, -- Carlos Llamas