v3: Rebase on the next branch of linux-kselftest.git,
modify the patch title and update the commit message
v2: Rebase on 6.5-rc1 and update the commit message
Tiezhu Yang (2):
selftests/vDSO: Fix building errors on LoongArch
selftests/vDSO: Fix runtime errors on LoongArch
tools/testing/selftests/vDSO/vdso_config.h | 6 ++++-
.../testing/selftests/vDSO/vdso_test_getcpu.c | 16 +++++-------
.../selftests/vDSO/vdso_test_gettimeofday.c | 26 +++++--------------
3 files changed, 18 insertions(+), 30 deletions(-)
--
2.42.0
There exist the following errors when build vDSO selftests on LoongArch:
# make headers && cd tools/testing/selftests/vDSO && make
...
error: 'VDSO_VERSION' undeclared (first use in this function)
...
error: 'VDSO_NAMES' undeclared (first use in this function)
We can see the following code in arch/loongarch/vdso/vdso.lds.S:
VERSION
{
LINUX_5.10 {
global:
__vdso_getcpu;
__vdso_clock_getres;
__vdso_clock_gettime;
__vdso_gettimeofday;
__vdso_rt_sigreturn;
local: *;
};
}
so VDSO_VERSION should be 6 and VDSO_NAMES should be 1 for LoongArch,
add them to fix the building errors on LoongArch.
Signed-off-by: Tiezhu Yang <[email protected]>
---
tools/testing/selftests/vDSO/vdso_config.h | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/vDSO/vdso_config.h b/tools/testing/selftests/vDSO/vdso_config.h
index cdfed403ba13..7b543e7f04d7 100644
--- a/tools/testing/selftests/vDSO/vdso_config.h
+++ b/tools/testing/selftests/vDSO/vdso_config.h
@@ -53,15 +53,19 @@
#if __riscv_xlen == 32
#define VDSO_32BIT 1
#endif
+#elif defined(__loongarch__)
+#define VDSO_VERSION 6
+#define VDSO_NAMES 1
#endif
-static const char *versions[6] = {
+static const char *versions[7] = {
"LINUX_2.6",
"LINUX_2.6.15",
"LINUX_2.6.29",
"LINUX_2.6.39",
"LINUX_4",
"LINUX_4.15",
+ "LINUX_5.10"
};
static const char *names[2][6] = {
--
2.42.0
It could not find __vdso_getcpu and __vdso_gettimeofday when test
getcpu and gettimeofday on LoongArch.
# make headers && cd tools/testing/selftests/vDSO && make
# ./vdso_test_getcpu
Could not find __vdso_getcpu
# ./vdso_test_gettimeofday
Could not find __vdso_gettimeofday
One simple way is to add LoongArch case to define version and name,
just like commit d942f231afc0 ("selftests/vDSO: Add riscv getcpu &
gettimeofday test"), but it is not the best way.
Since each architecture has already defined names and versions in
vdso_config.h, it is proper to include vdso_config.h to get version
and name for all archs.
Signed-off-by: Tiezhu Yang <[email protected]>
---
.../testing/selftests/vDSO/vdso_test_getcpu.c | 16 +++++-------
.../selftests/vDSO/vdso_test_gettimeofday.c | 26 +++++--------------
2 files changed, 13 insertions(+), 29 deletions(-)
diff --git a/tools/testing/selftests/vDSO/vdso_test_getcpu.c b/tools/testing/selftests/vDSO/vdso_test_getcpu.c
index 1df5d057d79f..b758f68c6c9c 100644
--- a/tools/testing/selftests/vDSO/vdso_test_getcpu.c
+++ b/tools/testing/selftests/vDSO/vdso_test_getcpu.c
@@ -13,13 +13,7 @@
#include "../kselftest.h"
#include "parse_vdso.h"
-
-#if defined(__riscv)
-const char *version = "LINUX_4.15";
-#else
-const char *version = "LINUX_2.6";
-#endif
-const char *name = "__vdso_getcpu";
+#include "vdso_config.h"
struct getcpu_cache;
typedef long (*getcpu_t)(unsigned int *, unsigned int *,
@@ -27,6 +21,8 @@ typedef long (*getcpu_t)(unsigned int *, unsigned int *,
int main(int argc, char **argv)
{
+ const char *version = versions[VDSO_VERSION];
+ const char **name = (const char **)&names[VDSO_NAMES];
unsigned long sysinfo_ehdr;
unsigned int cpu, node;
getcpu_t get_cpu;
@@ -40,9 +36,9 @@ int main(int argc, char **argv)
vdso_init_from_sysinfo_ehdr(getauxval(AT_SYSINFO_EHDR));
- get_cpu = (getcpu_t)vdso_sym(version, name);
+ get_cpu = (getcpu_t)vdso_sym(version, name[4]);
if (!get_cpu) {
- printf("Could not find %s\n", name);
+ printf("Could not find %s\n", name[4]);
return KSFT_SKIP;
}
@@ -50,7 +46,7 @@ int main(int argc, char **argv)
if (ret == 0) {
printf("Running on CPU %u node %u\n", cpu, node);
} else {
- printf("%s failed\n", name);
+ printf("%s failed\n", name[4]);
return KSFT_FAIL;
}
diff --git a/tools/testing/selftests/vDSO/vdso_test_gettimeofday.c b/tools/testing/selftests/vDSO/vdso_test_gettimeofday.c
index e411f287a426..ee4f1ca56a71 100644
--- a/tools/testing/selftests/vDSO/vdso_test_gettimeofday.c
+++ b/tools/testing/selftests/vDSO/vdso_test_gettimeofday.c
@@ -18,25 +18,13 @@
#include "../kselftest.h"
#include "parse_vdso.h"
-
-/*
- * ARM64's vDSO exports its gettimeofday() implementation with a different
- * name and version from other architectures, so we need to handle it as
- * a special case.
- */
-#if defined(__aarch64__)
-const char *version = "LINUX_2.6.39";
-const char *name = "__kernel_gettimeofday";
-#elif defined(__riscv)
-const char *version = "LINUX_4.15";
-const char *name = "__vdso_gettimeofday";
-#else
-const char *version = "LINUX_2.6";
-const char *name = "__vdso_gettimeofday";
-#endif
+#include "vdso_config.h"
int main(int argc, char **argv)
{
+ const char *version = versions[VDSO_VERSION];
+ const char **name = (const char **)&names[VDSO_NAMES];
+
unsigned long sysinfo_ehdr = getauxval(AT_SYSINFO_EHDR);
if (!sysinfo_ehdr) {
printf("AT_SYSINFO_EHDR is not present!\n");
@@ -47,10 +35,10 @@ int main(int argc, char **argv)
/* Find gettimeofday. */
typedef long (*gtod_t)(struct timeval *tv, struct timezone *tz);
- gtod_t gtod = (gtod_t)vdso_sym(version, name);
+ gtod_t gtod = (gtod_t)vdso_sym(version, name[0]);
if (!gtod) {
- printf("Could not find %s\n", name);
+ printf("Could not find %s\n", name[0]);
return KSFT_SKIP;
}
@@ -61,7 +49,7 @@ int main(int argc, char **argv)
printf("The time is %lld.%06lld\n",
(long long)tv.tv_sec, (long long)tv.tv_usec);
} else {
- printf("%s failed\n", name);
+ printf("%s failed\n", name[0]);
return KSFT_FAIL;
}
--
2.42.0
+ Andrew Morton <[email protected]>
+ Mark Brown <[email protected]>
On 12/13/2023 09:22 AM, Tiezhu Yang wrote:
> v3: Rebase on the next branch of linux-kselftest.git,
> modify the patch title and update the commit message
>
> v2: Rebase on 6.5-rc1 and update the commit message
>
> Tiezhu Yang (2):
> selftests/vDSO: Fix building errors on LoongArch
> selftests/vDSO: Fix runtime errors on LoongArch
>
> tools/testing/selftests/vDSO/vdso_config.h | 6 ++++-
> .../testing/selftests/vDSO/vdso_test_getcpu.c | 16 +++++-------
> .../selftests/vDSO/vdso_test_gettimeofday.c | 26 +++++--------------
> 3 files changed, 18 insertions(+), 30 deletions(-)
>
Hi Shuah, Andrew and Mark,
The patches still seem to apply cleanly.
Could you please review and merge them for the upcoming merge window?
https://lore.kernel.org/lkml/[email protected]/
Thanks,
Tiezhu
On 12/13/23 6:22 AM, Tiezhu Yang wrote:
> There exist the following errors when build vDSO selftests on LoongArch:
>
> # make headers && cd tools/testing/selftests/vDSO && make
> ...
> error: 'VDSO_VERSION' undeclared (first use in this function)
> ...
> error: 'VDSO_NAMES' undeclared (first use in this function)
>
> We can see the following code in arch/loongarch/vdso/vdso.lds.S:
>
> VERSION
> {
> LINUX_5.10 {
> global:
> __vdso_getcpu;
> __vdso_clock_getres;
> __vdso_clock_gettime;
> __vdso_gettimeofday;
> __vdso_rt_sigreturn;
> local: *;
> };
> }
>
> so VDSO_VERSION should be 6 and VDSO_NAMES should be 1 for LoongArch,
> add them to fix the building errors on LoongArch.
>
> Signed-off-by: Tiezhu Yang <[email protected]>
Reviewed-by: Muhammad Usama Anjum <[email protected]>
> ---
> tools/testing/selftests/vDSO/vdso_config.h | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/vDSO/vdso_config.h b/tools/testing/selftests/vDSO/vdso_config.h
> index cdfed403ba13..7b543e7f04d7 100644
> --- a/tools/testing/selftests/vDSO/vdso_config.h
> +++ b/tools/testing/selftests/vDSO/vdso_config.h
> @@ -53,15 +53,19 @@
> #if __riscv_xlen == 32
> #define VDSO_32BIT 1
> #endif
> +#elif defined(__loongarch__)
> +#define VDSO_VERSION 6
> +#define VDSO_NAMES 1
> #endif
>
> -static const char *versions[6] = {
> +static const char *versions[7] = {
> "LINUX_2.6",
> "LINUX_2.6.15",
> "LINUX_2.6.29",
> "LINUX_2.6.39",
> "LINUX_4",
> "LINUX_4.15",
> + "LINUX_5.10"
> };
>
> static const char *names[2][6] = {
--
BR,
Muhammad Usama Anjum
On 12/13/23 6:23 AM, Tiezhu Yang wrote:
> It could not find __vdso_getcpu and __vdso_gettimeofday when test
> getcpu and gettimeofday on LoongArch.
>
> # make headers && cd tools/testing/selftests/vDSO && make
> # ./vdso_test_getcpu
> Could not find __vdso_getcpu
> # ./vdso_test_gettimeofday
> Could not find __vdso_gettimeofday
>
> One simple way is to add LoongArch case to define version and name,
> just like commit d942f231afc0 ("selftests/vDSO: Add riscv getcpu &
> gettimeofday test"), but it is not the best way.
>
> Since each architecture has already defined names and versions in
> vdso_config.h, it is proper to include vdso_config.h to get version
> and name for all archs.
>
> Signed-off-by: Tiezhu Yang <[email protected]>
Reviewed-by: Muhammad Usama Anjum <[email protected]>
Tested on x86, works fine.
Tested-by: Muhammad Usama Anjum <[email protected]>
> ---
> .../testing/selftests/vDSO/vdso_test_getcpu.c | 16 +++++-------
> .../selftests/vDSO/vdso_test_gettimeofday.c | 26 +++++--------------
> 2 files changed, 13 insertions(+), 29 deletions(-)
>
> diff --git a/tools/testing/selftests/vDSO/vdso_test_getcpu.c b/tools/testing/selftests/vDSO/vdso_test_getcpu.c
> index 1df5d057d79f..b758f68c6c9c 100644
> --- a/tools/testing/selftests/vDSO/vdso_test_getcpu.c
> +++ b/tools/testing/selftests/vDSO/vdso_test_getcpu.c
> @@ -13,13 +13,7 @@
>
> #include "../kselftest.h"
> #include "parse_vdso.h"
> -
> -#if defined(__riscv)
> -const char *version = "LINUX_4.15";
> -#else
> -const char *version = "LINUX_2.6";
> -#endif
> -const char *name = "__vdso_getcpu";
> +#include "vdso_config.h"
>
> struct getcpu_cache;
> typedef long (*getcpu_t)(unsigned int *, unsigned int *,
> @@ -27,6 +21,8 @@ typedef long (*getcpu_t)(unsigned int *, unsigned int *,
>
> int main(int argc, char **argv)
> {
> + const char *version = versions[VDSO_VERSION];
> + const char **name = (const char **)&names[VDSO_NAMES];
> unsigned long sysinfo_ehdr;
> unsigned int cpu, node;
> getcpu_t get_cpu;
> @@ -40,9 +36,9 @@ int main(int argc, char **argv)
>
> vdso_init_from_sysinfo_ehdr(getauxval(AT_SYSINFO_EHDR));
>
> - get_cpu = (getcpu_t)vdso_sym(version, name);
> + get_cpu = (getcpu_t)vdso_sym(version, name[4]);
> if (!get_cpu) {
> - printf("Could not find %s\n", name);
> + printf("Could not find %s\n", name[4]);
> return KSFT_SKIP;
> }
>
> @@ -50,7 +46,7 @@ int main(int argc, char **argv)
> if (ret == 0) {
> printf("Running on CPU %u node %u\n", cpu, node);
> } else {
> - printf("%s failed\n", name);
> + printf("%s failed\n", name[4]);
> return KSFT_FAIL;
> }
>
> diff --git a/tools/testing/selftests/vDSO/vdso_test_gettimeofday.c b/tools/testing/selftests/vDSO/vdso_test_gettimeofday.c
> index e411f287a426..ee4f1ca56a71 100644
> --- a/tools/testing/selftests/vDSO/vdso_test_gettimeofday.c
> +++ b/tools/testing/selftests/vDSO/vdso_test_gettimeofday.c
> @@ -18,25 +18,13 @@
>
> #include "../kselftest.h"
> #include "parse_vdso.h"
> -
> -/*
> - * ARM64's vDSO exports its gettimeofday() implementation with a different
> - * name and version from other architectures, so we need to handle it as
> - * a special case.
> - */
> -#if defined(__aarch64__)
> -const char *version = "LINUX_2.6.39";
> -const char *name = "__kernel_gettimeofday";
> -#elif defined(__riscv)
> -const char *version = "LINUX_4.15";
> -const char *name = "__vdso_gettimeofday";
> -#else
> -const char *version = "LINUX_2.6";
> -const char *name = "__vdso_gettimeofday";
> -#endif
> +#include "vdso_config.h"
>
> int main(int argc, char **argv)
> {
> + const char *version = versions[VDSO_VERSION];
> + const char **name = (const char **)&names[VDSO_NAMES];
> +
> unsigned long sysinfo_ehdr = getauxval(AT_SYSINFO_EHDR);
> if (!sysinfo_ehdr) {
> printf("AT_SYSINFO_EHDR is not present!\n");
> @@ -47,10 +35,10 @@ int main(int argc, char **argv)
>
> /* Find gettimeofday. */
> typedef long (*gtod_t)(struct timeval *tv, struct timezone *tz);
> - gtod_t gtod = (gtod_t)vdso_sym(version, name);
> + gtod_t gtod = (gtod_t)vdso_sym(version, name[0]);
>
> if (!gtod) {
> - printf("Could not find %s\n", name);
> + printf("Could not find %s\n", name[0]);
> return KSFT_SKIP;
> }
>
> @@ -61,7 +49,7 @@ int main(int argc, char **argv)
> printf("The time is %lld.%06lld\n",
> (long long)tv.tv_sec, (long long)tv.tv_usec);
> } else {
> - printf("%s failed\n", name);
> + printf("%s failed\n", name[0]);
> return KSFT_FAIL;
> }
>
--
BR,
Muhammad Usama Anjum
On 12/27/23 12:55 PM, Tiezhu Yang wrote:
> + Andrew Morton <[email protected]>
> + Mark Brown <[email protected]>
>
> On 12/13/2023 09:22 AM, Tiezhu Yang wrote:
>> v3: Rebase on the next branch of linux-kselftest.git,
>> modify the patch title and update the commit message
>>
>> v2: Rebase on 6.5-rc1 and update the commit message
>>
>> Tiezhu Yang (2):
>> selftests/vDSO: Fix building errors on LoongArch
>> selftests/vDSO: Fix runtime errors on LoongArch
>>
>> tools/testing/selftests/vDSO/vdso_config.h | 6 ++++-
>> .../testing/selftests/vDSO/vdso_test_getcpu.c | 16 +++++-------
>> .../selftests/vDSO/vdso_test_gettimeofday.c | 26 +++++--------------
>> 3 files changed, 18 insertions(+), 30 deletions(-)
>>
>
> Hi Shuah, Andrew and Mark,
>
> The patches still seem to apply cleanly.
> Could you please review and merge them for the upcoming merge window?
People may be on vacation. I'm also waiting to hear back on my patches.
Lets see when they get back and start picking up patches.
>
> https://lore.kernel.org/lkml/[email protected]/
>
> Thanks,
> Tiezhu
>
>
--
BR,
Muhammad Usama Anjum
Hi Muhammad,
On 12/30/23 15:07, Muhammad Usama Anjum wrote:
> On 12/27/23 12:55 PM, Tiezhu Yang wrote:
>> + Andrew Morton <[email protected]>
>> + Mark Brown <[email protected]>
>>
>> On 12/13/2023 09:22 AM, Tiezhu Yang wrote:
>>> v3: Rebase on the next branch of linux-kselftest.git,
>>> modify the patch title and update the commit message
>>>
>>> v2: Rebase on 6.5-rc1 and update the commit message
>>>
>>> Tiezhu Yang (2):
>>> selftests/vDSO: Fix building errors on LoongArch
>>> selftests/vDSO: Fix runtime errors on LoongArch
>>>
>>> tools/testing/selftests/vDSO/vdso_config.h | 6 ++++-
>>> .../testing/selftests/vDSO/vdso_test_getcpu.c | 16 +++++-------
>>> .../selftests/vDSO/vdso_test_gettimeofday.c | 26 +++++--------------
>>> 3 files changed, 18 insertions(+), 30 deletions(-)
>>>
>>
>> Hi Shuah, Andrew and Mark,
>>
>> The patches still seem to apply cleanly.
>> Could you please review and merge them for the upcoming merge window?
> People may be on vacation. I'm also waiting to hear back on my patches.
> Lets see when they get back and start picking up patches.
Thank you very much for your reply and review, happy new year.
Thanks,
Tiezhu
On 12/27/2023 03:55 PM, Tiezhu Yang wrote:
> + Andrew Morton <[email protected]>
> + Mark Brown <[email protected]>
>
> On 12/13/2023 09:22 AM, Tiezhu Yang wrote:
>> v3: Rebase on the next branch of linux-kselftest.git,
>> modify the patch title and update the commit message
>>
>> v2: Rebase on 6.5-rc1 and update the commit message
>>
>> Tiezhu Yang (2):
>> selftests/vDSO: Fix building errors on LoongArch
>> selftests/vDSO: Fix runtime errors on LoongArch
>>
>> tools/testing/selftests/vDSO/vdso_config.h | 6 ++++-
>> .../testing/selftests/vDSO/vdso_test_getcpu.c | 16 +++++-------
>> .../selftests/vDSO/vdso_test_gettimeofday.c | 26 +++++--------------
>> 3 files changed, 18 insertions(+), 30 deletions(-)
>>
>
> Hi Shuah, Andrew and Mark,
>
> The patches still seem to apply cleanly.
> Could you please review and merge them for the upcoming merge window?
>
> https://lore.kernel.org/lkml/[email protected]/
Ping, any comments?
Thanks,
Tiezhu
Hi Shuah and Andrew,
On 01/29/2024 04:27 PM, Tiezhu Yang wrote:
>
>
> On 12/27/2023 03:55 PM, Tiezhu Yang wrote:
>> + Andrew Morton <[email protected]>
>> + Mark Brown <[email protected]>
>>
>> On 12/13/2023 09:22 AM, Tiezhu Yang wrote:
>>> v3: Rebase on the next branch of linux-kselftest.git,
>>> modify the patch title and update the commit message
>>>
>>> v2: Rebase on 6.5-rc1 and update the commit message
>>>
>>> Tiezhu Yang (2):
>>> selftests/vDSO: Fix building errors on LoongArch
>>> selftests/vDSO: Fix runtime errors on LoongArch
>>>
>>> tools/testing/selftests/vDSO/vdso_config.h | 6 ++++-
>>> .../testing/selftests/vDSO/vdso_test_getcpu.c | 16 +++++-------
>>> .../selftests/vDSO/vdso_test_gettimeofday.c | 26 +++++--------------
>>> 3 files changed, 18 insertions(+), 30 deletions(-)
>>>
>>
>> Hi Shuah, Andrew and Mark,
>>
>> The patches still seem to apply cleanly.
>> Could you please review and merge them for the upcoming merge window?
>>
>> https://lore.kernel.org/lkml/[email protected]/
>>
>
> Ping, any comments?
This series has received Reviewed-by and Tested-by for two months,
since the merge window is coming soon, should it take through
shuah/linux-kselftest.git or akpm/mm.git?
Thanks,
Tiezhu
On 02/29/2024 05:13 PM, Tiezhu Yang wrote:
> Hi Shuah and Andrew,
>
> On 01/29/2024 04:27 PM, Tiezhu Yang wrote:
>>
>>
>> On 12/27/2023 03:55 PM, Tiezhu Yang wrote:
>>> + Andrew Morton <[email protected]>
>>> + Mark Brown <[email protected]>
>>>
>>> On 12/13/2023 09:22 AM, Tiezhu Yang wrote:
>>>> v3: Rebase on the next branch of linux-kselftest.git,
>>>> modify the patch title and update the commit message
>>>>
>>>> v2: Rebase on 6.5-rc1 and update the commit message
>>>>
>>>> Tiezhu Yang (2):
>>>> selftests/vDSO: Fix building errors on LoongArch
>>>> selftests/vDSO: Fix runtime errors on LoongArch
>>>>
>>>> tools/testing/selftests/vDSO/vdso_config.h | 6 ++++-
>>>> .../testing/selftests/vDSO/vdso_test_getcpu.c | 16 +++++-------
>>>> .../selftests/vDSO/vdso_test_gettimeofday.c | 26 +++++--------------
>>>> 3 files changed, 18 insertions(+), 30 deletions(-)
>>>>
>>>
>>> Hi Shuah, Andrew and Mark,
>>>
>>> The patches still seem to apply cleanly.
>>> Could you please review and merge them for the upcoming merge window?
>>>
>>> https://lore.kernel.org/lkml/[email protected]/
>>>
>>>
>>
>> Ping, any comments?
>
> This series has received Reviewed-by and Tested-by for two months,
> since the merge window is coming soon, should it take through
> shuah/linux-kselftest.git or akpm/mm.git?
Hi Andrew,
There is already a tag linux_kselftest-next-6.9-rc1 [1],
it seems no chance to merge them through kselftest tree,
would you be able to pick them up through your tree [2]?
"If you cannot find a maintainer for the subsystem you are
working on, Andrew Morton ([email protected]) serves
as a maintainer of last resort."
[1]
https://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest.git/tag/?h=linux_kselftest-next-6.9-rc1
[2] https://www.kernel.org/doc/html/latest/process/submitting-patches.html
Thanks,
Tiezhu