Skip to contentSkip to conversation

Two fixes for KVM unit tests

PATCH In review Pierre Morel 5 participants 13 messages Aug 25, 2021 – Sep 21, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Two fixes for KVM unit tests

Hello,

I am not sure about the first one, cscope, it works for me but may be someone has a better solution.

The second one fixes a bug of mine...

Regards,
Pierre

Pierre Morel (2):
Makefile: Fix cscope
s390x: fixing I/O memory allocation

 Makefile              | 2 +-
 lib/s390x/malloc_io.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/2 Makefile: Fix cscope

In Linux, cscope uses a wrong directory.
Simply search from the directory where the make is started.

---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +1 -1
index f7b9f28c..c8b0d74f 100644
@@ -119,7 +119,7 @@ cscope: cscope_dirs = lib lib/libfdt lib/linux $(TEST_DIR) $(ARCH_LIBDIRS) lib/a
 cscope:
 	$(RM) ./cscope.*
 	find -L $(cscope_dirs) -maxdepth 1 \
-		-name '*.[chsS]' -exec realpath --relative-base=$(PWD) {} \; | sort -u > ./cscope.files
+		-name '*.[chsS]' -exec realpath --relative-base=. {} \; | sort -u > ./cscope.files
 	cscope -bk
 
 .PHONY: tags
Signature · 1 line
2.25.1
#2 lore raw

Re: [kvm-unit-tests PATCH 1/2] Makefile: Fix cscope

Quoted 13 lines · Pierre Morel

In Linux, cscope uses a wrong directory.
Simply search from the directory where the make is started.

---
  Makefile | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +0 -0
index f7b9f28c..c8b0d74f 100644

Makefile cscope: cscope_dirs = lib lib/libfdt lib/linux $(TEST_DIR) $(ARCH_LIBDIRS) lib/a · line 122

Quoted 5 lines
Makefile +1 -1
@@ -119,7 +119,7 @@ cscope: cscope_dirs = lib lib/libfdt lib/linux $(TEST_DIR) $(ARCH_LIBDIRS) lib/a
  cscope:
  	$(RM) ./cscope.*
  	find -L $(cscope_dirs) -maxdepth 1 \
-		-name '*.[chsS]' -exec realpath --relative-base=$(PWD) {} \; | sort -u > ./cscope.files
+		-name '*.[chsS]' -exec realpath --relative-base=. {} \; | sort -u > ./cscope.files

Why is $PWD not pointing to the same location as "." ? Are you doing in-tree or out-of-tree builds?

Thomas

#3 lore raw

Re: [kvm-unit-tests PATCH 1/2] Makefile: Fix cscope

Quoted 25 lines · Thomas Huth
Quoted 13 lines · Pierre Morel

In Linux, cscope uses a wrong directory.
Simply search from the directory where the make is started.

---
  Makefile | 2 +-

  1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +0 -0
index f7b9f28c..c8b0d74f 100644
@@ -119,7 +119,7 @@ cscope: cscope_dirs = lib lib/libfdt lib/linux 
Quoted 8 lines

$(TEST_DIR) $(ARCH_LIBDIRS) lib/a
  cscope:
      $(RM) ./cscope.*
      find -L $(cscope_dirs) -maxdepth 1 \
-        -name '*.[chsS]' -exec realpath --relative-base=$(PWD) {} \; | sort -u > ./cscope.files
+        -name '*.[chsS]' -exec realpath --relative-base=. {} \; | sort -u > ./cscope.files

Why is $PWD not pointing to the same location as "." ? Are you doing in-tree or out-of-tree builds?

Quoted 2 lines

 Thomas

In tree.
That is the point, why is PWD indicating void ? I use a bash on s390x.
inside bash PWD shows current directory GNU Make is 4.2.1 on Ubuntu 18.04

This works on X with redhat and GNU make 3.82

This happens on s390x since:
51b8f0b1 2017-11-23 Andrew Jones Makefile: fix cscope target

So I add Andrew as CC, I did forgot to do before.

Regards,
Pierre

Signature · 2 lines
Pierre Morel
IBM Lab Boeblingen
#4 lore raw

