From patchwork Thu Sep 22 12:13:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 76770 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp10722qgf; Thu, 22 Sep 2016 05:45:43 -0700 (PDT) X-Received: by 10.55.15.146 with SMTP id 18mr1802226qkp.164.1474548343887; Thu, 22 Sep 2016 05:45:43 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id r11si1010843qtb.104.2016.09.22.05.45.43 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 22 Sep 2016 05:45:43 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:43218 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn3Nn-0003f2-CA for patch@linaro.org; Thu, 22 Sep 2016 08:45:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53307) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn2uU-0000GV-Aw for qemu-devel@nongnu.org; Thu, 22 Sep 2016 08:15:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bn2uR-0006km-HX for qemu-devel@nongnu.org; Thu, 22 Sep 2016 08:15:25 -0400 Received: from mail-lf0-f46.google.com ([209.85.215.46]:33302) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn2uR-0006kd-9d for qemu-devel@nongnu.org; Thu, 22 Sep 2016 08:15:23 -0400 Received: by mail-lf0-f46.google.com with SMTP id b71so38939583lfg.0 for ; Thu, 22 Sep 2016 05:15:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=gyfDZdxqraH8RIXe2LRcMEY4JoJjXLcs6hh/tRO0BFo=; b=BPha4cufIb9UL5dsieU29z+8976LaS98iVxQm+0eAfiD+gde/dw8tG/t69Fg3Ptd92 qpSpZKwCOmKct4DqBmuMexFkD/YCj+xkUjZpYskgnBzg0sqgY9M3ym+TfiPC7zB9LXox xwjMiaUTPlIiDBmIyuOuAkP3HzMoDxwlzoM8Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=gyfDZdxqraH8RIXe2LRcMEY4JoJjXLcs6hh/tRO0BFo=; b=ZUD4y0d9PFahAcETBVpAEebFjF4X0I6SmfRNc6Rry6ceiJ9uUXika0GUa8mcX3FObH kNbp+JUN5UoLShLMT9DspLg56xQkRdtsIAmsWVpwOfgnpax9SV+ppLTg2oTB2S80FSsO Q4m2r5RVdWUo3Ily3nIxAaCKeniFbN37NZc4bNvOmGQJInvC6kMg4ZNkockEcJ8zS2TL JApzQdngDX814k5czXN5wZ7iPnkIex7YVvCfv3mxMB08qZbO5KLQAGMtqSSm+GrlRSL3 Hz0mdQioBrHKiCMM/Je+aDMB6phgecjlHnUHkfSmkJzVh6kZG9ERIQ0ennGVkFo7yLVU y1Qw== X-Gm-Message-State: AE9vXwPN88JqCDUHXV6FpXAcleiay3xV7zytQkz56ykcbd4Wmy6ASZDhsXTVHKvqDQ+tZm0R X-Received: by 10.25.190.201 with SMTP id o192mr766849lff.23.1474546462322; Thu, 22 Sep 2016 05:14:22 -0700 (PDT) Received: from beaming.home (91-157-170-157.elisa-laajakaista.fi. [91.157.170.157]) by smtp.gmail.com with ESMTPSA id u14sm294378lja.11.2016.09.22.05.14.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 22 Sep 2016 05:14:21 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Thu, 22 Sep 2016 15:13:43 +0300 Message-Id: <7cfbd386b92e93fbfae033b9ac89a20d1fe72573.1474546244.git.riku.voipio@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.215.46 Subject: [Qemu-devel] [PULL 23/26] linux-user: Remove unnecessary nptl_flags variable from do_fork() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell The 'nptl_flags' variable in do_fork() is set to a copy of 'flags', and then the CLONE_NPTL_FLAGS are cleared out of 'flags'. However the only effect of this is that the later check on "if (flags & CLONE_PARENT_SETTID)" is never true. Since we will already have done the setting of parent_tidptr in clone_func() in the child thread, we don't need to do it again. Delete the dead if() and the clearing of CLONE_NPTL_FLAGS from 'flags', and then use 'flags' where we were previously using 'nptl_flags', so we can delete the unnecessary variable. Signed-off-by: Peter Maydell Signed-off-by: Riku Voipio --- linux-user/syscall.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) -- 2.1.4 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 27ad6a2..3b7b51f 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -6011,7 +6011,6 @@ static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp, TaskState *ts; CPUState *new_cpu; CPUArchState *new_env; - unsigned int nptl_flags; sigset_t sigmask; /* Emulate vfork() with fork() */ @@ -6034,15 +6033,14 @@ static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp, ts->bprm = parent_ts->bprm; ts->info = parent_ts->info; ts->signal_mask = parent_ts->signal_mask; - nptl_flags = flags; - flags &= ~CLONE_NPTL_FLAGS2; - if (nptl_flags & CLONE_CHILD_CLEARTID) { + if (flags & CLONE_CHILD_CLEARTID) { ts->child_tidptr = child_tidptr; } - if (nptl_flags & CLONE_SETTLS) + if (flags & CLONE_SETTLS) { cpu_set_tls (new_env, newtls); + } /* Grab a mutex so that thread setup appears atomic. */ pthread_mutex_lock(&clone_lock); @@ -6052,10 +6050,12 @@ static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp, pthread_mutex_lock(&info.mutex); pthread_cond_init(&info.cond, NULL); info.env = new_env; - if (nptl_flags & CLONE_CHILD_SETTID) + if (flags & CLONE_CHILD_SETTID) { info.child_tidptr = child_tidptr; - if (nptl_flags & CLONE_PARENT_SETTID) + } + if (flags & CLONE_PARENT_SETTID) { info.parent_tidptr = parent_tidptr; + } ret = pthread_attr_init(&attr); ret = pthread_attr_setstacksize(&attr, NEW_STACK_SIZE); @@ -6074,8 +6074,6 @@ static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp, /* Wait for the child to initialize. */ pthread_cond_wait(&info.cond, &info.mutex); ret = info.tid; - if (flags & CLONE_PARENT_SETTID) - put_user_u32(ret, parent_tidptr); } else { ret = -1; }