Revert "xpmem: fix mapping of attachment and segment"

This reverts commit a5fcc91656.

Change-Id: If29415369d724391b291939ecce76482138e82f5
This commit is contained in:
Masamichi Takagi
2020-06-16 10:38:31 +09:00
parent 33b7414615
commit e774e1b984
43 changed files with 284 additions and 2875 deletions

View File

@@ -39,8 +39,8 @@ do
SEG_PGSIZE=`cat ${log_file} | awk '/OK/,/DONE/' | \
grep -o "large_page_allocation.*${SEG_ADDR}.*" | awk '{ print $5; }'`
XPMEM_ADDR=`grep xpmem_attachment_addr ${log_file} | awk '{ print $NF; }'`
XPMEM_PGSIZE=`grep -o "xpmem_page_attach.*${XPMEM_ADDR}.*" ${log_file} | awk '{ print $NF; }'`
XPMEM_ADDR=`grep xpmem_attachment_addr ${log_file} | awk '{ print $3; }'`
XPMEM_PGSIZE=`grep -o "xpmem_page_attach.*${XPMEM_ADDR}.*" ${log_file} | awk '{ print $5; }'`
if [ "${SEG_PGSIZE}" = "${EXPECT_PGSIZE}" ]; then
echo "** [ OK ] seg_addr ($SEG_ADDR) is allocated until xpmem_attach"
@@ -81,24 +81,21 @@ do
SEG_PGSIZE=`cat ${log_file} | awk '/OK/,/DONE/' | \
grep -o "large_page_allocation.*${SEG_ADDR}.*" | awk '{ print $5; }'`
XPMEM_ADDR=`grep xpmem_attachment_addr ${log_file} | awk '{ print $NF; }'`
XPMEM_PGSIZE=`grep -o "xpmem_page_attach.*${XPMEM_ADDR}.*" ${log_file} | awk '{ print $NF; }'`
XPMEM_ADDR=`grep xpmem_attachment_addr ${log_file} | awk '{ print $3; }'`
XPMEM_PGSIZE=`grep -o "xpmem_page_attach.*${XPMEM_ADDR}.*" ${log_file} | awk '{ print $5; }'`
if [ "${SEG_PGSIZE}" = "${EXPECT_PGSIZE}" ]; then
printf "** [ OK ] "
echo "** [ OK ] seg_addr ($SEG_ADDR) is allocated until xpmem_attach"
else
printf "** [ NG ] "
echo "** [ NG ] seg_addr ($SEG_ADDR) is NOT allocated until xpmem_attach"
let ng++
fi
echo "size of 1st page of segment at ${SEG_ADDR}: ${SEG_PGSIZE}, expected: ${EXPECT_PGSIZE}"
if [ "${XPMEM_PGSIZE}" = "${EXPECT_PGSIZE}" ]; then
printf "** [ OK ] "
echo "** [ OK ] xpmem_addr ($XPMEM_ADDR) is allocated using large pages"
else
printf "** [ NG ] "
echo "** [ NG ] xpmem_addr ($XPMEM_ADDR) is NOT allocated using large pages"
let ng++
fi
echo "size of 1st page of attachment at ${XPMEM_ADDR}: ${XPMEM_PGSIZE}, expected: ${EXPECT_PGSIZE}"
done
if [ ${ng} -eq 0 ]; then
echo "*** C${issue}T${tid}: PASSED"
@@ -119,8 +116,8 @@ ${IHKOSCTL} 0 kmsg >> ${log_file}
EXPECT_PGSIZE=`grep EXPECT_PAGE_SIZE ${log_file} | awk '{ print $2; }'`
XPMEM_ADDR=`grep xpmem_attachment_addr ${log_file} | awk '{ print $NF; }'`
XPMEM_PGSIZE=`grep -o "xpmem_page_attach.*${XPMEM_ADDR}.*" ${log_file} | awk '{ print $NF; }'`
XPMEM_ADDR=`grep xpmem_attachment_addr ${log_file} | awk '{ print $3; }'`
XPMEM_PGSIZE=`grep -o "xpmem_page_attach.*${XPMEM_ADDR}.*" ${log_file} | awk '{ print $5; }'`
if [ "${XPMEM_PGSIZE}" = "${EXPECT_PGSIZE}" ]; then
echo "** [ OK ] xpmem_addr ($XPMEM_ADDR) is allocated using small pages"
@@ -143,13 +140,13 @@ pgshift=${PGSHIFT_LIST[0]}
${IHKOSCTL} 0 clear_kmsg
log_file="./C${issue}T${tid}_${pgshift}.log"
echo pageshift: ${pgshift}
${MCEXEC} ./multi_vmr_xpmem ${pgshift} 1 | tee ${log_file}
${MCEXEC} ./multi_vmr_xpmem ${pgshift} 1 > ${log_file}
${IHKOSCTL} 0 kmsg >> ${log_file}
EXPECT_PGSIZE=`grep EXPECT_PAGE_SIZE ${log_file} | awk '{ print $2; }'`
XPMEM_ADDR=`grep xpmem_large ${log_file} | awk '{ print $NF; }'`
XPMEM_PGSIZE=`grep -o "xpmem_page_attach.*${XPMEM_ADDR}.*" ${log_file} | awk '{ print $NF; }'`
XPMEM_ADDR=`grep xpmem_large ${log_file} | awk '{ print $3; }'`
XPMEM_PGSIZE=`grep -o "xpmem_page_attach.*${XPMEM_ADDR}.*" ${log_file} | awk '{ print $5; }'`
if [ "${XPMEM_PGSIZE}" = "${EXPECT_PGSIZE}" ]; then
echo "** [ OK ] xpmem_addr ($XPMEM_ADDR) is allocated using large pages"
@@ -170,7 +167,7 @@ echo "*** C${issue}T${tid} start *******************************"
echo "** xpmem testsuite"
cwd=`pwd`
cd ${XPMEM_BUILD_DIR}/test
. ${cwd}/mc_run.sh
${cwd}/mc_run.sh
cd ${cwd}
# xpmem basic test