Re: [kvm-unit-tests PATCH 1/2] Makefile: Fix cscope

Quoted 29 lines · Pierre Morel
Quoted 26 lines · Thomas Huth
Quoted 13 lines · Pierre Morel

In Linux, cscope uses a wrong directory.
Simply search from the directory where the make is started.

---
  Makefile | 2 +-

  1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +0 -0
index f7b9f28c..c8b0d74f 100644
@@ -119,7 +119,7 @@ cscope: cscope_dirs = lib lib/libfdt lib/linux
Quoted 8 lines

$(TEST_DIR) $(ARCH_LIBDIRS) lib/a
  cscope:
      $(RM) ./cscope.*
      find -L $(cscope_dirs) -maxdepth 1 \
-        -name '*.[chsS]' -exec realpath --relative-base=$(PWD) {} \; | sort -u > ./cscope.files
+        -name '*.[chsS]' -exec realpath --relative-base=. {} \; | sort -u > ./cscope.files

Why is $PWD not pointing to the same location as "." ? Are you doing in-tree or out-of-tree builds?

Quoted 5 lines
Quoted 2 lines

 Thomas

In tree.
That is the point, why is PWD indicating void ?

If you do 'env' I'll bet you'll see something like

...
PWD=
...

Quoted 8 lines

I use a bash on s390x.
inside bash PWD shows current directory
GNU Make is 4.2.1 on Ubuntu 18.04

This works on X with redhat and GNU make 3.82

This happens on s390x since:
51b8f0b1 2017-11-23 Andrew Jones Makefile: fix cscope target

No surprise there, that's when the $(PWD) use was first introduced.

Quoted 3 lines

So I add Andrew as CC, I did forgot to do before.

I'll send a patch changing $(PWD) to $(shell pwd)

Thanks,
drew

maintainer
#5 lore raw

Re: [kvm-unit-tests PATCH 1/2] Makefile: Fix cscope

Quoted 6 lines · Andrew Jones
Quoted 1 line

51b8f0b1 2017-11-23 Andrew Jones Makefile: fix cscope target

No surprise there, that's when the $(PWD) use was first introduced.

Quoted 2 lines

So I add Andrew as CC, I did forgot to do before.

I'll send a patch changing $(PWD) to $(shell pwd)

I could not find the patch using $(CURDIR) in my mailbox, though I found it on spinics.net. I fudged the following

From 164507376abae4be15b0f65aa14d56f179198a99 Mon Sep 17 00:00:00 2001
From: Andrew Jones <[email protected]>
Date: Fri, 27 Aug 2021 12:31:15 +0200
Subject: [PATCH kvm-unit-tests] Makefile: Don't trust PWD

It's possible that PWD is already set to something which isn't the full path of the current working directory. Let's use $(CURDIR) instead, which is always correct.

Makefile +1 -1
index f7b9f28..6792b93 100644
@@ -119,7 +119,7 @@ cscope: cscope_dirs = lib lib/libfdt lib/linux $(TEST_DIR) $(ARCH_LIBDIRS) lib/a
 cscope:
 	$(RM) ./cscope.*
 	find -L $(cscope_dirs) -maxdepth 1 \
-		-name '*.[chsS]' -exec realpath --relative-base=$(PWD) {} \; | sort -u > ./cscope.files
+		-name '*.[chsS]' -exec realpath --relative-base=$(CURDIR) {} \; | sort -u > ./cscope.files
 	cscope -bk
 
 .PHONY: tags

and queued it.

Paolo

Reviewed-by Pierre Morel Reviewed-by Thomas Huth
#6 lore raw

Re: [kvm-unit-tests PATCH 1/2] Makefile: Fix cscope

Quoted 37 lines · Paolo Bonzini
Quoted 6 lines · Andrew Jones
Quoted 1 line

51b8f0b1 2017-11-23 Andrew Jones Makefile: fix cscope target

No surprise there, that's when the $(PWD) use was first introduced.

Quoted 2 lines

So I add Andrew as CC, I did forgot to do before.

I'll send a patch changing $(PWD) to $(shell pwd)

I could not find the patch using $(CURDIR) in my mailbox, though I found it on spinics.net. I fudged the following

