From patchwork Thu May 7 15:52:02 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Starikovskiy X-Patchwork-Id: 22359 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n47G23ES024084 for ; Thu, 7 May 2009 16:02:04 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756761AbZEGQBP (ORCPT ); Thu, 7 May 2009 12:01:15 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1757334AbZEGQBP (ORCPT ); Thu, 7 May 2009 12:01:15 -0400 Received: from relay1.telecom.mipt.ru ([81.5.91.10]:60226 "EHLO relay1.telecom.mipt.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760279AbZEGQBM (ORCPT ); Thu, 7 May 2009 12:01:12 -0400 Received: from localhost (localhost [127.0.0.1]) by relay1.telecom.mipt.ru (Postfix) with ESMTP id 4E97B195D57; Thu, 7 May 2009 19:51:48 +0400 (MSD) X-Virus-Scanned: amavisd-new at telecom.mipt.ru Received: from relay1.telecom.mipt.ru ([127.0.0.1]) by localhost (relay1.telecom.mipt.ru [127.0.0.1]) (amavisd-new, port 10024) with LMTP id cG1tXWTkanih; Thu, 7 May 2009 19:51:47 +0400 (MSD) Received: from [127.0.1.1] (unknown [10.55.44.27]) by relay1.telecom.mipt.ru (Postfix) with ESMTP id 4CA0E195B46; Thu, 7 May 2009 19:51:47 +0400 (MSD) From: Alexey Starikovskiy To: "Moore, Robert" Cc: Linux-acpi@vger.kernel.org Subject: [PATCH 1/4] ACPICA: Remove use of caches in controlled way Date: Thu, 07 May 2009 19:52:02 +0400 Message-ID: <20090507155202.26361.38778.stgit@thinkpad> User-Agent: StGIT/0.14.2 MIME-Version: 1.0 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Signed-off-by: Alexey Starikovskiy --- source/components/utilities/utcache.c | 99 +++++---------------------------- 1 files changed, 14 insertions(+), 85 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/source/components/utilities/utcache.c b/source/components/utilities/utcache.c index aabc0a2..d08d520 100644 --- a/source/components/utilities/utcache.c +++ b/source/components/utilities/utcache.c @@ -287,49 +287,15 @@ AcpiOsReleaseObject ( ACPI_MEMORY_LIST *Cache, void *Object) { - ACPI_STATUS Status; - - ACPI_FUNCTION_ENTRY (); - if (!Cache || !Object) { return (AE_BAD_PARAMETER); } - /* If cache is full, just free this object */ - - if (Cache->CurrentDepth >= Cache->MaxDepth) - { - ACPI_FREE (Object); - ACPI_MEM_TRACKING (Cache->TotalFreed++); - } - - /* Otherwise put this object back into the cache */ - - else - { - Status = AcpiUtAcquireMutex (ACPI_MTX_CACHES); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - /* Mark the object as cached */ - - ACPI_MEMSET (Object, 0xCA, Cache->ObjectSize); - ACPI_SET_DESCRIPTOR_TYPE (Object, ACPI_DESC_TYPE_CACHED); - - /* Put the object at the head of the cache list */ - - * (ACPI_CAST_INDIRECT_PTR (char, - &(((char *) Object)[Cache->LinkOffset]))) = Cache->ListHead; - Cache->ListHead = Object; - Cache->CurrentDepth++; - - (void) AcpiUtReleaseMutex (ACPI_MTX_CACHES); - } + ACPI_FREE (Object); + ACPI_MEM_TRACKING (Cache->TotalFreed++); return (AE_OK); } @@ -353,8 +319,6 @@ AcpiOsAcquireObject ( ACPI_MEMORY_LIST *Cache) { ACPI_STATUS Status; - void *Object; - ACPI_FUNCTION_NAME (OsAcquireObject); @@ -372,61 +336,26 @@ AcpiOsAcquireObject ( ACPI_MEM_TRACKING (Cache->Requests++); - /* Check the cache first */ + /* The cache is empty, create a new object */ - if (Cache->ListHead) - { - /* There is an object available, use it */ - - Object = Cache->ListHead; - Cache->ListHead = *(ACPI_CAST_INDIRECT_PTR (char, - &(((char *) Object)[Cache->LinkOffset]))); - - Cache->CurrentDepth--; - - ACPI_MEM_TRACKING (Cache->Hits++); - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Object %p from %s cache\n", Object, Cache->ListName)); - - Status = AcpiUtReleaseMutex (ACPI_MTX_CACHES); - if (ACPI_FAILURE (Status)) - { - return (NULL); - } - - /* Clear (zero) the previously used Object */ - - ACPI_MEMSET (Object, 0, Cache->ObjectSize); - } - else - { - /* The cache is empty, create a new object */ - - ACPI_MEM_TRACKING (Cache->TotalAllocated++); + ACPI_MEM_TRACKING (Cache->TotalAllocated++); #ifdef ACPI_DBG_TRACK_ALLOCATIONS - if ((Cache->TotalAllocated - Cache->TotalFreed) > Cache->MaxOccupied) - { - Cache->MaxOccupied = Cache->TotalAllocated - Cache->TotalFreed; - } + if ((Cache->TotalAllocated - Cache->TotalFreed) > Cache->MaxOccupied) + { + Cache->MaxOccupied = Cache->TotalAllocated - Cache->TotalFreed; + } #endif - /* Avoid deadlock with ACPI_ALLOCATE_ZEROED */ + /* Avoid deadlock with ACPI_ALLOCATE_ZEROED */ - Status = AcpiUtReleaseMutex (ACPI_MTX_CACHES); - if (ACPI_FAILURE (Status)) - { - return (NULL); - } - - Object = ACPI_ALLOCATE_ZEROED (Cache->ObjectSize); - if (!Object) - { - return (NULL); - } + Status = AcpiUtReleaseMutex (ACPI_MTX_CACHES); + if (ACPI_FAILURE (Status)) + { + return (NULL); } - return (Object); + return ACPI_ALLOCATE_ZEROED (Cache->ObjectSize); } #endif /* ACPI_USE_LOCAL_CACHE */