diff mbox

[2/2] cxl: Fix allocating a minimum of 2 pages for the SPA

Message ID 1467202586-13412-2-git-send-email-imunsie@au.ibm.com (mailing list archive)
State Accepted
Headers show

Commit Message

Ian Munsie June 29, 2016, 12:16 p.m. UTC
From: Ian Munsie <imunsie@au1.ibm.com>

The Scheduled Process Area is allocated dynamically with enough pages to
fit at least as many processes as the AFU descriptor indicated. Since
the calculation is non-trivial, it does this by calculating how many
processes could fit in an allocation of a given order, and increasing
that order until it can fit enough processes or hits the maximum
supported size.

Currently, it will start this search using a SPA of 2 pages instead of
1. This can waste a page of memory if the AFU's maximum number of
supported processes was small enough to fit in one page.

Fix the algorithm to start the search at 1 page.

Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
 drivers/misc/cxl/native.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Frederic Barrat June 29, 2016, 4:06 p.m. UTC | #1
Le 29/06/2016 14:16, Ian Munsie a écrit :
> From: Ian Munsie <imunsie@au1.ibm.com>
>
> The Scheduled Process Area is allocated dynamically with enough pages to
> fit at least as many processes as the AFU descriptor indicated. Since
> the calculation is non-trivial, it does this by calculating how many
> processes could fit in an allocation of a given order, and increasing
> that order until it can fit enough processes or hits the maximum
> supported size.
>
> Currently, it will start this search using a SPA of 2 pages instead of
> 1. This can waste a page of memory if the AFU's maximum number of
> supported processes was small enough to fit in one page.
>
> Fix the algorithm to start the search at 1 page.
>
> Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>


Reviewed-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
Andrew Donnellan June 29, 2016, 11:07 p.m. UTC | #2
On 29/06/16 22:16, Ian Munsie wrote:
> From: Ian Munsie <imunsie@au1.ibm.com>
>
> The Scheduled Process Area is allocated dynamically with enough pages to
> fit at least as many processes as the AFU descriptor indicated. Since
> the calculation is non-trivial, it does this by calculating how many
> processes could fit in an allocation of a given order, and increasing
> that order until it can fit enough processes or hits the maximum
> supported size.
>
> Currently, it will start this search using a SPA of 2 pages instead of
> 1. This can waste a page of memory if the AFU's maximum number of
> supported processes was small enough to fit in one page.
>
> Fix the algorithm to start the search at 1 page.
>
> Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>

Makes sense.

Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Michael Ellerman July 11, 2016, 10:19 a.m. UTC | #3
On Wed, 2016-29-06 at 12:16:26 UTC, Ian Munsie wrote:
> From: Ian Munsie <imunsie@au1.ibm.com>
> 
> The Scheduled Process Area is allocated dynamically with enough pages to
> fit at least as many processes as the AFU descriptor indicated. Since
> the calculation is non-trivial, it does this by calculating how many
> processes could fit in an allocation of a given order, and increasing
> that order until it can fit enough processes or hits the maximum
> supported size.
> 
> Currently, it will start this search using a SPA of 2 pages instead of
> 1. This can waste a page of memory if the AFU's maximum number of
> supported processes was small enough to fit in one page.
> 
> Fix the algorithm to start the search at 1 page.
> 
> Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
> Reviewed-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
> Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/2224b6719b09052a9fbf29422a

cheers
diff mbox

Patch

diff --git a/drivers/misc/cxl/native.c b/drivers/misc/cxl/native.c
index e80d8f7..120c468 100644
--- a/drivers/misc/cxl/native.c
+++ b/drivers/misc/cxl/native.c
@@ -189,7 +189,7 @@  int cxl_alloc_spa(struct cxl_afu *afu)
 	unsigned spa_size;
 
 	/* Work out how many pages to allocate */
-	afu->native->spa_order = 0;
+	afu->native->spa_order = -1;
 	do {
 		afu->native->spa_order++;
 		spa_size = (1 << afu->native->spa_order) * PAGE_SIZE;