From: paulmck@kernel.org
To: linux-kernel@vger.kernel.org
Cc: peterz@infradead.org, yury.norov@gmail.com, kernel-team@fb.com,
Paul Gortmaker <paul.gortmaker@windriver.com>,
"Paul E . McKenney" <paulmck@kernel.org>
Subject: [PATCH RFC cpumask 1/5] cpumask: Un-inline cpulist_parse for SMP; prepare for ascii helpers
Date: Tue, 5 Jan 2021 16:49:52 -0800 [thread overview]
Message-ID: <20210106004956.11961-1-paulmck@kernel.org> (raw)
In-Reply-To: <20210106004850.GA11682@paulmck-ThinkPad-P72>
From: Paul Gortmaker <paul.gortmaker@windriver.com>
In order to support convenience tokens like "all", and "none" and
"last" in CPU lists, we'll have to use string operations and expand
on what is currently a simple wrapper around the underlying bitmap
function call.
Rather than add header dependencies to cpumask.h and code more complex
operations not really appropriate for a header file, we prepare by
simply un-inlining it here and move it to the lib dir alongside the
other more complex cpumask functions.
Since lib/cpumask.c is built conditionally on CONFIG_SMP, and there
are non-SMP callers, we leave the one-line stub behind for that case.
If they want to check "0-0" is a valid range, they can still do it.
In the meantime, we can add the ascii helpers for CONFIG_SMP users.
The use of NR_CPUS vs. CONFIG_SMP is consistent with the existing file.
Aside from an additional exported symbol in the SMP case, no functional
changes are anticipated with this move.
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
include/linux/cpumask.h | 8 ++++++++
lib/cpumask.c | 13 +++++++++++++
2 files changed, 21 insertions(+)
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index 383684e..1f506e2 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -685,11 +685,19 @@ static inline int cpumask_parse(const char *buf, struct cpumask *dstp)
* @dstp: the cpumask to set.
*
* Returns -errno, or 0 for success.
+ *
+ * There are instances of non-SMP callers of this, and the easiest way
+ * to remain 100% runtime compatible is to let them continue to have the
+ * one-line stub, while the SMP version in lib/cpumask.c gets improved.
*/
+#if NR_CPUS == 1
static inline int cpulist_parse(const char *buf, struct cpumask *dstp)
{
return bitmap_parselist(buf, cpumask_bits(dstp), nr_cpumask_bits);
}
+#else
+int cpulist_parse(const char *buf, struct cpumask *dstp);
+#endif
/**
* cpumask_size - size to allocate for a 'struct cpumask' in bytes
diff --git a/lib/cpumask.c b/lib/cpumask.c
index 3592402..6e6e835 100644
--- a/lib/cpumask.c
+++ b/lib/cpumask.c
@@ -95,6 +95,19 @@ int cpumask_next_wrap(int n, const struct cpumask *mask, int start, bool wrap)
}
EXPORT_SYMBOL(cpumask_next_wrap);
+/**
+ * cpulist_parse - extract a cpumask from a user string of ranges
+ * @buf: the buffer to extract from
+ * @dstp: the cpumask to set.
+ *
+ * Returns -errno, or 0 for success.
+ */
+int cpulist_parse(const char *buf, struct cpumask *dstp)
+{
+ return bitmap_parselist(buf, cpumask_bits(dstp), nr_cpumask_bits);
+}
+EXPORT_SYMBOL(cpulist_parse);
+
/* These are not inline because of header tangles. */
#ifdef CONFIG_CPUMASK_OFFSTACK
/**
--
2.9.5
next prev parent reply other threads:[~2021-01-06 0:51 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-06 0:48 [PATCH RFC cpumask] Allow "all", "none", and "last" in cpumask strings Paul E. McKenney
2021-01-06 0:49 ` paulmck [this message]
2021-01-06 0:49 ` [PATCH RFC cpumask 2/5] cpumask: Make "all" alias global and not just RCU paulmck
2021-01-06 6:32 ` Yury Norov
2021-01-06 0:49 ` [PATCH RFC cpumask 3/5] cpumask: Add a "none" alias to complement "all" paulmck
2021-01-06 6:59 ` Yury Norov
2021-01-06 0:49 ` [PATCH RFC cpumask 4/5] cpumask: Add "last" alias for cpu list specifications paulmck
2021-01-06 8:41 ` Yury Norov
2021-01-06 9:49 ` Peter Zijlstra
2021-01-06 17:45 ` Paul Gortmaker
2021-01-06 21:16 ` Yury Norov
2021-01-07 14:18 ` Peter Zijlstra
2021-01-07 14:47 ` Paul E. McKenney
2021-01-07 14:59 ` Peter Zijlstra
2021-01-07 15:32 ` Paul E. McKenney
2021-01-07 15:05 ` Paul E. McKenney
2021-01-06 0:49 ` [PATCH RFC cpumask 5/5] rcutorture: Use "all" and "last" in "nohz_full" and "rcu_nocbs" paulmck
2021-01-06 8:49 ` [PATCH RFC cpumask] Allow "all", "none", and "last" in cpumask strings Yury Norov
2021-01-21 7:11 ` Yury Norov
2021-01-21 16:57 ` Paul E. McKenney
2021-01-21 21:39 ` Paul E. McKenney
2021-01-21 22:42 ` Paul Gortmaker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210106004956.11961-1-paulmck@kernel.org \
--to=paulmck@kernel.org \
--cc=kernel-team@fb.com \
--cc=linux-kernel@vger.kernel.org \
--cc=paul.gortmaker@windriver.com \
--cc=peterz@infradead.org \
--cc=yury.norov@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).