Skip to contentSkip to conversation

syscalls/mallinfo01: Disable free fastbin blocks

PATCH New Yang Xu 3 participants 4 messages May 13, 2021

lore
Share & tools
lore

Yang Xu

author
#0 lore raw

PATCH 1/1 syscalls/mallinfo01: Disable free fastbin blocks

When using malloc to allocate small space, it will use fastbin block firstly if we have free fastbin free blocks, it is more quickly.
In here, we just test oldblks free chunks, it is the number of ordinary (i.e. non-fastbin) free blocks. So use mallopt(M_MXFAST, 0) to disable free fastbin block.

---
 testcases/kernel/syscalls/mallinfo/mallinfo01.c | 2 ++
 1 file changed, 2 insertions(+)
testcases/kernel/syscalls/mallinfo/mallinfo01.c +2 -0
index 48fce0132..4e10e352e 100644
@@ -64,6 +64,8 @@ static void setup(void)
 {
 	if (sizeof(info1.arena) != sizeof(int))
 		tst_res(TFAIL, "The member of mallinfo struct is not int");
+	if (mallopt(M_MXFAST, 0) == 0)
+		tst_res(TFAIL, "mallopt(M_MXFAST, 0) failed");
 
 	info1 = mallinfo();
 	print_mallinfo("Start", &info1);
Signature · 1 line
2.23.0
#1 lore raw

PATCH 1/1 syscalls/mallinfo01: Disable free fastbin blocks

Hello,

Quoted 17 lines · Yang Xu

When using malloc to allocate small space, it will use fastbin block firstly if we have free fastbin free blocks, it is more quickly.
In here, we just test oldblks free chunks, it is the number of ordinary (i.e. non-fastbin) free blocks. So use mallopt(M_MXFAST, 0) to disable free fastbin block.

---
 testcases/kernel/syscalls/mallinfo/mallinfo01.c | 2 ++
 1 file changed, 2 insertions(+)
testcases/kernel/syscalls/mallinfo/mallinfo01.c +0 -0
index 48fce0132..4e10e352e 100644

testcases/kernel/syscalls/mallinfo/mallinfo01.c static void setup(void) · line 71

Quoted 8 lines
testcases/kernel/syscalls/mallinfo/mallinfo01.c +2 -0
@@ -64,6 +64,8 @@ static void setup(void)
 {
 	if (sizeof(info1.arena) != sizeof(int))
 		tst_res(TFAIL, "The member of mallinfo struct is not int");
+	if (mallopt(M_MXFAST, 0) == 0)
+		tst_res(TFAIL, "mallopt(M_MXFAST, 0) failed");
 
 	info1 = mallinfo();
 	print_mallinfo("Start", &info1);

Sorry but this does not fix the problem. The failing subtest assumes that:
- malloc() will never increase ordblks
- free() will allways increase ordblks

mallinfo01 is failing because both of these assumptions are wrong. Disabling fastbin block usage will not fix the failure.

Signature · 7 lines
Martin Doucha   [email protected]
QA Engineer for Software Maintenance
SUSE LINUX, s.r.o.
CORSO IIa
Krizikova 148/34
186 00 Prague 8
Czech Republic
#2 lore raw

PATCH 1/1 syscalls/mallinfo01: Disable free fastbin blocks

Hi Martin
I don't have a proper fix. So you can remove it from runtest file.

Best Regards
Yang Xu

Quoted 36 lines

Hello,

Quoted 17 lines · Yang Xu

When using malloc to allocate small space, it will use fastbin block firstly if we have free fastbin free blocks, it is more quickly.
In here, we just test oldblks free chunks, it is the number of ordinary (i.e. non-fastbin) free blocks. So use mallopt(M_MXFAST, 0) to disable free fastbin block.

---
  testcases/kernel/syscalls/mallinfo/mallinfo01.c | 2 ++
  1 file changed, 2 insertions(+)
testcases/kernel/syscalls/mallinfo/mallinfo01.c +0 -0
index 48fce0132..4e10e352e 100644

testcases/kernel/syscalls/mallinfo/mallinfo01.c static void setup(void) · line 71

Quoted 8 lines
testcases/kernel/syscalls/mallinfo/mallinfo01.c +2 -0
@@ -64,6 +64,8 @@ static void setup(void)
  {
  	if (sizeof(info1.arena) != sizeof(int))
  		tst_res(TFAIL, "The member of mallinfo struct is not int");
+	if (mallopt(M_MXFAST, 0) == 0)
+		tst_res(TFAIL, "mallopt(M_MXFAST, 0) failed");
 
  	info1 = mallinfo();
  	print_mallinfo("Start",&info1);

Sorry but this does not fix the problem. The failing subtest assumes that:
- malloc() will never increase ordblks
- free() will allways increase ordblks

mallinfo01 is failing because both of these assumptions are wrong. Disabling fastbin block usage will not fix the failure.

#3 lore raw

PATCH 1/1 syscalls/mallinfo01: Disable free fastbin blocks

Hi!

Quoted 1 line

I don't have a proper fix. So you can remove it from runtest file.

I've pushed a patch that removes it from the runtest file, thanks.

Signature · 2 lines
Cyril Hrubis
[email protected]