From patchwork Sun Feb 8 16:51:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 44506 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f199.google.com (mail-lb0-f199.google.com [209.85.217.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A46FE2153F for ; Sun, 8 Feb 2015 16:52:20 +0000 (UTC) Received: by mail-lb0-f199.google.com with SMTP id f15sf16047754lbj.2 for ; Sun, 08 Feb 2015 08:52:19 -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=mLUq/LrQgp8TRHOGA4KNyYa5s7xBR0T0u4ykNokOiWc=; b=L1t+yOpQZQmwXMPC6tu3B88nmASDc86zFKxkWfasBQ4NEF/AC/+poUh2C3EaBJxQ/1 PEvDK+lYXqGiYL6DzWhDg1/evoLH8WwwB2qQl8Avxbvvxw2M52jNiOa3b+HrA6wIAIOE r5t52vMwThwZ7iDHBSkHNk+0u9Tl65Ao7T9IW6DBMFWgybaE1H4nCddxnvcOzok4NvhI gSq9bYG1nbJlTeYSYZenjBRgrCn6yn0ONxMXD0q5q+fikGf3PgNJHYp4urBDWIBz1Y39 QtqXloVQEEoZaLUNh9uBw3jjTlMiyrES4lQB6UN+yxNsGZDo0tn1vIZmkNlYe/9vmKEO gSqA== X-Gm-Message-State: ALoCoQmImu6UBGIAuLZd5QMePcjFqAE5BKPCG1MRGhFGoNWPjucyYxkHlTSLkAaOsyJitjCaLzAJ X-Received: by 10.112.30.131 with SMTP id s3mr1494313lbh.13.1423414339633; Sun, 08 Feb 2015 08:52:19 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.242.164 with SMTP id wr4ls502029lac.79.gmail; Sun, 08 Feb 2015 08:52:19 -0800 (PST) X-Received: by 10.152.204.97 with SMTP id kx1mr12394406lac.75.1423414339514; Sun, 08 Feb 2015 08:52:19 -0800 (PST) Received: from mail-lb0-f169.google.com (mail-lb0-f169.google.com. [209.85.217.169]) by mx.google.com with ESMTPS id ba10si4210674lab.162.2015.02.08.08.52.19 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 08 Feb 2015 08:52:19 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.169 as permitted sender) client-ip=209.85.217.169; Received: by mail-lb0-f169.google.com with SMTP id f15so25788793lbj.0 for ; Sun, 08 Feb 2015 08:52:19 -0800 (PST) X-Received: by 10.152.6.195 with SMTP id d3mr10513323laa.36.1423414339122; Sun, 08 Feb 2015 08:52:19 -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 h5csp2925332lbj; Sun, 8 Feb 2015 08:52:18 -0800 (PST) X-Received: by 10.107.133.36 with SMTP id h36mr3667549iod.40.1423414337615; Sun, 08 Feb 2015 08:52:17 -0800 (PST) Received: from lists.sourceforge.net (lists.sourceforge.net. [216.34.181.88]) by mx.google.com with ESMTPS id b19si5980089iob.67.2015.02.08.08.52.16 (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 08 Feb 2015 08:52:17 -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-3.v29.ch3.sourceforge.com) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1YKV5U-00068U-DE; Sun, 08 Feb 2015 16:52:00 +0000 Received: from sog-mx-2.v43.ch3.sourceforge.com ([172.29.43.192] helo=mx.sourceforge.net) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1YKV5S-00068J-LS for edk2-devel@lists.sourceforge.net; Sun, 08 Feb 2015 16:51:58 +0000 Received-SPF: pass (sog-mx-2.v43.ch3.sourceforge.com: domain of linaro.org designates 209.85.192.181 as permitted sender) client-ip=209.85.192.181; envelope-from=ard.biesheuvel@linaro.org; helo=mail-pd0-f181.google.com; Received: from mail-pd0-f181.google.com ([209.85.192.181]) by sog-mx-2.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1YKV5R-0006s7-Pi for edk2-devel@lists.sourceforge.net; Sun, 08 Feb 2015 16:51:58 +0000 Received: by pdno5 with SMTP id o5so3571772pdn.8 for ; Sun, 08 Feb 2015 08:51:52 -0800 (PST) X-Received: by 10.66.117.231 with SMTP id kh7mr21723884pab.21.1423414312184; Sun, 08 Feb 2015 08:51:52 -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.49 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 08 Feb 2015 08:51:51 -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:16 +0800 Message-Id: <1423414278-8455-5-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 X-Headers-End: 1YKV5R-0006s7-Pi Subject: [edk2] [PATCH 4/6] MdeModulePkg: carve pool pages into the largest chunks possible 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.169 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 the next patch, that serves allocations from higher-up bins if the current bin is depleted, this patch updates the carving up strategy to populate the largest bins first. To ensure that there will always be an allocation of the appropriate size made, the current allocation request is served first from the newly allocated memory region. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel --- MdeModulePkg/Core/Dxe/Mem/Pool.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/MdeModulePkg/Core/Dxe/Mem/Pool.c b/MdeModulePkg/Core/Dxe/Mem/Pool.c index 0c5cf3d28451..23409d35c428 100644 --- a/MdeModulePkg/Core/Dxe/Mem/Pool.c +++ b/MdeModulePkg/Core/Dxe/Mem/Pool.c @@ -352,9 +352,15 @@ CoreAllocatePoolI ( } // - // Carve up new page into free pool blocks + // Serve the allocation request from the head of the allocated block // - Offset = 0; + Head = (POOL_HEAD *) NewPage; + Offset = LIST_TO_SIZE (Index); + + // + // Carve up remaining space into free pool blocks + // + Index = SIZE_TO_LIST (Granularity) - 1; while (Offset < Granularity) { ASSERT (Index < MAX_POOL_LIST); FSize = LIST_TO_SIZE(Index); @@ -371,7 +377,7 @@ CoreAllocatePoolI ( } ASSERT (Offset == Granularity); - Index = SIZE_TO_LIST(Size); + goto Done; } //