From 164507376abae4be15b0f65aa14d56f179198a99 Mon Sep 17 00:00:00 2001
From: Andrew Jones <[email protected]>
Date: Fri, 27 Aug 2021 12:31:15 +0200
Subject: [PATCH kvm-unit-tests] Makefile: Don't trust PWD

It's possible that PWD is already set to something which isn't the full path of the current working directory. Let's use $(CURDIR) instead, which is always correct.

Makefile +1 -1
index f7b9f28..6792b93 100644
@@ -119,7 +119,7 @@ cscope: cscope_dirs = lib lib/libfdt lib/linux $(TEST_DIR) $(ARCH_LIBDIRS) lib/a
 cscope:
 	$(RM) ./cscope.*
 	find -L $(cscope_dirs) -maxdepth 1 \
-		-name '*.[chsS]' -exec realpath --relative-base=$(PWD) {} \; | sort -u > ./cscope.files
+		-name '*.[chsS]' -exec realpath --relative-base=$(CURDIR) {} \; | sort -u > ./cscope.files
 	cscope -bk
 .PHONY: tags
 
Quoted 1 line

and queued it.

Hi Paolo,

You'll get a conflict when you go to merge because I already did it :-)

commit 3d4eb24cb5b4de6c26f79b849fe2818d5315a691 (origin/misc/queue, misc/queue)

Author: Andrew Jones <[email protected]>
Date:   Fri Aug 27 12:25:27 2021 +0200

Makefile: Don't trust PWD

PWD comes from the environment and it's possible that it's already set to something which isn't the full path of the current working directory. Use the make variable $(CURDIR) instead.

misc/queue is something I recently invented for stuff like this in order to help lighten your load a bit.

Thanks,
drew

maintainer
#7 lore raw

Re: [kvm-unit-tests PATCH 1/2] Makefile: Fix cscope

Quoted 21 lines · Andrew Jones

Hi Paolo,

You'll get a conflict when you go to merge because I already did it :-)

commit 3d4eb24cb5b4de6c26f79b849fe2818d5315a691 (origin/misc/queue, misc/queue)

Author: Andrew Jones <[email protected]>
Date:   Fri Aug 27 12:25:27 2021 +0200

Makefile: Don't trust PWD

PWD comes from the environment and it's possible that it's already set to something which isn't the full path of the current working directory. Use the make variable $(CURDIR) instead.

Quoted 2 lines

misc/queue is something I recently invented for stuff like this in order to help lighten your load a bit.

Ok, are you going to create a merge request?

#8 lore raw

Re: [kvm-unit-tests PATCH 1/2] Makefile: Fix cscope

Quoted 20 lines · Paolo Bonzini
Quoted 19 lines · Andrew Jones

Hi Paolo,

You'll get a conflict when you go to merge because I already did it :-)

commit 3d4eb24cb5b4de6c26f79b849fe2818d5315a691 (origin/misc/queue, misc/queue)

Author: Andrew Jones <[email protected]>
Date:   Fri Aug 27 12:25:27 2021 +0200

Makefile: Don't trust PWD
PWD comes from the environment and it's possible that it's already set to something which isn't the full path of the current working directory. Use the make variable $(CURDIR) instead.

Quoted 5 lines
Quoted 2 lines

misc/queue is something I recently invented for stuff like this in order to help lighten your load a bit.

Ok, are you going to create a merge request?

I did. And I merged it.

https://gitlab.com/kvm-unit-tests/kvm-unit-tests/-/merge_requests/16

Thanks,
drew

#9 lore raw

Re: [kvm-unit-tests PATCH 1/2] Makefile: Fix cscope

In reply to Pierre Morel
Quoted 28 lines · Pierre Morel
Quoted 25 lines · Thomas Huth
Quoted 13 lines · Pierre Morel

In Linux, cscope uses a wrong directory.
Simply search from the directory where the make is started.

---
  Makefile | 2 +-

  1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +0 -0
index f7b9f28c..c8b0d74f 100644
@@ -119,7 +119,7 @@ cscope: cscope_dirs = lib lib/libfdt lib/linux 
Quoted 8 lines

