Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp850274rdb; Thu, 30 Nov 2023 23:21:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IF7hBohaMGORtvhGq/QHTQt2azWcEDxFObyvoE6QPGcCUZLq6a5Kho91kpjwAGYYAGQBUSj X-Received: by 2002:a05:6830:22cc:b0:6d6:4968:2c11 with SMTP id q12-20020a05683022cc00b006d649682c11mr2235208otc.2.1701415300161; Thu, 30 Nov 2023 23:21:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701415300; cv=none; d=google.com; s=arc-20160816; b=oNG3ssaLKor7v8Pprgc3WcdiCCk2h5Z/Nif1siYq79z8E1ECXuEW7aV3TxXdyhOBIE 7oaXO8/1ZSapy7i0gTRRcQN6eV61QgoU22jKfrX+4Y7W5bvL25JdEASdQbNKmL6B6fuA gAQGFeybhtYOuC033PzaelYAaOw94YmA/nGqfSL8DjKq1MidNLryMPIQ5qTUNd12oEpN dOhryEUXwLFfdnQYfBC478EzegVYvYG4Opvn7rcPj3ZKqopX3K9R2Ely9HXAuwTfd8wS vhc/rYWHlrtQVmcoKi3Wfsu4qjZT8ipfVnVPGc0DolQNV5qnnttVl4I0cZRH7DLFrKZZ tdVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=XDasWdCvdIpecxENqyCgimTWujwkKIN82JQqjC/O2NE=; fh=658IzL/FnSGry58xenYrijK6lVYrX2ZKm8jUOjcb14s=; b=wpUIpZSnO94KcWvTTNcZpF2W6rWTHGSWg+pzJ0fBO9NPX0Yd89jUfMGxPNti5fhRN1 k/2OUp2BxwYGmUAvmHo3pfnOZyILP0JKHS5yE1rcpcSO7gKZTBy29nh8IN5xX3xhXJuL gocygoNS7OKmhKEz8c3GvzTenvojFvJgl+dFK8UW1tJ8W2r1yxl/4SOujU6OeeMtZhcI qnnFCkbYzK75dO6tY0w5tQhlXGWwRG63SmXAdSUiVgQdDHX+p2TND/SiEhfL8XucUseU glxzReUIIEixE11/e5rXVpXzKfWClq330Q6qFNuA7xmh3NO7k6hkK2y7K+i+3VaDR49I cmXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ekUBJMT7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id bm1-20020a656e81000000b005c626128e67si3191157pgb.494.2023.11.30.23.21.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 23:21:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ekUBJMT7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 8DE4682E3323; Thu, 30 Nov 2023 23:21:13 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377756AbjLAHUr (ORCPT + 99 others); Fri, 1 Dec 2023 02:20:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377751AbjLAHUg (ORCPT ); Fri, 1 Dec 2023 02:20:36 -0500 Received: from mail-ot1-x332.google.com (mail-ot1-x332.google.com [IPv6:2607:f8b0:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57B411724 for ; Thu, 30 Nov 2023 23:20:41 -0800 (PST) Received: by mail-ot1-x332.google.com with SMTP id 46e09a7af769-6d858670630so142477a34.0 for ; Thu, 30 Nov 2023 23:20:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1701415240; x=1702020040; 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=XDasWdCvdIpecxENqyCgimTWujwkKIN82JQqjC/O2NE=; b=ekUBJMT7tMfdFNKognBxzTWNdiHtAgQsZYqVX+byzgKqtmtDGOOb70/Dm2LHRb7bpD fdaaXiYDkFqln6peG5FzDP2bUdoAMMj1iBZ5zGCIw05tDG5vc1w6rCD20kvPs57IVxIW Go5XZXNZ7Iw8OAIdPMOsuu4ZuOktDW1uu+KmrJH9vqE3ZrHEg42LGPudAL8D7WtgmsUx CrQgBe8WGB0a8g+w4csZVD1pB/DZJ3v1d06EqHShtDv8D05YvsIeAIII/UvdyBXgu4it VPDLfOyP1llKZim58kBrnUlTam+n9IjMa4+oAYhu7DVB2g4QwlCR7nr48tEp2y1ZTMZs QrQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701415240; x=1702020040; 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=XDasWdCvdIpecxENqyCgimTWujwkKIN82JQqjC/O2NE=; b=h9auO/CEG4RumyPbW6FsFebGmHfgryl11k0ovyfI+Q/DnqGCBua202DTPO4ka7F1aT XY2ERMayBaekaOKfsMDiwINbqMc7RFu08CCafWnKl7NKQhQMJLJ1hmSgRZeEuJMbtidr kncIHdTdGqVLsuo+2LnW+WOKzYWm9/IYRlUI+EKuk37GilKz1L5sWOfi1pJ46ByR9qWp d/RwCcMvHwipKx5wYNImrcoTY/h8hlzstKtYeZSmzTCFyzg8MPwB21p67f97kmFuA+ET t7KRtjySeExnHqZA/FHdtj6fS9/YPtFuW0J1YpqI8sOTbPPW5Iq5yu3J2o9uqpVxVMyZ FFBw== X-Gm-Message-State: AOJu0Yxp3V2bHWpfa2oSTSm5M25BvgN9sbzGeFy3lPxGuqMw5wgQqChA 3GYbC5HUCyAMVa2d/eyOLFca3A== X-Received: by 2002:a9d:750b:0:b0:6c6:4843:2abe with SMTP id r11-20020a9d750b000000b006c648432abemr2219718otk.14.1701415240429; Thu, 30 Nov 2023 23:20:40 -0800 (PST) Received: from google.com (170.102.105.34.bc.googleusercontent.com. [34.105.102.170]) by smtp.gmail.com with ESMTPSA id c22-20020a63da16000000b005b92d3cb4c2sm2472797pgh.58.2023.11.30.23.20.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 23:20:39 -0800 (PST) Date: Fri, 1 Dec 2023 07:20:36 +0000 From: Carlos Llamas To: Alice Ryhl Cc: Arve =?iso-8859-1?B?SGr4bm5lduVn?= , Christian Brauner , Greg Kroah-Hartman , Joel Fernandes , kernel-team@android.com, linux-kernel@vger.kernel.org, Martijn Coenen , Suren Baghdasaryan , Todd Kjos Subject: Re: [PATCH 17/21] binder: malloc new_buffer outside of locks Message-ID: References: <20231102185934.773885-18-cmllamas@google.com> <20231107090838.260730-1-aliceryhl@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231107090838.260730-1-aliceryhl@google.com> X-Spam-Status: No, score=-4.6 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FSL_HELO_FAKE,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SORTED_RECIPS,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Thu, 30 Nov 2023 23:21:13 -0800 (PST) On Tue, Nov 07, 2023 at 09:08:38AM +0000, Alice Ryhl wrote: > Carlos Llamas writes: > > Preallocate new_buffer before acquiring the alloc->mutex and hand it > > down to binder_alloc_new_buf_locked(). The new buffer will be used in > > the vast majority of requests (measured at 98.2% in field data). The > > buffer is discarded otherwise. This change is required in preparation > > for transitioning alloc->mutex into a spinlock in subsequent commits. > > > > Signed-off-by: Carlos Llamas > > You also need to free the new buffer here: > > if (unlikely(!best_fit)) { > binder_alloc_debug(BINDER_DEBUG_USER_ERROR, > "%d: binder_alloc_buf size %zd failed, no address space\n", > alloc->pid, size); > debug_no_space_locked(alloc); > return ERR_PTR(-ENOSPC); > } Ouch! this is true and there is a second instance that needs the kfree as well. Thanks for catching it. -- Carlos Llamas