All of lore.kernel.org
 help / color / mirror / Atom feed
From: Clark Williams <williams@redhat.com>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: linux-rt-users@vger.kernel.org,
	David Sommerseth <davids@redhat.com>,
	John Kacur <jkacur@redhat.com>
Subject: Re: [PATCH] hackbench: init child's struct before using it
Date: Thu, 11 Apr 2013 12:08:00 -0500	[thread overview]
Message-ID: <20130411120800.06d750b2@riff.lan> (raw)
In-Reply-To: <1365693605-22704-1-git-send-email-bigeasy@linutronix.de>

[-- Attachment #1: Type: text/plain, Size: 2359 bytes --]

Applied to my work branch for the next release. I've CC'd John Kacur
who has been doing the heavy lifting on rt-tests recently.

Clark

On Thu, 11 Apr 2013 17:20:05 +0200
Sebastian Andrzej Siewior <bigeasy@linutronix.de> wrote:

> Commit ad27df7 ("Reimplement better child tracking and improve error
> handling") changed the way of reporting pid/error after creating a
> child. It will return an union which is a mix pid_t, pthread_t and a
> signed long long for errors.
> Now on 32bit x86 both pid_t and pthread_t are four byte in size and are
> stored in the first 4 bytes. Now if the most significant bit of the long
> long variable happens to be set by chance (because nobody really
> initializes the variable here) then error variable will be negative. On
> little endian machines the assignment of pid or threadid won't reset the
> sign bit and you see this:
> 
> | Running in process mode with 10 groups using 40 file descriptors each (== 400 tasks)
> | Each sender will pass 100 messages of 100 bytes
> | 0 children started.  Expected 40
> | sending SIGTERM to all child processes
> | signaling 0 worker threads to terminate
> | Creating workers (error: Success)
> 
> A machine with proper endian handlig (that is big endian) would reset
> the sign bit during the assignment of pid and I would not have to make
> this patch :)
> 
> While here, I make create_worker() since it is not used outside of this
> file.
> 
> Cc: David Sommerseth <davids@redhat.com>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
>  src/hackbench/hackbench.c |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/src/hackbench/hackbench.c b/src/hackbench/hackbench.c
> index 8baeb23..c21b4db 100644
> --- a/src/hackbench/hackbench.c
> +++ b/src/hackbench/hackbench.c
> @@ -189,13 +189,14 @@ static void *receiver(struct receiver_context* ctx)
>  	return NULL;
>  }
>  
> -childinfo_t create_worker(void *ctx, void *(*func)(void *))
> +static childinfo_t create_worker(void *ctx, void *(*func)(void *))
>  {
>  	pthread_attr_t attr;
>  	int err;
>  	childinfo_t child;
>  	pid_t childpid;
>  
> +	memset(&child, 0, sizeof(child));
>  	switch (process_mode) {
>  	case PROCESS_MODE: /* process mode */
>  		/* Fork the sender/receiver child. */
> -- 
> 1.7.10.4
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

  reply	other threads:[~2013-04-11 17:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-11 15:20 [PATCH] hackbench: init child's struct before using it Sebastian Andrzej Siewior
2013-04-11 17:08 ` Clark Williams [this message]
2013-04-11 18:11   ` David Sommerseth

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=20130411120800.06d750b2@riff.lan \
    --to=williams@redhat.com \
    --cc=bigeasy@linutronix.de \
    --cc=davids@redhat.com \
    --cc=jkacur@redhat.com \
    --cc=linux-rt-users@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.