From: Pu Lehui <pulehui@huaweicloud.com>
To: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: mhiramat@kernel.org, oleg@redhat.com, peterz@infradead.org,
akpm@linux-foundation.org, Liam.Howlett@oracle.com,
vbabka@suse.cz, jannh@google.com, pfalcato@suse.de,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org, pulehui@huawei.com
Subject: Re: [PATCH v1 4/4] selftests/mm: Add test about uprobe pte be orphan during vma merge
Date: Tue, 3 Jun 2025 15:08:22 +0800 [thread overview]
Message-ID: <c093f0d7-58b2-492b-bba5-5e1007a78056@huaweicloud.com> (raw)
In-Reply-To: <9117d6d8-df01-4949-a695-29cafe7fe65f@lucifer.local>
On 2025/5/30 19:32, Lorenzo Stoakes wrote:
> On Thu, May 29, 2025 at 03:56:50PM +0000, Pu Lehui wrote:
>> From: Pu Lehui <pulehui@huawei.com>
>>
>> Add test about uprobe pte be orphan during vma merge.
>>
>> Signed-off-by: Pu Lehui <pulehui@huawei.com>
>> ---
>> tools/testing/selftests/mm/merge.c | 42 ++++++++++++++++++++++++++++++
>> 1 file changed, 42 insertions(+)
>>
>> diff --git a/tools/testing/selftests/mm/merge.c b/tools/testing/selftests/mm/merge.c
>> index c76646cdf6e6..8e1f38d23384 100644
>> --- a/tools/testing/selftests/mm/merge.c
>> +++ b/tools/testing/selftests/mm/merge.c
>> @@ -2,11 +2,13 @@
>>
>> #define _GNU_SOURCE
>> #include "../kselftest_harness.h"
>> +#include <fcntl.h>
>> #include <stdio.h>
>> #include <stdlib.h>
>> #include <unistd.h>
>> #include <sys/mman.h>
>> #include <sys/wait.h>
>> +#include <linux/perf_event.h>
>> #include "vm_util.h"
>
> Need to include sys/syscall.h...
>
>>
>> FIXTURE(merge)
>> @@ -452,4 +454,44 @@ TEST_F(merge, forked_source_vma)
>> ASSERT_EQ(procmap->query.vma_end, (unsigned long)ptr2 + 5 * page_size);
>> }
>>
>> +TEST_F(merge, handle_uprobe_upon_merged_vma)
>> +{
>> + const size_t attr_sz = sizeof(struct perf_event_attr);
>> + unsigned int page_size = self->page_size;
>> + const char *probe_file = "./foo";
>> + char *carveout = self->carveout;
>> + struct perf_event_attr attr;
>> + unsigned long type;
>> + void *ptr1, *ptr2;
>> + int fd;
>> +
>> + fd = open(probe_file, O_RDWR|O_CREAT, 0600);
>> + ASSERT_GE(fd, 0);
>> +
>> + ASSERT_EQ(ftruncate(fd, page_size), 0);
>> + ASSERT_EQ(read_sysfs("/sys/bus/event_source/devices/uprobe/type", &type), 0);
>> +
>> + memset(&attr, 0, attr_sz);
>> + attr.size = attr_sz;
>> + attr.type = type;
>> + attr.config1 = (__u64)(long)probe_file;
>> + attr.config2 = 0x0;
>> +
>> + ASSERT_GE(syscall(__NR_perf_event_open, &attr, 0, -1, -1, 0), 0);
>
> ...Because this results in:
>
> In file included from merge.c:4:
> merge.c: In function ‘merge_handle_uprobe_upon_merged_vma’:
> merge.c:480:27: error: ‘__NR_perf_event_open’ undeclared (first use in this function)
> 480 | ASSERT_GE(syscall(__NR_perf_event_open, &attr, 0, -1, -1, 0), 0);
>
I did not encounter this problem when compiling in the
tools/testing/selftests/mm directory, but in any case, adding the
sys/syscall.h header file makes sense.
> Otherwise :>)
>
>> +
>> + ptr1 = mmap(&carveout[page_size], 10 * page_size, PROT_EXEC,
>> + MAP_PRIVATE | MAP_FIXED, fd, 0);
>> + ASSERT_NE(ptr1, MAP_FAILED);
>> +
>> + ptr2 = mremap(ptr1, page_size, 2 * page_size,
>> + MREMAP_MAYMOVE | MREMAP_FIXED, ptr1 + 5 * page_size);
>> + ASSERT_NE(ptr2, MAP_FAILED);
>> +
>> + ASSERT_NE(mremap(ptr2, page_size, page_size,
>> + MREMAP_MAYMOVE | MREMAP_FIXED, ptr1), MAP_FAILED);
>> +
>> + close(fd);
>> + remove(probe_file);
>> +}
>> +
>> TEST_HARNESS_MAIN
>> --
>> 2.34.1
>>
next prev parent reply other threads:[~2025-06-03 7:08 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-29 15:56 [PATCH v1 0/4] Fix uprobe pte be overwritten when expanding vma Pu Lehui
2025-05-29 15:56 ` [PATCH v1 1/4] mm: " Pu Lehui
2025-05-30 9:28 ` Lorenzo Stoakes
2025-05-30 18:51 ` David Hildenbrand
2025-06-02 11:55 ` Lorenzo Stoakes
2025-06-02 12:26 ` David Hildenbrand
2025-06-02 13:26 ` Lorenzo Stoakes
2025-06-02 16:28 ` David Hildenbrand
2025-06-02 17:01 ` Lorenzo Stoakes
2025-06-03 12:16 ` David Hildenbrand
2025-06-04 1:51 ` Andrew Morton
2025-05-29 15:56 ` [PATCH v1 2/4] mm: Expose abnormal new_pte during move_ptes Pu Lehui
2025-05-29 19:19 ` Andrew Morton
2025-05-30 1:24 ` Pu Lehui
2025-05-30 3:47 ` Andrew Morton
2025-05-30 10:21 ` Lorenzo Stoakes
2025-05-30 16:44 ` Oleg Nesterov
2025-05-29 15:56 ` [PATCH v1 3/4] selftests/mm: Extract read_sysfs and write_sysfs into vm_util Pu Lehui
2025-05-30 11:48 ` Lorenzo Stoakes
2025-06-03 7:17 ` Pu Lehui
2025-06-04 2:36 ` Andrew Morton
2025-06-04 8:21 ` Pu Lehui
2025-05-29 15:56 ` [PATCH v1 4/4] selftests/mm: Add test about uprobe pte be orphan during vma merge Pu Lehui
2025-05-30 11:32 ` Lorenzo Stoakes
2025-06-03 7:08 ` Pu Lehui [this message]
2025-06-03 9:56 ` Lorenzo Stoakes
2025-06-10 10:37 ` Aishwarya
2025-06-10 11:27 ` Pedro Falcato
2025-06-10 11:34 ` Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c093f0d7-58b2-492b-bba5-5e1007a78056@huaweicloud.com \
--to=pulehui@huaweicloud.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=jannh@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=mhiramat@kernel.org \
--cc=oleg@redhat.com \
--cc=peterz@infradead.org \
--cc=pfalcato@suse.de \
--cc=pulehui@huawei.com \
--cc=stable@vger.kernel.org \
--cc=vbabka@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox