public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] increasing buffer size for correct alignment
@ 2015-01-26  9:46 Han Pingtian
  2015-01-26 13:45 ` Cyril Hrubis
  0 siblings, 1 reply; 4+ messages in thread
From: Han Pingtian @ 2015-01-26  9:46 UTC (permalink / raw)
  To: ltp-list

Hey there,

I have a patch for aio-stress to align buffer address correctly. Please
have a look. Thanks in advance.

For align buffer address to the number specified by -a option in
aio-stress, it needs to add page_size_mask extra length to total_ram
before call allocation functions. Or it wouldn't be correct in this line
after the allocation:

         p = (char *)((intptr_t) (p + page_size_mask) & ~page_size_mask);

Signed-off-by: Han Pingtian <hanpt@linux.vnet.ibm.com>
---
 testcases/kernel/io/ltp-aiodio/aio-stress.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/testcases/kernel/io/ltp-aiodio/aio-stress.c b/testcases/kernel/io/ltp-aiodio/aio-stress.c
index 0b7148c..24675ec 100644
--- a/testcases/kernel/io/ltp-aiodio/aio-stress.c
+++ b/testcases/kernel/io/ltp-aiodio/aio-stress.c
@@ -1022,7 +1022,7 @@ int setup_shared_mem(int num_threads, int num_files, int depth,
 	if (use_shm == USE_MALLOC) {
 		p = malloc(total_ram + page_size_mask);
 	} else if (use_shm == USE_SHM) {
-		shm_id = shmget(IPC_PRIVATE, total_ram, IPC_CREAT | 0700);
+		shm_id = shmget(IPC_PRIVATE, total_ram + page_size_mask, IPC_CREAT | 0700);
 		if (shm_id < 0) {
 			perror("shmget");
 			drop_shm();
@@ -1046,9 +1046,9 @@ int setup_shared_mem(int num_threads, int num_files, int depth,
 			goto free_buffers;
 		}
 		unlink(mmap_name);
-		ftruncate(fd, total_ram);
+		ftruncate(fd, total_ram + page_size_mask);
 		shm_id = fd;
-		p = mmap((char *)0x50000000, total_ram,
+		p = mmap((char *)0x50000000, total_ram + page_size_mask,
 			 PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
 
 		if (p == MAP_FAILED) {
-- 
1.9.3


------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-01-28 12:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-26  9:46 [LTP] [PATCH] increasing buffer size for correct alignment Han Pingtian
2015-01-26 13:45 ` Cyril Hrubis
2015-01-27  1:31   ` Han Pingtian
2015-01-28 12:10     ` Cyril Hrubis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox