From patchwork Sun Feb 8 16:51:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 44505 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f69.google.com (mail-ee0-f69.google.com [74.125.83.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 049D02153F for ; Sun, 8 Feb 2015 16:52:18 +0000 (UTC) Received: by mail-ee0-f69.google.com with SMTP id b57sf4713857eek.0 for ; Sun, 08 Feb 2015 08:52:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:subject:precedence:reply-to:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version :content-type:content-transfer-encoding:errors-to:x-original-sender :x-original-authentication-results:mailing-list; bh=HVf+CvAO18B51e16rsvSBDEXcWxOcYiVlMHKnarLN6U=; b=Js54b1ABhkHcNtBg8OOUtYsWug6kDk0rVUkxNG0RJtH6wngNcRwxJ2ILqMPmAVXeiD d30A1H2thji+9KPvKUKPHXVHKoU23l8sHxusmqDCBXx4t9ZaaPLXHZSN1OrjVOmr0BU7 Xw59vCpvxFwXqOvYvCBl/AB4DgiuaUvLzq7XJVnws1Y0OWFou8lUGiWT4B4I5yK4EbLY dIE8wRQuIDsJP2DAaMrlb+lVx4YCt88O+If91Yp9Z9iqDZ09T6LNOgn3s9cf+5uQyav5 /8cKsc1gz6S35FSCF1TF18ryxsZ5MK5ReRCXdFdUWbxkRQrPUonNHaXcYSXEb5mZ4CX5 B0Uw== X-Gm-Message-State: ALoCoQnDMwO/wboyzurxbfL3ZyLLujAX6E4dT+un5T5qfVGN/o1GvBfwnJEpbZcbrhf24TBsZXI4 X-Received: by 10.194.178.234 with SMTP id db10mr1453420wjc.2.1423414336797; Sun, 08 Feb 2015 08:52:16 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.204.39 with SMTP id kv7ls418422lac.76.gmail; Sun, 08 Feb 2015 08:52:16 -0800 (PST) X-Received: by 10.152.3.70 with SMTP id a6mr12504478laa.71.1423414336508; Sun, 08 Feb 2015 08:52:16 -0800 (PST) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com. [209.85.217.182]) by mx.google.com with ESMTPS id po2si7002807lbc.18.2015.02.08.08.52.16 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 08 Feb 2015 08:52:16 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.182 as permitted sender) client-ip=209.85.217.182; Received: by mail-lb0-f182.google.com with SMTP id l4so25792056lbv.13 for ; Sun, 08 Feb 2015 08:52:16 -0800 (PST) X-Received: by 10.152.181.168 with SMTP id dx8mr12358170lac.76.1423414336298; Sun, 08 Feb 2015 08:52:16 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp2925318lbj; Sun, 8 Feb 2015 08:52:15 -0800 (PST) X-Received: by 10.50.111.168 with SMTP id ij8mr12675332igb.43.1423414332430; Sun, 08 Feb 2015 08:52:12 -0800 (PST) Received: from lists.sourceforge.net (lists.sourceforge.net. [216.34.181.88]) by mx.google.com with ESMTPS id o18si4834836igx.50.2015.02.08.08.52.11 (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 08 Feb 2015 08:52:12 -0800 (PST) Received-SPF: pass (google.com: domain of edk2-devel-bounces@lists.sourceforge.net designates 216.34.181.88 as permitted sender) client-ip=216.34.181.88; Received: from localhost ([127.0.0.1] helo=sfs-ml-2.v29.ch3.sourceforge.com) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1YKV5S-0002D3-00; Sun, 08 Feb 2015 16:51:58 +0000 Received: from sog-mx-3.v43.ch3.sourceforge.com ([172.29.43.193] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1YKV5Q-0002Cx-Pi for edk2-devel@lists.sourceforge.net; Sun, 08 Feb 2015 16:51:56 +0000 Received-SPF: pass (sog-mx-3.v43.ch3.sourceforge.com: domain of linaro.org designates 209.85.192.174 as permitted sender) client-ip=209.85.192.174; envelope-from=ard.biesheuvel@linaro.org; helo=mail-pd0-f174.google.com; Received: from mail-pd0-f174.google.com ([209.85.192.174]) by sog-mx-3.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1YKV5P-0001tP-2L for edk2-devel@lists.sourceforge.net; Sun, 08 Feb 2015 16:51:56 +0000 Received: by pdbfl12 with SMTP id fl12so1051300pdb.2 for ; Sun, 08 Feb 2015 08:51:49 -0800 (PST) X-Received: by 10.66.219.35 with SMTP id pl3mr22246348pac.32.1423414309365; Sun, 08 Feb 2015 08:51:49 -0800 (PST) Received: from ards-macbook-pro.local ([113.28.134.59]) by mx.google.com with ESMTPSA id di5sm759152pbc.36.2015.02.08.08.51.47 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 08 Feb 2015 08:51:48 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.sourceforge.net, lersek@redhat.com, olivier.martin@arm.com, roy.franz@linaro.org, leif.lindholm@linaro.org, jordan.l.justen@intel.com, feng.tian@intel.com Date: Mon, 9 Feb 2015 00:51:15 +0800 Message-Id: <1423414278-8455-4-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1423414278-8455-1-git-send-email-ard.biesheuvel@linaro.org> References: <1423414278-8455-1-git-send-email-ard.biesheuvel@linaro.org> X-Spam-Score: -1.5 (-) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain -0.0 SPF_PASS SPF: sender matches SPF record -0.0 AWL AWL: Adjusted score from AWL reputation of From: address X-Headers-End: 1YKV5P-0001tP-2L Subject: [edk2] [PATCH 3/6] MdeModulePkg: use index to traverse free pool pages X-BeenThere: edk2-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list Reply-To: edk2-devel@lists.sourceforge.net List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.sourceforge.net X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ard.biesheuvel@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.182 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 In preparation of making the pool code capable of serving allocations from higher-up bins, update the free path to traverse a candidate page by following the index of POOL_FREE header instead of duplicating the carving logic that was used at page allocation time. This allows chunks to be split into smaller ones, where one can be returned to serve the allocation, and the other stored in a smaller bin for later use. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel --- MdeModulePkg/Core/Dxe/Mem/Pool.c | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/MdeModulePkg/Core/Dxe/Mem/Pool.c b/MdeModulePkg/Core/Dxe/Mem/Pool.c index c7998e80cce6..0c5cf3d28451 100644 --- a/MdeModulePkg/Core/Dxe/Mem/Pool.c +++ b/MdeModulePkg/Core/Dxe/Mem/Pool.c @@ -495,7 +495,6 @@ CoreFreePoolI ( UINTN NoPages; UINTN Size; CHAR8 *NewPage; - UINTN FSize; UINTN Offset; BOOLEAN AllFree; UINTN Granularity; @@ -589,22 +588,16 @@ CoreFreePoolI ( if (Free->Signature == POOL_FREE_SIGNATURE) { - Index = Free->Index; - AllFree = TRUE; Offset = 0; while ((Offset < Granularity) && (AllFree)) { - FSize = LIST_TO_SIZE(Index); - while (Offset + FSize <= Granularity) { - Free = (POOL_FREE *) &NewPage[Offset]; - ASSERT(Free != NULL); - if (Free->Signature != POOL_FREE_SIGNATURE) { - AllFree = FALSE; - } - Offset += FSize; + Free = (POOL_FREE *) &NewPage[Offset]; + ASSERT(Free != NULL); + if (Free->Signature != POOL_FREE_SIGNATURE) { + AllFree = FALSE; } - Index -= 1; + Offset += LIST_TO_SIZE(Free->Index); } if (AllFree) { @@ -616,18 +609,13 @@ CoreFreePoolI ( // Free = (POOL_FREE *) &NewPage[0]; ASSERT(Free != NULL); - Index = Free->Index; Offset = 0; while (Offset < Granularity) { - FSize = LIST_TO_SIZE(Index); - while (Offset + FSize <= Granularity) { - Free = (POOL_FREE *) &NewPage[Offset]; - ASSERT(Free != NULL); - RemoveEntryList (&Free->Link); - Offset += FSize; - } - Index -= 1; + Free = (POOL_FREE *) &NewPage[Offset]; + ASSERT(Free != NULL); + RemoveEntryList (&Free->Link); + Offset += LIST_TO_SIZE(Free->Index); } //