View File

@@ -113,7 +113,7 @@ int main(int argc, char **argv)
addr.apid = apid;
addr.offset = 0;
attach = xpmem_attach(addr, map_size, NULL);
attach = xpmem_attach(addr, pgsize * pgnum, NULL);
CHKANDJUMP(attach == (void *)-1, EXIT_FAILURE,
"xpmem_attach failed: %s\n", strerror(errno));

View File

@@ -1,8 +1,8 @@
diff --git arch/arm64/kernel/memory.c arch/arm64/kernel/memory.c
index a84bc21..f329fcf 100644
index a84bc21..7368ada 100644
--- arch/arm64/kernel/memory.c
+++ arch/arm64/kernel/memory.c
@@ -2701,6 +2701,16 @@ int set_range_l1(void *args0, pte_t *ptep, uintptr_t base, uintptr_t start,
@@ -2701,6 +2701,13 @@ int set_range_l1(void *args0, pte_t *ptep, uintptr_t base, uintptr_t start,
ptl1_set(ptep, pte);
error = 0;
@@ -11,15 +11,12 @@ index a84bc21..f329fcf 100644
+ __page_offset(base, PTL1_CONT_SIZE) == 0) {
+ kprintf("%s: large_page_allocation, addr: %016lx, size: 0x%lx , phys: %lx\n",
+ __func__, base, PTL1_CONT_SIZE, phys);
+ if (args->range->private_data)
+ kprintf("%s: xpmem_page_attach, addr: %016lx, size: 0x%lx\n",
+ __func__, base, PTL1_CONT_SIZE);
+ }
+
// call memory_stat_rss_add() here because pgshift is resolved here
if (!(args->attr[0] & PTE_CONT)) {
if (rusage_memory_stat_add(args->range, phys,
@@ -2810,6 +2820,23 @@ retry:
@@ -2810,6 +2817,17 @@ retry:
level);
error = 0;
@@ -28,57 +25,45 @@ index a84bc21..f329fcf 100644
+ if (__page_offset(base, tbl.cont_pgsize) == 0) {
+ kprintf("%s: large_page_allocation, addr: %016lx, size: 0x%lx , phys: %lx\n",
+ __func__, base, tbl.cont_pgsize, phys);
+ if (args->range->private_data)
+ kprintf("%s: xpmem_page_attach, addr: %016lx, size: 0x%lx\n",
+ __func__, base, tbl.cont_pgsize);
+ }
+ } else {
+ kprintf("%s: large_page_allocation, addr: %016lx, size: 0x%lx , phys: %lx\n",
+ __func__, base, tbl.pgsize, phys);
+ if (args->range->private_data)
+ kprintf("%s: xpmem_page_attach, addr: %016lx, size: 0x%lx\n",
+ __func__, base, tbl.pgsize);
+ }
+
dkprintf("set_range_middle(%lx,%lx,%lx,%d):"
"large page. %d %lx\n",
base, start, end, level, error, *ptep);
diff --git arch/x86_64/kernel/memory.c arch/x86_64/kernel/memory.c
index 6b34036..4ca3a1a 100644
index df545e1..633e390 100644
--- arch/x86_64/kernel/memory.c
+++ arch/x86_64/kernel/memory.c
@@ -1932,6 +1932,13 @@ retry:
@@ -1931,6 +1931,10 @@ retry:
dkprintf("set_range_l2(%lx,%lx,%lx):"
"2MiB page. %d %lx\n",
base, start, end, error, *ptep);
+
+ kprintf("%s: large_page_allocation, addr: %016lx, size: 0x%lx\n",
+ __func__, base, PTL2_SIZE);
+ if (args->range->private_data)
+ kprintf("%s: xpmem_page_attach, addr: %016lx, size: 0x%lx\n",
+ __func__, base, PTL2_SIZE);
+
// Call memory_stat_rss_add() here because pgshift is resolved here
if (rusage_memory_stat_add(args->range, phys, PTL2_SIZE, PTL2_SIZE)) {
dkprintf("%lx+,%s: calling memory_stat_rss_add(),base=%lx,phys=%lx,size=%ld,pgsize=%ld\n", phys, __FUNCTION__, base, phys, PTL2_SIZE, PTL2_SIZE);
@@ -2021,6 +2028,12 @@ retry:
@@ -2020,6 +2024,9 @@ retry:
"1GiB page. %d %lx\n",
base, start, end, error, *ptep);
+ kprintf("%s: large_page_allocation, addr: %016lx, size: 0x%lx\n",
+ __func__, base, PTL3_SIZE);
+ if (args->range->private_data)
+ kprintf("%s: xpmem_page_attach, addr: %016lx, size: 0x%lx\n",
+ __func__, base, PTL3_SIZE);
+
// Call memory_stat_rss_add() here because pgshift is resolved here
if (rusage_memory_stat_add(args->range, phys, PTL3_SIZE, PTL3_SIZE)) {
dkprintf("%lx+,%s: calling memory_stat_rss_add(),base=%lx,phys=%lx,size=%ld,pgsize=%ld\n", phys, __FUNCTION__, base, phys, PTL3_SIZE, PTL3_SIZE);
diff --git kernel/process.c kernel/process.c
index 1624726..d867b4d 100644
index 809f5e0..cba9e5a 100644
--- kernel/process.c
+++ kernel/process.c
@@ -2138,6 +2138,12 @@ retry:
@@ -2059,6 +2059,12 @@ retry:
}
dkprintf("%s: attr=%x\n", __FUNCTION__, attr);
@@ -92,10 +77,10 @@ index 1624726..d867b4d 100644
pgsize, phys, attr);
if (error) {
diff --git kernel/xpmem.c kernel/xpmem.c
index 9fedf26..a0a7990 100644
index e1d0231..c9da711 100644
--- kernel/xpmem.c
+++ kernel/xpmem.c
@@ -490,6 +490,7 @@ static int xpmem_make(
@@ -514,6 +514,7 @@ static int xpmem_make(
*segid_p = segid;
XPMEM_DEBUG("return: ret=%d, segid=0x%lx", 0, *segid_p);
@@ -103,15 +88,12 @@ index 9fedf26..a0a7990 100644
return 0;
}
@@ -1886,6 +1887,11 @@ static int _xpmem_fault_process_memory_range(
goto out;
}
@@ -1994,6 +1995,8 @@ int xpmem_update_process_page_table(
flush_tlb_single(vaddr);
att->flags |= XPMEM_FLAG_VALIDPTEs;
+ if (att_pgsize == PAGE_SIZE) {
+ kprintf("xpmem_page_attach, addr: %016lx, size: 0x%lx\n",
+ vaddr, att_pgsize);
+ }
+
XPMEM_DEBUG("att_pgaddr: %lx, att_pgsize: %lx, "
"seg_vaddr: %lx, seg_pgsize: %lx, seg_phys: %lx\n",
att_pgaddr, att_pgsize, seg_vaddr,
+ kprintf("%s: xpmem_page_attach, addr: %016lx, size: 0x%lx\n",
+ __func__, vaddr, seg_pgsize);
seg_vaddr += seg_pgsize;
vaddr += seg_pgsize;
}

View File

@@ -10,6 +10,6 @@ done
echo 0 > /tmp/xpmem.lock
# Run the main test app
${MCEXEC} $PWD/xpmem_master
mcexec $PWD/xpmem_master
exit 0

View File

@@ -110,7 +110,6 @@ int main(int argc, char **argv)
addr.apid = apid;
addr.offset = 0;
printf("child: attaching...\n");
attach = xpmem_attach(addr, map_size + (extr_size * 2), NULL);
CHKANDJUMP(attach == (void *)-1, EXIT_FAILURE,
@@ -152,7 +151,6 @@ int main(int argc, char **argv)
CHKANDJUMP(shm == (void *)-1, EXIT_FAILURE,
"shmat failed: %s\n", strerror(errno));
printf("parent: making...\n");
segid = xpmem_make(mem_1, map_size + (extr_size * 2),
XPMEM_PERMIT_MODE, (void *)0666);
CHKANDJUMP(segid == -1, EXIT_FAILURE,
@@ -160,7 +158,6 @@ int main(int argc, char **argv)
*(xpmem_segid_t *)shm = segid;
printf("parent: waiting...\n");
ret = waitpid(pid, &status, 0);
printf("child exited\n");
CHKANDJUMP(ret == -1, EXIT_FAILURE, "waitpid failed\n");