Flexible I/O Tester development
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: fio@vger.kernel.org, Jens Axboe <jaxboe@fusionio.com>
Subject: [PATCH] Reduce thread stack size
Date: Sun, 1 Aug 2010 17:01:06 +0200	[thread overview]
Message-ID: <201008011701.06711.bvanassche@acm.org> (raw)

This patch reduces the stack size required by fio threads and hence allows
to run fio with 200 or more threads on systems with a moderate amount of
virtual memory.

Signed-off-by: Bart Van Assche <bart.vanassche@gmail.com>

diff --git a/fio.c b/fio.c
index 896f797..6ab0f4a 100644
--- a/fio.c
+++ b/fio.c
@@ -1380,9 +1380,13 @@ static void *gtod_thread_main(void *data)
 
 static int fio_start_gtod_thread(void)
 {
+	pthread_attr_t attr;
 	int ret;
 
-	ret = pthread_create(&gtod_thread, NULL, gtod_thread_main, NULL);
+	pthread_attr_init(&attr);
+	pthread_attr_setstacksize(&attr, PTHREAD_STACK_MIN);
+	ret = pthread_create(&gtod_thread, &attr, gtod_thread_main, NULL);
+	pthread_attr_destroy(&attr);
 	if (ret) {
 		log_err("Can't create gtod thread: %s\n", strerror(ret));
 		return 1;
diff --git a/verify.c b/verify.c
index 42ea462..7957bd4 100644
--- a/verify.c
+++ b/verify.c
@@ -886,12 +886,16 @@ done:
 int verify_async_init(struct thread_data *td)
 {
 	int i, ret;
+	pthread_attr_t attr;
+
+	pthread_attr_init(&attr);
+	pthread_attr_setstacksize(&attr, PTHREAD_STACK_MIN);
 
 	td->verify_thread_exit = 0;
 
 	td->verify_threads = malloc(sizeof(pthread_t) * td->o.verify_async);
 	for (i = 0; i < td->o.verify_async; i++) {
-		ret = pthread_create(&td->verify_threads[i], NULL,
+		ret = pthread_create(&td->verify_threads[i], &attr,
 					verify_async_thread, td);
 		if (ret) {
 			log_err("fio: async verify creation failed: %s\n",
@@ -907,6 +911,8 @@ int verify_async_init(struct thread_data *td)
 		td->nr_verify_threads++;
 	}
 
+	pthread_attr_destroy(&attr);
+
 	if (i != td->o.verify_async) {
 		log_err("fio: only %d verify threads started, exiting\n", i);
 		td->verify_thread_exit = 1;

             reply	other threads:[~2010-08-01 15:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-01 15:01 Bart Van Assche [this message]
2010-08-01 19:33 ` [PATCH] Reduce thread stack size Jens Axboe

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=201008011701.06711.bvanassche@acm.org \
    --to=bvanassche@acm.org \
    --cc=fio@vger.kernel.org \
    --cc=jaxboe@fusionio.com \
    /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