$(TEST_DIR) $(ARCH_LIBDIRS) lib/a
  cscope:
      $(RM) ./cscope.*
      find -L $(cscope_dirs) -maxdepth 1 \
-        -name '*.[chsS]' -exec realpath --relative-base=$(PWD) {} \; | sort -u > ./cscope.files
+        -name '*.[chsS]' -exec realpath --relative-base=. {} \; | sort -u > ./cscope.files

Why is $PWD not pointing to the same location as "." ? Are you doing in-tree or out-of-tree builds?

Quoted 8 lines
Quoted 2 lines

  Thomas

In tree.
That is the point, why is PWD indicating void ? I use a bash on s390x.
inside bash PWD shows current directory GNU Make is 4.2.1 on Ubuntu 18.04

Hmm, looking at the code twice, $(PWD) is used a a Make variable, not as a shell variable. For using a shell variable, it should use double $$ instead ...
So yes, this is broken since $(PWD) does not seem to be an official Make variable. There is $(CURDIR) which could do the job, too, but I guess "." is just fine as well. Andrew, what do you think?

Thomas

#10 lore raw

PATCH 2/2 s390x: fixing I/O memory allocation

In reply to Pierre Morel

The allocator allocate pages it follows the size must be rounded to pages before the allocation.

Fixes b0fe3988 "s390x: define UV compatible I/O allocation"
---
 lib/s390x/malloc_io.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/s390x/malloc_io.c +2 -2
index 78582eac..080fc694 100644
@@ -41,7 +41,7 @@ static void unshare_pages(void *p, int count)
 
 void *alloc_io_mem(int size, int flags)
 {
-	int order = get_order(size >> PAGE_SHIFT);
+	int order = get_order(PAGE_ALIGN(size) >> PAGE_SHIFT);
 	void *p;
 	int n;
 
@@ -62,7 +62,7 @@ void *alloc_io_mem(int size, int flags)
 
 void free_io_mem(void *p, int size)
 {
-	int order = get_order(size >> PAGE_SHIFT);
+	int order = get_order(PAGE_ALIGN(size) >> PAGE_SHIFT);
 
 	assert(IS_ALIGNED((uintptr_t)p, PAGE_SIZE));
 
Signature · 1 line
2.25.1
Reviewed-by on v1 2/2
#11 lore raw

Re: [kvm-unit-tests PATCH 2/2] s390x: fixing I/O memory allocation

Quoted 6 lines · On Wed, 25 Aug 2021 18:20:21 +0200 Pierre Morel <[email protected]> wrote:

The allocator allocate pages it follows the size must be rounded to pages before the allocation.

Fixes b0fe3988 "s390x: define UV compatible I/O allocation"
Quoted 26 lines
---
 lib/s390x/malloc_io.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/s390x/malloc_io.c +2 -2
index 78582eac..080fc694 100644
@@ -41,7 +41,7 @@ static void unshare_pages(void *p, int count)
 
 void *alloc_io_mem(int size, int flags)
 {
-	int order = get_order(size >> PAGE_SHIFT);
+	int order = get_order(PAGE_ALIGN(size) >> PAGE_SHIFT);
 	void *p;
 	int n;
 
@@ -62,7 +62,7 @@ void *alloc_io_mem(int size, int flags)
 
 void free_io_mem(void *p, int size)
 {
-	int order = get_order(size >> PAGE_SHIFT);
+	int order = get_order(PAGE_ALIGN(size) >> PAGE_SHIFT);
 
 	assert(IS_ALIGNED((uintptr_t)p, PAGE_SIZE));
 
#12 lore raw

Re: [kvm-unit-tests PATCH 2/2] s390x: fixing I/O memory allocation

Quoted 12 lines · Claudio Imbrenda
Quoted 6 lines · On Wed, 25 Aug 2021 18:20:21 +0200 Pierre Morel <[email protected]> wrote:

The allocator allocate pages it follows the size must be rounded to pages before the allocation.

Fixes b0fe3988 "s390x: define UV compatible I/O allocation"

Thanks,
Pierre

Signature · 2 lines
Pierre Morel
IBM Lab Boeblingen