[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <a83f3883-cef8-ec88-0411-d9638dd4b4ae@arm.com>
Date: Fri, 13 Nov 2020 11:47:35 +0000
From: Vincenzo Frascino <vincenzo.frascino@....com>
To: Alexander Potapenko <glider@...gle.com>,
Andrey Konovalov <andreyknvl@...gle.com>
Cc: Catalin Marinas <catalin.marinas@....com>,
Will Deacon <will.deacon@....com>,
Dmitry Vyukov <dvyukov@...gle.com>,
Andrey Ryabinin <aryabinin@...tuozzo.com>,
Marco Elver <elver@...gle.com>,
Evgenii Stepanov <eugenis@...gle.com>,
Branislav Rankov <Branislav.Rankov@....com>,
Kevin Brodsky <kevin.brodsky@....com>,
Andrew Morton <akpm@...ux-foundation.org>,
kasan-dev <kasan-dev@...glegroups.com>,
Linux ARM <linux-arm-kernel@...ts.infradead.org>,
Linux Memory Management List <linux-mm@...ck.org>,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v9 44/44] kselftest/arm64: Check GCR_EL1 after context
switch
Hi Alexander,
thank you for the review.
On 11/12/20 3:59 PM, Alexander Potapenko wrote:
> On Tue, Nov 10, 2020 at 11:12 PM Andrey Konovalov <andreyknvl@...gle.com> wrote:
>>
>> From: Vincenzo Frascino <vincenzo.frascino@....com>
>>
>> This test is specific to MTE and verifies that the GCR_EL1 register
>> is context switched correctly.
>>
>> It spawn 1024 processes and each process spawns 5 threads. Each thread
>
> Nit: "spawns"
>
I will fix it in the next iteration.
>
>> + srand(time(NULL) ^ (pid << 16) ^ (tid << 16));
>> +
>> + prctl_tag_mask = rand() % 0xffff;
>
> Nit: if you want values between 0 and 0xffff you probably want to use
> bitwise AND.
>
The main goal here is to have a good probability of having a different setting
to the GCR_EL1 register. Hence the difference in between 0xffff and 0xffff-1 is
negligible. Anyway I agree that we should aim to cover all the possible
combinations.
>
>> +
>> +int execute_test(pid_t pid)
>> +{
>> + pthread_t thread_id[MAX_THREADS];
>> + int thread_data[MAX_THREADS];
>> +
>> + for (int i = 0; i < MAX_THREADS; i++)
>> + pthread_create(&thread_id[i], NULL,
>> + execute_thread, (void *)&pid);
>
> It might be simpler to call getpid() in execute_thread() instead.
>
Yes it might, but I would like to avoid another syscall if I can.
>> +int mte_gcr_fork_test()
>> +{
>> + pid_t pid[NUM_ITERATIONS];
>> + int results[NUM_ITERATIONS];
>> + pid_t cpid;
>> + int res;
>> +
>> + for (int i = 0; i < NUM_ITERATIONS; i++) {
>> + pid[i] = fork();
>> +
>> + if (pid[i] == 0) {
>
> pid[i] isn't used anywhere else. Did you want to keep the pids to
> ensure that all children finished the work?
> If not, we can probably go with a scalar here.
>
Yes, I agree, I had some debug code making use of it, but I removed it in the end.
>
>> + for (int i = 0; i < NUM_ITERATIONS; i++) {
>> + wait(&res);
>> +
>> + if(WIFEXITED(res))
>> + results[i] = WEXITSTATUS(res);
>> + else
>> + --i;
>
> Won't we get stuck in this loop if fork() returns -1 for one of the processes?
>
Yes I agree, I forgot to check a condition. We should abort the test in such a
case returning KSFT_FAIL directly.
>> + }
>> +
>> + for (int i = 0; i < NUM_ITERATIONS; i++)
>> + if (results[i] == KSFT_FAIL)
>> + return KSFT_FAIL;
>> +
>> + return KSFT_PASS;
>> +}
>> +
>
>
--
Regards,
Vincenzo
Powered by blists - more mailing lists