From patchwork Wed Feb 4 14:01:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Parth Dixit X-Patchwork-Id: 44341 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-we0-f199.google.com (mail-we0-f199.google.com [74.125.82.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 014552029F for ; Wed, 4 Feb 2015 14:04:54 +0000 (UTC) Received: by mail-we0-f199.google.com with SMTP id u56sf1468120wes.2 for ; Wed, 04 Feb 2015 06:04:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:cc:subject:precedence:list-id:list-unsubscribe:list-post :list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list:list-archive; bh=ynl/DbcXJtgkBTuOcGENECr1Ov2dpunwx5RUC/FQjf8=; b=dS3FJxtmMSb9DdbWk5cUddq9EY3uSchkVWwWPcHJEaAKmeZKJ0ro5gvhA4ktZyNffa jT887PLmpTqZEucagpTphfHR//utJnNEuKUt4Rli6qIzltj3SOQzR/2+Xd41F20aEgjY ANcn3dKNA9EBX6U0GarVbk4RbVI10m5FyKgE8Aw0diZi9q89kFa6XH0P6QiSx38zecqY ciodC3rDQctQvF9FgMyxdCHo6z9FBh4c5lZOuxTmc1qPG+hkW7RdB2uGDYd2A2GT/RKJ jj8H44AIWwlB9MDM3o4VhD7ZVMJqvuCWyYnI3f2iTMfoMLqN8o0G8UpYu6d4018qOtWN QKcg== X-Gm-Message-State: ALoCoQm2Gzjt4n6OorjM/pLnIPSSC6a7IuyVkcvuLOeJbgtWCgoZSQtbwTotavYwKbpYBr+PRgKd X-Received: by 10.112.143.167 with SMTP id sf7mr3871612lbb.0.1423058693208; Wed, 04 Feb 2015 06:04:53 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.9.132 with SMTP id z4ls31442laa.97.gmail; Wed, 04 Feb 2015 06:04:53 -0800 (PST) X-Received: by 10.112.172.167 with SMTP id bd7mr30976798lbc.14.1423058693037; Wed, 04 Feb 2015 06:04:53 -0800 (PST) Received: from mail-la0-f53.google.com (mail-la0-f53.google.com. [209.85.215.53]) by mx.google.com with ESMTPS id p3si1387569laj.107.2015.02.04.06.04.52 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Feb 2015 06:04:53 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 as permitted sender) client-ip=209.85.215.53; Received: by mail-la0-f53.google.com with SMTP id gq15so1668985lab.12 for ; Wed, 04 Feb 2015 06:04:52 -0800 (PST) X-Received: by 10.152.5.226 with SMTP id v2mr8774723lav.34.1423058692774; Wed, 04 Feb 2015 06:04:52 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp506555lbj; Wed, 4 Feb 2015 06:04:51 -0800 (PST) X-Received: by 10.52.115.169 with SMTP id jp9mr16280199vdb.91.1423058690954; Wed, 04 Feb 2015 06:04:50 -0800 (PST) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id c8si715904vcs.68.2015.02.04.06.04.49 (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 04 Feb 2015 06:04:50 -0800 (PST) Received-SPF: none (google.com: xen-devel-bounces@lists.xen.org does not designate permitted sender hosts) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YJ0Yj-0006oj-Ae; Wed, 04 Feb 2015 14:04:01 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YJ0Yh-0006ml-Dk for xen-devel@lists.xen.org; Wed, 04 Feb 2015 14:03:59 +0000 Received: from [193.109.254.147] by server-7.bemta-14.messagelabs.com id 20/29-03172-EC622D45; Wed, 04 Feb 2015 14:03:58 +0000 X-Env-Sender: parth.dixit@linaro.org X-Msg-Ref: server-9.tower-27.messagelabs.com!1423058636!12770478!1 X-Originating-IP: [209.85.220.50] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.13.4; banners=-,-,- X-VirusChecked: Checked Received: (qmail 5964 invoked from network); 4 Feb 2015 14:03:57 -0000 Received: from mail-pa0-f50.google.com (HELO mail-pa0-f50.google.com) (209.85.220.50) by server-9.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 4 Feb 2015 14:03:57 -0000 Received: by mail-pa0-f50.google.com with SMTP id rd3so2909950pab.9 for ; Wed, 04 Feb 2015 06:03:56 -0800 (PST) X-Received: by 10.68.138.194 with SMTP id qs2mr11451232pbb.8.1423058635901; Wed, 04 Feb 2015 06:03:55 -0800 (PST) Received: from parthd-ubunutu.qualcomm.com ([202.46.23.62]) by mx.google.com with ESMTPSA id kg12sm2161881pbb.44.2015.02.04.06.03.51 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 04 Feb 2015 06:03:54 -0800 (PST) From: parth.dixit@linaro.org To: xen-devel@lists.xen.org Date: Wed, 4 Feb 2015 19:31:53 +0530 Message-Id: <1423058539-26403-10-git-send-email-parth.dixit@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1423058539-26403-1-git-send-email-parth.dixit@linaro.org> References: <1423058539-26403-1-git-send-email-parth.dixit@linaro.org> Cc: ian.campbell@citrix.com, Naresh Bhat , julien.grall@linaro.org, tim@xen.org, stefano.stabellini@citrix.com, jbeulich@suse.com, christoffer.dall@linaro.org Subject: [Xen-devel] [PATCH RFC 09/35] Add cpumask_next_zero set_cpu_present and possible X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: parth.dixit@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Archive: From: Naresh Bhat Introduce and use cpumask_next_zero, set_cpu_present and set_cpu_possible. Signed-off-by: Naresh Bhat --- xen/common/cpu.c | 18 ++++++++++++++++++ xen/include/xen/cpumask.h | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/xen/common/cpu.c b/xen/common/cpu.c index 630881e..da399c9 100644 --- a/xen/common/cpu.c +++ b/xen/common/cpu.c @@ -216,3 +216,21 @@ void enable_nonboot_cpus(void) cpumask_clear(&frozen_cpus); } + +static DECLARE_BITMAP(cpu_present_bits, NR_CPUS) __read_mostly; +static DECLARE_BITMAP(cpu_possible_bits, NR_CPUS) __read_mostly; +void set_cpu_possible(unsigned int cpu, bool possible) +{ + if ( possible ) + cpumask_set_cpu(cpu, to_cpumask(cpu_possible_bits)); + else + cpumask_clear_cpu(cpu, to_cpumask(cpu_possible_bits)); +} + +void set_cpu_present(unsigned int cpu, bool present) +{ + if ( present ) + cpumask_set_cpu(cpu, to_cpumask(cpu_present_bits)); + else + cpumask_clear_cpu(cpu, to_cpumask(cpu_present_bits)); +} diff --git a/xen/include/xen/cpumask.h b/xen/include/xen/cpumask.h index 850b4a2..209483e 100644 --- a/xen/include/xen/cpumask.h +++ b/xen/include/xen/cpumask.h @@ -78,6 +78,7 @@ #include #include #include +#include typedef struct cpumask{ DECLARE_BITMAP(bits, NR_CPUS); } cpumask_t; @@ -295,6 +296,22 @@ static inline int cpulist_scnprintf(char *buf, int len, } /* + * cpumask_next_zero - get the next unset cpu in a cpumask + * @n: the cpu prior to the place to search (ie. return will be > @n) + * @srcp: the cpumask pointer + * + * Returns >= nr_cpu_ids if no further cpus unset. + */ +static inline unsigned int cpumask_next_zero(int n, const cpumask_t *srcp) +{ + /* -1 is a legal arg here. */ + if (n != -1) + cpumask_check(n); + + return find_next_zero_bit(srcp->bits, nr_cpu_ids, n+1); +} + +/* * cpumask_var_t: struct cpumask for stack usage. * * Oh, the wicked games we play! In order to make kernel coding a @@ -440,6 +457,29 @@ extern cpumask_t cpu_present_map; #define for_each_online_cpu(cpu) for_each_cpu(cpu, &cpu_online_map) #define for_each_present_cpu(cpu) for_each_cpu(cpu, &cpu_present_map) +/* Wrappers for arch boot code to manipulate normally-constant masks */ +void set_cpu_possible(unsigned int cpu, bool possible); +void set_cpu_present(unsigned int cpu, bool present); + +/* + * to_cpumask - convert an NR_CPUS bitmap to a struct cpumask * + * @bitmap: the bitmap + * + * There are a few places where cpumask_var_t isn't appropriate and + * static cpumasks must be used (eg. very early boot), yet we don't + * expose the definition of 'struct cpumask'. + * + * This does the conversion, and can be used as a constant initializer. + */ +#define to_cpumask(bitmap) \ + ((struct cpumask *)(1 ? (bitmap) \ + : (void *)sizeof(__check_is_bitmap(bitmap)))) + +static inline int __check_is_bitmap(const unsigned long *bitmap) +{ + return 1; +} + /* Copy to/from cpumap provided by control tools. */ struct xenctl_bitmap; int cpumask_to_xenctl_bitmap(struct xenctl_bitmap *, const cpumask_t *);