From patchwork Wed Mar 30 12:00:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 64691 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp2550468lbc; Wed, 30 Mar 2016 05:02:13 -0700 (PDT) X-Received: by 10.98.15.142 with SMTP id 14mr12543339pfp.6.1459339333107; Wed, 30 Mar 2016 05:02:13 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gl9si3404224pac.111.2016.03.30.05.02.12; Wed, 30 Mar 2016 05:02:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753402AbcC3MCJ (ORCPT + 29 others); Wed, 30 Mar 2016 08:02:09 -0400 Received: from mail-wm0-f51.google.com ([74.125.82.51]:34982 "EHLO mail-wm0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752855AbcC3MBR (ORCPT ); Wed, 30 Mar 2016 08:01:17 -0400 Received: by mail-wm0-f51.google.com with SMTP id 191so86552385wmq.0 for ; Wed, 30 Mar 2016 05:01:15 -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=WSmaHbAKx57VZm7/SB0Eah3W5+00JHql5eEmuPg7XvI=; b=PjESOPF9Q8fr9aggbSuCSR3HNY4zZNVhYqkvZo63yjcB7Qvz9bzncPBbAxNF8J1eVd wTQZbfNmyVMMAh7gXaoRIWM7k6XIUbMyxENHFrLgEOqocVrMuKxUpNMiFSGfhN/Iklxl fXArqAhCSZTKq+oKdL8bBVPDxORkvRbhkDM6k= 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=WSmaHbAKx57VZm7/SB0Eah3W5+00JHql5eEmuPg7XvI=; b=d3ZOrOrmX3hO9OjII6YwSx1+fCM44b72bcJnLphMjLA/q3E987DN6fDONMgokk89Ff qwmxjU3t7XhjhpVW1liXuaJzLuznPGpyFb8QDS3nvzdjn+DiSa5z0eITcoHbLzVpnau9 ex/48/dcmWnoWoaUmozew1ndZCVtYpdFDiE1FukJl/aqLv5rNbcy8wUbktYSOWmA1Oyi CMu8eWtNZYtJVkePPMuujhQtmQjuTOwfSLQrWsfS4aK0YQyZ3kza5htoowLKvdr6grIA 3W7kdvI8jQuouAnf5dcSXyw9XNjHFsItQ9qaTbC7dkpytEs60zQHmo2rrLr+utMsgPM1 rSXw== X-Gm-Message-State: AD7BkJIvgiA3QdQEr25Cfo0Zxe9KgoVmn1j4/SHdme5T+D+AazSpE9pCmrq2dLMfmO+L+sx5 X-Received: by 10.28.36.85 with SMTP id k82mr9179827wmk.65.1459339274851; Wed, 30 Mar 2016 05:01:14 -0700 (PDT) Received: from localhost.localdomain (cpc87017-aztw30-2-0-cust65.18-1.cable.virginm.net. [92.232.232.66]) by smtp.gmail.com with ESMTPSA id e190sm1175530wma.15.2016.03.30.05.01.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 30 Mar 2016 05:01:14 -0700 (PDT) From: Kieran Bingham To: jan.kiszka@siemens.com, linux-kernel@vger.kernel.org Cc: lee.jones@linaro.org, peter.griffin@linaro.org, maxime.coquelin@st.com, Kieran Bingham Subject: [PATCHv4 09/12] scripts/gdb: Add cpu iterators Date: Wed, 30 Mar 2016 13:00:48 +0100 Message-Id: <1459339251-29611-10-git-send-email-kieran.bingham@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1459339251-29611-1-git-send-email-kieran.bingham@linaro.org> References: <1459339251-29611-1-git-send-email-kieran.bingham@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The linux kernel provides macro's for iterating against values from the cpu_list masks. By providing some commonly used masks, we can mirror the kernels helper macros with easy to use generators. Signed-off-by: Kieran Bingham --- Changes from v3: - rebased to adapt for the cpu_*_mask indirection layer removals - cpu_active_mask added for completeness - print_cpus() converted to lx-cpus command --- scripts/gdb/linux/cpus.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) -- 2.5.0 diff --git a/scripts/gdb/linux/cpus.py b/scripts/gdb/linux/cpus.py index 4297b83fedef..fc316fb3a3d4 100644 --- a/scripts/gdb/linux/cpus.py +++ b/scripts/gdb/linux/cpus.py @@ -100,6 +100,44 @@ def cpu_list(mask_name): yield cpu +def each_online_cpu(): + for cpu in cpu_list("__cpu_online_mask"): + yield cpu + + +def each_present_cpu(): + for cpu in cpu_list("__cpu_present_mask"): + yield cpu + + +def each_possible_cpu(): + for cpu in cpu_list("__cpu_possible_mask"): + yield cpu + + +def each_active_cpu(): + for cpu in cpu_list("__cpu_active_mask"): + yield cpu + + +class LxCpus(gdb.Command): + """List CPU status arrays + +Displays the known state of each CPU based on the kernel masks +and can help identify the state of hotplugged CPUs""" + + def __init__(self): + super(LxCpus, self).__init__("lx-cpus", gdb.COMMAND_DATA) + + def invoke(self, arg, from_tty): + gdb.write("Possible CPUs : {}\n".format(list(each_possible_cpu()))) + gdb.write("Present CPUs : {}\n".format(list(each_present_cpu()))) + gdb.write("Online CPUs : {}\n".format(list(each_online_cpu()))) + gdb.write("Active CPUs : {}\n".format(list(each_active_cpu()))) + +LxCpus() + + class PerCpu(gdb.Function): """Return per-cpu variable.