mempool: fix search of maximum contiguous pages
PATCH 1/1 mempool: fix search of maximum contiguous pages
paddr[i] + pg_sz always points to the start physical address of the 2nd page after pddr[i], so only up to 2 pages can be combinded to be used. With this revision, more than 2 pages can be used.
--- lib/librte_mempool/rte_mempool.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
lib/librte_mempool/rte_mempool.c +4 -1
@@ -426,9 +426,12 @@ rte_mempool_populate_phys_tab(struct rte_mempool *mp, char *vaddr,for (i =0 ; i < pg_num && mp->populated_size < mp->size; i += n) { +phys_addr_t paddr_next; + paddr_next = paddr[i] + pg_sz; +/* populate with the largest group of contiguous pages */ for (n =1 ; (i + n) < pg_num && - paddr[i] + pg_sz == paddr[i+n]; n++) + paddr_next == paddr[i+n]; n++, paddr_next += pg_sz) ; ret = rte_mempool_populate_phys(mp, vaddr + i * pg_sz,
Signature · 1 line
2.7.4
+Olivier
Quoted 29 lines · Wei Dai
paddr[i] +
pg_szalways points to the start physical address of the 2nd page after pddr[i], so only up to 2 pages can be combinded to be used. With this revision, more than 2 pages can be used.Fixes 84121f197187 ("mempool: store memory chunks in a list")Signed-off-by Wei Dai <[email protected]>--- lib/librte_mempool/rte_mempool.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)lib/librte_mempool/rte_mempool.c +4
-1@@ -426,9 +426,12 @@ rte_mempool_populate_phys_tab(struct rte_mempool *mp, char *vaddr,for (i =0 ; i < pg_num && mp->populated_size < mp->size; i += n) { +phys_addr_t paddr_next; + paddr_next = paddr[i] + pg_sz; +/* populate with the largest group of contiguous pages */ for (n =1 ; (i + n) < pg_num && - paddr[i] + pg_sz == paddr[i+n]; n++) + paddr_next == paddr[i+n]; n++, paddr_next += pg_sz) ; ret = rte_mempool_populate_phys(mp, vaddr + i * pg_sz,
Hi
Quoted 12 lines
Signed-off-by Wei Dai <[email protected]>--- lib/librte_mempool/rte_mempool.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)lib/librte_mempool/rte_mempool.c +0
-0@@ -426,9 +426,12 @@ rte_mempool_populate_phys_tab(struct rte_mempool *mp, char *vaddr,
lib/librte_mempool/rte_mempool.c rte_mempool_populate_phys_tab(struct rte_mempool *mp, char *vaddr, · line 435
Quoted 10 lines
lib/librte_mempool/rte_mempool.c +4
-1for (i =0 ; i < pg_num && mp->populated_size < mp->size; i += n) { +phys_addr_t paddr_next; + paddr_next = paddr[i] + pg_sz; +/* populate with the largest group of contiguous pages */ for (n =1 ; (i + n) < pg_num && - paddr[i] + pg_sz == paddr[i+n]; n++) + paddr_next == paddr[i+n]; n++, paddr_next += pg_sz) ;
Good catch.
Why not just paddr[i + n - 1] != paddr[i + n]? Then you don't need extra variable (paddr_next) here. Konstantin
Quoted 4 lines
lib/librte_mempool/rte_mempool.c +0
-1ret = rte_mempool_populate_phys(mp, vaddr + i * pg_sz, --2.7.4
Quoted 25 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Ananyev, Konstantin
Sent: Thursday, October 13, 2016 10:54 AM
To: Dai, Wei <[email protected]>; [email protected]; Gonzalez Monroy, Sergio <[email protected]>; Tan, Jianfeng <[email protected]>; Dai, Wei <[email protected]>
Subject: Re: [dpdk-dev] [PATCH] mempool: fix search of maximum contiguous pagesHi
Quoted 14 lines
Signed-off-by Wei Dai <[email protected]>--- lib/librte_mempool/rte_mempool.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)lib/librte_mempool/rte_mempool.c +0
-0@@ -426,9 +426,12 @@ rte_mempool_populate_phys_tab(struct rte_mempool *mp, char *vaddr,for (i =0 ; i < pg_num && mp->populated_size < mp->size; i += n) {
Quoted 11 lines
lib/librte_mempool/rte_mempool.c rte_mempool_populate_phys_tab(struct rte_mempool *mp, char *vaddr, · line 435
Quoted 8 lines
lib/librte_mempool/rte_mempool.c +4
-1+phys_addr_t paddr_next; + paddr_next = paddr[i] + pg_sz; +/* populate with the largest group of contiguous pages */ for (n =1 ; (i + n) < pg_num && - paddr[i] + pg_sz == paddr[i+n]; n++) + paddr_next == paddr[i+n]; n++, paddr_next += pg_sz) ;Good catch.
Why not just paddr[i + n - 1] != paddr[i + n]?
Sorry, I meant 'paddr[i + n - 1] + pg_sz == paddr[i+n]' off course.
Quoted 7 lines
Then you don't need extra variable (
paddr_next) here. KonstantinQuoted 4 lines
lib/librte_mempool/rte_mempool.c +0
-1ret = rte_mempool_populate_phys(mp, vaddr + i * pg_sz, --2.7.4
Quoted 22 lines
Quoted 10 lines
Quoted 10 lines
lib/librte_mempool/rte_mempool.c +0
-0@@ -426,9 +426,12 @@ rte_mempool_populate_phys_tab(struct rte_mempool *mp, char *vaddr, for (i = 0; i < pg_num && mp->populated_size < mp->size; i += n) {Quoted 11 lines
lib/librte_mempool/rte_mempool.c rte_mempool_populate_phys_tab(struct rte_mempool *mp, char *vaddr, · line 435
Quoted 8 lines
lib/librte_mempool/rte_mempool.c +4
-1+phys_addr_t paddr_next; + paddr_next = paddr[i] + pg_sz; +/* populate with the largest group of contiguous pages */ for (n =1 ; (i + n) < pg_num && - paddr[i] + pg_sz == paddr[i+n]; n++) + paddr_next == paddr[i+n]; n++, paddr_next += pg_sz) ;Good catch.
Why not just paddr[i + n - 1] != paddr[i + n]?
Quoted 4 lines
Sorry, I meant 'paddr[i + n - 1] +
pg_sz== paddr[i+n]' off course.Quoted 2 lines
Then you don't need extra variable (
paddr_next) here. Konstantin
Thank you, Konstantin
'paddr[i + n - 1] + pg_sz = paddr[i + n]' also can fix it and have straight meaning. But I assume that my revision with paddr_next += pg_sz may have a bit better performance. By the way, paddr[i] + n * pg_sz = paddr[i + n] can also resolve it.
/Wei
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
lib/librte_mempool/rte_mempool.c +0
-1ret = rte_mempool_populate_phys(mp, vaddr + i * pg_sz, --2.7.4
Quoted 24 lines
Quoted 24 lines
Quoted 23 lines
Quoted 10 lines
lib/librte_mempool/rte_mempool.c +0
-0@@ -426,9 +426,12 @@ rte_mempool_populate_phys_tab(struct rte_mempool *mp, char *vaddr,lib/librte_mempool/rte_mempool.c rte_mempool_populate_phys_tab(struct · line 436
Quoted 10 lines
lib/librte_mempool/rte_mempool.c +4
-1for (i =0 ; i < pg_num && mp->populated_size < mp->size; i += n) { +phys_addr_t paddr_next; + paddr_next = paddr[i] + pg_sz; +/* populate with the largest group of contiguous pages */ for (n =1 ; (i + n) < pg_num && - paddr[i] + pg_sz == paddr[i+n]; n++) + paddr_next == paddr[i+n]; n++, paddr_next += pg_sz) ;Good catch.
Why not just paddr[i + n - 1] != paddr[i + n]?
Quoted 8 lines
Quoted 4 lines
Sorry, I meant 'paddr[i + n - 1] +
pg_sz== paddr[i+n]' off course.Quoted 2 lines
Then you don't need extra variable (
paddr_next) here. KonstantinThank you, Konstantin
'paddr[i + n - 1] +pg_sz= paddr[i + n]' also can fix it and have straight meaning. But I assume that my revision withpaddr_next+=pg_szmay have a bit better performance.
I don't think there would be any real difference, again it is not performance critical code-path.
Quoted 1 line
By the way, paddr[i] + n *
pg_sz= paddr[i + n] can also resolve it.
Yes, that's one seems even better for me - make things more clear. Konstantin
Quoted 8 lines
/Wei
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
lib/librte_mempool/rte_mempool.c +0
-1ret = rte_mempool_populate_phys(mp, vaddr + i * pg_sz, --2.7.4
Hi Wei,
Quoted 33 lines · Konstantin
Quoted 24 lines
Quoted 24 lines
Quoted 23 lines
Quoted 10 lines
lib/librte_mempool/rte_mempool.c +0
-0@@ -426,9 +426,12 @@ rte_mempool_populate_phys_tab(struct rte_mempool *mp, char *vaddr,lib/librte_mempool/rte_mempool.c rte_mempool_populate_phys_tab(struct · line 436
Quoted 10 lines
lib/librte_mempool/rte_mempool.c +4
-1for (i =0 ; i < pg_num && mp->populated_size < mp->size; i += n) { +phys_addr_t paddr_next; + paddr_next = paddr[i] + pg_sz; +/* populate with the largest group of contiguous pages */ for (n =1 ; (i + n) < pg_num && - paddr[i] + pg_sz == paddr[i+n]; n++) + paddr_next == paddr[i+n]; n++, paddr_next += pg_sz) ;Good catch.
Why not just paddr[i + n - 1] != paddr[i + n]?Quoted 8 lines
Quoted 4 lines
Sorry, I meant 'paddr[i + n - 1] +
pg_sz== paddr[i+n]' off course.Quoted 2 lines
Then you don't need extra variable (
paddr_next) here. KonstantinThank you, Konstantin
'paddr[i + n - 1] +pg_sz= paddr[i + n]' also can fix it and have straight meaning. But I assume that my revision withpaddr_next+=pg_szmay have a bit better performance.
Quoted 5 lines
I don't think there would be any real difference, again it is not performance critical code-path.
Quoted 1 line
By the way, paddr[i] + n *
pg_sz= paddr[i + n] can also resolve it.Yes, that's one seems even better for me - make things more clear.
Thank you for fixing this.
My vote would go for "addr[i + n - 1] + pg_sz == paddr[i + n]"
If you feel "paddr[i] + n * pg_sz = paddr[i + n]" is clearer, I have no problem with it either.
Regards,
Olivier
2016-10-13 17:05, Olivier MATZ:
Quoted 40 lines
Hi Wei,
Quoted 37 lines · Konstantin
Quoted 24 lines
Quoted 24 lines
Quoted 23 lines
Quoted 10 lines
lib/librte_mempool/rte_mempool.c +0
-0@@ -426,9 +426,12 @@ rte_mempool_populate_phys_tab(struct rte_mempool *mp, char *vaddr,lib/librte_mempool/rte_mempool.c rte_mempool_populate_phys_tab(struct · line 436
Quoted 10 lines
lib/librte_mempool/rte_mempool.c +4
-1for (i =0 ; i < pg_num && mp->populated_size < mp->size; i += n) { +phys_addr_t paddr_next; + paddr_next = paddr[i] + pg_sz; +/* populate with the largest group of contiguous pages */ for (n =1 ; (i + n) < pg_num && - paddr[i] + pg_sz == paddr[i+n]; n++) + paddr_next == paddr[i+n]; n++, paddr_next += pg_sz) ;Good catch.
Why not just paddr[i + n - 1] != paddr[i + n]?Quoted 8 lines
Quoted 4 lines
Sorry, I meant 'paddr[i + n - 1] +
pg_sz== paddr[i+n]' off course.Quoted 2 lines
Then you don't need extra variable (
paddr_next) here. KonstantinThank you, Konstantin
'paddr[i + n - 1] +pg_sz= paddr[i + n]' also can fix it and have straight meaning. But I assume that my revision withpaddr_next+=pg_szmay have a bit better performance.I don't think there would be any real difference, again it is not performance critical code-path.
Quoted 1 line
By the way, paddr[i] + n *
pg_sz= paddr[i + n] can also resolve it.
Quoted 8 lines
Quoted 1 line
Yes, that's one seems even better for me - make things more clear.
Thank you for fixing this.
My vote would go for "addr[i + n - 1] +
pg_sz== paddr[i + n]"If you feel "paddr[i] + n *
pg_sz= paddr[i + n]" is clearer, I have no problem with it either.
No answer from Wei Dai.
Please Olivier advise what to do with this patch.
Thanks
Hi Thomas,
Quoted 45 lines · Thomas Monjalon
2016-10-13 17:05, Olivier MATZ:
Quoted 44 lines
Hi Wei,
Quoted 33 lines · Konstantin
Quoted 24 lines
Quoted 24 lines
Quoted 23 lines
Quoted 10 lines
lib/librte_mempool/rte_mempool.c +0
-0@@ -426,9 +426,12 @@ rte_mempool_populate_phys_tab(struct rte_mempool *mp, char *vaddr,lib/librte_mempool/rte_mempool.c rte_mempool_populate_phys_tab(struct · line 436
Quoted 10 lines
lib/librte_mempool/rte_mempool.c +4
-1for (i =0 ; i < pg_num && mp->populated_size < mp->size; i += n) { +phys_addr_t paddr_next; + paddr_next = paddr[i] + pg_sz; +/* populate with the largest group of contiguous pages */ for (n =1 ; (i + n) < pg_num && - paddr[i] + pg_sz == paddr[i+n]; n++) + paddr_next == paddr[i+n]; n++, paddr_next += pg_sz) ;Good catch.
Why not just paddr[i + n - 1] != paddr[i + n]?Quoted 8 lines
Quoted 4 lines
Sorry, I meant 'paddr[i + n - 1] +
pg_sz== paddr[i+n]' off course.Quoted 2 lines
Then you don't need extra variable (
paddr_next) here. KonstantinThank you, Konstantin
'paddr[i + n - 1] +pg_sz= paddr[i + n]' also can fix it and have straight meaning. But I assume that my revision withpaddr_next+=pg_szmay have a bit better performance.Quoted 5 lines
I don't think there would be any real difference, again it is not performance critical code-path.
Quoted 1 line
By the way, paddr[i] + n *
pg_sz= paddr[i + n] can also resolve it.Yes, that's one seems even better for me - make things more clear.
Thank you for fixing this.
Quoted 9 lines
Quoted 4 lines
My vote would go for "addr[i + n - 1] +
pg_sz== paddr[i + n]"If you feel "paddr[i] + n *
pg_sz= paddr[i + n]" is clearer, I have no problem with it either.No answer from Wei Dai.
Please Olivier advise what to do with this patch.
Thanks
I think it's good to have this fix in 16.11.
I'm sending a v2 based on Wei's patch.
Olivier
PATCH v2 1/1 mempool: fix search of maximum contiguous pages
In reply to Wei DaiFrom: Wei Dai <[email protected]>
paddr[i] + pg_sz always points to the start physical address of the 2nd page after pddr[i], so only up to 2 pages can be combinded to be used. With this revision, more than 2 pages can be used.
--- lib/librte_mempool/rte_mempool.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_mempool/rte_mempool.c +1 -1
@@ -428,7 +428,7 @@ rte_mempool_populate_phys_tab(struct rte_mempool *mp, char *vaddr,/* populate with the largest group of contiguous pages */ for (n =1 ; (i + n) < pg_num && - paddr[i] + pg_sz == paddr[i+n]; n++) + paddr[i + n -1 ] + pg_sz == paddr[i + n]; n++) ; ret = rte_mempool_populate_phys(mp, vaddr + i * pg_sz,
Signature · 1 line
2.8.1
Thomas Monjalon
Applied2016-10-25 17:01, Olivier Matz:
Quoted 10 lines
From: Wei Dai <[email protected]>
paddr[i] +
pg_szalways points to the start physical address of the 2nd page after pddr[i], so only up to 2 pages can be combinded to be used. With this revision, more than 2 pages can be used.Fixes 84121f197187 ("mempool: store memory chunks in a list")Signed-off-by Wei Dai <[email protected]>Signed-off-by Olivier Matz <[email protected]>
Applied, thanks