From patchwork Wed Sep 9 18:11:59 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Goldish X-Patchwork-Id: 46428 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n89IFe3g019143 for ; Wed, 9 Sep 2009 18:15:40 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753955AbZIISPe (ORCPT ); Wed, 9 Sep 2009 14:15:34 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753919AbZIISPc (ORCPT ); Wed, 9 Sep 2009 14:15:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:2757 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753932AbZIISPa (ORCPT ); Wed, 9 Sep 2009 14:15:30 -0400 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n89IFXI1014941; Wed, 9 Sep 2009 14:15:33 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n89IFWCF017617; Wed, 9 Sep 2009 14:15:32 -0400 Received: from localhost.localdomain (dhcp-1-188.tlv.redhat.com [10.35.1.188]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n89IFNFR012008; Wed, 9 Sep 2009 14:15:31 -0400 From: Michael Goldish To: autotest@test.kernel.org, kvm@vger.kernel.org Cc: Michael Goldish Subject: [PATCH 06/19] KVM test: timedrift test: set CPU affinity recursively for all children Date: Wed, 9 Sep 2009 21:11:59 +0300 Message-Id: <1252519932-30733-6-git-send-email-mgoldish@redhat.com> In-Reply-To: <1252519932-30733-5-git-send-email-mgoldish@redhat.com> References: <1252519932-30733-1-git-send-email-mgoldish@redhat.com> <1252519932-30733-2-git-send-email-mgoldish@redhat.com> <1252519932-30733-3-git-send-email-mgoldish@redhat.com> <1252519932-30733-4-git-send-email-mgoldish@redhat.com> <1252519932-30733-5-git-send-email-mgoldish@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.18 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org In addition to setting the CPU affinity of the given process, set it for all of its children too. Signed-off-by: Michael Goldish --- client/tests/kvm/kvm_tests.py | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-) diff --git a/client/tests/kvm/kvm_tests.py b/client/tests/kvm/kvm_tests.py index 1ee7775..deab59e 100644 --- a/client/tests/kvm/kvm_tests.py +++ b/client/tests/kvm/kvm_tests.py @@ -578,6 +578,7 @@ def run_timedrift(test, params, env): def set_cpu_affinity(pid, mask): """ Set the CPU affinity of all threads of the process with PID pid. + Do this recursively for all child processes as well. @param pid: The process ID. @param mask: The CPU affinity mask. @@ -589,6 +590,9 @@ def run_timedrift(test, params, env): prev_mask = commands.getoutput("taskset -p %s" % tid).split()[-1] prev_masks[tid] = prev_mask commands.getoutput("taskset -p %s %s" % (mask, tid)) + children = commands.getoutput("ps --ppid=%s -o pid=" % pid).split() + for child in children: + prev_masks.update(set_cpu_affinity(child, mask)) return prev_masks def restore_cpu_affinity(prev_masks): @@ -683,13 +687,9 @@ def run_timedrift(test, params, env): output_func=logging.debug, output_prefix="(host load %d) " % i, timeout=0.5)) - # Set the CPU affinity of the shell running the load process + # Set the CPU affinity of the load process pid = host_load_sessions[-1].get_shell_pid() set_cpu_affinity(pid, cpu_mask) - # Try setting the CPU affinity of the load process itself - pid = host_load_sessions[-1].get_pid() - if pid: - set_cpu_affinity(pid, cpu_mask) # Sleep for a while (during load) logging.info("Sleeping for %s seconds..." % load_duration)