Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1158884
| From | Vikas Shivappa <vikas.shivappa@linux.intel.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 01/10] cpumask: Introduce cpumask_any_online_but |
| Date | 2015-06-05 02:10 +0200 |
| Message-ID | <pxNmV-8sC-5@gated-at.bofh.it> (permalink) |
| References | <pxNmV-8sC-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
There is currently no cpumask helper function to pick a "random" cpu
from a mask which is also online.
cpumask_any_online_but() does that which is similar to cpumask_any_but()
but also returns a cpu that is online.
Signed-off-by: Vikas Shivappa <vikas.shivappa@linux.intel.com>
---
include/linux/cpumask.h | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index 27e285b..f2d7e8a 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -548,6 +548,24 @@ static inline void cpumask_copy(struct cpumask *dstp,
#define cpumask_of(cpu) (get_cpu_mask(cpu))
/**
+ * cpumask_any_online_but - return a "random" and online cpu in a cpumask,
+ * but not this one
+ * @mask: the input mask to search
+ * @cpu: the cpu to ignore
+ *
+ * Returns >= nr_cpu_ids if no cpus set.
+*/
+static inline unsigned int cpumask_any_online_but(const struct cpumask *mask,
+ unsigned int cpu)
+{
+ cpumask_t tmp;
+
+ cpumask_and(&tmp, cpu_online_mask, mask);
+ cpumask_clear_cpu(cpu, &tmp);
+ return cpumask_any(&tmp);
+}
+
+/**
* cpumask_parse_user - extract a cpumask from a user string
* @buf: the buffer to extract from
* @len: the length of the buffer
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next | Find similar | Unroll thread
[PATCH 01/10] cpumask: Introduce cpumask_any_online_but Vikas Shivappa <vikas.shivappa@linux.intel.com> - 2015-06-05 02:10 +0200
csiph-web